* [PATCH] KVM: SVM: Fix svm the vmexit error_code of WRMSR
@ 2020-03-02 12:19 Haiwei Li
2020-03-02 12:54 ` Vitaly Kuznetsov
0 siblings, 1 reply; 3+ messages in thread
From: Haiwei Li @ 2020-03-02 12:19 UTC (permalink / raw)
To: linux-kernel, kvm, x86
Cc: hpa, bp, mingo, tglx, joro, jmattson, wanpengli, vkuznets,
Sean Christopherson, pbonzini
From 1f755f75dfd73ad7cabb0e0f43e9993dd9f69120 Mon Sep 17 00:00:00 2001
From: Haiwei Li <lihaiwei@tencent.com>
Date: Mon, 2 Mar 2020 19:19:59 +0800
Subject: [PATCH] KVM: SVM: Fix svm the vmexit error_code of WRMSR
In svm, exit_code of write_msr is not EXIT_REASON_MSR_WRITE which
belongs to vmx.
According to amd manual, SVM_EXIT_MSR(7ch) is the exit_code of VMEXIT_MSR
due to RDMSR or WRMSR access to protected MSR. Additionally, the processor
indicates in the VMCB's EXITINFO1 whether a RDMSR(EXITINFO1=0) or
WRMSR(EXITINFO1=1) was intercepted.
Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
---
arch/x86/kvm/svm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index fd3fc9f..ef71755 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6296,7 +6296,8 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu
*vcpu,
enum exit_fastpath_completion *exit_fastpath)
{
if (!is_guest_mode(vcpu) &&
- to_svm(vcpu)->vmcb->control.exit_code ==
EXIT_REASON_MSR_WRITE)
+ (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR) &&
+ (to_svm(vcpu)->vmcb->control.exit_info_1 & 1))
*exit_fastpath = handle_fastpath_set_msr_irqoff(vcpu);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: SVM: Fix svm the vmexit error_code of WRMSR
2020-03-02 12:19 [PATCH] KVM: SVM: Fix svm the vmexit error_code of WRMSR Haiwei Li
@ 2020-03-02 12:54 ` Vitaly Kuznetsov
2020-03-02 16:05 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Vitaly Kuznetsov @ 2020-03-02 12:54 UTC (permalink / raw)
To: Haiwei Li
Cc: hpa, bp, mingo, tglx, joro, jmattson, wanpengli,
Sean Christopherson, pbonzini, linux-kernel, kvm, x86
Haiwei Li <lihaiwei.kernel@gmail.com> writes:
> From 1f755f75dfd73ad7cabb0e0f43e9993dd9f69120 Mon Sep 17 00:00:00 2001
> From: Haiwei Li <lihaiwei@tencent.com>
> Date: Mon, 2 Mar 2020 19:19:59 +0800
> Subject: [PATCH] KVM: SVM: Fix svm the vmexit error_code of WRMSR
>
> In svm, exit_code of write_msr is not EXIT_REASON_MSR_WRITE which
> belongs to vmx.
EXIT_REASON_MSR_WRITE is '32', in SVM this corresponds to
SVM_EXIT_READ_DR0. There were issues I guess. Or did you only detect
that the fastpath is not working?
>
> According to amd manual, SVM_EXIT_MSR(7ch) is the exit_code of VMEXIT_MSR
> due to RDMSR or WRMSR access to protected MSR. Additionally, the processor
> indicates in the VMCB's EXITINFO1 whether a RDMSR(EXITINFO1=0) or
> WRMSR(EXITINFO1=1) was intercepted.
>
> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
Fixes: 1e9e2622a149 ("KVM: VMX: FIXED+PHYSICAL mode single target IPI fastpath")
> ---
> arch/x86/kvm/svm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index fd3fc9f..ef71755 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -6296,7 +6296,8 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu
> *vcpu,
> enum exit_fastpath_completion *exit_fastpath)
> {
> if (!is_guest_mode(vcpu) &&
> - to_svm(vcpu)->vmcb->control.exit_code ==
> EXIT_REASON_MSR_WRITE)
There is an extra newline here (in case it's not just me).
> + (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR) &&
> + (to_svm(vcpu)->vmcb->control.exit_info_1 & 1))
Could we add defines for '1' and '0', like
SVM_EXITINFO_MSR_WRITE/SVM_EXITINFO_MSR_READ maybe?
> *exit_fastpath = handle_fastpath_set_msr_irqoff(vcpu);
> }
>
> --
> 1.8.3.1
>
--
Vitaly
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: SVM: Fix svm the vmexit error_code of WRMSR
2020-03-02 12:54 ` Vitaly Kuznetsov
@ 2020-03-02 16:05 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-03-02 16:05 UTC (permalink / raw)
To: Vitaly Kuznetsov, Haiwei Li
Cc: hpa, bp, mingo, tglx, joro, jmattson, wanpengli,
Sean Christopherson, linux-kernel, kvm, x86
On 02/03/20 13:54, Vitaly Kuznetsov wrote:
>> enum exit_fastpath_completion *exit_fastpath)
>> {
>> if (!is_guest_mode(vcpu) &&
>> - to_svm(vcpu)->vmcb->control.exit_code ==
>> EXIT_REASON_MSR_WRITE)
> There is an extra newline here (in case it's not just me).
Yes, the whole patch has broken newlines. I fixed it up and applied.
>> + (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR) &&
>> + (to_svm(vcpu)->vmcb->control.exit_info_1 & 1))
>
> Could we add defines for '1' and '0', like
> SVM_EXITINFO_MSR_WRITE/SVM_EXITINFO_MSR_READ maybe?
We can eliminate "& 1" completely since that's what msr_interception does.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-02 16:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02 12:19 [PATCH] KVM: SVM: Fix svm the vmexit error_code of WRMSR Haiwei Li
2020-03-02 12:54 ` Vitaly Kuznetsov
2020-03-02 16:05 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.