Provide convenience C wrappers for RDPKRU and WRPKRU instructions.
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D18893
This commit is contained in:
parent
27e3adb11b
commit
7fc374eaa9
@ -627,6 +627,22 @@ cpu_mwait(u_long extensions, u_int hints)
|
||||
__asm __volatile("mwait" : : "a" (hints), "c" (extensions));
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
rdpkru(void)
|
||||
{
|
||||
uint32_t res;
|
||||
|
||||
__asm __volatile("rdpkru" : "=a" (res) : "c" (0) : "edx");
|
||||
return (res);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
wrpkru(uint32_t mask)
|
||||
{
|
||||
|
||||
__asm __volatile("wrpkru" : : "a" (mask), "c" (0), "d" (0));
|
||||
}
|
||||
|
||||
#ifdef _KERNEL
|
||||
/* This is defined in <machine/specialreg.h> but is too painful to get to */
|
||||
#ifndef MSR_FSBASE
|
||||
|
@ -726,6 +726,22 @@ intr_restore(register_t eflags)
|
||||
write_eflags(eflags);
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
rdpkru(void)
|
||||
{
|
||||
uint32_t res;
|
||||
|
||||
__asm __volatile("rdpkru" : "=a" (res) : "c" (0) : "edx");
|
||||
return (res);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
wrpkru(uint32_t mask)
|
||||
{
|
||||
|
||||
__asm __volatile("wrpkru" : : "a" (mask), "c" (0), "d" (0));
|
||||
}
|
||||
|
||||
#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
|
||||
|
||||
int breakpoint(void);
|
||||
|
Loading…
Reference in New Issue
Block a user