git: b0bc769c363e - stable/15 - x86_msr_op(9): consistently return the value read from MSR
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 19 Feb 2026 22:08:47 UTC
The branch stable/15 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=b0bc769c363ef616c1e7c21a9d4b031be11ef00e
commit b0bc769c363ef616c1e7c21a9d4b031be11ef00e
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-02-04 00:24:58 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-02-19 22:05:20 +0000
x86_msr_op(9): consistently return the value read from MSR
(cherry picked from commit 36ceb5509d01ff2e6482a78ca809c344574e9a25)
---
sys/x86/x86/cpu_machdep.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c
index 023b02ba7c76..6c3f4add6202 100644
--- a/sys/x86/x86/cpu_machdep.c
+++ b/sys/x86/x86/cpu_machdep.c
@@ -136,6 +136,8 @@ x86_msr_op_one_safe(struct msr_op_arg *a)
atomic_cmpset_int(&a->error, 0, error);
break;
}
+ if (a->res != NULL)
+ atomic_store_64(a->res, v);
v &= ~a->arg1;
error = wrmsr_safe(a->msr, v);
if (error != 0)
@@ -147,6 +149,8 @@ x86_msr_op_one_safe(struct msr_op_arg *a)
atomic_cmpset_int(&a->error, 0, error);
break;
}
+ if (a->res != NULL)
+ atomic_store_64(a->res, v);
v |= a->arg1;
error = wrmsr_safe(a->msr, v);
if (error != 0)
@@ -159,10 +163,12 @@ x86_msr_op_one_safe(struct msr_op_arg *a)
break;
case MSR_OP_READ:
error = rdmsr_safe(a->msr, &v);
- if (error == 0)
- *a->res = v;
- else
+ if (error == 0) {
+ if (a->res != NULL)
+ atomic_store_64(a->res, v);
+ } else {
atomic_cmpset_int(&a->error, 0, error);
+ }
break;
}
}
@@ -175,11 +181,15 @@ x86_msr_op_one_unsafe(struct msr_op_arg *a)
switch (a->op) {
case MSR_OP_ANDNOT:
v = rdmsr(a->msr);
+ if (a->res != NULL)
+ atomic_store_64(a->res, v);
v &= ~a->arg1;
wrmsr(a->msr, v);
break;
case MSR_OP_OR:
v = rdmsr(a->msr);
+ if (a->res != NULL)
+ atomic_store_64(a->res, v);
v |= a->arg1;
wrmsr(a->msr, v);
break;
@@ -188,7 +198,8 @@ x86_msr_op_one_unsafe(struct msr_op_arg *a)
break;
case MSR_OP_READ:
v = rdmsr(a->msr);
- *a->res = v;
+ if (a->res != NULL)
+ atomic_store_64(a->res, v);
break;
default:
__assert_unreachable();