From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>, Wei Liu <wei.liu2@citrix.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Tim Deegan <tim@xen.org>, Xen-devel <xen-devel@lists.xen.org>,
Paul Durrant <paul.durrant@citrix.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH for-4.7 4/4] x86/hvm: Fix invalidation for emulated invlpg instructions
Date: Mon, 9 May 2016 15:08:35 +0100 [thread overview]
Message-ID: <573099E3.8050403@citrix.com> (raw)
In-Reply-To: <5730B35302000078000E999C@prv-mh.provo.novell.com>
On 09/05/16 14:57, Jan Beulich wrote:
>>>> On 09.05.16 at 15:15, <andrew.cooper3@citrix.com> wrote:
>> --- a/xen/arch/x86/hvm/svm/svm.c
>> +++ b/xen/arch/x86/hvm/svm/svm.c
>> @@ -2222,10 +2222,13 @@ static void svm_invlpga_intercept(
>>
>> static void svm_invlpg_intercept(unsigned long vaddr)
>> {
>> - struct vcpu *curr = current;
>> HVMTRACE_LONG_2D(INVLPG, 0, TRC_PAR_LONG(vaddr));
>> - paging_invlpg(curr, vaddr);
>> - svm_asid_g_invlpg(curr, vaddr);
>> + paging_invlpg(current, vaddr);
>> +}
>> +
>> +static void svm_invlpg(unsigned long vaddr)
>> +{
>> + svm_asid_g_invlpg(current, vaddr);
> Since paging_invlpg() already gets passed a struct vcpu *, having
> it hand it to ->invlpg() would seem quite natural.
Ok.
>
>> @@ -2432,10 +2432,14 @@ static void vmx_dr_access(unsigned long
>> exit_qualification,
>>
>> static void vmx_invlpg_intercept(unsigned long vaddr)
>> {
>> - struct vcpu *curr = current;
>> HVMTRACE_LONG_2D(INVLPG, /*invlpga=*/ 0, TRC_PAR_LONG(vaddr));
>> - if ( paging_invlpg(curr, vaddr) && cpu_has_vmx_vpid )
> So the previous dependency on paging_invlpg()'s return value gets
> moved into that function (making the call here conditional). While
> that's fine for VMX, SVM previously didn't pay attention to that
> return value, and hence you're altering behavior in a way not
> spelled out in the description (and to be honest I'm also not 100%
> certain that change is correct).
I thought I had included this in the commit message, but it appears it
got lost.
AMD is over-the-top with its TLB flushing generally, and will allocate a
new ASID rather than shooting a single mapping out of the current ASID.
The new svm_invlpg() should be a simple invlpga() call with the in-use
ASID. However, the instruction emulator forwards invlpga to invlpg and
loses the ASID, meaning that the only reason it functions is because
this case over-flushes at the moment. I opted not to break that usecase.
However, for the cases where paging_invlpg() returns 0, there is no need
to allocate an ASID at all, as there are no mapping needing invalidation
which could have been cached in the TLB. As such, this change is a
performance improvement, albeit a minor one as the common case is dealt
with directly in hardware without Xen's interaction.
>
>> --- a/xen/arch/x86/mm.c
>> +++ b/xen/arch/x86/mm.c
>> @@ -6478,6 +6478,19 @@ const unsigned long *__init get_platform_badpages(unsigned int *array_size)
>> return bad_pages;
>> }
>>
>> +bool_t paging_invlpg(struct vcpu *v, unsigned long va)
>> +{
>> + bool_t invl = paging_mode_external(v->domain)
>> + ? is_canonical_address(va) : __addr_ok(va);
>> +
>> + if ( invl )
>> + invl = paging_get_hostmode(v)->invlpg(v, va);
>> + if ( invl && is_hvm_domain(v->domain) )
> has_hvm_container_domain() (or paging_mode_external(),
> implying the former)?
I could have sworn I already fixed this... Will do for v2.
~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 14:08 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
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 [this message]
[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=573099E3.8050403@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=boris.ostrovsky@oracle.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=paul.durrant@citrix.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=tim@xen.org \
--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.