Date: Thu, 23 Jul 2026 10:00:25 +0000 From: Olivier Certner <olce@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Konstantin Belousov <kib@FreeBSD.org> Subject: git: 8b2546469323 - stable/14 - x86_msr_op(9): consistently return the value read from MSR Message-ID: <6a61e639.3d397.6cf43856@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=8b2546469323c72a954d4c0c1202d0845b80c3ee commit 8b2546469323c72a954d4c0c1202d0845b80c3ee Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2026-02-04 00:24:58 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2026-07-23 09:59:00 +0000 x86_msr_op(9): consistently return the value read from MSR If the operation is executed on more than one CPU, a random instance of the read value is returned. Reviewed by: markj, olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D55045 (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 6e49a25f8ece..0228e127419b 100644 --- a/sys/x86/x86/cpu_machdep.c +++ b/sys/x86/x86/cpu_machdep.c @@ -137,6 +137,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) @@ -148,6 +150,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) @@ -160,10 +164,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; } } @@ -176,11 +182,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; @@ -189,7 +199,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();home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a61e639.3d397.6cf43856>
