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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 957EFC6FA99 for ; Fri, 10 Mar 2023 18:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbjCJS1e (ORCPT ); Fri, 10 Mar 2023 13:27:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbjCJS1c (ORCPT ); Fri, 10 Mar 2023 13:27:32 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 672D15D44C for ; Fri, 10 Mar 2023 10:27:31 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2005) id 038CF67373; Fri, 10 Mar 2023 19:27:27 +0100 (CET) Date: Fri, 10 Mar 2023 19:27:26 +0100 From: Torsten Duwe To: Li Zhengyu , Paul Walmsley , Conor Dooley , Palmer Dabbelt Cc: Albert Ou , Li Huafei , Liao Chang , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] riscv: relocate R_RISCV_CALL_PLT in kexec_file Message-ID: <20230310182726.GA25154@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Depending on the toolchain (here: gcc-12, binutils-2.40) the relocation entries for function calls are no longer R_RISCV_CALL, but R_RISCV_CALL_PLT. When trying kexec_load_file on such kernels, it will fail with kexec_image: Unknown rela relocation: 19 kexec_image: Error loading purgatory ret=-8 The binary code at the call site remains the same, so tell arch_kexec_apply_relocations_add() to handle _PLT alike. fixes: 838b3e28488f702 ("Load purgatory in kexec_file") Signed-off-by: Torsten Duwe Cc: stable@vger.kernel.org --- --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -425,6 +425,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, * sym, instead of searching the whole relsec. */ case R_RISCV_PCREL_HI20: + case R_RISCV_CALL_PLT: case R_RISCV_CALL: *(u64 *)loc = CLEAN_IMM(UITYPE, *(u64 *)loc) | ENCODE_UJTYPE_IMM(val - addr);