mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] KVM: x86: move LAPIC initialization after VMCS creation
@ 2018-02-24  0:39 Liran Alon
  2018-02-24  0:43 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Liran Alon @ 2018-02-24  0:39 UTC (permalink / raw)
  To: pbonzini; +Cc: linux-kernel, kvm


----- pbonzini@redhat.com wrote:

> The initial reset of the local APIC is performed before the VMCS has
> been
> created, but it tries to do a vmwrite:
> 
>  vmwrite error: reg 810 value 4a00 (err 18944)
>  CPU: 54 PID: 38652 Comm: qemu-kvm Tainted: G        W I     
> 4.16.0-0.rc2.git0.1.fc28.x86_64 #1
>  Hardware name: Intel Corporation S2600CW/S2600CW, BIOS
> SE5C610.86B.01.01.0003.090520141303 09/05/2014
>  Call Trace:
>   vmx_set_rvi [kvm_intel]
>   vmx_hwapic_irr_update [kvm_intel]
>   kvm_lapic_reset [kvm]
>   kvm_create_lapic [kvm]
>   kvm_arch_vcpu_init [kvm]
>   kvm_vcpu_init [kvm]
>   vmx_create_vcpu [kvm_intel]
>   kvm_vm_ioctl [kvm]
> 
> Move it later, after the VMCS has been created.
> 
> Fixes: 851c1a18c5412fd321e387cfe60739387cdbf37d
> Cc: Liran Alon <liran.alon@oracle.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/lapic.c | 1 -
>  arch/x86/kvm/x86.c   | 1 +
>  2 files changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 924ac8ce9d50..cc5fe7a50dde 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -2165,7 +2165,6 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
>  	 */
>  	vcpu->arch.apic_base = MSR_IA32_APICBASE_ENABLE;
>  	static_key_slow_inc(&apic_sw_disabled.key); /* sw disabled at reset
> */
> -	kvm_lapic_reset(vcpu, false);
>  	kvm_iodevice_init(&apic->dev, &apic_mmio_ops);
>  
>  	return 0;
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index c8a0b545ac20..ca90d9515137 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -7975,6 +7975,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
>  	kvm_vcpu_mtrr_init(vcpu);
>  	vcpu_load(vcpu);
>  	kvm_vcpu_reset(vcpu, false);
> +	kvm_lapic_reset(vcpu, false);
>  	kvm_mmu_setup(vcpu);
>  	vcpu_put(vcpu);
>  	return 0;
> -- 
> 1.8.3.1

I agree with the bug and the fix.
It makes sense to reset LAPIC in the same place other components are reset
rather than in it's creation.

However, I failed to understand why you mention it fixes commit:
851c1a18c541 ("KVM: nVMX: Fix injection to L2 when L1 don't intercept external-interrupts")

Before and after that commit, vmx_hwapic_irr_update() did exactly the same
because is_guest_mode(vcpu)==false at this point.
Therefore, vmx_hwapic_irr_update() has always just called vmx_set_rvi()
which has not changed in that commit.

It seems to me that the commit which introduced this issue is actually:
4191db26b714 ("KVM: x86: Update APICv on APIC reset")

What am I missing?

-Liran

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

* Re: [PATCH] KVM: x86: move LAPIC initialization after VMCS creation
  2018-02-24  0:39 [PATCH] KVM: x86: move LAPIC initialization after VMCS creation Liran Alon
@ 2018-02-24  0:43 ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2018-02-24  0:43 UTC (permalink / raw)
  To: Liran Alon; +Cc: linux-kernel, kvm

On 24/02/2018 01:39, Liran Alon wrote:
> I agree with the bug and the fix.
> It makes sense to reset LAPIC in the same place other components are reset
> rather than in it's creation.
> 
> However, I failed to understand why you mention it fixes commit:
> 851c1a18c541 ("KVM: nVMX: Fix injection to L2 when L1 don't intercept external-interrupts")
> 
> Before and after that commit, vmx_hwapic_irr_update() did exactly the same
> because is_guest_mode(vcpu)==false at this point.
> Therefore, vmx_hwapic_irr_update() has always just called vmx_set_rvi()
> which has not changed in that commit.
> 
> It seems to me that the commit which introduced this issue is actually:
> 4191db26b714 ("KVM: x86: Update APICv on APIC reset")
> 
> What am I missing?

No, you're right.  But then I'm not sure why I'm only seeing the issue
now, and not with 4.15 kernels.

Paolo

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

* [PATCH] KVM: x86: move LAPIC initialization after VMCS creation
@ 2018-02-23 22:43 Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2018-02-23 22:43 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: liran.alon

The initial reset of the local APIC is performed before the VMCS has been
created, but it tries to do a vmwrite:

 vmwrite error: reg 810 value 4a00 (err 18944)
 CPU: 54 PID: 38652 Comm: qemu-kvm Tainted: G        W I      4.16.0-0.rc2.git0.1.fc28.x86_64 #1
 Hardware name: Intel Corporation S2600CW/S2600CW, BIOS SE5C610.86B.01.01.0003.090520141303 09/05/2014
 Call Trace:
  vmx_set_rvi [kvm_intel]
  vmx_hwapic_irr_update [kvm_intel]
  kvm_lapic_reset [kvm]
  kvm_create_lapic [kvm]
  kvm_arch_vcpu_init [kvm]
  kvm_vcpu_init [kvm]
  vmx_create_vcpu [kvm_intel]
  kvm_vm_ioctl [kvm]

Move it later, after the VMCS has been created.

Fixes: 851c1a18c5412fd321e387cfe60739387cdbf37d
Cc: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/lapic.c | 1 -
 arch/x86/kvm/x86.c   | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 924ac8ce9d50..cc5fe7a50dde 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2165,7 +2165,6 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
 	 */
 	vcpu->arch.apic_base = MSR_IA32_APICBASE_ENABLE;
 	static_key_slow_inc(&apic_sw_disabled.key); /* sw disabled at reset */
-	kvm_lapic_reset(vcpu, false);
 	kvm_iodevice_init(&apic->dev, &apic_mmio_ops);
 
 	return 0;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c8a0b545ac20..ca90d9515137 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7975,6 +7975,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
 	kvm_vcpu_mtrr_init(vcpu);
 	vcpu_load(vcpu);
 	kvm_vcpu_reset(vcpu, false);
+	kvm_lapic_reset(vcpu, false);
 	kvm_mmu_setup(vcpu);
 	vcpu_put(vcpu);
 	return 0;
-- 
1.8.3.1

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

end of thread, other threads:[~2018-02-24  0:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-24  0:39 [PATCH] KVM: x86: move LAPIC initialization after VMCS creation Liran Alon
2018-02-24  0:43 ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2018-02-23 22:43 Paolo Bonzini

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®