* [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run()
@ 2020-09-14 6:55 Wanpeng Li
2020-09-14 20:43 ` Krish Sadhukhan
0 siblings, 1 reply; 7+ messages in thread
From: Wanpeng Li @ 2020-09-14 6:55 UTC (permalink / raw)
To: linux-kernel, kvm
Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel
From: Wanpeng Li <wanpengli@tencent.com>
Analyze is_guest_mode() in svm_vcpu_run() instead of svm_exit_handlers_fastpath()
in conformity with VMX version.
Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
---
arch/x86/kvm/svm/svm.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 3da5b2f..009035a 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3393,8 +3393,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
static fastpath_t svm_exit_handlers_fastpath(struct kvm_vcpu *vcpu)
{
- if (!is_guest_mode(vcpu) &&
- to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR &&
+ if (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR &&
to_svm(vcpu)->vmcb->control.exit_info_1)
return handle_fastpath_set_msr_irqoff(vcpu);
@@ -3580,6 +3579,10 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
svm_handle_mce(svm);
svm_complete_interrupts(svm);
+
+ if (is_guest_mode(vcpu))
+ return EXIT_FASTPATH_NONE;
+
exit_fastpath = svm_exit_handlers_fastpath(vcpu);
return exit_fastpath;
}
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run()
2020-09-14 6:55 [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run() Wanpeng Li
@ 2020-09-14 20:43 ` Krish Sadhukhan
2020-09-15 11:29 ` Haiwei Li
2020-09-22 13:43 ` Paolo Bonzini
0 siblings, 2 replies; 7+ messages in thread
From: Krish Sadhukhan @ 2020-09-14 20:43 UTC (permalink / raw)
To: Wanpeng Li, linux-kernel, kvm
Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel
On 9/13/20 11:55 PM, Wanpeng Li wrote:
> From: Wanpeng Li <wanpengli@tencent.com>
>
> Analyze is_guest_mode() in svm_vcpu_run() instead of svm_exit_handlers_fastpath()
> in conformity with VMX version.
>
> Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> ---
> arch/x86/kvm/svm/svm.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 3da5b2f..009035a 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -3393,8 +3393,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
>
> static fastpath_t svm_exit_handlers_fastpath(struct kvm_vcpu *vcpu)
> {
> - if (!is_guest_mode(vcpu) &&
> - to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR &&
> + if (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR &&
> to_svm(vcpu)->vmcb->control.exit_info_1)
> return handle_fastpath_set_msr_irqoff(vcpu);
>
> @@ -3580,6 +3579,10 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
> svm_handle_mce(svm);
>
> svm_complete_interrupts(svm);
> +
> + if (is_guest_mode(vcpu))
> + return EXIT_FASTPATH_NONE;
> +
> exit_fastpath = svm_exit_handlers_fastpath(vcpu);
> return exit_fastpath;
Not related to your changes, but should we get rid of the variable
'exit_fastpath' and just do,
return svm_exit_handler_fastpath(vcpu);
It seems the variable isn't used anywhere else and svm_vcpu_run()
doesn't return from anywhere else either.
Also, svm_exit_handlers_fastpath() doesn't have any other caller.
Should we get rid of it as well ?
For your changes,
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run()
2020-09-14 20:43 ` Krish Sadhukhan
@ 2020-09-15 11:29 ` Haiwei Li
2020-09-22 13:43 ` Paolo Bonzini
1 sibling, 0 replies; 7+ messages in thread
From: Haiwei Li @ 2020-09-15 11:29 UTC (permalink / raw)
To: Krish Sadhukhan, Wanpeng Li, linux-kernel, kvm
Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel
On 20/9/15 04:43, Krish Sadhukhan wrote:
>
> On 9/13/20 11:55 PM, Wanpeng Li wrote:
>> From: Wanpeng Li <wanpengli@tencent.com>
>>
>> Analyze is_guest_mode() in svm_vcpu_run() instead of
>> svm_exit_handlers_fastpath()
>> in conformity with VMX version.
>>
>> Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
>> ---
>> arch/x86/kvm/svm/svm.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
>> index 3da5b2f..009035a 100644
>> --- a/arch/x86/kvm/svm/svm.c
>> +++ b/arch/x86/kvm/svm/svm.c
>> @@ -3393,8 +3393,7 @@ static void svm_cancel_injection(struct kvm_vcpu
>> *vcpu)
>> static fastpath_t svm_exit_handlers_fastpath(struct kvm_vcpu *vcpu)
>> {
>> - if (!is_guest_mode(vcpu) &&
>> - to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR &&
>> + if (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR &&
>> to_svm(vcpu)->vmcb->control.exit_info_1)
>> return handle_fastpath_set_msr_irqoff(vcpu);
>> @@ -3580,6 +3579,10 @@ static __no_kcsan fastpath_t
>> svm_vcpu_run(struct kvm_vcpu *vcpu)
>> svm_handle_mce(svm);
>> svm_complete_interrupts(svm);
>> +
>> + if (is_guest_mode(vcpu))
>> + return EXIT_FASTPATH_NONE;
>> +
>> exit_fastpath = svm_exit_handlers_fastpath(vcpu);
>> return exit_fastpath;
>
> Not related to your changes, but should we get rid of the variable
> 'exit_fastpath' and just do,
>
> return svm_exit_handler_fastpath(vcpu);
>
> It seems the variable isn't used anywhere else and svm_vcpu_run()
> doesn't return from anywhere else either.
>
> Also, svm_exit_handlers_fastpath() doesn't have any other caller. Should
> we get rid of it as well ?
I will do this soon, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run()
2020-09-14 20:43 ` Krish Sadhukhan
2020-09-15 11:29 ` Haiwei Li
@ 2020-09-22 13:43 ` Paolo Bonzini
2020-09-22 14:54 ` Haiwei Li
1 sibling, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2020-09-22 13:43 UTC (permalink / raw)
To: Krish Sadhukhan, Wanpeng Li, linux-kernel, kvm
Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel
On 14/09/20 22:43, Krish Sadhukhan wrote:
>>
>
> Not related to your changes, but should we get rid of the variable
> 'exit_fastpath' and just do,
>
> return svm_exit_handler_fastpath(vcpu);
>
> It seems the variable isn't used anywhere else and svm_vcpu_run()
> doesn't return from anywhere else either.
Yes (also because vmx will do the same once we can push
EXIT_FASTPATH_REENTER_GUEST handling up to vcpu_enter_guest)...
> Also, svm_exit_handlers_fastpath() doesn't have any other caller.
> Should we get rid of it as well ?
... and no, because svm_vcpu_run is a very large function and therefore
it's better to keep its flow streamlined.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run()
2020-09-22 13:43 ` Paolo Bonzini
@ 2020-09-22 14:54 ` Haiwei Li
2020-09-22 14:56 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Haiwei Li @ 2020-09-22 14:54 UTC (permalink / raw)
To: Paolo Bonzini, Krish Sadhukhan, Wanpeng Li, linux-kernel, kvm
Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel
On 20/9/22 21:43, Paolo Bonzini wrote:
> On 14/09/20 22:43, Krish Sadhukhan wrote:
>>>
>>
>> Not related to your changes, but should we get rid of the variable
>> 'exit_fastpath' and just do,
>>
>> return svm_exit_handler_fastpath(vcpu);
>>
>> It seems the variable isn't used anywhere else and svm_vcpu_run()
>> doesn't return from anywhere else either.
>
> Yes (also because vmx will do the same once we can push
> EXIT_FASTPATH_REENTER_GUEST handling up to vcpu_enter_guest)...
Hi, Paolo
I have sent a patch to do this,
https://lore.kernel.org/kvm/20200915113033.61817-1-lihaiwei.kernel@gmail.com/
Thanks.
Haiwei
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run()
2020-09-22 14:54 ` Haiwei Li
@ 2020-09-22 14:56 ` Paolo Bonzini
2020-09-22 15:04 ` Haiwei Li
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2020-09-22 14:56 UTC (permalink / raw)
To: Haiwei Li, Krish Sadhukhan, Wanpeng Li, linux-kernel, kvm
Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel
On 22/09/20 16:54, Haiwei Li wrote:
>> EXIT_FASTPATH_REENTER_GUEST handling up to vcpu_enter_guest)...
> Hi, Paolo
>
> I have sent a patch to do this,
>
> https://lore.kernel.org/kvm/20200915113033.61817-1-lihaiwei.kernel@gmail.com/
Cool, thanks. I think I'll just squash it in Wanpeng's if you don't mind.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run()
2020-09-22 14:56 ` Paolo Bonzini
@ 2020-09-22 15:04 ` Haiwei Li
0 siblings, 0 replies; 7+ messages in thread
From: Haiwei Li @ 2020-09-22 15:04 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Krish Sadhukhan, Wanpeng Li, linux-kernel, kvm,
Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel
On Tue, Sep 22, 2020 at 10:56 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 22/09/20 16:54, Haiwei Li wrote:
> >> EXIT_FASTPATH_REENTER_GUEST handling up to vcpu_enter_guest)...
> > Hi, Paolo
> >
> > I have sent a patch to do this,
> >
> > https://lore.kernel.org/kvm/20200915113033.61817-1-lihaiwei.kernel@gmail.com/
>
> Cool, thanks. I think I'll just squash it in Wanpeng's if you don't mind.
It's all ok. I don't mind. Thanks.
Haiwei
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-22 15:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 6:55 [PATCH] KVM: SVM: Analyze is_guest_mode() in svm_vcpu_run() Wanpeng Li
2020-09-14 20:43 ` Krish Sadhukhan
2020-09-15 11:29 ` Haiwei Li
2020-09-22 13:43 ` Paolo Bonzini
2020-09-22 14:54 ` Haiwei Li
2020-09-22 14:56 ` Paolo Bonzini
2020-09-22 15:04 ` Haiwei Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®