All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Juergen Gross <jgross@suse.com>,
	Xen-devel <xen-devel@lists.xenproject.org>,
	Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH RFC 3/4] x86: add invpcid.h
Date: Thu, 15 Feb 2018 12:26:32 +0000	[thread overview]
Message-ID: <afe5b9c9-e104-e695-b825-7050fd70dc2d@citrix.com> (raw)
In-Reply-To: <20180215122455.3aignbojfrx67pn4@citrix.com>

On 15/02/18 12:24, Wei Liu wrote:
> On Thu, Feb 15, 2018 at 12:15:56PM +0000, Andrew Cooper wrote:
>> On 15/02/18 12:10, Wei Liu wrote:
>>> Provide the functions needed for different modes.
>>>
>>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>>> ---
>>>  xen/include/asm-x86/invpcid.h | 61 +++++++++++++++++++++++++++++++++++++++++++
>>>  1 file changed, 61 insertions(+)
>>>  create mode 100644 xen/include/asm-x86/invpcid.h
>>>
>>> diff --git a/xen/include/asm-x86/invpcid.h b/xen/include/asm-x86/invpcid.h
>>> new file mode 100644
>>> index 0000000000..7c307ecfc3
>>> --- /dev/null
>>> +++ b/xen/include/asm-x86/invpcid.h
>>> @@ -0,0 +1,61 @@
>>> +#ifndef _ASM_X86_INVPCID_H_
>>> +#define _ASM_X86_INVPCID_H_
>>> +
>>> +#include <xen/types.h>
>>> +
>>> +#define INVPCID_TYPE_INDIV_ADDR      0
>>> +#define INVPCID_TYPE_SINGLE_CTXT     1
>>> +#define INVPCID_TYPE_ALL_INCL_GLOBAL 2
>>> +#define INVPCID_TYPE_ALL_NON_GLOBAL  3
>>> +
>>> +struct invpcid_desc {
>>> +    uint64_t pcid:12;
>>> +    uint64_t reserved:52;
>>> +    uint64_t addr;
>>> +};
>>> +
>>> +static inline void invpcid(unsigned long pcid, unsigned long addr,
>>> +                           unsigned long type)
>>> +{
>>> +    struct invpcid_desc desc = { .pcid = pcid, .addr = addr };
>>> +
>>> +    asm volatile ("invpcid (%0), %1"
>>> +                  : : "r" (&desc), "r" (type) : "memory" );
>> invpcid %[desc], %[type]
>>
>> And you can use [desc] "m" (desc) for the constraint.  The structure
>> will be built on the stack, meaning that an %rsp based memory reference
>> is more efficient than forcing the use of a register.
> NP.
>
>> We probably also need a -DHAVE_GAS_INVPCID, as INVPCID is newer than
>> some of the instruction groups we already check for.
>>
> Or we can just use the byte code directly -- it is the same for both 64
> and 32 bit, then manually specify the ModRM byte. That's what Linux
> does.

See the vmx __invept() wrapper, which is very similar, but doesn't need
the BUG() handling.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-02-15 12:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 12:10 [PATCH RFC 0/4] Use INVPCID to flush global mappings Wei Liu
2018-02-15 12:10 ` [PATCH RFC 1/4] x86: introduce cpu_has_invpcid Wei Liu
2018-02-15 12:31   ` Jan Beulich
2018-02-15 12:10 ` [PATCH RFC 2/4] x86: report if PCID and INVPCID are supported Wei Liu
2018-02-15 12:10 ` [PATCH RFC 3/4] x86: add invpcid.h Wei Liu
2018-02-15 12:15   ` Andrew Cooper
2018-02-15 12:24     ` Wei Liu
2018-02-15 12:26       ` Andrew Cooper [this message]
2018-02-15 12:34   ` Jan Beulich
2018-02-15 12:35     ` Wei Liu
2018-02-15 13:23       ` Jan Beulich
2018-02-15 12:10 ` [PATCH RFC 4/4] x86: use invpcid to do global flush Wei Liu
2018-02-15 15:38 ` [PATCH RFC 0/4] Use INVPCID to flush global mappings Juergen Gross

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=afe5b9c9-e104-e695-b825-7050fd70dc2d@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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.