svn commit: r344466 - in stable/12/sys: amd64/include i386/include
Konstantin Belousov
kib at FreeBSD.org
Fri Feb 22 12:26:29 UTC 2019
Author: kib
Date: Fri Feb 22 12:26:28 2019
New Revision: 344466
URL: https://svnweb.freebsd.org/changeset/base/344466
Log:
MFC r344296:
Provide convenience C wrappers for RDPKRU and WRPKRU instructions.
Modified:
stable/12/sys/amd64/include/cpufunc.h
stable/12/sys/i386/include/cpufunc.h
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/amd64/include/cpufunc.h
==============================================================================
--- stable/12/sys/amd64/include/cpufunc.h Fri Feb 22 12:12:01 2019 (r344465)
+++ stable/12/sys/amd64/include/cpufunc.h Fri Feb 22 12:26:28 2019 (r344466)
@@ -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
Modified: stable/12/sys/i386/include/cpufunc.h
==============================================================================
--- stable/12/sys/i386/include/cpufunc.h Fri Feb 22 12:12:01 2019 (r344465)
+++ stable/12/sys/i386/include/cpufunc.h Fri Feb 22 12:26:28 2019 (r344466)
@@ -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);
More information about the svn-src-all
mailing list