aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBojan Novković <bnovkov@FreeBSD.org>2024-12-15 14:02:13 +0000
committerBojan Novković <bnovkov@FreeBSD.org>2024-12-15 15:39:36 +0000
commit593e874e61249c845ca83e9284e4d9061643e8fb (patch)
tree1c8305652be686a06e56f277cb401c26ba6dd36e
parent04e832672159cae412e8984e0b0cabfa6e7428b7 (diff)
amd64: Add wrappers for XRSTORS and XSAVES
Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D46984
-rw-r--r--sys/amd64/include/cpufunc.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index ca53d73b0186..d180f5c76afb 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -942,6 +942,29 @@ sgx_eremove(void *epc)
return (sgx_encls(SGX_EREMOVE, 0, (uint64_t)epc, 0));
}
+static __inline void
+xrstors(uint8_t *save_area, uint64_t state_bitmap)
+{
+ uint32_t low, hi;
+
+ low = state_bitmap;
+ hi = state_bitmap >> 32;
+ __asm __volatile("xrstors %0" : : "m"(*save_area), "a"(low),
+ "d"(hi));
+}
+
+static __inline void
+xsaves(uint8_t *save_area, uint64_t state_bitmap)
+{
+ uint32_t low, hi;
+
+ low = state_bitmap;
+ hi = state_bitmap >> 32;
+ __asm __volatile("xsaves %0" : "=m"(*save_area) : "a"(low),
+ "d"(hi)
+ : "memory");
+}
+
void reset_dbregs(void);
#ifdef _KERNEL