Message ID | alpine.DEB.2.21.1807202307400.1694@nanos.tec.linutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: x86: SVM: Call x86_spec_ctrl_set_guest/host() with interrupts disabled | expand |
On 12/08/2018 20:59, Thomas Gleixner wrote: > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -5580,8 +5580,6 @@ static void svm_vcpu_run(struct kvm_vcpu > > clgi(); > > - local_irq_enable(); > - > /* > * If this vCPU has touched SPEC_CTRL, restore the guest's value if > * it's non-zero. Since vmentry is serialising on affected CPUs, there > @@ -5590,6 +5588,8 @@ static void svm_vcpu_run(struct kvm_vcpu > */ > x86_spec_ctrl_set_guest(svm->spec_ctrl, svm->virt_spec_ctrl); > > + local_irq_enable(); > + It is actually a false positive because the clgi() keeps interrupts disabled even if IF=1. (This complication in the AMD virtualization extensions is there because IF=1 tells VMRUN that you should exit in case an interrupt arrives, but they it won't be serviced until the corresponding STGI). Likewise for the call to x86_spec_ctrl_restore_host. Still, the patch is correct and it's a good idea to keep the GIF=0/IF=1 area as small and self-contained as possible. So: Acked-by: Paolo Bonzini <pbonzini@redhat.com> Paolo
--- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -5580,8 +5580,6 @@ static void svm_vcpu_run(struct kvm_vcpu clgi(); - local_irq_enable(); - /* * If this vCPU has touched SPEC_CTRL, restore the guest's value if * it's non-zero. Since vmentry is serialising on affected CPUs, there @@ -5590,6 +5588,8 @@ static void svm_vcpu_run(struct kvm_vcpu */ x86_spec_ctrl_set_guest(svm->spec_ctrl, svm->virt_spec_ctrl); + local_irq_enable(); + asm volatile ( "push %%" _ASM_BP "; \n\t" "mov %c[rbx](%[svm]), %%" _ASM_BX " \n\t" @@ -5712,12 +5712,12 @@ static void svm_vcpu_run(struct kvm_vcpu if (unlikely(!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL))) svm->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL); - x86_spec_ctrl_restore_host(svm->spec_ctrl, svm->virt_spec_ctrl); - reload_tss(vcpu); local_irq_disable(); + x86_spec_ctrl_restore_host(svm->spec_ctrl, svm->virt_spec_ctrl); + vcpu->arch.cr2 = svm->vmcb->save.cr2; vcpu->arch.regs[VCPU_REGS_RAX] = svm->vmcb->save.rax; vcpu->arch.regs[VCPU_REGS_RSP] = svm->vmcb->save.rsp;