Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Feb 2019 12:26:28 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r344466 - in stable/12/sys: amd64/include i386/include
Message-ID:  <201902221226.x1MCQSZE047908@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902221226.x1MCQSZE047908>