* [PATCH] Clear temporary interrupt blocking on halt in real mode
@ 2008-08-05 8:37 Laurent Vivier
2008-08-10 8:36 ` Avi Kivity
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Vivier @ 2008-08-05 8:37 UTC (permalink / raw)
To: kvm; +Cc: Avi Kivity, Stefan Hajnoczi, Laurent Vivier
When "halt" is emulated, skip_emulated_instruction() is called and interruptibility state is cleared.
But when halt is emulated in real mode, skip_emulated_instruction() is not called and the interruptiblity state is not cleared.
The following code, from gPXE, never exits from loop because interrupts are not delivered to increase %fs:(0x6c):
movl %fs:(0x6c), %eax
1: pushf
sti
hlt
popf
cmpl %fs:(0x6c), %eax
je 1b
This patch clears the interruptibility state when halt is emulated in real mode.
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
---
arch/x86/kvm/vmx.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c4510fe..82c4324 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2329,7 +2329,17 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
handle_rmode_exception(vcpu, intr_info & INTR_INFO_VECTOR_MASK,
error_code)) {
if (vcpu->arch.halt_request) {
+ u32 interruptibility;
vcpu->arch.halt_request = 0;
+ /*
+ * We emulated an instruction, so temporary interrupt blocking
+ * should be removed, if set.
+ */
+ interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
+ if (interruptibility & 3)
+ vmcs_write32(GUEST_INTERRUPTIBILITY_INFO,
+ interruptibility & ~3);
+ vcpu->arch.interrupt_window_open = 1;
return kvm_emulate_halt(vcpu);
}
return 1;
--
1.5.2.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Clear temporary interrupt blocking on halt in real mode
2008-08-05 8:37 [PATCH] Clear temporary interrupt blocking on halt in real mode Laurent Vivier
@ 2008-08-10 8:36 ` Avi Kivity
2008-09-04 15:51 ` Laurent Vivier
0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2008-08-10 8:36 UTC (permalink / raw)
To: Laurent Vivier; +Cc: kvm, Stefan Hajnoczi
Laurent Vivier wrote:
> When "halt" is emulated, skip_emulated_instruction() is called and interruptibility state is cleared.
> But when halt is emulated in real mode, skip_emulated_instruction() is not called and the interruptiblity state is not cleared.
>
> The following code, from gPXE, never exits from loop because interrupts are not delivered to increase %fs:(0x6c):
>
> movl %fs:(0x6c), %eax
> 1: pushf
> sti
> hlt
> popf
> cmpl %fs:(0x6c), %eax
> je 1b
>
> This patch clears the interruptibility state when halt is emulated in real mode.
>
> Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
> ---
> arch/x86/kvm/vmx.c | 10 ++++++++++
> 1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index c4510fe..82c4324 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2329,7 +2329,17 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
> handle_rmode_exception(vcpu, intr_info & INTR_INFO_VECTOR_MASK,
> error_code)) {
> if (vcpu->arch.halt_request) {
> + u32 interruptibility;
> vcpu->arch.halt_request = 0;
> + /*
> + * We emulated an instruction, so temporary interrupt blocking
> + * should be removed, if set.
> + */
> + interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
> + if (interruptibility & 3)
> + vmcs_write32(GUEST_INTERRUPTIBILITY_INFO,
> + interruptibility & ~3);
> + vcpu->arch.interrupt_window_open = 1;
> return kvm_emulate_halt(vcpu);
> }
> return 1;
>
Shouldn't interruptibility state be cleared if *any* instruction is
emulated?
(of course, an emulated instruction may update interruptibility state
itself, say sti).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Clear temporary interrupt blocking on halt in real mode
2008-08-10 8:36 ` Avi Kivity
@ 2008-09-04 15:51 ` Laurent Vivier
0 siblings, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2008-09-04 15:51 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, Stefan Hajnoczi
Le dimanche 10 août 2008 à 11:36 +0300, Avi Kivity a écrit :
> Laurent Vivier wrote:
> > When "halt" is emulated, skip_emulated_instruction() is called and interruptibility state is cleared.
> > But when halt is emulated in real mode, skip_emulated_instruction() is not called and the interruptiblity state is not cleared.
> >
> > The following code, from gPXE, never exits from loop because interrupts are not delivered to increase %fs:(0x6c):
> >
> > movl %fs:(0x6c), %eax
> > 1: pushf
> > sti
> > hlt
> > popf
> > cmpl %fs:(0x6c), %eax
> > je 1b
> >
> > This patch clears the interruptibility state when halt is emulated in real mode.
> >
> > Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
> > ---
> > arch/x86/kvm/vmx.c | 10 ++++++++++
> > 1 files changed, 10 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> > index c4510fe..82c4324 100644
> > --- a/arch/x86/kvm/vmx.c
> > +++ b/arch/x86/kvm/vmx.c
> > @@ -2329,7 +2329,17 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
> > handle_rmode_exception(vcpu, intr_info & INTR_INFO_VECTOR_MASK,
> > error_code)) {
> > if (vcpu->arch.halt_request) {
> > + u32 interruptibility;
> > vcpu->arch.halt_request = 0;
> > + /*
> > + * We emulated an instruction, so temporary interrupt blocking
> > + * should be removed, if set.
> > + */
> > + interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
> > + if (interruptibility & 3)
> > + vmcs_write32(GUEST_INTERRUPTIBILITY_INFO,
> > + interruptibility & ~3);
> > + vcpu->arch.interrupt_window_open = 1;
> > return kvm_emulate_halt(vcpu);
> > }
> > return 1;
> >
>
>
> Shouldn't interruptibility state be cleared if *any* instruction is
> emulated?
>
> (of course, an emulated instruction may update interruptibility state
> itself, say sti).
I don't know what to do with that...
I think emulated instructions already clear interruptibility state via
skip_emulated_instruction().
The case of kvm_emulate_halt() and real mode is a special case.
Laurent
--
----------------- Laurent.Vivier@bull.net ------------------
"La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-04 15:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-05 8:37 [PATCH] Clear temporary interrupt blocking on halt in real mode Laurent Vivier
2008-08-10 8:36 ` Avi Kivity
2008-09-04 15:51 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox