[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aCazfDoU8DV3s/mh@intel.com>
Date: Fri, 16 May 2025 11:39:40 +0800
From: Chao Gao <chao.gao@...el.com>
To: Maxim Levitsky <mlevitsk@...hat.com>
CC: <kvm@...r.kernel.org>, Thomas Gleixner <tglx@...utronix.de>, "Sean
Christopherson" <seanjc@...gle.com>, Borislav Petkov <bp@...en8.de>,
<x86@...nel.org>, Ingo Molnar <mingo@...hat.com>,
<linux-kernel@...r.kernel.org>, "H. Peter Anvin" <hpa@...or.com>, "Paolo
Bonzini" <pbonzini@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>
Subject: Re: [PATCH v4 4/4] x86: KVM: VMX: preserve DEBUGCTLMSR_FREEZE_IN_SMM
>@@ -7368,6 +7381,9 @@ fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags)
> if (run_flags & KVM_RUN_LOAD_GUEST_DR6)
> set_debugreg(vcpu->arch.dr6, 6);
>
>+ if (run_flags & KVM_RUN_LOAD_DEBUGCTL)
>+ vmx_guest_debugctl_write(vcpu, vmx_guest_debugctl_read());
...
>+
> /*
> * Refresh vmcs.HOST_CR3 if necessary. This must be done immediately
> * prior to VM-Enter, as the kernel may load a new ASID (PCID) any time
>diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h
>index 1b80479505d3..5ddedf73392b 100644
>--- a/arch/x86/kvm/vmx/vmx.h
>+++ b/arch/x86/kvm/vmx/vmx.h
>@@ -416,6 +416,8 @@ static inline void vmx_set_intercept_for_msr(struct kvm_vcpu *vcpu, u32 msr,
>
> void vmx_update_cpu_dirty_logging(struct kvm_vcpu *vcpu);
> u64 vmx_get_supported_debugctl(struct kvm_vcpu *vcpu, bool host_initiated);
>+void vmx_guest_debugctl_write(struct kvm_vcpu *vcpu, u64 val);
>+u64 vmx_guest_debugctl_read(void);
>
> /*
> * Note, early Intel manuals have the write-low and read-high bitmap offsets
>diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>index 684b8047e0f2..a85078dfa36d 100644
>--- a/arch/x86/kvm/x86.c
>+++ b/arch/x86/kvm/x86.c
>@@ -10752,7 +10752,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
> dm_request_for_irq_injection(vcpu) &&
> kvm_cpu_accept_dm_intr(vcpu);
> fastpath_t exit_fastpath;
>- u64 run_flags;
>+ u64 run_flags, host_debug_ctl;
>
> bool req_immediate_exit = false;
>
>@@ -11024,7 +11024,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
> set_debugreg(0, 7);
> }
>
>- vcpu->arch.host_debugctl = get_debugctlmsr();
>+ host_debug_ctl = get_debugctlmsr();
>+ if (host_debug_ctl != vcpu->arch.host_debugctl)
>+ run_flags |= KVM_RUN_LOAD_DEBUGCTL;
>+ vcpu->arch.host_debugctl = host_debug_ctl;
IIUC, using run_flags here may only update the GUEST_DEBUGCTL field of a vmcs02,
leaving vmcs01 not updated.
>
> guest_timing_enter_irqoff();
>
>--
>2.46.0
>
>
Powered by blists - more mailing lists