linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: "Luis Chamberlain" <mcgrof@kernel.org>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Jessica Yu" <jeyu@kernel.org>,
	"Michal Suchánek" <msuchanek@suse.de>
Subject: [PATCH v6 2/4] powerpc/64: Add module check for ELF ABI version
Date: Mon, 28 Nov 2022 14:15:37 +1000	[thread overview]
Message-ID: <20221128041539.1742489-3-npiggin@gmail.com> (raw)
In-Reply-To: <20221128041539.1742489-1-npiggin@gmail.com>

Override the generic module ELF check to provide a check for the ELF ABI
version. This becomes important if we allow big-endian ELF ABI V2 builds
but it doesn't hurt to check now.

Cc: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[np: split patch, added changelog, adjust to Jessica's proposal]
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/module_64.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 7e45dc98df8a..ff045644f13f 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -31,6 +31,16 @@
    this, and makes other things simpler.  Anton?
    --RR.  */
 
+bool module_elf_check_arch(Elf_Ehdr *hdr)
+{
+	unsigned long abi_level = hdr->e_flags & 0x3;
+
+	if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2))
+		return abi_level == 2;
+	else
+		return abi_level < 2;
+}
+
 #ifdef CONFIG_PPC64_ELF_ABI_V2
 
 static func_desc_t func_desc(unsigned long addr)
-- 
2.37.2


  parent reply	other threads:[~2022-11-28  4:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  4:15 [PATCH v6 0/4] Option to build big-endian with ELFv2 ABI Nicholas Piggin
2022-11-28  4:15 ` [PATCH v6 1/4] module: add module_elf_check_arch for module-specific checks Nicholas Piggin
2022-11-28  4:15 ` Nicholas Piggin [this message]
2022-11-28  4:15 ` [PATCH v6 3/4] powerpc/64: Add big-endian ELFv2 flavour to crypto VMX asm generation Nicholas Piggin
2022-11-28  4:15 ` [PATCH v6 4/4] powerpc/64: Option to build big-endian with ELFv2 ABI Nicholas Piggin
2022-11-29  3:02 ` [PATCH v6 0/4] " Joel Stanley
2022-12-08 12:39 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221128041539.1742489-3-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=jeyu@kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mcgrof@kernel.org \
    --cc=msuchanek@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).