* [PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT
@ 2014-08-25 7:58 Wanpeng Li
2014-08-25 9:01 ` Paolo Bonzini
0 siblings, 1 reply; 6+ messages in thread
From: Wanpeng Li @ 2014-08-25 7:58 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Marcelo Tosatti, Gleb Natapov, Zhang Yang, kvm, linux-kernel,
Wanpeng Li
This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=82211
(XEN) ..MP-BIOS bug: 8254 timer not connected to IO-APIC
(XEN) ...trying to set up timer (IRQ0) through the 8259A ... failed.
(XEN) ...trying to set up timer as Virtual Wire IRQ... failed.
(XEN) ...trying to set up timer as ExtINT IRQ... failed :(.
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) IO-APIC + timer doesn't work! Boot with apic_verbosity=debug and send a report.
(XEN) ****************************************
Commit 6addfc42992b ("KVM: x86: avoid useless set of KVM_REQ_EVENT after
emulation") sets a KVM_REQ_EVENT if an interrupt could be injected, which
happens a) if an interrupt shadow bit (STI or MOV SS) has gone away; b)
if the interrupt flag has just been set. However, a KVM_REQ_EVENT should
be set if there is no sti sequence. This patch fix it by set a KVM_REQ_EVENT
if both the first and the second instructions are not sti.
Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
---
arch/x86/kvm/x86.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c10408e..b7c0073 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4928,6 +4928,8 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
if (!mask)
kvm_make_request(KVM_REQ_EVENT, vcpu);
}
+ if (!(int_shadow || mask))
+ kvm_make_request(KVM_REQ_EVENT, vcpu);
}
static void inject_emulated_exception(struct kvm_vcpu *vcpu)
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT
2014-08-25 7:58 [PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT Wanpeng Li
@ 2014-08-25 9:01 ` Paolo Bonzini
2014-08-25 9:08 ` Wanpeng Li
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2014-08-25 9:01 UTC (permalink / raw)
To: Wanpeng Li; +Cc: Marcelo Tosatti, Gleb Natapov, Zhang Yang, kvm, linux-kernel
Il 25/08/2014 09:58, Wanpeng Li ha scritto:
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index c10408e..b7c0073 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4928,6 +4928,8 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
> if (!mask)
> kvm_make_request(KVM_REQ_EVENT, vcpu);
> }
> + if (!(int_shadow || mask))
> + kvm_make_request(KVM_REQ_EVENT, vcpu);
> }
>
> static void inject_emulated_exception(struct kvm_vcpu *vcpu)
No, this patch undoes the optimization in the buggy patch.
A KVM_REQ_EVENT must be missing somewhere else.
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT
2014-08-25 9:01 ` Paolo Bonzini
@ 2014-08-25 9:08 ` Wanpeng Li
2014-08-25 9:16 ` Paolo Bonzini
0 siblings, 1 reply; 6+ messages in thread
From: Wanpeng Li @ 2014-08-25 9:08 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Marcelo Tosatti, Gleb Natapov, Zhang Yang, kvm, linux-kernel
Hi Paolo,
On Mon, Aug 25, 2014 at 11:01:07AM +0200, Paolo Bonzini wrote:
>Il 25/08/2014 09:58, Wanpeng Li ha scritto:
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index c10408e..b7c0073 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -4928,6 +4928,8 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
>> if (!mask)
>> kvm_make_request(KVM_REQ_EVENT, vcpu);
>> }
>> + if (!(int_shadow || mask))
>> + kvm_make_request(KVM_REQ_EVENT, vcpu);
>> }
>>
>> static void inject_emulated_exception(struct kvm_vcpu *vcpu)
>
>No, this patch undoes the optimization in the buggy patch.
>
>A KVM_REQ_EVENT must be missing somewhere else.
>
Could you give some tips in order that I can figure it out?
Regards,
Wanpeng Li
>Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT
2014-08-25 9:08 ` Wanpeng Li
@ 2014-08-25 9:16 ` Paolo Bonzini
2014-08-25 9:40 ` Wanpeng Li
2014-08-26 4:07 ` Wanpeng Li
0 siblings, 2 replies; 6+ messages in thread
From: Paolo Bonzini @ 2014-08-25 9:16 UTC (permalink / raw)
To: Wanpeng Li; +Cc: Marcelo Tosatti, Gleb Natapov, Zhang Yang, kvm, linux-kernel
Il 25/08/2014 11:08, Wanpeng Li ha scritto:
> Hi Paolo,
> On Mon, Aug 25, 2014 at 11:01:07AM +0200, Paolo Bonzini wrote:
>> Il 25/08/2014 09:58, Wanpeng Li ha scritto:
>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>> index c10408e..b7c0073 100644
>>> --- a/arch/x86/kvm/x86.c
>>> +++ b/arch/x86/kvm/x86.c
>>> @@ -4928,6 +4928,8 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
>>> if (!mask)
>>> kvm_make_request(KVM_REQ_EVENT, vcpu);
>>> }
>>> + if (!(int_shadow || mask))
>>> + kvm_make_request(KVM_REQ_EVENT, vcpu);
>>> }
>>>
>>> static void inject_emulated_exception(struct kvm_vcpu *vcpu)
>>
>> No, this patch undoes the optimization in the buggy patch.
>>
>> A KVM_REQ_EVENT must be missing somewhere else.
>>
>
> Could you give some tips in order that I can figure it out?
I have no idea right now (I was planning to debug it this week).
(BTW, look at the original commit that introduced KVM_REQ_EVENT --
https://git.kernel.org/cgit/virt/kvm/kvm.git/commit/?id=3842d135 -- and
compare the patch and the commit message. You can see that it was added
to the emulator because it is a "place that can set EFLAGS" and this
idea is preserved in the buggy patch).
The important thing is that (despite Xen being involved) this is not
related to nested virtualization. So I would first of all try to see if
some module parameter makes it go away (apicv and unrestricted mode
especially), then capture a trace of the panic. At least this is how I
was planning to start... :)
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT
2014-08-25 9:16 ` Paolo Bonzini
@ 2014-08-25 9:40 ` Wanpeng Li
2014-08-26 4:07 ` Wanpeng Li
1 sibling, 0 replies; 6+ messages in thread
From: Wanpeng Li @ 2014-08-25 9:40 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Marcelo Tosatti, Gleb Natapov, Zhang Yang, kvm, linux-kernel
Hi Paolo,
On Mon, Aug 25, 2014 at 11:16:16AM +0200, Paolo Bonzini wrote:
>Il 25/08/2014 11:08, Wanpeng Li ha scritto:
>> Hi Paolo,
>> On Mon, Aug 25, 2014 at 11:01:07AM +0200, Paolo Bonzini wrote:
>>> Il 25/08/2014 09:58, Wanpeng Li ha scritto:
>>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>>> index c10408e..b7c0073 100644
>>>> --- a/arch/x86/kvm/x86.c
>>>> +++ b/arch/x86/kvm/x86.c
>>>> @@ -4928,6 +4928,8 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
>>>> if (!mask)
>>>> kvm_make_request(KVM_REQ_EVENT, vcpu);
>>>> }
>>>> + if (!(int_shadow || mask))
>>>> + kvm_make_request(KVM_REQ_EVENT, vcpu);
>>>> }
>>>>
>>>> static void inject_emulated_exception(struct kvm_vcpu *vcpu)
>>>
>>> No, this patch undoes the optimization in the buggy patch.
>>>
>>> A KVM_REQ_EVENT must be missing somewhere else.
>>>
>>
>> Could you give some tips in order that I can figure it out?
>
>I have no idea right now (I was planning to debug it this week).
>
>(BTW, look at the original commit that introduced KVM_REQ_EVENT --
>https://git.kernel.org/cgit/virt/kvm/kvm.git/commit/?id=3842d135 -- and
>compare the patch and the commit message. You can see that it was added
>to the emulator because it is a "place that can set EFLAGS" and this
>idea is preserved in the buggy patch).
>
>The important thing is that (despite Xen being involved) this is not
>related to nested virtualization. So I would first of all try to see if
>some module parameter makes it go away (apicv and unrestricted mode
This bug can be reproduced w/o apicv.
>especially), then capture a trace of the panic. At least this is how I
>was planning to start... :)
Great, I will also continue to debug it. ;-)
Regards,
Wanpeng Li
>
>Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT
2014-08-25 9:16 ` Paolo Bonzini
2014-08-25 9:40 ` Wanpeng Li
@ 2014-08-26 4:07 ` Wanpeng Li
1 sibling, 0 replies; 6+ messages in thread
From: Wanpeng Li @ 2014-08-26 4:07 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Marcelo Tosatti, Gleb Natapov, Zhang Yang, kvm, linux-kernel
On Mon, Aug 25, 2014 at 11:16:16AM +0200, Paolo Bonzini wrote:
>Il 25/08/2014 11:08, Wanpeng Li ha scritto:
>> Hi Paolo,
>> On Mon, Aug 25, 2014 at 11:01:07AM +0200, Paolo Bonzini wrote:
>>> Il 25/08/2014 09:58, Wanpeng Li ha scritto:
>>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>>> index c10408e..b7c0073 100644
>>>> --- a/arch/x86/kvm/x86.c
>>>> +++ b/arch/x86/kvm/x86.c
>>>> @@ -4928,6 +4928,8 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
>>>> if (!mask)
>>>> kvm_make_request(KVM_REQ_EVENT, vcpu);
>>>> }
>>>> + if (!(int_shadow || mask))
>>>> + kvm_make_request(KVM_REQ_EVENT, vcpu);
>>>> }
>>>>
>>>> static void inject_emulated_exception(struct kvm_vcpu *vcpu)
>>>
>>> No, this patch undoes the optimization in the buggy patch.
>>>
>>> A KVM_REQ_EVENT must be missing somewhere else.
>>>
>>
>> Could you give some tips in order that I can figure it out?
>
>I have no idea right now (I was planning to debug it this week).
>
>(BTW, look at the original commit that introduced KVM_REQ_EVENT --
>https://git.kernel.org/cgit/virt/kvm/kvm.git/commit/?id=3842d135 -- and
>compare the patch and the commit message. You can see that it was added
>to the emulator because it is a "place that can set EFLAGS" and this
>idea is preserved in the buggy patch).
>
>From xen codes which report panic:
check_timer
timer_irq_works
local_save_flags(flags); => pushf;pop
local_irq_enable(); => sti
delay xxxx
local_irq_restore(flags); => pushfq;andq;orq;popfq
Regards,
Wanpeng Li
>The important thing is that (despite Xen being involved) this is not
>related to nested virtualization. So I would first of all try to see if
>some module parameter makes it go away (apicv and unrestricted mode
>especially), then capture a trace of the panic. At least this is how I
>was planning to start... :)
>
>Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-08-26 4:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-25 7:58 [PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT Wanpeng Li
2014-08-25 9:01 ` Paolo Bonzini
2014-08-25 9:08 ` Wanpeng Li
2014-08-25 9:16 ` Paolo Bonzini
2014-08-25 9:40 ` Wanpeng Li
2014-08-26 4:07 ` Wanpeng Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox