From patchwork Wed Apr 10 20:51:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 13625055 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7174CD11C2 for ; Wed, 10 Apr 2024 20:52:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C9F6B007B; Wed, 10 Apr 2024 16:52:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 106106B0088; Wed, 10 Apr 2024 16:52:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC1AF6B0089; Wed, 10 Apr 2024 16:52:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CC4D36B007B for ; Wed, 10 Apr 2024 16:52:37 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1D95C1C0CB7 for ; Wed, 10 Apr 2024 20:52:37 +0000 (UTC) X-FDA: 81994820754.25.F0DC654 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by imf10.hostedemail.com (Postfix) with ESMTP id 54880C000D for ; Wed, 10 Apr 2024 20:52:35 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AT41ltnk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf10.hostedemail.com: domain of shorne@gmail.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=shorne@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712782355; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=ZAB7CSzfCNbcsG/QWe5zEEDp9vPAJdmTeslJpz9VGoQ=; b=Vw1feISn7Qmwj76v60t4HrhejsSBM74MlKJwcyoajL6Xaa5aj+BlShAD7+U+91q/oXNOzW a4pJmx7q8NJlMeS0r3LDJjKJIQwvz/TzqY3vf5/lcrak3fE0QhuFT288jyjPJNVG164zL7 VlJuX2UHYby4+PEMDNYLrFAzgfnx02A= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AT41ltnk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf10.hostedemail.com: domain of shorne@gmail.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=shorne@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712782355; a=rsa-sha256; cv=none; b=uuvzBOnSNe24dCNAE7YEdBjODAkryLQ5vPIIIk3zDFpkyDPOveUdLA2BKFqkXU0gXT7XZb LzY2YueQQOuAhHkcdRAaDPgK+IOdiPnWsBNmpmEhWZywvHxNmYOiAVI+SeWs9Q2duofitw JE9gO3+oRmwGEvcTcxVOiv6NCvOGRUs= Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-343f1957ffcso153426f8f.0 for ; Wed, 10 Apr 2024 13:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712782354; x=1713387154; darn=kvack.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=AT41ltnkjsbfrAdqI4yKm5oUIwIWvSPFD/VsLsj21zF1+l+t9xKd3CGcz0+apXWiMN CxvPipFOM+OWfncUKZ5BoAMzJKbu50EyAozR4E7dQbBM42zvfcVCtdNUe0e8npytXadR VzDxuAadpii0Tq/5/kN35H0E9FGCO6xaUe0eJgbT9D/V7s9tqWm978puBKM30Q6k1nSS J4ZVa0xahvicvDRedFB2GFgtteJEW8Om+qkiJ9SOWGDn+adUuxWyUnjokx8EfsT8YfLD Q92MrGULGeQc101vI0nynXBelVkIclj6D+7J5wCoM4hipDij4yon7SMubV+9YsbXxn3z mUvQ== 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=cfS2MtBs50lMvwkhxcbIcW8+0rFOVu5ArakHNTiSqVZPUkupPCvO9/usK9oKgYDYiL j7ajkeEZUxvui1eBwDoqsueBQlHK+r1Aff4BEtf+RZqT9+7VVQjiPr1QwHvMhycXKFNa TvYRZcn5r0lbcCpd/BqXlZjDGejvA3k8zqpOfd0jY32K6cA4ROpntYXWJ3YpS+CQ0vZs FMJaIn4VCzPfIGFWdNlDBTWoFd9uXPeDFEehLYEKOTQxbJub1wXW2Xd/kC/8F6HjFo+0 trvloPprjN9JJql8/8RWcR53ZHESixQI5JifBEg1/4ZNgq9NqxdmMnpXulKMcJmoY9I7 dJbQ== X-Forwarded-Encrypted: i=1; AJvYcCUYDNBLRE+o7oezf0hKi0oll13gNgC1uKjAkkXQYU8JjyjxEpk1uNX47SKnJsfcaBE/Zarc5nzdMl+Rw/a7nJvbOzI= X-Gm-Message-State: AOJu0YxrHFLZo7oHaiY8D+4DwC7I9k2cfiGS/6qEgwH+zn/bm7s/FaHS pYz2qbcBeEYDTxJUQqacFM7k6NPtIXPz70w9v5iH3EInMYWCupRQ X-Google-Smtp-Source: AGHT+IHTHB3WYBhvJvgexVeAt59v3jWUk5M5VRPwVp2DIkmaL+4lDbNkanOWQuGwTGXlenLPEI6CAg== 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 MIME-Version: 1.0 X-Rspamd-Queue-Id: 54880C000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 7qmkusc36bfsxhrbo3wadiy476ubdks4 X-HE-Tag: 1712782355-769369 X-HE-Meta: U2FsdGVkX19BBMO03k4GNX2Wy8OdU07fBdNNLDdXgQjD6UWXI9/MFm0mBKjd0R9CnkXNdEw2UcnbsdCZ51jmruOfIfmMQoGXtEdSYsTTNufx/WHxc2HV0H3g7YE2t4+Q5ovLWsaJrMJwSN86aVHm4EK9eDf3vIF/mvuYSVTTYojyYq2sbhYh8+LNm5+aOWVZrqlj3JIMCO8/MM20seZhDSpT39y/oZlYqUKt263DUF05vXd0fzfEXztPTqYV3JHcYkxLPLSK+roEBFOvEHSsIx8hRdrnJpffuT1yt9i+AKXSN+xddzaLarA77dC6hfne0OJHCP9HoJzYrFgPTM0aYbWLZSqRR9jlL4orw3URZA3EGxD+LFFphKPy/cGVgZGHNRfr238sigt0duMgUpiT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, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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));