aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2026-09-26 11:43:34 +0000
committerBrooks Davis <brooks@FreeBSD.org>2026-09-26 11:43:34 +0000
commit53fe018630d06eeef6791cfacaa6dc9acdf4d669 (patch)
treef63cba51e54d435fe3d3e13027c892cbacb27597
parent2a717d519e04c5af9f70fb0c0cad0e25aba62d0b (diff)
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
-rw-r--r--sys/amd64/include/cpufunc.h10
1 files changed, 10 insertions, 0 deletions
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)