Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp850524rwb; Wed, 26 Jul 2023 04:04:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlE+o1q0UhhW2pXlxUy3wnXFayb+UU9rbdn/v40RVb3hg9Ttiercxmc08NiGWifn7cSjH9p8 X-Received: by 2002:a92:ce41:0:b0:348:d5fc:fed with SMTP id a1-20020a92ce41000000b00348d5fc0fedmr1408122ilr.32.1690369491385; Wed, 26 Jul 2023 04:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690369491; cv=none; d=google.com; s=arc-20160816; b=X+R4GVD/B01WG3V3n5jNH4TTt40m8DYwHZNgBOMmFHLEHr8AUoC/M9JXe0NQcIlSVl GgjDJiXYrZ2VGcaP83DAux62CsCIt5eVKhd0yqWqVxuOeIf6c3Y6Vge08Jw86yk+25OT zqtuVAjv5oeP6H8kwwl2NgexdBgy/0kNtXsQnYk9QD+d8sMMRPmFYqCi7B8bTl03NuSp cxsVFw/y4eiJpnDYEb28ync5frqtkryit0nJbjkhH0lKksDGGL25JN4t0tmtcjbNp8VF iAtBFLHyKN8s6DrVG0tjRQ6EhtlC/KlxIp+iINZflCQ0DS0fSMRDOXsZGjc4bLs0uqAb t6pg== 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=628iOkxKoFjwYFpe4/UUsO7eEG2fFpt/bCqQ+fGWed4=; b=hqR0Qwy0NZZ7vQu8Co3r5VekscIKFacBO7yJQINFvAnU2hrOzKropNad/Oh/2ufrks 0iegZAjU9dsLkSHJPEe4EWG7SpZk6ViZD6dO7t0hr/Wju8w5wrfk/CEjbNZiez7SxZBs 9l8n+T0b9ecCikXhU+9230qbz/qgEfId0s5ZYvrAQqq/IxHvJx1kLXGj2kYNYoQwLyxO noFpJlfGKs5AJwc+p6EolSFObFoWLqu5c4IaOIujo1w0wOVOxMaIEG8CoDO9N11dDvoE OoLc/0c2Q4Qyp9yNowpqXqpEluFqDXJF1L0UtBBZ5aXMyRIeujGZ2AfrHwgrpZK+anKB w2ew== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a656944000000b00551bb2b99besi703685pgq.85.2023.07.26.04.04.34; Wed, 26 Jul 2023 04:04: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 S232019AbjGZJ4S (ORCPT + 99 others); Wed, 26 Jul 2023 05:56:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232091AbjGZJzl (ORCPT ); Wed, 26 Jul 2023 05:55:41 -0400 Received: from frasgout13.his.huawei.com (unknown [14.137.139.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD3AC2D5F for ; Wed, 26 Jul 2023 02:55:02 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.229]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4R9pqw28pDz9xFGg for ; Wed, 26 Jul 2023 17:43:40 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.81.211.226]) by APP1 (Coremail) with SMTP id LxC2BwBHo95C7cBk+WYTBQ--.33492S3; Wed, 26 Jul 2023 10:54:32 +0100 (CET) From: Petr Tesarik To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Li Huafei , Liao Chang , Masahiro Yamada , Kees Cook , Andrew Morton , Heiko Stuebner , Ricardo Ribalda , Alyssa Ross , Li Zhengyu , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE), kexec@lists.infradead.org, linux-kernel@vger.kernel.org (open list) Cc: Torsten Duwe , Roberto Sassu , petr@tesarici.cz Subject: [PATCH v2 1/3] riscv/kexec: handle R_RISCV_CALL_PLT relocation type Date: Wed, 26 Jul 2023 11:53:59 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: LxC2BwBHo95C7cBk+WYTBQ--.33492S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr47uw13tFW5WFWfZF4ruFg_yoW8WFy3pw 17Crn8KrWkGw1Sk3yagr48W348Ga1kurWaqa98GFW0qrsxXry0v3yvg3WUWF1jyrn5K3yS vFySgr1rZa15ArJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 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_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfUU-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, 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 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); -- 2.25.1