Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp878461ybt; Wed, 8 Jul 2020 14:10:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2sIT62bq7nJfIwjPkWsqAAYpySiHIwQp0G2M1RO2OuVHXZsA0Xs3RVewYmyr/L2+9jz4e X-Received: by 2002:a05:6402:1803:: with SMTP id g3mr65881509edy.377.1594242643552; Wed, 08 Jul 2020 14:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594242643; cv=none; d=google.com; s=arc-20160816; b=ibXBbRTljKtkuOTLJw2qpZe9WtOznRVmK6fb3RGnRjAnCikQRT+3M5q5QilsnAxMCK kK/xnq0v62c7JGOqpVHm/ly7MzkLEWvikK7LyE1T2wucympV9nBO6rxI1AHo6y3Mxshx bb7vpnuWrNNf/aswg06/Ee/wdSfe/WFcOrQSi/f51BpJQ3TPkEgPPgPYKPyIksqQslAI nKOnCHa1/e1+TtPUiiINAMGsXDfBJ2uZCBG0vOFLhvgVIKsiY5WLODVJVQDsv4/poj2G vuiPFPcL8OoUc707mzjYeC3lWnb65IV+sZN4016E76NSYTQsxO2Rb+aVDAxSZXoS3tgh udTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=b784eys00Qgsi/BMM5jGhHc/bDGWKgJTJjPySpMRijA=; b=yldSw1xV/6VOXx+xHqpgxr3elXbWe4N7uus/aRhJpXvPR6F4y4plMIaiLYq2CCexMD 1N7tuzWakn4L+9gR5LDYGZHsDNiUx2vQQ8nNmEYkYc/eXCLZkBnh+Gkk54PoAbTOJUb7 mRkrGDuo++f2Ch6enjux607C2DyRAHhnB2xXjYmJ6YDLTLFHxmhqy8wUZa4xet+eBqki Y6hXXYER1AuyDI3g6tqtCdcnlVUIwsG1LvANbvBfw31RwVQl5EB2xNuRln4AqMYEO3y7 RyHhv0lm0aVQ/GV5UiWa7DswWwtteTxT1q0RXzAAUheHwryPBxN26Sb6DMAbutxXga0m u7iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=JYy025NM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y5si700857edw.306.2020.07.08.14.10.20; Wed, 08 Jul 2020 14:10:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=JYy025NM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726140AbgGHVKO (ORCPT + 99 others); Wed, 8 Jul 2020 17:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgGHVKN (ORCPT ); Wed, 8 Jul 2020 17:10:13 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F0FAC061A0B; Wed, 8 Jul 2020 14:10:13 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id l17so4685105wmj.0; Wed, 08 Jul 2020 14:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=b784eys00Qgsi/BMM5jGhHc/bDGWKgJTJjPySpMRijA=; b=JYy025NMzEmNSpPgiMeWuuPkd5cl0MfwTVBJJZqahDI5dLyrIPOOC9114DaSoraiwb I5njcBEugFseAfRHPIpZMJZLYxQ8FWV9kfzv2edy60DBDq36VPQ136CfAbBAZogz4JVw inmYt3WV12JZyu6v5eASjLEmtXbbnODgPc8EvSD/lYXrkCW0PvujjLUdNg/PRRoJbz4X 7NKNti9UxIlRh7PNJ02hb++EtUCk//KujORIriqXgzcp80FHa/qrMndtm82L9mBG7eM+ z1W6Kg0QrR013Qsj9VYvBtwB5sEXwd3nLySjz5l5FO58XETC1M/fBriY8V7MPVcwLUtS tCLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=b784eys00Qgsi/BMM5jGhHc/bDGWKgJTJjPySpMRijA=; b=qdryP8pPXpUnEwx8Pi8O8JGWyCQv32/PY7LHXVOF6pL67c1LeWk+oiEV4cZKANkCkF h4EemZI/7z5mdceLpg1oRQDGt+lZIQAad6FCXfI1ggb3lyjvtBCCqWzbl1A9kdQNeLJc +7OcwgiTYjbuvF6y8Aapo3fYKd/Qo6GwcBniJk6UCkq2hxwlxnGpcU0d9o0IJdlnc/N9 ihSsU4hKg3sQBYeGOugVrv9lZMPqqfzDSORk4LMZh87DNRnSZjb6ujmBIsxVFbwLtyaf xvNGNFRbunZmt0RXvq3r1pbwa/2NTO5T08KTUnZiIIhEAE8FH3D5R8DcM8Eq4fwAo+0L 3a0g== X-Gm-Message-State: AOAM533FrNSVJGo1izHDzMho1Enqv/ROHaSulDmzxKKYBCoor9WrgtIH n19Im7OCIzHWOlaz8XSYTu4= X-Received: by 2002:a7b:cf10:: with SMTP id l16mr11193177wmg.93.1594242612326; Wed, 08 Jul 2020 14:10:12 -0700 (PDT) Received: from localhost.localdomain ([80.71.140.73]) by smtp.gmail.com with ESMTPSA id u23sm1971515wru.94.2020.07.08.14.10.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 14:10:11 -0700 (PDT) From: Emil Renner Berthing To: linux-riscv@lists.infradead.org Cc: Emil Renner Berthing , Palmer Dabbelt , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Paul Walmsley , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] riscv: Support R_RISCV_ADD64 and R_RISCV_SUB64 relocs Date: Wed, 8 Jul 2020 23:09:47 +0200 Message-Id: <20200708210948.34197-1-kernel@esmil.dk> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These are needed for the __jump_table in modules using static keys/jump-labels with the layout from HAVE_ARCH_JUMP_LABEL_RELATIVE on 64bit kernels. Signed-off-by: Emil Renner Berthing --- Tested on the HiFive Unleashed board. This patch is new in v2. It fixes an error loading modules containing static keys found by Björn Töpel. arch/riscv/kernel/module.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c index 7191342c54da..104fba889cf7 100644 --- a/arch/riscv/kernel/module.c +++ b/arch/riscv/kernel/module.c @@ -263,6 +263,13 @@ static int apply_r_riscv_add32_rela(struct module *me, u32 *location, return 0; } +static int apply_r_riscv_add64_rela(struct module *me, u32 *location, + Elf_Addr v) +{ + *(u64 *)location += (u64)v; + return 0; +} + static int apply_r_riscv_sub32_rela(struct module *me, u32 *location, Elf_Addr v) { @@ -270,6 +277,13 @@ static int apply_r_riscv_sub32_rela(struct module *me, u32 *location, return 0; } +static int apply_r_riscv_sub64_rela(struct module *me, u32 *location, + Elf_Addr v) +{ + *(u64 *)location -= (u64)v; + return 0; +} + static int (*reloc_handlers_rela[]) (struct module *me, u32 *location, Elf_Addr v) = { [R_RISCV_32] = apply_r_riscv_32_rela, @@ -290,7 +304,9 @@ static int (*reloc_handlers_rela[]) (struct module *me, u32 *location, [R_RISCV_RELAX] = apply_r_riscv_relax_rela, [R_RISCV_ALIGN] = apply_r_riscv_align_rela, [R_RISCV_ADD32] = apply_r_riscv_add32_rela, + [R_RISCV_ADD64] = apply_r_riscv_add64_rela, [R_RISCV_SUB32] = apply_r_riscv_sub32_rela, + [R_RISCV_SUB64] = apply_r_riscv_sub64_rela, }; int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, -- 2.27.0