From nobody Fri Feb 13 08:17:55 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4fC4mM6j91z6SjDR for ; Fri, 13 Feb 2026 08:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fC4mM5mz0z3fP6 for ; Fri, 13 Feb 2026 08:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770970675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jJk587gR6XTvbo1XDD0E5rlU/djowQoSocfx9o/OwCw=; b=TMXMCiIkOEeZD0BNv7d4JPsgbipfFBEVuloXTmfwx4v/PowZunW5nCYkd2CZA37AME46iF PN5vPIR3Zya/G9VEODo+b5MYq0PtduQijQRbsgFqLBY7QYkGZ+V9yiM4sb82czc8u6zDvZ FqeMBdVVylVvEU0ZzbkSr6HrVeu8y+mY36+gRwM6v4qyEIb6RzT0zHIK1SalIyLhYW5DBX d5SH4Q5Oueffl6leJs2gtQ8+jpmi8bCUQmdp2CmvAQaU6JVFLkz0DA5SgVEOS/oQWNr7AW FEnJXKK8uV+3wOnqMbx0bg5WUX5L8/M0efdtsFDniXl1y9NW6d/WN4+1cGWE3Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770970675; a=rsa-sha256; cv=none; b=nxJwOivThitTjojj90XcriHpD9+yueAfh7CZivGULGu3rAJWLy2gKpv9BkU4hc2mdOYkCj I7CdfTVeqzgXe/PpRSySeXaoHztIuQM0gkk+j5OpGxwKlcyVqHMavir/hRpo0ni9zug8yH fiuUAXD98d0FXT5RPC9pHk+/+mCwdtO6J2WAEh5ZDXz/11asM3eyQZEedRWnqF4Y7cFY+/ /zblYfACjXZWqCVWApdHIrBRHilWCtQm9tfCjgK6LYIwgvVDYYGarD33njBcHGwP6j7wTs BWmCFmBfYs0eazqHwkE/vrkVOwxXCeDdpPUFhUk8/fc24JZ/WhYwBq/nFe/mEQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770970675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jJk587gR6XTvbo1XDD0E5rlU/djowQoSocfx9o/OwCw=; b=kxAmfmMu1pvnpiFMmizaeZhZrop8C8R/t0gCECMreqBIk+1chaImz5uwRENMWGUPJA33Z+ R07HwEPi8CZUIt9VujhTOfkKd3mOjQOTAEBou2lW5Du9Jazv1ZRFTxXXOtZhWYHXgsqY7e RQc2hyzwPAy6lFNq/M/3f6K7CXq95yuYpf2oIzx6LXa/6KsBBbUdC6VosSJRzoylRSLJyk 6EL1E7v25HNC+IC25DWen8IgF/cc28uNi4Df1dDrX9gpXlUc6uuZdssgBf+0LDbOEWOLUZ 5skwMd94c94/Ve1dBr1zcDIdr94MWZyqyISk3/S3/M3rnHi6+qR6kZs+MouO1Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fC4mM5N10z1CVJ for ; Fri, 13 Feb 2026 08:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 40456 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 13 Feb 2026 08:17:55 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 36ceb5509d01 - main - x86_msr_op(9): consistently return the value read from MSR List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36ceb5509d01ff2e6482a78ca809c344574e9a25 Auto-Submitted: auto-generated Date: Fri, 13 Feb 2026 08:17:55 +0000 Message-Id: <698ede33.40456.5f8393c3@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=36ceb5509d01ff2e6482a78ca809c344574e9a25 commit 36ceb5509d01ff2e6482a78ca809c344574e9a25 Author: Konstantin Belousov AuthorDate: 2026-02-04 00:24:58 +0000 Commit: Konstantin Belousov CommitDate: 2026-02-13 07:55:04 +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 --- 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();