All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huaitong Han <huaitong.han@intel.com>
To: jbeulich@suse.com, andrew.cooper3@citrix.com,
	george.dunlap@eu.citrix.com, wei.liu2@citrix.com, keir@xen.org
Cc: Huaitong Han <huaitong.han@intel.com>, xen-devel@lists.xen.org
Subject: [PATCH V6 3/5] x86/hvm: pkeys, add xstate support for pkeys
Date: Tue, 19 Jan 2016 15:30:57 +0800	[thread overview]
Message-ID: <1453188659-8908-4-git-send-email-huaitong.han@intel.com> (raw)
In-Reply-To: <1453188659-8908-1-git-send-email-huaitong.han@intel.com>

The XSAVE feature set can operate on PKRU state only if the feature set is
enabled (CR4.OSXSAVE = 1) and has been configured to manage PKRU state
(XCR0[9] = 1). And XCR0.PKRU is disabled on PV mode without PKU feature
enabled.

Signed-off-by: Huaitong Han <huaitong.han@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/xstate.c        | 4 ++++
 xen/include/asm-x86/xstate.h | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c
index 4e87ab3..b79b20b 100644
--- a/xen/arch/x86/xstate.c
+++ b/xen/arch/x86/xstate.c
@@ -579,6 +579,10 @@ int handle_xsetbv(u32 index, u64 new_bv)
     if ( (new_bv & ~xfeature_mask) || !valid_xcr0(new_bv) )
         return -EINVAL;
 
+    /* XCR0.PKRU is disabled on PV mode. */
+    if ( is_pv_vcpu(curr) && (new_bv & XSTATE_PKRU) )
+        return -EINVAL;
+
     if ( !set_xcr0(new_bv) )
         return -EFAULT;
 
diff --git a/xen/include/asm-x86/xstate.h b/xen/include/asm-x86/xstate.h
index 12d939b..f7c41ba 100644
--- a/xen/include/asm-x86/xstate.h
+++ b/xen/include/asm-x86/xstate.h
@@ -34,13 +34,15 @@
 #define XSTATE_OPMASK  (1ULL << 5)
 #define XSTATE_ZMM     (1ULL << 6)
 #define XSTATE_HI_ZMM  (1ULL << 7)
+#define XSTATE_PKRU    (1ULL << 9)
 #define XSTATE_LWP     (1ULL << 62) /* AMD lightweight profiling */
 #define XSTATE_FP_SSE  (XSTATE_FP | XSTATE_SSE)
 #define XCNTXT_MASK    (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK | \
                         XSTATE_ZMM | XSTATE_HI_ZMM | XSTATE_NONLAZY)
 
 #define XSTATE_ALL     (~(1ULL << 63))
-#define XSTATE_NONLAZY (XSTATE_LWP | XSTATE_BNDREGS | XSTATE_BNDCSR)
+#define XSTATE_NONLAZY (XSTATE_LWP | XSTATE_BNDREGS | XSTATE_BNDCSR | \
+                        XSTATE_PKRU)
 #define XSTATE_LAZY    (XSTATE_ALL & ~XSTATE_NONLAZY)
 #define XSTATE_COMPACTION_ENABLED  (1ULL << 63)
 
-- 
2.4.3

  parent reply	other threads:[~2016-01-19  7:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19  7:30 [PATCH V6 0/5] x86/hvm: pkeys, add memory protection-key support Huaitong Han
2016-01-19  7:30 ` [PATCH V6 1/5] x86/hvm: pkeys, disable pkeys for guests in non-paging mode Huaitong Han
2016-01-19  7:30 ` [PATCH V6 2/5] x86/hvm: pkeys, add pkeys support for guest_walk_tables Huaitong Han
2016-01-25 15:46   ` Jan Beulich
2016-01-27  3:18     ` Han, Huaitong
2016-01-27 10:20       ` Jan Beulich
2016-01-19  7:30 ` Huaitong Han [this message]
2016-01-25 15:48   ` [PATCH V6 3/5] x86/hvm: pkeys, add xstate support for pkeys Jan Beulich
2016-01-19  7:30 ` [PATCH V6 4/5] xen/mm: Clean up pfec handling in gva_to_gfn Huaitong Han
2016-01-25 15:56   ` Jan Beulich
2016-01-26 14:30   ` Tim Deegan
2016-01-27  7:22     ` Han, Huaitong
2016-01-27  9:34       ` Tim Deegan
2016-01-27 10:13         ` Han, Huaitong
2016-01-19  7:30 ` [PATCH V6 5/5] x86/hvm: pkeys, add pkeys support for cpuid handling Huaitong Han
2016-01-19  9:19   ` Wei Liu
2016-01-25 16:04   ` Jan Beulich
2016-01-25 15:25 ` [PATCH V6 0/5] x86/hvm: pkeys, add memory protection-key support Jan Beulich
2016-01-26  8:06   ` Han, Huaitong

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=1453188659-8908-4-git-send-email-huaitong.han@intel.com \
    --to=huaitong.han@intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@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.