[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [V2 PATCH 6/9] x86/hvm: pkeys, add functions to support PKRU access
This patch adds functions to support PKRU access. Signed-off-by: Huaitong Han <huaitong.han@xxxxxxxxx> --- xen/include/asm-x86/processor.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index 3f8411f..68d86cb 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -342,6 +342,21 @@ static inline void write_cr4(unsigned long val) asm volatile ( "mov %0,%%cr4" : : "r" (val) ); } +/* Macros for PKRU domain */ +#define PKRU_READ 0 +#define PKRU_WRITE 1 +#define PKRU_ATTRS 2 + +/* + * PKRU defines 32 bits, there are 16 domains and 2 attribute bits per + * domain in pkru, pkeys is index to a defined domain, so the value of + * pte_pkeys * PKRU_ATTRS + R/W is offset of a defined domain attribute. + */ +#define READ_PKRU_AD(pkru, pkey) \ + ((pkru >> (pkey * PKRU_ATTRS + PKRU_READ)) & 1) +#define READ_PKRU_WD(pkru, pkey) \ + ((pkru >> (pkey * PKRU_ATTRS + PKRU_WRITE)) & 1) + /* Clear and set 'TS' bit respectively */ static inline void clts(void) { -- 2.4.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |