
From: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> virt inclusion category: feature bugzilla: https://gitee.com/openeuler/qemu/issues/IBSJV9 ------------------------------------------------------------------------ The retrieved mask will be used later to check whether we can write to ID register fields. Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Signed-off-by: Jinqian Yang <yangjinqian1@huawei.com> --- target/arm/cpu.h | 2 ++ target/arm/kvm.c | 1 + target/arm/kvm64.c | 11 +++++++++++ target/arm/kvm_arm.h | 1 + 4 files changed, 15 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a5ba7f2a26..6622256bdd 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1121,6 +1121,8 @@ struct ArchCPU { /* Generic timer counter frequency, in Hz */ uint64_t gt_cntfrq_hz; + + uint64_t *writable_masks; }; typedef struct ARMCPUInfo { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ee5ba68305..01ff28671f 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -188,6 +188,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) cpu->kvm_target = arm_host_cpu_features.target; cpu->dtb_compatible = arm_host_cpu_features.dtb_compatible; cpu->isar = arm_host_cpu_features.isar; + cpu->writable_masks = arm_host_cpu_features.writable_masks; env->features = arm_host_cpu_features.features; } diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index b099287ed0..540da767c1 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -281,6 +281,8 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) */ struct kvm_vcpu_init init = { .target = -1, }; + struct reg_mask_range range; + uint64_t *writable_masks; /* * Ask for SVE if supported, so that we can query ID_AA64ZFR0, * which is otherwise RAZ. @@ -454,6 +456,15 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) } } + writable_masks = g_new0(uint64_t, KVM_ARM_FEATURE_ID_RANGE_SIZE); + memset(&range, 0, sizeof(range)); + range.addr = (__u64)writable_masks; + if (!ioctl(fdarray[1], KVM_ARM_GET_REG_WRITABLE_MASKS, &range)) { + ahcf->writable_masks = writable_masks; + } else { + g_free(writable_masks); + } + kvm_arm_destroy_scratch_host_vcpu(fdarray); if (err < 0) { diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 31457a57f7..bbf869860b 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -242,6 +242,7 @@ typedef struct ARMHostCPUFeatures { uint64_t features; uint32_t target; const char *dtb_compatible; + uint64_t *writable_masks; } ARMHostCPUFeatures; /** -- 2.33.0