git: 4a8acccc2e59 - main - amd64 cpufunc.h: add WRMSRNS helpers

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 22 Sep 2026 15:41:46 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=4a8acccc2e59b6ac5f4068471d94b40347ebeff0

commit 4a8acccc2e59b6ac5f4068471d94b40347ebeff0
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-09-19 08:31:59 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-22 15:40:40 +0000

    amd64 cpufunc.h: add WRMSRNS helpers
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D59815
---
 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 e52c55dc80f0..38dfbf2a493b 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -380,6 +380,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)
 {