diff options
author | kib <kib@FreeBSD.org> | 2017-08-21 09:04:43 +0000 |
---|---|---|
committer | Luiz Souza <luiz@netgate.com> | 2018-02-21 15:18:14 -0300 |
commit | c512707de74a71e1a3d5d82fc9747ead87cfefda (patch) | |
tree | f36aba439d99c9d3901df508a1f62e99a2815424 | |
parent | 05ab1684179efc5baff3db229caf891d546043c3 (diff) | |
download | FreeBSD-src-c512707de74a71e1a3d5d82fc9747ead87cfefda.zip FreeBSD-src-c512707de74a71e1a3d5d82fc9747ead87cfefda.tar.gz |
MFC r322495:
Add {rd,wr}{fs,gs}base C wrappers for instructions.
(cherry picked from commit 26ec28780cfd5213d56ad9d182c70613df690ba8)
-rw-r--r-- | sys/amd64/include/cpufunc.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 5fa0d77..2107b2ba 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -651,6 +651,38 @@ load_gs(u_short sel) } #endif +static __inline uint64_t +rdfsbase(void) +{ + uint64_t x; + + __asm __volatile("rdfsbase %0" : "=r" (x)); + return (x); +} + +static __inline void +wrfsbase(uint64_t x) +{ + + __asm __volatile("wrfsbase %0" : : "r" (x)); +} + +static __inline uint64_t +rdgsbase(void) +{ + uint64_t x; + + __asm __volatile("rdgsbase %0" : "=r" (x)); + return (x); +} + +static __inline void +wrgsbase(uint64_t x) +{ + + __asm __volatile("wrgsbase %0" : : "r" (x)); +} + static __inline void bare_lgdt(struct region_descriptor *addr) { |