hypervisor: aarch64: Use offset_of for nested fields

`std::mem::offset_of` could be used for calculating nested fields, use
this feature to shorten aarch64 reg offset calculation.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
Ruoqing He
2025-07-10 02:16:44 +00:00
committed by Bo Chen
parent 07cc1f6545
commit 6da5c32fd9
2 changed files with 16 additions and 18 deletions

View File

@@ -2963,19 +2963,19 @@ mod tests {
#[cfg(test)]
mod tests {
#[cfg(feature = "kvm")]
use std::mem;
use std::{mem, mem::offset_of};
use arch::layout;
use hypervisor::arch::aarch64::regs::MPIDR_EL1;
#[cfg(feature = "kvm")]
use hypervisor::arm64_core_reg_id;
#[cfg(feature = "kvm")]
use hypervisor::kvm::aarch64::is_system_register;
#[cfg(feature = "kvm")]
use hypervisor::kvm::kvm_bindings::{
user_pt_regs, KVM_REG_ARM64, KVM_REG_ARM64_SYSREG, KVM_REG_ARM_CORE, KVM_REG_SIZE_U64,
};
use hypervisor::HypervisorCpuError;
#[cfg(feature = "kvm")]
use hypervisor::{arm64_core_reg_id, offset_of};
#[test]
fn test_setup_regs() {