Skip to contentSkip to conversation

KVM: SVM: Fix __svm_vcpu_run declaration.

PATCH Applied Uros Bizjak 3 participants 9 messages Apr 9, 2020 – Apr 15, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: SVM: Fix __svm_vcpu_run declaration.

The function returns no value.

Cc Paolo Bonzini <[email protected]>
Fixes 199cd1d7b534 ("KVM: SVM: Split svm_vcpu_run inline assembly to separate file")
---
 arch/x86/kvm/svm/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +1 -1
index 2be5bbae3a40..061d19e69c73 100644
@@ -3276,7 +3276,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
 	svm_complete_interrupts(svm);
 }
 
-bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);
+void __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);
 
 static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 {
Signature · 1 line
2.25.2
#1 lore raw

Hi Bizjak,

Quoted 14 lines · Uros Bizjak

The function returns no value.

Cc Paolo Bonzini <[email protected]>
Fixes 199cd1d7b534 ("KVM: SVM: Split svm_vcpu_run inline assembly to separate file")
---
  arch/x86/kvm/svm/svm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +0 -0
index 2be5bbae3a40..061d19e69c73 100644

arch/x86/kvm/svm/svm.c static void svm_cancel_injection(struct kvm_vcpu *vcpu) · line 3279

Quoted 4 lines
arch/x86/kvm/svm/svm.c +0 -1
@@ -3276,7 +3276,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
  	svm_complete_interrupts(svm);
  }
 
-bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);

Just curious if __svm_vcpu_run() will fail to enter SVM guest mode,
and a return value could indicate that nothing went wrong rather than blindly keeping silent.

Thanks,
Like Xu

Quoted 4 lines
arch/x86/kvm/svm/svm.c +1 -0
+void __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);
 
  static void svm_vcpu_run(struct kvm_vcpu *vcpu)
  {
maintainer
#2 lore raw
Quoted 5 lines · Like
Quoted 2 lines

  -bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);

Just curious if __svm_vcpu_run() will fail to enter SVM guest mode, and a return value could indicate that nothing went wrong rather than blindly keeping silent.

That's already available in the exit code (which is 0xffffffff when vmentry fails).

Paolo

#3 lore raw

Hi Paolo,

Quoted 7 lines · Paolo Bonzini
Quoted 4 lines · Like
Quoted 1 line

  -bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);

Just curious if __svm_vcpu_run() will fail to enter SVM guest mode, and a return value could indicate that nothing went wrong rather than blindly keeping silent.

That's already available in the exit code (which is 0xffffffff when vmentry fails).

Yes, I assume the svm->vmcb->control.exit_code is referred.

What makes me confused is
why we need "vmx->exit_reason" and "vmx->fail"
for the same general purpose, but svm does not.

Thanks,
Like Xu

Quoted 3 lines

Paolo

maintainer
#4 lore raw
Quoted 6 lines · Like
Quoted 1 line

Yes, I assume the svm->vmcb->control.exit_code is referred.

What makes me confused is
why we need "vmx->exit_reason" and "vmx->fail"
for the same general purpose, but svm does not.

Because VMLAUNCH/VMRESUME can also report vmFailValid and vmFailInvalid via the carry and zero flags, there is no equivalent of that for AMD virtualization extensions.

Paolo

#5 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Like

Yes, I assume the svm->vmcb->control.exit_code is referred.

What makes me confused is
why we need "vmx->exit_reason" and "vmx->fail"
for the same general purpose, but svm does not.

Because VMLAUNCH/VMRESUME can also report vmFailValid and vmFailInvalid via the carry and zero flags, there is no equivalent of that for AMD virtualization extensions.

Oh, this makes sense to me. Thanks!
Let me confirm it from both specifications.

Quoted 3 lines

Paolo

#6 lore raw
In reply to Xu, Like
Quoted 21 lines · Like

Hi Bizjak,

Quoted 17 lines · Uros Bizjak

The function returns no value.

Cc Paolo Bonzini <[email protected]>
Fixes 199cd1d7b534 ("KVM: SVM: Split svm_vcpu_run inline assembly to separate file")
---
  arch/x86/kvm/svm/svm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +0 -0
index 2be5bbae3a40..061d19e69c73 100644
@@ -3276,7 +3276,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
      svm_complete_interrupts(svm);
  }
 
Quoted 4 lines

arch/x86/kvm/svm/svm.c static void svm_cancel_injection(struct kvm_vcpu *vcpu) · line 3279

Quoted 1 line
arch/x86/kvm/svm/svm.c +0 -1
-bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);

Just curious if __svm_vcpu_run() will fail to enter SVM guest mode, and a return value could indicate that nothing went wrong rather than blindly keeping silent.

vmload, vmrun and vmsave do not return anything in flags or registers, so we can't detect anything at this point, modulo exception that is handled below the respective instruction.

BTW: the change by itself does not change the generated code, the fake return value from __svm_vcpu_run is already ignored. So, the change is mostly cosmetic.

Uros.

#7 lore raw
Quoted 21 lines · Uros Bizjak
Quoted 20 lines · Like

Hi Bizjak,

Quoted 17 lines · Uros Bizjak

The function returns no value.

Cc Paolo Bonzini <[email protected]>
Fixes 199cd1d7b534 ("KVM: SVM: Split svm_vcpu_run inline assembly to separate file")
---
   arch/x86/kvm/svm/svm.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +0 -0
index 2be5bbae3a40..061d19e69c73 100644
@@ -3276,7 +3276,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
       svm_complete_interrupts(svm);
   }
 
Quoted 7 lines
Quoted 4 lines

arch/x86/kvm/svm/svm.c static void svm_cancel_injection(struct kvm_vcpu *vcpu) · line 3279

Quoted 1 line
arch/x86/kvm/svm/svm.c +0 -1
-bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);

Just curious if __svm_vcpu_run() will fail to enter SVM guest mode, and a return value could indicate that nothing went wrong rather than blindly keeping silent.

vmload, vmrun and vmsave do not return anything in flags or registers, so we can't detect anything at this point, modulo exception that is handled below the respective instruction.

If we check the __vmx_vcpu_run(), we have something like:

    /* VM-Fail.  Out-of-line to avoid a taken Jcc after VM-Exit. */ 2:    mov $1, %eax
    jmp 1b

so do we need it in the __svm_vcpu_run() or why not ?

Quoted 4 lines

BTW: the change by itself does not change the generated code, the fake return value from __svm_vcpu_run is already ignored. So, the change is mostly cosmetic.

Yes, the generated code is not affected and the change is reasonable.

Quoted 2 lines

Uros.

maintainer Applied
#8 lore raw
In reply to Uros Bizjak
Quoted 15 lines · Uros Bizjak

The function returns no value.

Cc Paolo Bonzini <[email protected]>
Fixes 199cd1d7b534 ("KVM: SVM: Split svm_vcpu_run inline assembly to separate file")
---
 arch/x86/kvm/svm/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/svm.c +0 -0
index 2be5bbae3a40..061d19e69c73 100644

arch/x86/kvm/svm/svm.c static void svm_cancel_injection(struct kvm_vcpu *vcpu) · line 3282

Quoted 8 lines
arch/x86/kvm/svm/svm.c +1 -1
@@ -3276,7 +3276,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
 	svm_complete_interrupts(svm);
 }
 
-bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);
+void __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);
 
 static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 {

Queued, thanks.

Paolo