Commit c91def97 authored by Marc Zyngier's avatar Marc Zyngier Committed by Junhao He
Browse files

KVM: arm64: Exclude mdcr_el2_host from kvm_vcpu_arch

mainline inclusion
from mainline-v6.9-rc1
commit 4bacd723705a6b6c8386daf3d5148aca66135f3c
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8EC9K
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4bacd723705a6b6c8386daf3d5148aca66135f3c



--------------------------------

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: default avatarMarc Zyngier <maz@kernel.org>
Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
parent 6fc469d6
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -475,6 +475,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;
};

@@ -534,9 +536,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;

+2 −2
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu)
	    !kern_hyp_va(vcpu->kvm)->arch.pfr1_nmi)
		sysreg_clear_set_s(SYS_HCRX_EL2, 0, HCRX_EL2_TALLINT);

	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)) {
@@ -251,7 +251,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);

	if (cpus_have_final_cap(ARM64_HAS_NMI) &&
	    !kern_hyp_va(vcpu->kvm)->arch.pfr1_nmi)