From: Avi Kivity <avi@redhat.com>
To: Stefan Fritsch <sf@sfritsch.de>
Cc: kvm@vger.kernel.org
Subject: Re: How to do fast accesses to LAPIC TPR under kvm?
Date: Thu, 25 Oct 2012 15:34:53 +0200 [thread overview]
Message-ID: <50893FFD.4000803@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1210241107300.5607@eru.sfritsch.de>
On 10/24/2012 11:19 AM, Stefan Fritsch wrote:
>>
>> With the decode table fix I think it should work.
>
> It needs some more changes. The patch below did the trick for me. It is
> against 3.5, because I didn't want to build a whole new kernel (my test
> machine is a dead slow AMD E-350).
>
> The patch is definitely incomplete. It now allows the lock prefix for
> all mov operations on the cr1-7, which should not be the case. Apart
> from that, do the changes look reasonable? I have not checked that this
> is the minimal patch that works. But the LockReg bit was definitely
> necessary, that was the final piece to make it work.
>
> Cheers,
> Stefan
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 4837375..c7f0ec7 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -128,6 +128,7 @@
> #define Priv (1<<27) /* instruction generates #GP if current CPL
> != 0 */
> #define No64 (1<<28)
> #define PageTable (1 << 29) /* instruction used to write page table */
> +#define LockReg (1<<30) /* lock prefix is allowed for the
> instruction even for reg destination */
> /* Source 2 operand type */
> #define Src2Shift (30)
LockReg conflicts with Src2Shift.
> #define Src2None (OpNone << Src2Shift)
> @@ -420,6 +421,7 @@ static int emulator_check_intercept(struct
> x86_emulate_ctxt *ctxt,
> struct x86_instruction_info info = {
> .intercept = intercept,
> .rep_prefix = ctxt->rep_prefix,
> + .lock_prefix = ctxt->lock_prefix,
> .modrm_mod = ctxt->modrm_mod,
> .modrm_reg = ctxt->modrm_reg,
> .modrm_rm = ctxt->modrm_rm,
> @@ -2874,7 +2876,10 @@ static int em_mov(struct x86_emulate_ctxt *ctxt)
>
> static int em_cr_write(struct x86_emulate_ctxt *ctxt)
> {
> - if (ctxt->ops->set_cr(ctxt, ctxt->modrm_reg, ctxt->src.val))
> + int cr = ctxt->modrm_reg;
Blank line here.
> + if (ctxt->lock_prefix && cr == 0)
> + cr = 8;
But maybe this is better dealt with during general decode, and
ctxt->modrm_reg adjusted instead. This removes the code triplicstion.
Please also #UD if modrm_reg != 0, and if the feature is not exposed to
the guest via cpuid.
Please regenerate against kvm.git next, there have been changes to
emulate.c.
--
error compiling committee.c: too many arguments to function
prev parent reply other threads:[~2012-10-25 13:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-17 19:24 How to do fast accesses to LAPIC TPR under kvm? Stefan Fritsch
2012-10-18 6:13 ` Jan Kiszka
2012-10-18 7:43 ` Stefan Fritsch
2012-10-18 9:35 ` Gleb Natapov
2012-10-18 12:27 ` Avi Kivity
2012-10-18 17:25 ` Stefan Fritsch
2012-10-19 22:39 ` Stefan Fritsch
2012-10-22 14:10 ` Avi Kivity
2012-10-24 9:19 ` Stefan Fritsch
2012-10-25 13:34 ` Avi Kivity [this message]
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=50893FFD.4000803@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=sf@sfritsch.de \
/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 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.