git: 53fe018630d0 - main - amd64: gate WRMSRNS immediate form on compiler support
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 26 Sep 2026 11:44:06 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=53fe018630d06eeef6791cfacaa6dc9acdf4d669
commit 53fe018630d06eeef6791cfacaa6dc9acdf4d669
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-09-26 11:43:34 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-09-26 11:43:34 +0000
amd64: gate WRMSRNS immediate form on compiler support
This support was introduced in LLVM 20 and we still support releases
with LLVM 19 so it's too early to require LLVM 20. Decay to the
non-immediate form when the compiler it too old. This makes the ifunc
pointless, but limits the need for other ifdefs.
Reviewed by: kib
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D60023
---
sys/amd64/include/cpufunc.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index 38dfbf2a493b..f56a7e763158 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -390,8 +390,18 @@ wrmsrns(u_int msr, uint64_t newval)
__asm __volatile("wrmsrns" : : "a" (low), "d" (high), "c" (msr));
}
+#if defined(__clang__) && \
+ (__clang_major__ > 20 || (__clang_major__ == 20 && __clang_minor__ >= 1))
#define wrmsr_imm(msr, val) \
__asm __volatile("wrmsrns %0, %1" : : "r" (val), "i" (msr))
+#else
+/*
+ * When Clang does not support the immediate form of wrmsr, decay it
+ * to plain wrmsr.
+ */
+#define wrmsr_imm(msr, val) \
+ wrmsr((msr), (val));
+#endif
static __inline void
load_cr0(u_long data)