(&self, sys_reg: u32)
| 2706 | /// |
| 2707 | #[cfg(target_arch = "aarch64")] |
| 2708 | fn get_sys_reg(&self, sys_reg: u32) -> cpu::Result<u64> { |
| 2709 | // |
| 2710 | // Arm Architecture Reference Manual defines the encoding of |
| 2711 | // AArch64 system registers, see |
| 2712 | // https://developer.arm.com/documentation/ddi0487 (chapter D12). |
| 2713 | // While KVM defines another ID for each AArch64 system register, |
| 2714 | // which is used in calling `KVM_G/SET_ONE_REG` to access a system |
| 2715 | // register of a guest. |
| 2716 | // A mapping exists between the Arm standard encoding and the KVM ID. |
| 2717 | // This function takes the standard u32 ID as input parameter, converts |
| 2718 | // it to the corresponding KVM ID, and call `KVM_GET_ONE_REG` API to |
| 2719 | // get the value of the system parameter. |
| 2720 | // |
| 2721 | let id: u64 = KVM_REG_ARM64 |
| 2722 | | KVM_REG_SIZE_U64 |
| 2723 | | KVM_REG_ARM64_SYSREG as u64 |
| 2724 | | ((((sys_reg) >> 5) |
| 2725 | & (KVM_REG_ARM64_SYSREG_OP0_MASK |
| 2726 | | KVM_REG_ARM64_SYSREG_OP1_MASK |
| 2727 | | KVM_REG_ARM64_SYSREG_CRN_MASK |
| 2728 | | KVM_REG_ARM64_SYSREG_CRM_MASK |
| 2729 | | KVM_REG_ARM64_SYSREG_OP2_MASK)) as u64); |
| 2730 | let mut bytes = [0_u8; 8]; |
| 2731 | self.fd |
| 2732 | .get_one_reg(id, &mut bytes) |
| 2733 | .map_err(|e| cpu::HypervisorCpuError::GetSysRegister(e.into()))?; |
| 2734 | Ok(u64::from_le_bytes(bytes)) |
| 2735 | } |
| 2736 | |
| 2737 | /// |
| 2738 | /// Gets the value of a non-core register |
no outgoing calls