All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Huaitong Han <huaitong.han@intel.com>,
	jbeulich@suse.com, jun.nakajima@intel.com, eddie.dong@intel.com,
	kevin.tian@intel.com, george.dunlap@eu.citrix.com,
	ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com,
	ian.campbell@citrix.com, wei.liu2@citrix.com, keir@xen.org
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH V5 4/6] x86/hvm: pkeys, add pkeys support for guest_walk_tables
Date: Tue, 22 Dec 2015 11:17:16 +0000	[thread overview]
Message-ID: <5679313C.7070906@citrix.com> (raw)
In-Reply-To: <1450780234-17236-5-git-send-email-huaitong.han@intel.com>

On 22/12/15 10:30, Huaitong Han wrote:
> --- a/xen/include/asm-x86/processor.h
> +++ b/xen/include/asm-x86/processor.h
> @@ -373,6 +373,45 @@ static always_inline void clear_in_cr4 (unsigned long mask)
>      write_cr4(read_cr4() & ~mask);
>  }
>  
> +static inline unsigned int read_pkru(void)
> +{
> +    unsigned int pkru;
> +
> +    /*
> +     * _PAGE_PKEY_BITS have a conflict with _PAGE_GNTTAB used by PV guests,
> +     * so that X86_CR4_PKE is disable on hypervisor, RDPKRU instruction can
> +     * be used with temporarily setting CR4.PKE.
> +     */
> +    set_in_cr4(X86_CR4_PKE);
> +    asm volatile (".byte 0x0f,0x01,0xee"
> +        : "=a" (pkru) : "c" (0) : "dx");
> +    clear_in_cr4(X86_CR4_PKE);

You can't use set/clear_in_cr4 here, as it modifies the global
mmu_cr4_features variable.

I would recommend

unsigned long cr4 = read_cr4();
write_cr4(cr4 | X86_CR4_PKE);
...
write_cr4(cr4);

instead.

  reply	other threads:[~2015-12-22 11:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 10:30 [PATCH V5 0/6] x86/hvm: pkeys, add memory protection-key support Huaitong Han
2015-12-22 10:30 ` [PATCH V5 1/6] x86/hvm: pkeys, add the flag to enable Memory Protection Keys Huaitong Han
2015-12-22 12:43   ` Jan Beulich
2015-12-22 10:30 ` [PATCH V5 2/6] x86/hvm: pkeys, add pkeys support when setting CR4 Huaitong Han
2015-12-22 10:30 ` [PATCH V5 3/6] x86/hvm: pkeys, disable pkeys for guests in non-paging mode Huaitong Han
2015-12-22 10:30 ` [PATCH V5 4/6] x86/hvm: pkeys, add pkeys support for guest_walk_tables Huaitong Han
2015-12-22 11:17   ` Andrew Cooper [this message]
2015-12-22 13:02   ` Jan Beulich
2015-12-22 15:23     ` George Dunlap
2015-12-22 15:39   ` George Dunlap
2015-12-22 16:38   ` George Dunlap
2015-12-22 10:30 ` [PATCH V5 5/6] x86/hvm: pkeys, add xstate support for pkeys Huaitong Han
2015-12-22 13:03   ` Jan Beulich
2015-12-22 10:30 ` [PATCH V5 6/6] x86/hvm: pkeys, add pkeys support for cpuid handling Huaitong Han
2015-12-22 13:06   ` Jan Beulich

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=5679313C.7070906@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=huaitong.han@intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=stefano.stabellini@eu.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.