Store the guest's written value of MSR_IA32_DEBUGCTL in a software field, insted of always reading/writing the GUEST_IA32_DEBUGCTL vmcs field. This will allow in the future to have a different value in the actual GUEST_IA32_DEBUGCTL from the value that the guest has set. Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx> --- arch/x86/kvm/vmx/vmx.c | 5 ++++- arch/x86/kvm/vmx/vmx.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 4237422dc4ed..c9208a4acda4 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -2196,11 +2196,14 @@ static u64 vmx_get_supported_debugctl(struct kvm_vcpu *vcpu, bool host_initiated u64 vmx_get_guest_debugctl(struct kvm_vcpu *vcpu) { - return vmcs_read64(GUEST_IA32_DEBUGCTL); + return to_vmx(vcpu)->msr_ia32_debugctl; } static void __vmx_set_guest_debugctl(struct kvm_vcpu *vcpu, u64 data) { + struct vcpu_vmx *vmx = to_vmx(vcpu); + + vmx->msr_ia32_debugctl = data; vmcs_write64(GUEST_IA32_DEBUGCTL, data); } diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index 8ac46fb47abd..699da6d2bc66 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -291,6 +291,7 @@ struct vcpu_vmx { /* SGX Launch Control public key hash */ u64 msr_ia32_sgxlepubkeyhash[4]; u64 msr_ia32_mcu_opt_ctrl; + u64 msr_ia32_debugctl; bool disable_fb_clear; struct pt_desc pt_desc; -- 2.26.3