diff options
author | jhb <jhb@FreeBSD.org> | 2012-07-05 18:19:35 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2012-07-05 18:19:35 +0000 |
commit | 01cf3702717619365bfc8c89f9a0fe9671fc2cd3 (patch) | |
tree | 35ea2f55ff86fbb0f5e157d71de2ac3a4eb47e4f /sys/amd64/include/cpufunc.h | |
parent | cb94d55db1288d2a92d7b4edfdc96bccbc64cebc (diff) | |
download | FreeBSD-src-01cf3702717619365bfc8c89f9a0fe9671fc2cd3.zip FreeBSD-src-01cf3702717619365bfc8c89f9a0fe9671fc2cd3.tar.gz |
Now that our assembler supports the xsave family of instructions, use them
natively rather than hand-assembled versions. For xgetbv/xsetbv, add a
wrapper API to deal with xcr* registers: rxcr() and load_xcr().
Reviewed by: kib
MFC after: 1 month
Diffstat (limited to 'sys/amd64/include/cpufunc.h')
-rw-r--r-- | sys/amd64/include/cpufunc.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 927d00f..829efc1 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -418,6 +418,25 @@ rcr4(void) return (data); } +static __inline u_long +rxcr(u_int reg) +{ + u_int low, high; + + __asm __volatile("xgetbv" : "=a" (low), "=d" (high) : "c" (reg)); + return (low | ((uint64_t)high << 32)); +} + +static __inline void +load_xcr(u_int reg, u_long val) +{ + u_int low, high; + + low = val; + high = val >> 32; + __asm __volatile("xsetbv" : : "c" (reg), "a" (low), "d" (high)); +} + /* * Global TLB flush (except for thise for pages marked PG_G) */ |