From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Paul Durrant <paul.durrant@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH for-4.7 3/4] x86/hvm: Correct the emulated interaction of invlpg with segments
Date: Mon, 9 May 2016 14:47:03 +0100 [thread overview]
Message-ID: <573094D7.7050600@citrix.com> (raw)
In-Reply-To: <5730AFD402000078000E9964@prv-mh.provo.novell.com>
On 09/05/16 14:42, Jan Beulich wrote:
>>>> On 09.05.16 at 15:15, <andrew.cooper3@citrix.com> wrote:
>> The `invlpg` instruction is documented to take a memory address, and is not
>> documented to suffer faults from segmentation violations.
>>
>> Experimentally, and subsequently confirmed by both Intel and AMD, the
>> instruction does take into account segment bases, but will happily invalidate
>> a TLB entry for a mapping beyond the segment limit.
> How about non-canonical addresses? If those don't #GP (which is
> what I assume), is such an INVLPG a NOP
They are explicitly documented by both Intel and AMD as being a NOP when
passed a non-canonical address. Experimentation confirms this.
(I am just putting the finishing touches on an XTF test for all of this).
> , or does it invalidate
> something (e.g. the translation for the address truncated to 48
> bits)? In that latter case we might need to also make our code
> behave that way...
>
>> The emulation logic will currently raise #GP/#SS faults for segment limit
>> violations, or non-canonical addresses, which doesn't match hardware's
>> behaviour. Instead, squash exceptions generated by
>> hvmemul_virtual_to_linear() and proceed with invalidation.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> albeit I think ...
>
>> --- a/xen/arch/x86/hvm/emulate.c
>> +++ b/xen/arch/x86/hvm/emulate.c
>> @@ -1608,7 +1608,22 @@ static int hvmemul_invlpg(
>> rc = hvmemul_virtual_to_linear(
>> seg, offset, 1, &reps, hvm_access_none, hvmemul_ctxt, &addr);
>>
>> - if ( rc == X86EMUL_OKAY )
>> + if ( rc == X86EMUL_EXCEPTION )
>> + {
>> + /*
>> + * `invlpg` takes segment bases into account, but is not subject to
>> + * faults from segment type/limit checks, and is specified as a NOP
>> + * when issued on non-canonical addresses.
>> + *
>> + * hvmemul_virtual_to_linear() raises exceptions for type/limit
>> + * violations, so squash them.
>> + */
>> + hvmemul_ctxt->exn_pending = 0;
>> + hvmemul_ctxt->trap = (struct hvm_trap){};
> ... this does more work than is really needed.
For sanity sake, I would prefer not to leave stale information in the
emulation context. This path is definitely not a hotpath.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-05-09 13:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-09 13:15 [PATCH for-4.7 0/4] Fixes for invlpg handling for HVM guests Andrew Cooper
2016-05-09 13:15 ` [PATCH for-4.7 1/4] x86/hvm: Always return the linear address from hvm_virtual_to_linear_addr() Andrew Cooper
2016-05-09 13:35 ` Jan Beulich
2016-05-09 13:15 ` [PATCH for-4.7 2/4] x86/hvm: Raise #SS faults for %ss-based segmentation violations Andrew Cooper
2016-05-09 13:37 ` Jan Beulich
2016-05-09 13:41 ` Wei Liu
2016-05-09 13:41 ` David Vrabel
2016-05-09 13:15 ` [PATCH for-4.7 3/4] x86/hvm: Correct the emulated interaction of invlpg with segments Andrew Cooper
2016-05-09 13:42 ` Jan Beulich
2016-05-09 13:47 ` Andrew Cooper [this message]
2016-05-09 13:48 ` Paul Durrant
2016-05-09 13:15 ` [PATCH for-4.7 4/4] x86/hvm: Fix invalidation for emulated invlpg instructions Andrew Cooper
2016-05-09 13:57 ` Jan Beulich
2016-05-09 14:08 ` Andrew Cooper
[not found] ` <20160509151439.GE39480@deinos.phlegethon.org>
2016-05-09 15:29 ` Andrew Cooper
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=573094D7.7050600@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=paul.durrant@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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 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.