From: Ard Biesheuvel <ardb@kernel.org>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: linux-efi <linux-efi@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"the arch/x86 maintainers" <x86@kernel.org>
Subject: Re: [PATCH 12/18] efi: clean up config_parse_tables()
Date: Mon, 17 Feb 2020 09:32:39 +0100 [thread overview]
Message-ID: <CAKv+Gu_NEuPAnEjFtk1MOs6xqcH-WNK2+6uP_EQ203vhjHzDaw@mail.gmail.com> (raw)
In-Reply-To: <20200216191219.GA589207@rani.riverdale.lan>
On Sun, 16 Feb 2020 at 20:12, Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> On Sun, Feb 16, 2020 at 07:23:28PM +0100, Ard Biesheuvel wrote:
> > config_parse_tables() is a jumble of pointer arithmetic, due to the
> > fact that on x86, we may be dealing with firmware whose native word
> > size differs from the kernel's.
> >
> > This is not a concern on other architectures, and doesn't quite
> > justify the state of the code, so let's clean it up by adding a
> > non-x86 code path, constifying statically allocated tables and
> > replacing preprocessor conditionals with IS_ENABLED() checks.
> >
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > ---
> > arch/ia64/kernel/efi.c | 3 +-
> > arch/x86/platform/efi/efi.c | 6 +--
> > drivers/firmware/efi/arm-init.c | 5 +--
> > drivers/firmware/efi/efi.c | 47 ++++++++++----------
> > include/linux/efi.h | 5 ++-
> > 5 files changed, 32 insertions(+), 34 deletions(-)
> >
...
if (!retval)
> > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> > index 2bfd6c0806ce..db1fe765380f 100644
> > --- a/drivers/firmware/efi/efi.c
> > +++ b/drivers/firmware/efi/efi.c
...
> > @@ -498,39 +498,38 @@ static __init int match_config_table(efi_guid_t *guid,
> > return 0;
> > }
> >
> > -int __init efi_config_parse_tables(void *config_tables, int count, int sz,
> > - efi_config_table_type_t *arch_tables)
> > +int __init efi_config_parse_tables(const efi_config_table_t *config_tables,
> > + int count,
> > + const efi_config_table_type_t *arch_tables)
> > {
> > - void *tablep;
> > + const efi_config_table_64_t *tbl64 = (void *)config_tables;
> > + const efi_config_table_32_t *tbl32 = (void *)config_tables;
> > + const efi_guid_t *guid;
> > + unsigned long table;
> > int i;
> >
> > - tablep = config_tables;
> > pr_info("");
> > for (i = 0; i < count; i++) {
> > - efi_guid_t guid;
> > - unsigned long table;
> > -
> > - if (efi_enabled(EFI_64BIT)) {
> > - u64 table64;
> > - guid = ((efi_config_table_64_t *)tablep)->guid;
> > - table64 = ((efi_config_table_64_t *)tablep)->table;
> > - table = table64;
> > -#ifndef CONFIG_64BIT
> > - if (table64 >> 32) {
> > + if (!IS_ENABLED(CONFIG_X86)) {
> > + guid = &config_tables[i].guid;
> > + table = (unsigned long)config_tables[i].table;
> > + } else if (efi_enabled(EFI_64BIT)) {
> > + guid = &tbl64[i].guid;
> > + table = tbl64[i].table;
> > +
> > + if (IS_ENABLED(CONFIG_X64_32) &&
> ^^^ typo, should be X86
>
Noted, thanks for spotting that.
next prev parent reply other threads:[~2020-02-17 8:32 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-16 18:23 [PATCH 00/18] efi: clean up contents of struct efi Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 01/18] efi: drop handling of 'boot_info' configuration table Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 02/18] efi/ia64: move HCDP and MPS table handling into IA64 arch code Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 03/18] efi: move UGA and PROP table handling to x86 code Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 04/18] efi: make rng_seed table handling local to efi.c Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 05/18] efi: move mem_attr_table out of struct efi Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 06/18] efi: make memreserve table handling local to efi.c Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 07/18] efi: merge EFI system table revision and vendor checks Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 08/18] efi/ia64: use existing helpers to locate ESI table Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 09/18] efi/ia64: use local variable for EFI system table address Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 10/18] efi/ia64: switch to efi_config_parse_tables() Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 11/18] efi: make efi_config_init() x86 only Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 12/18] efi: clean up config_parse_tables() Ard Biesheuvel
2020-02-16 19:12 ` Arvind Sankar
2020-02-17 8:32 ` Ard Biesheuvel [this message]
2020-02-16 18:23 ` [PATCH 13/18] efi/x86: remove runtime table address from kexec EFI setup data Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 14/18] efi/x86: make fw_vendor, config_table and runtime sysfs nodes x86 specific Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 15/18] efi/x86: merge assignments of efi.runtime_version Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 16/18] efi: add 'runtime' pointer to struct efi Ard Biesheuvel
2020-03-03 16:03 ` Guenter Roeck
2020-03-03 16:39 ` Ard Biesheuvel
2020-03-03 17:53 ` Guenter Roeck
2020-03-03 18:01 ` Ard Biesheuvel
2020-03-03 18:14 ` Ard Biesheuvel
2020-03-03 20:30 ` Guenter Roeck
2020-03-03 21:40 ` Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 17/18] efi/arm: drop unnecessary references to efi.systab Ard Biesheuvel
2020-02-16 18:23 ` [PATCH 18/18] efi/x86: drop 'systab' member from struct efi Ard Biesheuvel
2020-02-16 18:31 ` [PATCH 00/18] efi: clean up contents of " Ard Biesheuvel
2020-02-18 19:46 ` Luck, Tony
2020-02-18 22:08 ` Ard Biesheuvel
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=CAKv+Gu_NEuPAnEjFtk1MOs6xqcH-WNK2+6uP_EQ203vhjHzDaw@mail.gmail.com \
--to=ardb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nivedita@alum.mit.edu \
--cc=x86@kernel.org \
/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).