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 0FFEEC74A5B for ; Tue, 21 Mar 2023 15:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231556AbjCUPEN (ORCPT ); Tue, 21 Mar 2023 11:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbjCUPEL (ORCPT ); Tue, 21 Mar 2023 11:04:11 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA65B24710 for ; Tue, 21 Mar 2023 08:04:10 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 107) id BFDB168C7B; Tue, 21 Mar 2023 16:04:07 +0100 (CET) Received: from blackhole.lan (p5b2ece7e.dip0.t-ipconnect.de [91.46.206.126]) by verein.lst.de (Postfix) with ESMTPSA id 078CC6732D; Tue, 21 Mar 2023 16:03:52 +0100 (CET) Date: Tue, 21 Mar 2023 16:03:49 +0100 From: Torsten Duwe To: Palmer Dabbelt Cc: Li Zhengyu , Paul Walmsley , Conor Dooley , Albert Ou , Li Huafei , "Liao Chang" , , , Subject: Re: [PATCH] riscv: relocate R_RISCV_CALL_PLT in kexec_file Message-ID: <20230321160349.3b3a46df@blackhole.lan> In-Reply-To: References: <20230310182726.GA25154@lst.de> Organization: LST e.V. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.34; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 Mar 2023 11:13:17 +0800 Li Zhengyu wrote: > On Fri, 10 Mar 2023 19:27:03 +0100, Torsten Duwe wrote: > > 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. > > R_RISCV_CALL has already been deprecated, and replaced by R_RISCV_CALL_PLT. > > See Enum 18-19 in Table 3. Relocation types from > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc > . > > It was deprecated in ("Deprecated R_RISCV_CALL, prefer > R_RISCV_CALL_PLT") > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a0dced85018d7a0ec17023c9389cbd70b1dbc1b0 > > > > > 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); > > > > . > > Palmer, please apply these references to the commit message. > > Reviewed-by: Li Zhengyu > Ping?