Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Dec 2024 15:40:37 GMT
From:      Bojan =?utf-8?Q?Novkovi=C4=87?= <bnovkov@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 593e874e6124 - main - amd64: Add wrappers for XRSTORS and XSAVES
Message-ID:  <202412151540.4BFFebXj069394@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bnovkov:

URL: https://cgit.FreeBSD.org/src/commit/?id=593e874e61249c845ca83e9284e4d9061643e8fb

commit 593e874e61249c845ca83e9284e4d9061643e8fb
Author:     Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2024-12-15 14:02:13 +0000
Commit:     Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2024-12-15 15:39:36 +0000

    amd64: Add wrappers for XRSTORS and XSAVES
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D46984
---
 sys/amd64/include/cpufunc.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

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



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