git: 54cb4bf00b82 - stable/15 - amd64: gate WRMSRNS immediate form on compiler support
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 29 Sep 2026 00:31:52 UTC
The branch stable/15 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=54cb4bf00b82f4a9cafb9942089aa00bfcca06f0
commit 54cb4bf00b82f4a9cafb9942089aa00bfcca06f0
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-09-26 11:43:34 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-29 00:27:13 +0000
amd64: gate WRMSRNS immediate form on compiler support
(cherry picked from commit 53fe018630d06eeef6791cfacaa6dc9acdf4d669)
---
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 1703d0109595..7144866273fb 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -392,8 +392,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)