From nobody Wed Sep 04 09:11:46 2024
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 4WzGvl6sHjz5TTgJ;
Wed, 04 Sep 2024 09:11:47 +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 "R11" (verified OK))
by mx1.freebsd.org (Postfix) with ESMTPS id 4WzGvl5jVPz4hC3;
Wed, 4 Sep 2024 09:11:47 +0000 (UTC)
(envelope-from git@FreeBSD.org)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
t=1725441107;
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=OAidzEki7BZnHlw4/ysHT08Lh7Smm7sfLy38tD2HPFE=;
b=tLiNcO8jg3eefRAh6nGanw3gZ6hRF5z/U7va0Ib8Nq/jqHwFhxUmDo1Ig4xYx+4vKFQjmr
oATTKEw5nE7MCz9SGuw/99pOSXasIlGpMhxmRhOW60V4RMW9ZrmXQqdSf5IMcOZc+ALdrx
QNYw++lqcQPQRa4UT0vm5GwtrtTn/ANJohUafEtvEa1CTCAGZ/xEoEpGkoCbEpqJu5FDd0
feH8Xk9tHX9qv2B2GHMlTssWBFI+LEWAKNbXVchoFubx5e+Pph2he6C37fzehTBQvOmcwy
Z4NFHK1AxsmzUKk7ACoImmMQrGF2luG6e0nMbiH4zbx4A1a/nGiSX224agNvlA==
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725441107; a=rsa-sha256; cv=none;
b=CuTgwVz++CfTFGYo41d74LzSnkC2HDvkG9QHM4bZndFoxBz9WUdMRPm4vQYIqcpZUejtig
tHvBQJenz2nsJ61MjECoYJlxn5Zqpv5Wo9VRH5QJYO57Nfbg2DaJtVHXUIHgXoKo5qZWZP
0yNmwgM0cqK0SQ3wnYVGLIuTkdlNuo5qTqHPA/L6eXI5Bm8cVk1VUgAs3Gp/JEKCWZl/uG
r9khkEKQLafmk2e7Nd8GrytZBhFQ7dmTNKULWEGvSo3VkOnXeYZsDzoCKBsstsSPo3vm/M
8WGgs9hVo4zQ/qXSuc7t0BaC8D5FSdp467f1yUKasmIHyI4UUTiPhf4TWCxJ5g==
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=1725441107;
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=OAidzEki7BZnHlw4/ysHT08Lh7Smm7sfLy38tD2HPFE=;
b=twMbREcexWxnFmJFCE/RFX/6eqh5LJ/0Ixs1a4zzxoAPhs8Yxg+AOV43OzJl4wKt8K3OA9
d/H5MJOTwS+p5rEk7ZORHNIq90Oqd4Xt2f6YYBDwe+xYJCATziDwmUhkqKfz/TinxDpbb8
EAMr62A8sZalrhGBBT5UVYUCmUmbzb9iuhpSYf25sAjWHMmfhGst3vTE3aDqs7Z3wpBfXl
hH71x2hHmKCkSu/YoSsYGBicTha0R7ptSWkm5k6F9HsqeZfgG754qmkpKiNTwTLD1rsMVs
FTKo3xCteFyhLWAK0Hi074tFUJ+nD+y5pDmCxw9SeAPpAR37ud1uwdPuhtOh0A==
Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5])
(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 did not present a certificate)
by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WzGvl0HjPzHcp;
Wed, 4 Sep 2024 09:11:47 +0000 (UTC)
(envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org ([127.0.1.44])
by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4849BkKC037196;
Wed, 4 Sep 2024 09:11:46 GMT
(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4849Bk8d037174;
Wed, 4 Sep 2024 09:11:46 GMT
(envelope-from git)
Date: Wed, 4 Sep 2024 09:11:46 GMT
Message-Id: <202409040911.4849Bk8d037174@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
dev-commits-src-main@FreeBSD.org
From: Ruslan Bukin
Subject: git: e29afe64efd2 - main - riscv: fix csr_swap()
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: br
X-Git-Repository: src
X-Git-Refname: refs/heads/main
X-Git-Reftype: branch
X-Git-Commit: e29afe64efd22b5f503d1f2558c38362b56be812
Auto-Submitted: auto-generated
The branch main has been updated by br:
URL: https://cgit.FreeBSD.org/src/commit/?id=e29afe64efd22b5f503d1f2558c38362b56be812
commit e29afe64efd22b5f503d1f2558c38362b56be812
Author: Ruslan Bukin
AuthorDate: 2024-09-04 09:04:11 +0000
Commit: Ruslan Bukin
CommitDate: 2024-09-04 09:08:40 +0000
riscv: fix csr_swap()
Fix csr_swap() macro so that we don't overwrite the argument (which is not
even possible when the argument is an immediate value)
Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D46526
---
sys/riscv/include/riscvreg.h | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sys/riscv/include/riscvreg.h b/sys/riscv/include/riscvreg.h
index 6a59b0132b1b..e1ad09acedc8 100644
--- a/sys/riscv/include/riscvreg.h
+++ b/sys/riscv/include/riscvreg.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2015-2017 Ruslan Bukin
+ * Copyright (c) 2015-2024 Ruslan Bukin
* All rights reserved.
*
* Portions of this software were developed by SRI International and the
@@ -189,13 +189,14 @@
(__builtin_constant_p(val) && ((u_long)(val) < 32))
#define csr_swap(csr, val) \
-({ if (CSR_ZIMM(val)) \
+({ u_long ret; \
+ if (CSR_ZIMM(val)) \
__asm __volatile("csrrwi %0, " #csr ", %1" \
- : "=r" (val) : "i" (val)); \
+ : "=r" (ret) : "i" (val)); \
else \
__asm __volatile("csrrw %0, " #csr ", %1" \
- : "=r" (val) : "r" (val)); \
- val; \
+ : "=r" (ret) : "r" (val)); \
+ ret; \
})
#define csr_write(csr, val) \