KVM: arm64: Exclude mdcr_el2_host from kvm_vcpu_arch
authorMarc Zyngier <maz@kernel.org>
Tue, 27 Feb 2024 08:27:54 +0000 (08:27 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 12 Apr 2024 12:58:18 +0000 (13:58 +0100)
As for the rest of the host debug state, the host copy of mdcr_el2
has little to do in the vcpu, and is better placed in the host_data
structure.

Reviewed-by : Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/hyp/include/hyp/switch.h

index d7bcb8ce1d7b765561b0d17f214c45d624b4bbfb..a04e69fb28840fee622bb69c24ea3f5d69f28f61 100644 (file)
@@ -555,6 +555,8 @@ struct kvm_host_data {
                u64 pmscr_el1;
                /* Self-hosted trace */
                u64 trfcr_el1;
+               /* Values of trap registers for the host before guest entry. */
+               u64 mdcr_el2;
        } host_debug_state;
 };
 
@@ -616,9 +618,6 @@ struct kvm_vcpu_arch {
        u64 mdcr_el2;
        u64 cptr_el2;
 
-       /* Values of trap registers for the host before guest entry. */
-       u64 mdcr_el2_host;
-
        /* Exception Information */
        struct kvm_vcpu_fault_info fault;
 
index ae198b84ca0138cef7903c4c035ca49118ae63df..7d7de0245ed0f317462c3adeb591afc399f522cc 100644 (file)
@@ -232,7 +232,7 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu)
                vcpu_set_flag(vcpu, PMUSERENR_ON_CPU);
        }
 
-       vcpu->arch.mdcr_el2_host = read_sysreg(mdcr_el2);
+       *host_data_ptr(host_debug_state.mdcr_el2) = read_sysreg(mdcr_el2);
        write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
 
        if (cpus_have_final_cap(ARM64_HAS_HCX)) {
@@ -254,7 +254,7 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu)
 
 static inline void __deactivate_traps_common(struct kvm_vcpu *vcpu)
 {
-       write_sysreg(vcpu->arch.mdcr_el2_host, mdcr_el2);
+       write_sysreg(*host_data_ptr(host_debug_state.mdcr_el2), mdcr_el2);
 
        write_sysreg(0, hstr_el2);
        if (kvm_arm_support_pmu_v3()) {