Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp504499ioo; Sat, 21 May 2022 05:37:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv7RuEd9dW76EJtFHMLWG1/oAREhWrCyZLo8WXOXXl0yCH+wq58yJc0MuUbzyGyoAJN12c X-Received: by 2002:a17:906:4fc6:b0:6f4:da16:4a09 with SMTP id i6-20020a1709064fc600b006f4da164a09mr12530810ejw.599.1653136637372; Sat, 21 May 2022 05:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653136637; cv=none; d=google.com; s=arc-20160816; b=P0Su31fVPmPipwd+yswrDqFW70pZ3uwpuMyt7n24f+PG6LcQxkt9ijm/lp1yCPu0xa jnb9zDGjVh4avmxsO+Jro1znm2s4pVGOs4zP94NLte8mgIjsbsHmtEOfcwOtVYvIMaC0 RRF5z3j22+Jyo6zfyu6W91ImIQT6EjS7dcDCKn+CDAP/sBUl7sto7ngIH6g68FgKbDRp PZtsJbhcIeaPFPvJU8+GYdyCKBhcsXINH62Qlfvus5p7fCVKySOl3fatAv+LqHHxxzFJ YErBlx+CluJZ1eMSO0u4UptbhBZT2GLHpCpF+5AOVqSqmG4ER/o2vA6yn9KJrrNh+44B 6UQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:cc:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject :dkim-signature; bh=VE2vUXFOy2mJkujHyFNt0HPmwfcDu8WrrrqGHwab5YA=; b=XdFTW6wuOfLm5ew+olZs+V7URvMb2staEfJPZC0ubD26Xs+QO6BsM61T+YNcHd0Hto 3hhf2fJ1L2PZCmhDgJP10H3DZBHwPXeWewvkkzLMmmeqGy3oA4VOlr2aHndLN+9+EPA1 8Az4kEAw+yYSC21NCgGJaHlCWT0znOJ0zddGI5t2aJKPtXYo2eQfw9llTsyzIwcfkjQq /AUCg6N3Vm5/N4p6p+R8tPdhQWapunYcRlZex2OyI8XS4Nan1DfzWKj1WDRvo5Ze+7MK D8rxWHSiJas/kjiDLIc+bc2oph02BJ/f2PhGLAawiG2PQ2/tNLh8ChDY+DwE7MusyKO0 8tSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=tuEF1onr; 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 gl1-20020a1709073c8100b006e866549c5esi8083292ejc.702.2022.05.21.05.36.42; Sat, 21 May 2022 05:37:17 -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; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=tuEF1onr; 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 S1351077AbiETPpt (ORCPT + 99 others); Fri, 20 May 2022 11:45:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351062AbiETPpl (ORCPT ); Fri, 20 May 2022 11:45:41 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F29D179969 for ; Fri, 20 May 2022 08:45:27 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id ds11so8419167pjb.0 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=6VONx4GornRuXdHjIV1Y7rQNuQL7qahiScilQw6GaGLS5oMHq/C+li8hj+DXDUA5sC G7kMi40WAMKjOMZvGeesymY+2wKCaurSs15OkpxO4k0n2NrLdBmi28/UtvnyXyxGdzHG crKQlgo5vuaKXwHXFUI32QbnD1njFSZ0XE6AD8C7T4SNqllitaKAEdLFw8UGt0qRnMx8 5yROpgnBbkkWLYWp63qnNSGyPDSRmCsPnpqB5SSqrHlLLWVDWohXbBynpuKGrjR+DrMP x6HKz/8h13X1rY6PQbYX9qzBpdGOEyvL28B++27tEEMpo026r7nPQnLPuTe05ENUE7Hk IZlQ== X-Gm-Message-State: AOAM53038oG8YZmlK3b/JK9iOqhwSj5gSwd1mb9kCCauWnkoSdJU4Mg3 yI2g58Qj+YjRACT+rfpQk1AEEA== 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 Content-Transfer-Encoding: 8bit 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: 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; -- 2.34.1