public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Nathan Huckleberry <nhuck@google.com>,
	Palmer Dabbelt <palmerdabbelt@google.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-riscv@lists.infradead.org,
	clang-built-linux@googlegroups.com
Subject: [PATCH AUTOSEL 5.7 04/28] riscv/atomic: Fix sign extension for RV64I
Date: Tue, 23 Jun 2020 13:34:59 -0400	[thread overview]
Message-ID: <20200623173523.1355411-4-sashal@kernel.org> (raw)
In-Reply-To: <20200623173523.1355411-1-sashal@kernel.org>

From: Nathan Huckleberry <nhuck@google.com>

[ Upstream commit 6c58f25e6938c073198af8b1e1832f83f8f0df33 ]

The argument passed to cmpxchg is not guaranteed to be sign
extended, but lr.w sign extends on RV64I. This makes cmpxchg
fail on clang built kernels when __old is negative.

To fix this, we just cast __old to long which sign extends on
RV64I. With this fix, clang built RISC-V kernels now boot.

Link: https://github.com/ClangBuiltLinux/linux/issues/867
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/riscv/include/asm/cmpxchg.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/include/asm/cmpxchg.h b/arch/riscv/include/asm/cmpxchg.h
index d969bab4a26b5..262e5bbb27760 100644
--- a/arch/riscv/include/asm/cmpxchg.h
+++ b/arch/riscv/include/asm/cmpxchg.h
@@ -179,7 +179,7 @@
 			"	bnez %1, 0b\n"				\
 			"1:\n"						\
 			: "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr)	\
-			: "rJ" (__old), "rJ" (__new)			\
+			: "rJ" ((long)__old), "rJ" (__new)		\
 			: "memory");					\
 		break;							\
 	case 8:								\
@@ -224,7 +224,7 @@
 			RISCV_ACQUIRE_BARRIER				\
 			"1:\n"						\
 			: "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr)	\
-			: "rJ" (__old), "rJ" (__new)			\
+			: "rJ" ((long)__old), "rJ" (__new)		\
 			: "memory");					\
 		break;							\
 	case 8:								\
@@ -270,7 +270,7 @@
 			"	bnez %1, 0b\n"				\
 			"1:\n"						\
 			: "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr)	\
-			: "rJ" (__old), "rJ" (__new)			\
+			: "rJ" ((long)__old), "rJ" (__new)		\
 			: "memory");					\
 		break;							\
 	case 8:								\
@@ -316,7 +316,7 @@
 			"	fence rw, rw\n"				\
 			"1:\n"						\
 			: "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr)	\
-			: "rJ" (__old), "rJ" (__new)			\
+			: "rJ" ((long)__old), "rJ" (__new)		\
 			: "memory");					\
 		break;							\
 	case 8:								\
-- 
2.25.1


  parent reply	other threads:[~2020-06-23 17:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 17:34 [PATCH AUTOSEL 5.7 01/28] sata_rcar: handle pm_runtime_get_sync failure cases Sasha Levin
2020-06-23 17:34 ` [PATCH AUTOSEL 5.7 02/28] ata/libata: Fix usage of page address by page_address in ata_scsi_mode_select_xlat function Sasha Levin
2020-06-23 17:34 ` [PATCH AUTOSEL 5.7 03/28] drm/amd/display: Use kfree() to free rgb_user in calculate_user_regamma_ramp() Sasha Levin
2020-06-23 17:34 ` Sasha Levin [this message]
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 05/28] bcache: check and adjust logical block size for backing devices Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 06/28] hwrng: ks-sa - Fix runtime PM imbalance on error Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 07/28] arm64/sve: Eliminate data races on sve_default_vl Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 08/28] ibmvnic: Harden device login requests Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 09/28] net: alx: fix race condition in alx_remove Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 10/28] test_objagg: Fix potential memory leak in error handling Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 11/28] rocker: fix incorrect error handling in dma_rings_init Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 12/28] mvpp2: ethtool rxtx stats fix Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 13/28] pinctrl: qcom: spmi-gpio: fix warning about irq chip reusage Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 14/28] pinctrl: tegra: Use noirq suspend/resume callbacks Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 15/28] s390/seccomp: pass syscall arguments via seccomp_data Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 16/28] s390/ptrace: return -ENOSYS when invalid syscall is supplied Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 17/28] s390/ptrace: pass invalid syscall numbers to tracing Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 18/28] s390/ptrace: fix setting syscall number Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 19/28] s390/vdso: Use $(LD) instead of $(CC) to link vDSO Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 20/28] s390/vdso: fix vDSO clock_getres() Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 21/28] arm64: sve: Fix build failure when ARM64_SVE=y and SYSCTL=n Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 22/28] kbuild: improve cc-option to clean up all temporary files Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 23/28] recordmcount: support >64k sections Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 24/28] kprobes: Suppress the suspicious RCU warning on kprobes Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 25/28] blktrace: break out of blktrace setup on concurrent calls Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 26/28] nvdimm/region: always show the 'align' attribute Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 27/28] block: update hctx map when use multiple maps Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.7 28/28] RISC-V: Don't allow write+exec only page mapping request in mmap Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200623173523.1355411-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=nhuck@google.com \
    --cc=palmerdabbelt@google.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox