All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Fix virtual wire mode
@ 2017-05-20 11:24 Jan H. Schönherr
  2017-05-21 22:50 ` Wanpeng Li
       [not found] ` <6c3f2b42-df47-46c3-afb9-5fbb0869f1cd@gmail.com>
  0 siblings, 2 replies; 3+ messages in thread
From: Jan H. Schönherr @ 2017-05-20 11:24 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, kvm,
	Jan H. Schönherr

Intel SDM says, that at most one LAPIC should be configured with ExtINT
delivery. KVM configures all LAPICs this way. This causes pic_unlock()
to kick the first available vCPU from the internal KVM data structures.
If this vCPU is not the BSP, but some not-yet-booted AP, the BSP may
never realize that there is an interrupt.

Fix that by enabling ExtINT delivery only for the BSP.

This allows booting a Linux guest without a TSC in the above situation.
Otherwise the BSP gets stuck in calibrate_delay_converge().

Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
---
 arch/x86/kvm/lapic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index c329d28..df1b865 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1934,7 +1934,8 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
 	for (i = 0; i < KVM_APIC_LVT_NUM; i++)
 		kvm_lapic_set_reg(apic, APIC_LVTT + 0x10 * i, APIC_LVT_MASKED);
 	apic_update_lvtt(apic);
-	if (kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_LINT0_REENABLED))
+	if (kvm_vcpu_is_reset_bsp(vcpu) &&
+	    kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_LINT0_REENABLED))
 		kvm_lapic_set_reg(apic, APIC_LVT0,
 			     SET_APIC_DELIVERY_MODE(0, APIC_MODE_EXTINT));
 	apic_manage_nmi_watchdog(apic, kvm_lapic_get_reg(apic, APIC_LVT0));
-- 
2.3.1.dirty

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

* Re: [PATCH] KVM: x86: Fix virtual wire mode
  2017-05-20 11:24 [PATCH] KVM: x86: Fix virtual wire mode Jan H. Schönherr
@ 2017-05-21 22:50 ` Wanpeng Li
       [not found] ` <6c3f2b42-df47-46c3-afb9-5fbb0869f1cd@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread
From: Wanpeng Li @ 2017-05-21 22:50 UTC (permalink / raw)
  To: Jan H. Schönherr
  Cc: Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	the arch/x86 maintainers, kvm

2017-05-20 19:24 GMT+08:00 Jan H. Schönherr <jschoenh@amazon.de>:
> Intel SDM says, that at most one LAPIC should be configured with ExtINT
> delivery. KVM configures all LAPICs this way. This causes pic_unlock()
> to kick the first available vCPU from the internal KVM data structures.
> If this vCPU is not the BSP, but some not-yet-booted AP, the BSP may
> never realize that there is an interrupt.
>
> Fix that by enabling ExtINT delivery only for the BSP.
>
> This allows booting a Linux guest without a TSC in the above situation.
> Otherwise the BSP gets stuck in calibrate_delay_converge().
>
> Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>

Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>

> ---
>  arch/x86/kvm/lapic.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index c329d28..df1b865 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1934,7 +1934,8 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
>         for (i = 0; i < KVM_APIC_LVT_NUM; i++)
>                 kvm_lapic_set_reg(apic, APIC_LVTT + 0x10 * i, APIC_LVT_MASKED);
>         apic_update_lvtt(apic);
> -       if (kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_LINT0_REENABLED))
> +       if (kvm_vcpu_is_reset_bsp(vcpu) &&
> +           kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_LINT0_REENABLED))
>                 kvm_lapic_set_reg(apic, APIC_LVT0,
>                              SET_APIC_DELIVERY_MODE(0, APIC_MODE_EXTINT));
>         apic_manage_nmi_watchdog(apic, kvm_lapic_get_reg(apic, APIC_LVT0));
> --
> 2.3.1.dirty
>

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

* Re: [PATCH] KVM: x86: Fix virtual wire mode
       [not found] ` <6c3f2b42-df47-46c3-afb9-5fbb0869f1cd@gmail.com>
@ 2017-05-22  8:54   ` Jan H. Schönherr
  0 siblings, 0 replies; 3+ messages in thread
From: Jan H. Schönherr @ 2017-05-22  8:54 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, kvm

On 05/22/2017 09:19 AM, Xiao Guangrong wrote:
>
>
> On 05/20/2017 07:24 PM, Jan H. Schönherr wrote:
>> Intel SDM says, that at most one LAPIC should be configured with ExtINT
>> delivery. KVM configures all LAPICs this way. This causes pic_unlock()
>> to kick the first available vCPU from the internal KVM data structures.
>> If this vCPU is not the BSP, but some not-yet-booted AP, the BSP may
>> never realize that there is an interrupt.
>>
>> Fix that by enabling ExtINT delivery only for the BSP.
>>
>> This allows booting a Linux guest without a TSC in the above situation.
>> Otherwise the BSP gets stuck in calibrate_delay_converge().
>
> Patch looks good to me.
>
> BTW, what benefit do you want to get from notsc?
>

None. I just want my guest to boot in case it does that. :)

Regards
Jan
Amazon Development Center Germany GmbH
Berlin - Dresden - Aachen
main office: Krausenstr. 38, 10117 Berlin
Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger
Ust-ID: DE289237879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B

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

end of thread, other threads:[~2017-05-22  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-20 11:24 [PATCH] KVM: x86: Fix virtual wire mode Jan H. Schönherr
2017-05-21 22:50 ` Wanpeng Li
     [not found] ` <6c3f2b42-df47-46c3-afb9-5fbb0869f1cd@gmail.com>
2017-05-22  8:54   ` Jan H. Schönherr

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.