From patchwork Tue Jul 25 08:44:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Tesarik X-Patchwork-Id: 125448 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2344175vqg; Tue, 25 Jul 2023 02:26:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlF2UAjXZUbi+C0NUWUjsft3//o16ILRMR/MOuMjFMwdFfF9Z2qyFvLd1U0460md8G+5n01N X-Received: by 2002:a17:906:3281:b0:99b:48d3:5488 with SMTP id 1-20020a170906328100b0099b48d35488mr12459113ejw.24.1690277181521; Tue, 25 Jul 2023 02:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690277181; cv=none; d=google.com; s=arc-20160816; b=mnC4Os0DnRnec7h39agbFE9g0K2h2XM61MUMzzt0tYeytJeb9q4uglP/lHsfuXYuye 43zhiKTu169PlBAQ10xSEg3eUlsohEfrGfvGkMaxpOiBw8lD80aA97LkG5qCXoaGvRPY pHfB8g9eKMFyeE6HxOmEPnrBowQKUfP2L7sUAdwR+2JIVAIJXjGp92EaTO/cHaFnCIef 1YrQa8OOsUctlAeoRPtmO0iMAAxF1OalaBmz60wJ1mKB1LPReJ+wWd/RpB26p6jn8nj+ CP7dDb6BWzJ9HeecmVVm+FQoq4/5pTjlyrDQ/oSsNL7AZ9M5RUPpHY633Q8h0DS3Aae2 gfFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=D0jfazM/89bFPzEIvCiJp/9BHqvbXVjAiIRx4nN0Cho=; fh=lcXKo0NRrUXZg/5xK5FQthl2JcV2SVZShbwn9PnLCCI=; b=id77QItOW0SIVCT6zAiHrYDatdmFM2wk4s1sqmWXz45fKhCipNcJmNWGC6vVHLDfyb V/LmaH8W4cBr60HI1fv9HKjwJHpyTpVafKWY3/6yLDTjD+37lzbbsAun1gmwJYLuH6kE Ktc/dBpijyu1JwOlfJQkCWtZtZiRyLx62OKi2ZFDh9W2bs20OjK8RQ+XmbCdWI+9x39A tI+4YTNQ5IK8WCV0Qm1kn/1EwxsuTF0eobD41RtOoEr2Vkg390FcBgUOwEiu8Gl5mSHZ tkIy4gD3Le/czhQHgA+3FBxmKAcmJqrVDVYfMok9Cryj6ZiVczylW2R8bSIzJKBQ7LMu xvMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a170906240a00b00997e79e646esi8218422eja.557.2023.07.25.02.25.57; Tue, 25 Jul 2023 02:26:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231753AbjGYIt0 (ORCPT + 99 others); Tue, 25 Jul 2023 04:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbjGYIrj (ORCPT ); Tue, 25 Jul 2023 04:47:39 -0400 Received: from frasgout11.his.huawei.com (ecs-14-137-139-23.compute.hwclouds-dns.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99E5530C5 for ; Tue, 25 Jul 2023 01:46:06 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.229]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4R99L12xXQz9xrdf for ; Tue, 25 Jul 2023 16:34:01 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.48.128.235]) by APP2 (Coremail) with SMTP id GxC2BwB3Ijlwi79kXB38BA--.63760S3; Tue, 25 Jul 2023 09:44:55 +0100 (CET) From: Petr Tesarik To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Li Huafei , Liao Chang , Masahiro Yamada , Alyssa Ross , Nick Desaulniers , Ricardo Ribalda , Kees Cook , Heiko Stuebner , Li Zhengyu , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Cc: Roberto Sassu , petr@tesarici.cz Subject: [PATCH v1 1/3] riscv/kexec: handle R_RISCV_CALL_PLT relocation type Date: Tue, 25 Jul 2023 10:44:25 +0200 Message-Id: <652f652d571458522a615040f68a885f10b45ca7.1690274483.git.petr.tesarik.ext@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: GxC2BwB3Ijlwi79kXB38BA--.63760S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr47uw13tFW5WFWfZF4ruFg_yoW8WFy3pw 17Crn8KrWkGw1Sk3yagr48W348Ga1kurWaqa98GFW0qrsxXry0v3yvg3WUWF1jyrn5K3yS vFySgr1rZa15ArJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQ214x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1l84 ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJwAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY1x0262kKe7AKxVWUtVW8ZwCY1x0264kExVAvwVAq07x20xyl42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8Gjc xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0 cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8V AvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E 14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUU-B_DUUUU X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_L3,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772384085875057207 X-GMAIL-MSGID: 1772384085875057207 From: Torsten Duwe R_RISCV_CALL has been deprecated and replaced by R_RISCV_CALL_PLT. See Enum 18-19 in Table 3. Relocation types here: 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 Recent tools (at least GNU binutils-2.40) already use R_RISCV_CALL_PLT. Kernels built with such binutils fail kexec_load_file(2) 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: 838b3e28488f ("RISC-V: Load purgatory in kexec_file") Signed-off-by: Torsten Duwe Signed-off-by: Petr Tesarik Cc: Li Zhengyu Cc: stable@vger.kernel.org --- arch/riscv/kernel/elf_kexec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index 5372b708fae2..38390d3bdcac 100644 --- 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); From patchwork Tue Jul 25 08:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Tesarik X-Patchwork-Id: 125442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2342304vqg; Tue, 25 Jul 2023 02:21:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlGiiJ59KmBNViE/0sUghS2+KoEs2X00JS67B9TblTBWPRb+9JUIGqxO/tOBdiMVcpXXESaU X-Received: by 2002:a17:906:8a77:b0:993:d920:87d3 with SMTP id hy23-20020a1709068a7700b00993d92087d3mr10507442ejc.25.1690276911779; Tue, 25 Jul 2023 02:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690276911; cv=none; d=google.com; s=arc-20160816; b=DoEWZxNzASdLorTUbRmSZInOpAlalmgjl0ESAqesteuPj3/skhpS+OH9b74VKRQsbw +ajVUILeBjAcvWAYb6/SS7Ko1IZlqGvTAGZ0ob1Kx2Ltx9i+KVmnRE6j/R/BZ+mP7mxN ym1lWp+XH7Dkod5yBIGV7c4/u8t7+SEuX0eVATofm/zfN0JiJsvSQUdEyPeLVwRb1z4Z dCYrlMHCjdCtDwgVgZwmm1VTdSDVp1brRF0mnkf2XK4xKC3UFT78iYAuodgwyxsxLpR6 whJOGfEtJPqsIQxk3lGUE8bHuGvclUSIY1I2BuGwXPq7W2BklLtxUDJahXYLaV5Jh4Ia WrWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wty8JCtBL/p096nX7fvX9PTA1CKlYqvtvBS6jxkzxZI=; fh=lcXKo0NRrUXZg/5xK5FQthl2JcV2SVZShbwn9PnLCCI=; b=MVvTA2amTMgsx0dYZ7SdztC8bcP+V91TpgTPCfHzIqdmzfkLv8dQNaa0z7JmOnnzRJ BFsOZLNAG+3O8uIlrs2dmp6LCfWLc8/lXn/pPdIkbOc8CyQO8tNd4oAR5RFcpvNA0OV+ Yuc1Ny9D2W1sa10eKQpJtgA5YJyfmfawYS23MUfPikA6TrCdNrwwgJ3IhUvauOYA/r6U TpyOaTbhensaScjJ8zA97+NUfH1oHxAOAKIad2dbc8x70JU3qnoP5o7F/nX4q9G/JMdI VIH0u0FcQCda9mokQ+IM4C1dh+U/AEmLF5cYy4tD83awyaCR2cA1zpTVKj6JOYyV01gL dFAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a17090622ce00b009927d850155si7606767eja.892.2023.07.25.02.21.28; Tue, 25 Jul 2023 02:21:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231478AbjGYItT (ORCPT + 99 others); Tue, 25 Jul 2023 04:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232306AbjGYIrn (ORCPT ); Tue, 25 Jul 2023 04:47:43 -0400 Received: from frasgout12.his.huawei.com (unknown [14.137.139.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C82030E9 for ; Tue, 25 Jul 2023 01:46:13 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.229]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4R99J06vRWz9xtSP for ; Tue, 25 Jul 2023 16:32:16 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.48.128.235]) by APP2 (Coremail) with SMTP id GxC2BwB3Ijlwi79kXB38BA--.63760S4; Tue, 25 Jul 2023 09:45:05 +0100 (CET) From: Petr Tesarik To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Li Huafei , Liao Chang , Masahiro Yamada , Alyssa Ross , Nick Desaulniers , Ricardo Ribalda , Kees Cook , Heiko Stuebner , Li Zhengyu , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Cc: Roberto Sassu , petr@tesarici.cz Subject: [PATCH v1 2/3] riscv/kexec: handle R_RISCV_ADD16 and R_RISCV_SUB16 relocation types Date: Tue, 25 Jul 2023 10:44:26 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: GxC2BwB3Ijlwi79kXB38BA--.63760S4 X-Coremail-Antispam: 1UD129KBjvJXoW7tFy7AF1rGw1DKr1rWr18Grg_yoW8GrW8pw 4xGr48GFWDGr1Ik34xZaykC34rG3WDu3y3ta9Fy3W5Arn8JFy7CrZ2g3WUXF1jqr1FgFWS vFyIgr1rt3W8A3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI 8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwAC jcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka0x kIwI1lc7CjxVAKzI0EY4vE52x082I5MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY 6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMI IF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnI WIevJa73UjIFyTuYvjfUn3kuUUUUU X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_L3,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772383803089979294 X-GMAIL-MSGID: 1772383803089979294 From: Petr Tesarik 16-bit add and subtract relocation types are used by the purgatory code when the kernel is built with CONFIG_RISCV_ALTERNATIVES. If they are not handled, kexec_file_load(2) fails with: Unknown rela relocation: 34 kexec_image: Error loading purgatory ret=-8 or later with: Unknown rela relocation: 38 kexec_image: Error loading purgatory ret=-8 Note that alternatives are not yet handled in purgatory code; this patch merely allows to load it. Fixes: 838b3e28488f ("RISC-V: Load purgatory in kexec_file") Signed-off-by: Petr Tesarik Cc: Li Zhengyu Cc: stable@vger.kernel.org --- 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 38390d3bdcac..f23fd419c402 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -444,6 +444,12 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, case R_RISCV_SUB32: *(u32 *)loc -= val; break; + case R_RISCV_ADD16: + *(u16 *)loc += val; + break; + case R_RISCV_SUB16: + *(u16 *)loc -= val; + break; /* It has been applied by R_RISCV_PCREL_HI20 sym */ case R_RISCV_PCREL_LO12_I: case R_RISCV_ALIGN: From patchwork Tue Jul 25 08:44:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Tesarik X-Patchwork-Id: 125443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2343454vqg; Tue, 25 Jul 2023 02:24:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdTxTKhUz3U64ln+LqZyRemXteb9o3xRQVwP41vQeXdnoPI3RsVnQ2hP+6ANvl8cD4tkF4 X-Received: by 2002:a05:6402:394:b0:522:2d1b:5a2e with SMTP id o20-20020a056402039400b005222d1b5a2emr4676614edv.12.1690277083725; Tue, 25 Jul 2023 02:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690277083; cv=none; d=google.com; s=arc-20160816; b=jzv7JYjw/b6i6Yb2scOrvhl87RsrSY6pOl1Xd2gJOcdRWSPOJrp/oG1PbqXfSjRBTL reRIRpuQeWnETcBfrA2qLhMr7JBG5PKwdu7UzidiwrWUs29hHlpmAjusdA02kZQWkBx3 Qwzo7iQ9emH3Hnynglyf5whyAOZxKfArbCxghF/uownL5NwJFwnk0nj+i7JO3RHzlegp +bkkiMo2i7+B7OljHkUEuDLb5ija8ZppHvU+rPQOGnR8r9yPZbMm6rpB7zn4ZqTDCxKF CQIdATrTN/1PBm9aKcl0RkEaeG8W+88SKWFZTEZS0KQrChf/ljyVeYY62Y1GQ9Qk0uHF lYig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=EyGoeiM+yrLRCGQqYcq9vPEk3PJunYU9TAITardmcZU=; fh=lcXKo0NRrUXZg/5xK5FQthl2JcV2SVZShbwn9PnLCCI=; b=UBI1MTs2GKMz7S6PHOpqGZpk/gLQBdK1gahKeqegGjQvq8T2mwD6FJodHGapHLvuzZ i14GcWL4hxCmMMe1IyRrMvpQ0PMmTp1njO6iAigVo9ii5bUsgVxjKZ5uwItT4DfUD6ac EtmR5aApt6y2j2RZPB7zlqZmuLmzxd4EIm1k6gblyfJ/7GBzbaKj/sfXhlPdM/nI29/J sglE92vXq5CrKGihQJdNyF4CZD1mSbrU6Ruc0CpPX+QryOSHjY9DCBzIlGf+rJOwA4Kn qvfA5I9gVXkBkND9eAu0vCqSrWmhTUBPEZfHVJSNR21skaKy/Ft1/r4OOxkEPl5cKwV9 J0Fg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a056402060f00b005223181df11si2530586edv.598.2023.07.25.02.24.19; Tue, 25 Jul 2023 02:24:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231616AbjGYItX (ORCPT + 99 others); Tue, 25 Jul 2023 04:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232441AbjGYIsC (ORCPT ); Tue, 25 Jul 2023 04:48:02 -0400 Received: from frasgout13.his.huawei.com (unknown [14.137.139.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 698373A80 for ; Tue, 25 Jul 2023 01:46:22 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4R99LQ3tzNz9y5Yl for ; Tue, 25 Jul 2023 16:34:22 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.48.128.235]) by APP2 (Coremail) with SMTP id GxC2BwB3Ijlwi79kXB38BA--.63760S5; Tue, 25 Jul 2023 09:45:14 +0100 (CET) From: Petr Tesarik To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Li Huafei , Liao Chang , Masahiro Yamada , Alyssa Ross , Nick Desaulniers , Ricardo Ribalda , Kees Cook , Heiko Stuebner , Li Zhengyu , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Cc: Roberto Sassu , petr@tesarici.cz Subject: [PATCH v1 3/3] riscv/purgatory: do not link with string.o Date: Tue, 25 Jul 2023 10:44:27 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: GxC2BwB3Ijlwi79kXB38BA--.63760S5 X-Coremail-Antispam: 1UD129KBjvJXoWxJrWfuw15GrWfGF4xXw18Krg_yoW8tw1Dpa yxKayDK3s8Aw1kKrZ7XF1Uuw17Z3yUKrWFqF42grW5AFy5JF9IvryfXrWDAFWUJr1Ik3s8 AryIgFyUt3WFkwUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI 8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwAC jcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka0x kIwI1lc7CjxVAaw2AFwI0_Jw0_GFylc7CjxVAKzI0EY4vE52x082I5MxAIw28IcxkI7VAK I48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7 xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xII jxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfUnku4UUUUU X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772383983761990289 X-GMAIL-MSGID: 1772383983761990289 From: Petr Tesarik Linking with this object file it makes kexec_file_load(2) fail with: kexec_image: Unknown rela relocation: 20 kexec_image: Error loading purgatory ret=-8 This is R_RISCV_GOT_HI20, generated by the linker to handle references to the global variable _ctype from strcasecmp() and strncasecmp(). Rather than implementing GOT for the purgatory, remove the object file, because it is not needed by the purgatory code. Fixes: 838b3e28488f ("RISC-V: Load purgatory in kexec_file") Signed-off-by: Petr Tesarik Cc: Li Zhengyu Cc: stable@vger.kernel.org --- arch/riscv/purgatory/Makefile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/riscv/purgatory/Makefile b/arch/riscv/purgatory/Makefile index dc20e166983e..497bb72b6ba8 100644 --- a/arch/riscv/purgatory/Makefile +++ b/arch/riscv/purgatory/Makefile @@ -1,15 +1,12 @@ # SPDX-License-Identifier: GPL-2.0 OBJECT_FILES_NON_STANDARD := y -purgatory-y := purgatory.o sha256.o entry.o string.o ctype.o memcpy.o memset.o +purgatory-y := purgatory.o sha256.o entry.o ctype.o memcpy.o memset.o purgatory-y += strcmp.o strlen.o strncmp.o targets += $(purgatory-y) PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) -$(obj)/string.o: $(srctree)/lib/string.c FORCE - $(call if_changed_rule,cc_o_c) - $(obj)/ctype.o: $(srctree)/lib/ctype.c FORCE $(call if_changed_rule,cc_o_c) @@ -32,7 +29,6 @@ $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE $(call if_changed_rule,cc_o_c) CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY -CFLAGS_string.o := -D__DISABLE_EXPORTS CFLAGS_ctype.o := -D__DISABLE_EXPORTS # When profile-guided optimization is enabled, llvm emits two different @@ -83,9 +79,6 @@ CFLAGS_purgatory.o += $(PURGATORY_CFLAGS) CFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_sha256.o += $(PURGATORY_CFLAGS) -CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE) -CFLAGS_string.o += $(PURGATORY_CFLAGS) - CFLAGS_REMOVE_ctype.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_ctype.o += $(PURGATORY_CFLAGS)