Message ID | 20221031120733.3956781-3-npiggin@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | powerpc module arch checks | expand |
Le 31/10/2022 à 13:07, Nicholas Piggin a écrit : > 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.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c > index f6d6ae0a1692..d46bf9bfda26 100644 > --- a/arch/powerpc/kernel/module.c > +++ b/arch/powerpc/kernel/module.c > @@ -19,6 +19,23 @@ > > static LIST_HEAD(module_bug_list); > > +#ifdef CONFIG_PPC64 Can it go in arch/powerpc/kernel/module_64.c instead ? > +bool module_elf_check_arch(Elf_Ehdr *hdr) > +{ > + unsigned long abi_level = hdr->e_flags & 0x3; > + > + if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2)) { > + if (abi_level != 2) > + return false; > + } else { > + if (abi_level >= 2) > + return false; > + } > + > + return true; Can be simpler: if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2)) return abi_level == 2; else return abi_level < 2; > +} > +#endif > + > static const Elf_Shdr *find_section(const Elf_Ehdr *hdr, > const Elf_Shdr *sechdrs, > const char *name)
On Thu Nov 3, 2022 at 6:35 PM AEST, Christophe Leroy wrote: > > > Le 31/10/2022 à 13:07, Nicholas Piggin a écrit : > > 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.c | 17 +++++++++++++++++ > > 1 file changed, 17 insertions(+) > > > > diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c > > index f6d6ae0a1692..d46bf9bfda26 100644 > > --- a/arch/powerpc/kernel/module.c > > +++ b/arch/powerpc/kernel/module.c > > @@ -19,6 +19,23 @@ > > > > static LIST_HEAD(module_bug_list); > > > > +#ifdef CONFIG_PPC64 > > Can it go in arch/powerpc/kernel/module_64.c instead ? > > > +bool module_elf_check_arch(Elf_Ehdr *hdr) > > +{ > > + unsigned long abi_level = hdr->e_flags & 0x3; > > + > > + if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2)) { > > + if (abi_level != 2) > > + return false; > > + } else { > > + if (abi_level >= 2) > > + return false; > > + } > > + > > + return true; > > Can be simpler: > > if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2)) > return abi_level == 2; > else > return abi_level < 2; Yes I think both of those can be done. Good suggestions. Thanks, Nick
diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c index f6d6ae0a1692..d46bf9bfda26 100644 --- a/arch/powerpc/kernel/module.c +++ b/arch/powerpc/kernel/module.c @@ -19,6 +19,23 @@ static LIST_HEAD(module_bug_list); +#ifdef CONFIG_PPC64 +bool module_elf_check_arch(Elf_Ehdr *hdr) +{ + unsigned long abi_level = hdr->e_flags & 0x3; + + if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2)) { + if (abi_level != 2) + return false; + } else { + if (abi_level >= 2) + return false; + } + + return true; +} +#endif + static const Elf_Shdr *find_section(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, const char *name)