When preparing vmcb02 for nested VMRUN, KVM ORs DR6_ACTIVE_LOW into the guest DR6 to force the fixed bits to 1. DR6_ACTIVE_LOW forces bit 11 (DR6_BUS_LOCK) to 1 unconditionally. Use kvm_dr6_fixed() instead, which forces DR6_RTM and DR6_BUS_LOCK based on the guest's CPUID. DR6_RTM is a reserved bit on AMD and is thus always set to 1. DR6_BUS_LOCK is left writable once the guest supports Bus Lock Detect. Signed-off-by: Shivansh Dhiman --- Changelog: v3: * New patch. * Use kvm_dr6_fixed() instead of open-coding DR6_FIXED_1 | DR6_RTM. --- arch/x86/kvm/regs.c | 3 ++- arch/x86/kvm/regs.h | 1 + arch/x86/kvm/svm/nested.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/regs.c b/arch/x86/kvm/regs.c index d2caf5a67dba..1b5dfa765140 100644 --- a/arch/x86/kvm/regs.c +++ b/arch/x86/kvm/regs.c @@ -764,7 +764,7 @@ void kvm_update_dr7(struct kvm_vcpu *vcpu) } EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_update_dr7); -static u64 kvm_dr6_fixed(struct kvm_vcpu *vcpu) +u64 kvm_dr6_fixed(struct kvm_vcpu *vcpu) { u64 fixed = DR6_FIXED_1; @@ -775,6 +775,7 @@ static u64 kvm_dr6_fixed(struct kvm_vcpu *vcpu) fixed |= DR6_BUS_LOCK; return fixed; } +EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_dr6_fixed); int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val) { diff --git a/arch/x86/kvm/regs.h b/arch/x86/kvm/regs.h index 94fd86728fed..e85c3ff3e120 100644 --- a/arch/x86/kvm/regs.h +++ b/arch/x86/kvm/regs.h @@ -23,6 +23,7 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3); int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4); int kvm_set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8); int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val); +u64 kvm_dr6_fixed(struct kvm_vcpu *vcpu); unsigned long kvm_get_dr(struct kvm_vcpu *vcpu, int dr); unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu); void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw); diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 84248e6665cf..0a9e28a02692 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -811,7 +811,7 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm) if (unlikely(new_vmcb12 || vmcb12_is_dirty(control, VMCB_DR))) { vmcb02->save.dr7 = svm->nested.save.dr7 | DR7_FIXED_1; - svm->vcpu.arch.dr6 = svm->nested.save.dr6 | DR6_ACTIVE_LOW; + svm->vcpu.arch.dr6 = svm->nested.save.dr6 | kvm_dr6_fixed(vcpu); vmcb_mark_dirty(vmcb02, VMCB_DR); } -- 2.43.0