Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp22911lqg; Wed, 10 Apr 2024 14:04:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWqcwa/oXXYD8cCLkP0tHj8W001T+myw7iaO7y8uUVmWQz/HEuyeNFGxRhznn1v4rJN7cufZy5oEwA5OkgkAIOxAaHsjpxVB32Rzriug== X-Google-Smtp-Source: AGHT+IERQaYthRLaqH67MFO72IjcCiovx1jjED+1eG+h1E06mvvQVXmePvT7KAo7/3q+hIhFWPlj X-Received: by 2002:a05:6a00:244e:b0:6e8:f57d:f1ec with SMTP id d14-20020a056a00244e00b006e8f57df1ecmr4357418pfj.17.1712783052339; Wed, 10 Apr 2024 14:04:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712783052; cv=pass; d=google.com; s=arc-20160816; b=VK78HOPZbv7jiS5jaWwwkJGqmJFos2fHfDEupnxMPt/X3ntDWyLUIfgQi9QzR/kHXg A9UFG/9rhAmkjA+hRJbhB2plDsXV49TGSr8Fe7ydcELjV8TfPNPTYrSP6MkhrHHp0ERQ bCn3M/qquIjjHaCpbRBQVJO0P6szarX0kwOnSuz97p0494t46DFgrXkG9kHeho3pgIJC yuO6t9uhT1zhxQSyeakxSbrjUQy/87MjVZQOfZ+7IQ/jPq6KFaRJQ8tJB/IznBMhIroP wWNV+c5zSXY6Q2IDe2GUXlYxc7TbO+eYC2nAeyqPEdPFYKmMX9H61t1VY+DVi8FNKZEv MzYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=ZAB7CSzfCNbcsG/QWe5zEEDp9vPAJdmTeslJpz9VGoQ=; fh=GEydO11Kj33z2kHAM+iJyTKE4InuMtHFdT6508XxElI=; b=pIx/fQodITJgD48XzWfjZ8HiKNM2ZX7WbJo4CZcmmSD8nMLOJxsjgxIwTUhp0Rqf/j 5MQDXN7rt/0RDvUXJL5fD8WAhTiGG/7rf7yQ2EnaRnZCQYZYjz6JgKS2n8i+pykioVRQ MEbYC/QrkQ4rBIlmlnjyotP6rin9+ZQ5pWb0lg2jo+N8jdgPJTDJ+Sjiw9Hzuo9Hyp/b Z+hl2KrE/gAvONwngx9J547xixCugWvgj8p33929/q9gABzqWbMu2dI3ZUs3NXWjENMd p5aht+DpA73SK6VNeGRgnYxiVaUx4Es7vZRiFcBBW0GwtuUVV4TsjajguEIYLCvg9oqR e+4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ct3uKmVM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-139331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139331-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n26-20020aa78a5a000000b006ea7e52efe8si101669pfa.384.2024.04.10.14.04.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 14:04:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ct3uKmVM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-139331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139331-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B4FC6B228CF for ; Wed, 10 Apr 2024 20:52:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C0FE181CF2; Wed, 10 Apr 2024 20:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ct3uKmVM" Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2880615EFAD; Wed, 10 Apr 2024 20:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712782357; cv=none; b=CRczpN6byvm18JGWkQirAgS1ezfs3rrcx1P8ColYyx4ijRqhIS+gIVNh9f0nLKNz0NSnk8dxsENiEna55ZsWeosCSU+8RnKf5ruELXz0SDuE+dEiUM8ZhdlSEXdQEfElY9nMixNOoRIcIxlY5Km5jLJzafChMuf+iG6+CVhAORs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712782357; c=relaxed/simple; bh=LOH2uFOdtYg3Irj2bybDHrQvyp8PZBBdOjsOaPVQ+c0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gSdVJXbIPVqF1O5oBpahUZycWgkrxRKMpvVAfzGEO2il5Lg4b9UTvdwDTsqr2yX7BazdSLcRDlS81wL0N2YkiXTDlR9moScAf7+677cjbafogXdX+0TqcidToagKTrmJWGd6nfHiEJ2V66/hiPe8wsnXk6ZL39JYcj8ZEGyI7Gs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ct3uKmVM; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3442f4e098bso134030f8f.1; Wed, 10 Apr 2024 13:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712782354; x=1713387154; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZAB7CSzfCNbcsG/QWe5zEEDp9vPAJdmTeslJpz9VGoQ=; b=Ct3uKmVM4VompcgmaSsAy1iw+IryeKIKZGKtPqIGoyDuQEXY5mphIYbBdW5r9NfXPk vmjZJ7bTG2+TjSVXF9KFVx/nPaTArWLCZ65XQoPeE7ymP3GlOtKMqvLv21SjJQp6JKGH 6HD/1Vhao+1TR1t2hCECsiB6osbFVQlj1FpAIqMFOrlyJY9FuiBsucr9eVBv5IN0ey5L VjYZkzsAs2VUWtPBciXtEr5j3uPoyBos2lI2S91J0Si9XfyE39YYoej7/nh0XsL8hM1B 9PGtFR0PLA70llOLXgZzE0OyIE4G1HYrcUkNdC0nAuetcD9/urtbWPnFgW2EHjWksKuq qT5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712782354; x=1713387154; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZAB7CSzfCNbcsG/QWe5zEEDp9vPAJdmTeslJpz9VGoQ=; b=GdC31gNZEEyQhvjiLQ5O66itICmLEExbRbjzMWprXDgepx7Id2q7r2+ksfADtcK6fU e30QnYLeiGMTqwrm3/b+JaTIO6YhsKtrC6AyGcQA5cK3tSOUaO6dEd9yV+BggoOTzcXt jVvIC+YLGX9h4R6yXNv4jccSjTjqvmXUPZH6cUG1c02BKn0j5S4KI+sOkmSC7/YYKZvU Zrq/XLaRGSo4yMY2wLeE5AAmk306SQZSnfKwsIs4Nlep7I+F5cTfvr+Xo36X46M7eqy9 yTTyFEoxfYm6xo1AakYBU7Ppk719hNou7SJDKlf27cpEcIwq9fqoENAeOswLdQNYmYOh YiDg== X-Forwarded-Encrypted: i=1; AJvYcCX4mJ3jeeikypLAkJawg0EZtsQBwSWKfrroozHg5Codg9Ty8r45YeeqQXoxIMAVGliR6T2dDaum/Zi0ranmMxMO59i49NM64aGBfEPw5r8= X-Gm-Message-State: AOJu0YzJ/kIFht+54VO82yN7V3VaZP9fegAYHaOA7VVBBbCEtHjX09Nj 4fTNjCPV+0fx2HXueNa4o3aH/wmQbrycITQjpyt1qyUbvpL21uZoAd8xqw== X-Received: by 2002:adf:ebc6:0:b0:33e:d139:412c with SMTP id v6-20020adfebc6000000b0033ed139412cmr511385wrn.30.1712782353368; Wed, 10 Apr 2024 13:52:33 -0700 (PDT) Received: from localhost (cpc1-brnt4-2-0-cust862.4-2.cable.virginm.net. [86.9.131.95]) by smtp.gmail.com with ESMTPSA id n14-20020a5d660e000000b003433a379a51sm74113wru.101.2024.04.10.13.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 13:52:32 -0700 (PDT) From: Stafford Horne To: LKML Cc: Stafford Horne , Jonas Bonn , Stefan Kristiansson , Eric Biederman , Kees Cook , linux-openrisc@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] openrisc: Add support for more module relocations Date: Wed, 10 Apr 2024 21:51:58 +0100 Message-ID: <20240410205201.1885032-1-shorne@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When testing modules in OpenRISC I found R_OR32_AHI16 (signed adjusted high 16-bit) and R_OR32_SLO16 (split low 16-bit) relocations are used in modules but not implemented yet. This patch adds the relocations. Note, we use the old naming R_OR32_* instead or the new naming R_OR1K_* to avoid change as this header is exported as a user api. Signed-off-by: Stafford Horne --- arch/openrisc/include/uapi/asm/elf.h | 2 ++ arch/openrisc/kernel/module.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/arch/openrisc/include/uapi/asm/elf.h b/arch/openrisc/include/uapi/asm/elf.h index 6868f81c281e..0c882a388524 100644 --- a/arch/openrisc/include/uapi/asm/elf.h +++ b/arch/openrisc/include/uapi/asm/elf.h @@ -43,6 +43,8 @@ #define R_OR32_JUMPTARG 6 #define R_OR32_VTINHERIT 7 #define R_OR32_VTENTRY 8 +#define R_OR32_AHI16 35 +#define R_OR32_SLO16 39 typedef unsigned long elf_greg_t; diff --git a/arch/openrisc/kernel/module.c b/arch/openrisc/kernel/module.c index 532013f523ac..01bda5616114 100644 --- a/arch/openrisc/kernel/module.c +++ b/arch/openrisc/kernel/module.c @@ -55,6 +55,16 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, value |= *location & 0xfc000000; *location = value; break; + case R_OR32_AHI16: + /* Adjust the operand to match with a signed LO16. */ + value += 0x8000; + *((uint16_t *)location + 1) = value >> 16; + break; + case R_OR32_SLO16: + /* Split value lower 16-bits. */ + value = ((value & 0xf800) << 10) | (value & 0x7ff); + *location = (*location & ~0x3e007ff) | value; + break; default: pr_err("module %s: Unknown relocation: %u\n", me->name, ELF32_R_TYPE(rel[i].r_info)); -- 2.44.0