git: 61412c0ff5cc - stable/15 - amd64 cpufunc.h: add WRMSRNS helpers

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 29 Sep 2026 00:31:51 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=61412c0ff5cc69103a1e24ceaa387d4a2e150c40

commit 61412c0ff5cc69103a1e24ceaa387d4a2e150c40
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-09-19 08:31:59 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-29 00:26:31 +0000

    amd64 cpufunc.h: add WRMSRNS helpers
    
    (cherry picked from commit 4a8acccc2e59b6ac5f4068471d94b40347ebeff0)
---
 sys/amd64/include/cpufunc.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index 9a4c82275a99..1703d0109595 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -382,6 +382,19 @@ wrmsr(u_int msr, uint64_t newval)
 	__asm __volatile("wrmsr" : : "a" (low), "d" (high), "c" (msr));
 }
 
+static __inline void
+wrmsrns(u_int msr, uint64_t newval)
+{
+	uint32_t low, high;
+
+	low = newval;
+	high = newval >> 32;
+	__asm __volatile("wrmsrns" : : "a" (low), "d" (high), "c" (msr));
+}
+
+#define	wrmsr_imm(msr, val) \
+    __asm __volatile("wrmsrns %0, %1" : : "r" (val), "i" (msr))
+
 static __inline void
 load_cr0(u_long data)
 {