From patchwork Fri May 20 15:44:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 574674 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 792F7C433EF for ; Fri, 20 May 2022 15:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351101AbiETPpm (ORCPT ); Fri, 20 May 2022 11:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351041AbiETPp0 (ORCPT ); Fri, 20 May 2022 11:45:26 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88C21796FC for ; Fri, 20 May 2022 08:45:24 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id x12so8039565pgj.7 for ; Fri, 20 May 2022 08:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:cc:from:to; bh=avELjSEfO4YwxdS1hy2OFqCYNIZpTM4Eec2OkZMhhf8=; b=uzwPDcC0XNDiwV+Mifx3alyGqhvqonpDCfcELm9PIplNCWzW/NqPcz7dO5AZvP9aD/ 9DftJ2uI7dj8WLDMyULQL9Mzmc1Sw3yvKBYHDYFq5mmlt9/FBMk4iD2EQWZueEc2SOPY XVhWu4TTcLkAOsWufKOvZedwA75506ErlcRUoG/dg5Yzf/7w2VdM2e5A3R0RG/jQrebr WUB0GKOJ4kmaKKnMV38ouro+kV5lD5ureu3IhSzvLXkIPBO/tOcRZZnJcLQKaOJ4pIFD ivVBRmb/1LPO2IfDj8CG9AXLvr+6Wf30+Cf7gop/trMMi003rY5ezCy3QBoYTgXe1rFB h7JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=avELjSEfO4YwxdS1hy2OFqCYNIZpTM4Eec2OkZMhhf8=; b=kfzEYIGf8DrhgqPcLNhvA65lD9GRqkewBQmw/pLQkQt3yRuYGijwzXtudwNtG0ts2K ibY27nYmrngBEtwgaLRsa7iFEvVb1QmKZmGjbIVB1siUW7xrkE8mfd/oWUtwLMb8ltB2 Sn1Qy+wJM7xGr8/QrLi6y32MRkK7PSfr6JxaCumcinEGtTN/qENI1AYUa/gLAFBc6H+m GKFtvMrelDpyolE3OZ3+ywBrEO+ca+cBE0SImyAnwCvvAva4u3PxMlMI35Igol0m0OYa 1Mizuds4uDQyWouEOza8FiKu8JsE43K0qufOOlDNrd9UrhSmml7cxOPvg7fqk6JQPF5A OPIA== X-Gm-Message-State: AOAM532aC6pGLuyVU2j2516wB7bLMzG5c6aizmwbV4m9DOy4iMeNsCK3 k+PKEjNP2/EGu3JATWLqsJD9fw== X-Google-Smtp-Source: ABdhPJy0cSSVWa5pAf0mHY5fITaZVq1V36HgsUtNvAxSOP+5C4C+/tqwdW6Q0EnMt1H6wgdEVX6jxQ== X-Received: by 2002:a62:1413:0:b0:518:4259:200e with SMTP id 19-20020a621413000000b005184259200emr8368526pfu.41.1653061524395; Fri, 20 May 2022 08:45:24 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id t10-20020a17090340ca00b0015e8d4eb29esm5596985pld.232.2022.05.20.08.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 08:45:24 -0700 (PDT) Subject: [PATCH v1 1/5] drivers: of: kexec ima: Support 32-bit platforms Date: Fri, 20 May 2022 08:44:27 -0700 Message-Id: <20220520154430.18593-2-palmer@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220520154430.18593-1-palmer@rivosinc.com> References: <20220520154430.18593-1-palmer@rivosinc.com> MIME-Version: 1.0 Cc: Paul Walmsley , Palmer Dabbelt , aou@eecs.berkeley.edu, robh+dt@kernel.org, frowand.list@gmail.com, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, liaochang1@huawei.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux@rivosinc.com, Palmer Dabbelt From: Palmer Dabbelt To: lizhengyu3@huawei.com Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Palmer Dabbelt RISC-V recently added kexec_file() support, which uses enables kexec IMA. We're the first 32-bit platform to support this, so we found a build bug. Signed-off-by: Palmer Dabbelt Acked-by: Rob Herring --- drivers/of/kexec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c index b9bd1cff1793..ed3451ec2b24 100644 --- a/drivers/of/kexec.c +++ b/drivers/of/kexec.c @@ -236,8 +236,8 @@ static int setup_ima_buffer(const struct kimage *image, void *fdt, if (ret) return -EINVAL; - pr_debug("IMA buffer at 0x%llx, size = 0x%zx\n", - image->ima_buffer_addr, image->ima_buffer_size); + pr_debug("IMA buffer at 0x%pa, size = 0x%zx\n", + &image->ima_buffer_addr, image->ima_buffer_size); return 0; } From patchwork Fri May 20 15:44:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 574673 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 A273CC4332F for ; Fri, 20 May 2022 15:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351088AbiETPpu (ORCPT ); Fri, 20 May 2022 11:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351057AbiETPpk (ORCPT ); Fri, 20 May 2022 11:45:40 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ED8F1796F5 for ; Fri, 20 May 2022 08:45:27 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id nr2-20020a17090b240200b001df2b1bfc40so11805124pjb.5 for ; Fri, 20 May 2022 08:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:cc:from:to; bh=VE2vUXFOy2mJkujHyFNt0HPmwfcDu8WrrrqGHwab5YA=; b=tuEF1onridrYFom6GHGoVmHMvyrHQV/Jf6B0yeiPYn43PWuCZ4txpDmw1dqIEPI397 t5iPNCMjW7PoX+tc8jbAUuH+BtaBGhp84qL41HRaB+DxQsJQC5EubyjCwjzedw8vRa0M DOZewV7xP26BcxzG8nNBVz/1ZAHv+yYAEcqmwxfbbXeF+P45JlXSS2N9YAx08Gm4/53w jkQMCSJDbP6WMAnG9MJccNFyCBJ6Bz0WlkimSCCLCsYlwwcNmedJ2b3qjgTg30qXLW6B y3T1P3I694ihOLCY/fCBx+g/6qUP2n1uyx7/SrJKVy53gR9qE31qHY2VU7Q+nBgZveBu z18Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=VE2vUXFOy2mJkujHyFNt0HPmwfcDu8WrrrqGHwab5YA=; b=HzCRT+FPX5kkZssKshaKqGReIboLZmza4D1U/W+CwZDN7gvR7/v+e4e1o/Q0CdRZ0z W8uOuQGtMM0HMYRot87fbDH9uNs9xGvxHbM2PCbViMQOiVx5W+c8qmJg3joidiMDu7cd 4nOCW+d4BRynZqHfearU1f61Jj+UeEP+VsZoWHlwCrn39SstgtuDfjRBPIP37wuvFDbm VOo0rjM98+t8jet8FDLwoADbXZUOVbCG7N4By5A+JEiQiuU7wruV/4TCeXEen3rfnkAi wLgqrQ3yHcqyrUL8hXzRjM20+U/npa36t+iVOLSaQwr7dCT2pi6BfaKOr6m7nLHfcz5G iswQ== X-Gm-Message-State: AOAM530qiX7WX7SrrDbWLEjHALQo0rT8rNIqb57yb5DyJAgv9xgEIix5 Hp72L+VRRwuuOh8WS6bemQzeyQ== X-Google-Smtp-Source: ABdhPJxutQunHuqBnSDi1AyU5l++uXDUp12EI7aTjzru4LJnptzsRLuteBJZfMF6zOk21wIEpEwfSA== X-Received: by 2002:a17:90b:4b02:b0:1df:d622:dd07 with SMTP id lx2-20020a17090b4b0200b001dfd622dd07mr10203411pjb.160.1653061526701; Fri, 20 May 2022 08:45:26 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id a12-20020a62bd0c000000b0050dc7628188sm1982140pff.98.2022.05.20.08.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 08:45:26 -0700 (PDT) Subject: [PATCH v1 3/5] RISC-V: kexec: Use Elf64 on 64-bit targets Date: Fri, 20 May 2022 08:44:29 -0700 Message-Id: <20220520154430.18593-4-palmer@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220520154430.18593-1-palmer@rivosinc.com> References: <20220520154430.18593-1-palmer@rivosinc.com> MIME-Version: 1.0 Cc: Paul Walmsley , Palmer Dabbelt , aou@eecs.berkeley.edu, robh+dt@kernel.org, frowand.list@gmail.com, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, liaochang1@huawei.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux@rivosinc.com, Palmer Dabbelt From: Palmer Dabbelt To: lizhengyu3@huawei.com Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Palmer Dabbelt Most of the Elf macros automatically select the correct Elf type, this converts the one explicit Elf64 usage to depend on XLEN. Signed-off-by: Palmer Dabbelt --- arch/riscv/kernel/elf_kexec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index 9cb85095fd45..4532e3cf17a5 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -342,6 +342,12 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, #define CLEAN_IMM(type, x) \ ((~ENCODE_##type##_IMM((uint64_t)(-1))) & (x)) +#if __riscv_xlen == 32 +#define ELFN(T) ELF32 ## T +#else +#define ELFN(T) ELF64 ## T +#endif + int arch_kexec_apply_relocations_add(struct purgatory_info *pi, Elf_Shdr *section, const Elf_Shdr *relsec, @@ -367,7 +373,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, void *loc; /* tmp location to modify */ sym = (void *)pi->ehdr + symtab->sh_offset; - sym += ELF64_R_SYM(relas[i].r_info); + sym += ELFN(_R_SYM)(relas[i].r_info); if (sym->st_name) name = strtab + sym->st_name;