From: "H. Peter Anvin" <hpa@zytor.com>
To: Glauber Costa <glommer@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, avi@redhat.com
Subject: Re: [PATCH] disable interrupt shadow state for emulated instruction
Date: Wed, 08 Apr 2009 11:16:05 -0700 [thread overview]
Message-ID: <49DCE9E5.8020703@zytor.com> (raw)
In-Reply-To: <1239213452-5966-1-git-send-email-glommer@redhat.com>
Glauber Costa wrote:
> we currently unblock shadow interrupt state when we skip an instruction,
> but failing to do so when we actually emulate one. This blocks interrupts
> in key instruction blocks, in particular sti; hlt; sequences
>
> Without this patch, I cannot boot gpxe option roms at vmx machines.
> This is described at https://bugzilla.redhat.com/show_bug.cgi?id=494469
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index c6997c0..cee38e4 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -736,26 +736,34 @@ static void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
> vmcs_writel(GUEST_RFLAGS, rflags);
> }
>
> +static void vmx_block_interrupt_shadow(struct kvm_vcpu *vcpu)
> +{
> + /*
> + * We emulated an instruction, so temporary interrupt blocking
> + * should be removed, if set.
> + */
> + u32 interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
> + u32 interruptibility_mask = ((GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS));
> +
> + if (interruptibility & interruptibility_mask)
> + vmcs_write32(GUEST_INTERRUPTIBILITY_INFO,
> + interruptibility & ~interruptibility_mask);
> + vcpu->arch.interrupt_window_open = 1;
> +}
> +
How does this logic work when the instruction emulated is an STI or MOV
SS instruction? In particular, when does GUEST_INTERRUPTIBILITY_INFO
sets set to reflect the *blocking* operation?
The pseudo-code for this kind of stuff looks like:
forever {
tmp_int_flags <- int_flags
/* Begin instruction execution */
int_flags |= GUEST_INTR_STATE_STI /* STI instruction */
/* End instruction execution */
int_flags &= ~tmp_int_flags
if (irq_pending && eflags.if == 1 && int_flags == 0)
take_interrupt();
}
Note the behavior in the case of sequential STIs, that int_flags goes to
0 after the second execution.
-hpa
next prev parent reply other threads:[~2009-04-08 18:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-08 17:57 [PATCH] disable interrupt shadow state for emulated instruction Glauber Costa
2009-04-08 18:16 ` H. Peter Anvin [this message]
2009-04-08 18:31 ` Glauber Costa
2009-04-08 18:31 ` H. Peter Anvin
2009-04-08 18:43 ` Glauber Costa
2009-04-08 19:45 ` Gleb Natapov
2009-04-09 7:41 ` Avi Kivity
2009-04-09 7:41 ` Avi Kivity
2009-04-09 7:39 ` Avi Kivity
2009-04-08 19:48 ` Gleb Natapov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49DCE9E5.8020703@zytor.com \
--to=hpa@zytor.com \
--cc=avi@redhat.com \
--cc=glommer@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox