From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D76F301468 for ; Sun, 2 Aug 2026 17:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785692629; cv=none; b=qhLx6TjRS+pzRFXN2X0Om2XasxYW2azQd5d1ABuAlN0fKf+zr3Z7psXi/5GHrVZYxyzHphTygfx5H8ueRzhz2m7+G9Gsqt6nURmjT9U02yTz7GaDmdJRkVBoU3z5F1pkOmuIphatgGyDBdi6WVUve6G+f3vVkMZ6MfX+ZgjDgjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785692629; c=relaxed/simple; bh=2PdofMD4taq71C6oaKIJKrYG+dAb9Plu331zoDvQ0os=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Mzu55+lU4IiTBvcXbGqTJy/+ZErEBkQhudBjAIBdzAK+dnjmBhPo0Cprf+cS/BlwzWwvhFYhVdcbdVdHuWKPi1lqn/w7DI6hQWlQbBhiTdv+nDHgVH3/Rib/X5uImytVIwTvLH8G57MpW9tIwByTMAKO/EPjmyEDI56+A2GeW0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=maskray.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2ce87c7e3bbso26991925ad.1 for ; Sun, 02 Aug 2026 10:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785692627; x=1786297427; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=BFKIp+dilVhwH1i5aZzLKKk+gBZw8/UsY/+UeYQbT7Y=; b=olox0QRy0mMmq/PY9rmjL8L9kE395V8J2hqbQFn2d2q0WCmxmZoHZe3OZKJMaUdTQO ZO1nrJtcoJ3G6EqiIGqp6dZtI3hsJl+rY8RSiKIgmorBgQWMee7ha7idrSKSVFwWnxgv vXaEj4/W9CqTt/uEu1Ec+egL5wGsuAnYqy2+SL4KgR3noZbdYimc2ZlvglgHKZ9CwW6e h0f1xu5eQzXICLiTqvroL7+IQ9za7J7AJmkX3c06aGwFEs/5TT9zl1ciE5y/2NQBjo2z sLkulKChg/WmMFQrkORyqflXHWDSLRQafk5zJUlStsvvt5Gw4hiSLvK2YHFEsNxuTVq3 5aOg== X-Forwarded-Encrypted: i=1; AHgh+RqqIvfbYVCPB86JXYvNwaUw28C1r7srLpsQfUjkx8kUWv14+VF2kjKFCO6IDed43mefduH30XWbjHdVabQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw036fsiKfUpdtl9RvDvL9zj2VMNwlvGrkhKXGjyn9dQ+Zhloki 0yPBGUoXUGiWp6xQVxwqMS4eP34Vh3hrMzyiXkKUrUmcCUtPVn2am9AvqUIvWQ== X-Gm-Gg: AR+sD10c/uloNuaM15Plbp56/qQFkiQrJeddyjcv9oL6xWgX2CrDj++iQGuZUeWpU/U l+zWUEYvEFgf0Xla8A275A/kvV1RJ7p8MOLxEw+gg/qhVzs2XE4F+QuRy2THMfEXu+Q2daYZ+uc s5zrLGzpH0+oIHcXoS9vfLwq4HgStiWL0nc4eSB/CcV5YGggrL1jv0oSAZrQrjaZjMLUSyeKTn/ 0piBm1YYYKe8fq0mbcUUSdraZsaiMgT3pEl/L0Kf4QX/wpjckefPF7Ub1zuR+Hp/7tkyyh9tL63 hndmMMt3DR2c3TZBcJHX9PLFTtBvOE7eEy/PoMKgtphMn9TqvzGEiKn6HxT2smn2WO5wrEghjxQ frD76GflgvKHwp4+laL24MFzYmFtPVMr7D9mQp6GJinHjguQ1aJoQVwkBsshmSY4CcxU4tGADaE LhUYCU92BV3zXw/zboDv5R2CnN4/fw+FzxDHxBZYtLLUqRFkErdFu1PNfsHeAstj+TthVH8O2oD K1NsD3YFjjA1ei8RnJuvr7DGiMOEsttGcTGgCm+pybwYaPU X-Received: by 2002:a17:903:390b:b0:2cf:bfbb:61e2 with SMTP id d9443c01a7336-2d0524723b8mr69480925ad.39.1785692626770; Sun, 02 Aug 2026 10:43:46 -0700 (PDT) Received: from localhost (37-72-172-174.static.hvvc.us. [37.72.172.174]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3153e06f88fsm28231366eec.20.2026.08.02.10.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2026 10:43:46 -0700 (PDT) From: Fangrui Song To: Peter Zijlstra Cc: K Prateek Nayak , Guo Ren , Palmer Dabbelt , Charlie Jenkins , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Fangrui Song , Nathan Chancellor Subject: [PATCH] riscv/runtime-const: Disable linker relaxation for RUNTIME_MAGIC Date: Sun, 2 Aug 2026 10:43:42 -0700 Message-ID: <20260802174342.597092-1-i@maskray.me> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Commit ee10b1028129 ("riscv/runtime-const: Replace open-coded placeholder with RUNTIME_MAGIC") switched the lui + addi[w] placeholder from hand-encoded immediates to %hi()/%lo() of RUNTIME_MAGIC. GNU Assembler folds %hi()/%lo() of an absolute expression at assembly time. LLVM's integrated assembler since 21.1 defers it to the linker instead, which range checks it: on riscv64 R_RISCV_HI20 must fit a signed 20-bit field, and RUNTIME_MAGIC (0x89ABCDEF) is a positive 64-bit value rather than a sign-extended 32-bit one, so it does not: ld.lld: error: relocation R_RISCV_HI20 out of range: 563901 is not in [-524288, 524287] The sequence is patched at runtime and its instruction offsets are recorded via ".long 1b - .", so the linker must not touch it in the first place. Add ".option norelax", as is already done for ALTERNATIVE() and static keys; the integrated assembler then resolves %hi()/%lo() itself and emits no relocation, restoring the exact encoding the open-coded placeholder produced. Fixes: ee10b1028129 ("riscv/runtime-const: Replace open-coded placeholder with RUNTIME_MAGIC") Reported-by: Nathan Chancellor Closes: https://github.com/ClangBuiltLinux/linux/issues/2179 Signed-off-by: Fangrui Song --- Applies to tip/locking/core; the RISC-V tree (riscv/linux.git) does not carry ee10b1028129. arch/riscv/include/asm/runtime-const.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/include/asm/runtime-const.h b/arch/riscv/include/asm/runtime-const.h index a472ebbf0971..ce2008bb5227 100644 --- a/arch/riscv/include/asm/runtime-const.h +++ b/arch/riscv/include/asm/runtime-const.h @@ -23,6 +23,7 @@ typeof(sym) __ret; \ asm_inline(".option push\n\t" \ ".option norvc\n\t" \ + ".option norelax\n\t" \ "1:\t" \ "lui %[__ret], %%hi(" RUNTIME_MAGIC ")\n\t" \ "addi %[__ret],%[__ret], %%lo(" RUNTIME_MAGIC ")\n\t" \ @@ -47,6 +48,7 @@ #define RISCV_RUNTIME_CONST_64_PREAMBLE \ ".option push\n\t" \ ".option norvc\n\t" \ + ".option norelax\n\t" \ "1:\t" \ "lui %[__ret], %%hi(" RUNTIME_MAGIC ")\n\t" \ "lui %[__tmp], %%hi(" RUNTIME_MAGIC ")\n\t" \ base-commit: 5e601ab3615c86be7c4068ce992f94654693a032 -- 2.43.0