From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E46CFCF8855 for ; Fri, 4 Oct 2024 18:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1uyfgVByhR8MMN/XRDq9TXA6618wH9UL2APHkDToYBM=; b=nLqZWpBB6OOKjy rk4JDV+4depwM5vcmdZfyRPmEtC3kPluHQCgr4WWX8/Ym7yRgfaalblejr4kdTciOgLgB+9VkoOn/ oOo7YTRxSNMQe2PpJ4VFeQlLx+YZ6kzxFsa9Wyf12u6Xo0JHvpeZQZgA3D8sBgrGU5hpgBiEF7mz6 UYiVDJQjuGL+PAd8qL5TRqTiUFf/p73LS9V2C9yq1ChbYQA7PI5Z+mpOh01BgmnpTIPEUhOF09Ao2 T0jbMWfQjJ8CW9LjOKaraEmcCVlwkfWZ6jcUcOXYfa6upknBVjXihU458uL6PE1+NOWA3fTImyIdA qnju5WjM+ow1FdtnPR7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swmy3-0000000DgSd-2YSC; Fri, 04 Oct 2024 18:23:55 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swmxU-0000000DgHL-2htQ for linux-riscv@lists.infradead.org; Fri, 04 Oct 2024 18:23:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D467A5C0668; Fri, 4 Oct 2024 18:23:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0D24C4CECD; Fri, 4 Oct 2024 18:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728066199; bh=DTVQMn5qLMaxZLP5JEkomQkN+Rm1ujTymnl59WAJqOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l+r3nt8elslt7mqEsBuERN1jnrmQ7U/rqp69uUGDiTley/sa1Q3rw02Eyb67OKomd udzVkKWSKeudybvRW9x931yc+LNLrdetI8mX4IxPtohAOEllB3N5dBVUgxovKMThMH zdgQadZKPE2nSHOYDQQ7CLYUXOKb+kRDVrmuLX8X+u9iJCw92s6ho6tFTn7P+MBCrD RrBuk34ADpuro15HGZ92dCjN8HTqTFt//Fwtg40QTEbC5PROOFsVC+VniE7RAKvCQX gEhx/CLmllycKPj5pbxXw0R7obGT7QV/0n5q8ss1ysXvhcpg6pWhF6vKWA+ULXVh7O f4qNdoa40Iq2g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ying Sun , Petr Tesarik , Andrew Jones , Palmer Dabbelt , Sasha Levin , paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, akpm@linux-foundation.org, bhe@redhat.com, kent.overstreet@linux.dev, pasha.tatashin@soleen.com, surenb@google.com, linux-riscv@lists.infradead.org Subject: [PATCH AUTOSEL 6.10 40/70] riscv/kexec_file: Fix relocation type R_RISCV_ADD16 and R_RISCV_SUB16 unknown Date: Fri, 4 Oct 2024 14:20:38 -0400 Message-ID: <20241004182200.3670903-40-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241004182200.3670903-1-sashal@kernel.org> References: <20241004182200.3670903-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.10.13 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_112320_735700_4F5E9888 X-CRM114-Status: UNSURE ( 7.08 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Ying Sun [ Upstream commit c6ebf2c528470a09be77d0d9df2c6617ea037ac5 ] Runs on the kernel with CONFIG_RISCV_ALTERNATIVE enabled: kexec -sl vmlinux Error: kexec_image: Unknown rela relocation: 34 kexec_image: Error loading purgatory ret=-8 and kexec_image: Unknown rela relocation: 38 kexec_image: Error loading purgatory ret=-8 The purgatory code uses the 16-bit addition and subtraction relocation type, but not handled, resulting in kexec_file_load failure. So add handle to arch_kexec_apply_relocations_add(). Tested on RISC-V64 Qemu-virt, issue fixed. Co-developed-by: Petr Tesarik Signed-off-by: Petr Tesarik Signed-off-by: Ying Sun Reviewed-by: Andrew Jones Link: https://lore.kernel.org/r/20240711083236.2859632-1-sunying@isrc.iscas.ac.cn Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- arch/riscv/kernel/elf_kexec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index 11c0d2e0becfe..3c37661801f95 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -451,6 +451,12 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, *(u32 *)loc = CLEAN_IMM(CJTYPE, *(u32 *)loc) | ENCODE_CJTYPE_IMM(val - addr); break; + case R_RISCV_ADD16: + *(u16 *)loc += val; + break; + case R_RISCV_SUB16: + *(u16 *)loc -= val; + break; case R_RISCV_ADD32: *(u32 *)loc += val; break; -- 2.43.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv