Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 30 Jan 2020 15:34:33 +0000 (07:34 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 30 Jan 2020 15:34:33 +0000 (07:34 -0800)
Pull arm64 KVM fix from Catalin Marinas:
 "Set the correct MDCR_EL2 register value on the first run of a vCPU"

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  KVM: arm64: Write arch.mdcr_el2 changes since last vcpu_load on VHE

arch/arm64/kvm/debug.c

index 43487f0353858add6c187711b82dda7f16306bb1..7a7e425616b54710a0a10f8b494d31eb9f36bb15 100644 (file)
@@ -101,7 +101,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu)
 void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
 {
        bool trap_debug = !(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY);
-       unsigned long mdscr;
+       unsigned long mdscr, orig_mdcr_el2 = vcpu->arch.mdcr_el2;
 
        trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug);
 
@@ -197,6 +197,10 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
        if (vcpu_read_sys_reg(vcpu, MDSCR_EL1) & (DBG_MDSCR_KDE | DBG_MDSCR_MDE))
                vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
 
+       /* Write mdcr_el2 changes since vcpu_load on VHE systems */
+       if (has_vhe() && orig_mdcr_el2 != vcpu->arch.mdcr_el2)
+               write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
+
        trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2);
        trace_kvm_arm_set_dreg32("MDSCR_EL1", vcpu_read_sys_reg(vcpu, MDSCR_EL1));
 }