linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration
@ 2021-05-04 14:39 Maxim Levitsky
  2021-05-04 14:39 ` [PATCH v2 1/2] KVM: nSVM: always restore the L1's GIF on migration Maxim Levitsky
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Maxim Levitsky @ 2021-05-04 14:39 UTC (permalink / raw)
  To: kvm
  Cc: Borislav Petkov, Paolo Bonzini,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Wanpeng Li, Jim Mattson, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, linux-kernel, Cathy Avery, Sean Christopherson,
	Vitaly Kuznetsov, Joerg Roedel, Maxim Levitsky

Those are few fixes for issues I uncovered by doing variants of a
synthetic migration test I just created:

I modified the qemu, such that on each vm pause/resume cycle,
just prior to resuming a vCPU, qemu reads its KVM state,
then (optionaly) resets this state by uploading a
dummy reset state to KVM, and then it uploads back to KVM,
the state that this vCPU had before.

V2: those are only last 2 patches from V1,
updated with review feedback from Paolo (Thanks!).

Best regards,
	Maxim Levitsky

Maxim Levitsky (2):
  KVM: nSVM: always restore the L1's GIF on migration
  KVM: nSVM: remove a warning about vmcb01 VM exit reason

 arch/x86/kvm/svm/nested.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] KVM: nSVM: always restore the L1's GIF on migration
  2021-05-04 14:39 [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration Maxim Levitsky
@ 2021-05-04 14:39 ` Maxim Levitsky
  2021-05-04 14:39 ` [PATCH v2 2/2] KVM: nSVM: remove a warning about vmcb01 VM exit reason Maxim Levitsky
  2021-05-04 16:19 ` [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Maxim Levitsky @ 2021-05-04 14:39 UTC (permalink / raw)
  To: kvm
  Cc: Borislav Petkov, Paolo Bonzini,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Wanpeng Li, Jim Mattson, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, linux-kernel, Cathy Avery, Sean Christopherson,
	Vitaly Kuznetsov, Joerg Roedel, Maxim Levitsky

While usually the L1's GIF is set while L2 runs, and usually
migration nested state is loaded after a vCPU reset which
also sets L1's GIF to true, this is not guaranteed.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 arch/x86/kvm/svm/nested.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index 32400cba608d..b331446f67f3 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -1314,6 +1314,8 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
 	else
 		svm->nested.vmcb02.ptr->save = svm->vmcb01.ptr->save;
 
+	svm_set_gif(svm, !!(kvm_state->flags & KVM_STATE_NESTED_GIF_SET));
+
 	svm->nested.nested_run_pending =
 		!!(kvm_state->flags & KVM_STATE_NESTED_RUN_PENDING);
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] KVM: nSVM: remove a warning about vmcb01 VM exit reason
  2021-05-04 14:39 [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration Maxim Levitsky
  2021-05-04 14:39 ` [PATCH v2 1/2] KVM: nSVM: always restore the L1's GIF on migration Maxim Levitsky
@ 2021-05-04 14:39 ` Maxim Levitsky
  2021-05-04 16:19 ` [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Maxim Levitsky @ 2021-05-04 14:39 UTC (permalink / raw)
  To: kvm
  Cc: Borislav Petkov, Paolo Bonzini,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Wanpeng Li, Jim Mattson, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, linux-kernel, Cathy Avery, Sean Christopherson,
	Vitaly Kuznetsov, Joerg Roedel, Maxim Levitsky

While in most cases, when returning to use the VMCB01,
the exit reason stored in it will be SVM_EXIT_VMRUN,
on first VM exit after a nested migration this field
can contain anything since the VM entry did happen
before the migration.

Remove this warning to avoid the false positive.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 arch/x86/kvm/svm/nested.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index b331446f67f3..5e8d8443154e 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -764,7 +764,6 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
 	nested_svm_copy_common_state(svm->nested.vmcb02.ptr, svm->vmcb01.ptr);
 
 	svm_switch_vmcb(svm, &svm->vmcb01);
-	WARN_ON_ONCE(svm->vmcb->control.exit_code != SVM_EXIT_VMRUN);
 
 	/*
 	 * On vmexit the  GIF is set to false and
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration
  2021-05-04 14:39 [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration Maxim Levitsky
  2021-05-04 14:39 ` [PATCH v2 1/2] KVM: nSVM: always restore the L1's GIF on migration Maxim Levitsky
  2021-05-04 14:39 ` [PATCH v2 2/2] KVM: nSVM: remove a warning about vmcb01 VM exit reason Maxim Levitsky
@ 2021-05-04 16:19 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-05-04 16:19 UTC (permalink / raw)
  To: Maxim Levitsky, kvm
  Cc: Borislav Petkov, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Wanpeng Li, Jim Mattson, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, linux-kernel, Cathy Avery, Sean Christopherson,
	Vitaly Kuznetsov, Joerg Roedel

On 04/05/21 16:39, Maxim Levitsky wrote:
> Those are few fixes for issues I uncovered by doing variants of a
> synthetic migration test I just created:
> 
> I modified the qemu, such that on each vm pause/resume cycle,
> just prior to resuming a vCPU, qemu reads its KVM state,
> then (optionaly) resets this state by uploading a
> dummy reset state to KVM, and then it uploads back to KVM,
> the state that this vCPU had before.
> 
> V2: those are only last 2 patches from V1,
> updated with review feedback from Paolo (Thanks!).

Queued, thanks.

Paolo

> Best regards,
> 	Maxim Levitsky
> 
> Maxim Levitsky (2):
>    KVM: nSVM: always restore the L1's GIF on migration
>    KVM: nSVM: remove a warning about vmcb01 VM exit reason
> 
>   arch/x86/kvm/svm/nested.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-04 16:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 14:39 [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration Maxim Levitsky
2021-05-04 14:39 ` [PATCH v2 1/2] KVM: nSVM: always restore the L1's GIF on migration Maxim Levitsky
2021-05-04 14:39 ` [PATCH v2 2/2] KVM: nSVM: remove a warning about vmcb01 VM exit reason Maxim Levitsky
2021-05-04 16:19 ` [PATCH v2 0/2] KVM: nSVM: few fixes for the nested migration Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).