All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: "U-Boot Mailing List" <u-boot@lists.denx.de>,
	"Tom Rini" <trini@konsulko.com>, "Bin Meng" <bmeng.cn@gmail.com>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Alexander Graf" <agraf@csgraf.de>
Subject: Re: [PATCH 08/40] efi: Correct address handling with ACPI tables
Date: Wed, 1 Dec 2021 12:32:54 -0700	[thread overview]
Message-ID: <CAPnjgZ2xPxpfQFWcNHSQnU-ymwqoFs2sh7HfPgj7Mp0CtpMhhw@mail.gmail.com> (raw)
In-Reply-To: <2f4eb944-45ab-a8bd-7f8d-1380f5692410@gmx.de>

Hi Heinrich,

On Wed, 1 Dec 2021 at 11:13, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 12/1/21 17:02, Simon Glass wrote:
> > The current EFI implementation confuses pointers and addresses. Normally
> > we can get away with this but in the case of sandbox it causes failures.
> >
> > Despite the fact that efi_allocate_pages() returns a u64, it is actually
> > a pointer, not an address. Add special handling to avoid a crash when
> > running 'bootefi hello'.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >   lib/efi_loader/efi_acpi.c | 5 ++++-
> >   1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c
> > index 016bbf6db33..9d101aa843e 100644
> > --- a/lib/efi_loader/efi_acpi.c
> > +++ b/lib/efi_loader/efi_acpi.c
> > @@ -8,6 +8,7 @@
> >   #include <common.h>
> >   #include <efi_loader.h>
> >   #include <log.h>
> > +#include <mapmem.h>
> >   #include <acpi/acpi_table.h>
> >
> >   static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
> > @@ -22,6 +23,7 @@ efi_status_t efi_acpi_register(void)
> >       /* Map within the low 32 bits, to allow for 32bit ACPI tables */
> >       u64 acpi = U32_MAX;
> >       efi_status_t ret;
> > +     ulong addr;
> >
> >       /* Reserve 64kiB page for ACPI */
> >       ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> > @@ -34,7 +36,8 @@ efi_status_t efi_acpi_register(void)
> >        * a 4k-aligned address, so it is safe to assume that
> >        * write_acpi_tables() will write the table at that address.
> >        */
> > -     write_acpi_tables((ulong)acpi);
> > +     addr = map_to_sysmem((void *)(ulong)acpi);
>
> Please, don't pollute general code with sandbox specific stuff where
> this can be avoided.
>
> write_acpi_tables() anyway converts to a pointer. We should not convert
> twice. Correct the parameter of write_acpi_tables() instead to expect a
> pointer.

I don't want to use pointers to pass addresses. It is not the common
approach in U-Boot. We use ulong to pass addresses.

Re the need for this change, I beg to differ, and the crash shows that
I am right :-)

Don't you think it is odd that the EFI allocation routine returns a
u64 instead of a void *, like malloc()? If that were fixed, then this
code would make more sense. I think we talked about it before.

Regards,
Simon

  reply	other threads:[~2021-12-01 19:33 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 16:02 [PATCH 00/40] RFC: rpi: Enable ACPI booting on ARM with Raspberry Pi 4 Simon Glass
2021-12-01 16:02 ` [PATCH 01/40] Makefile: Allow LTO to be disabled for a build Simon Glass
2021-12-01 16:02 ` [PATCH 02/40] x86: Allow any arch to generate ACPI tables Simon Glass
2021-12-01 16:02 ` [PATCH 03/40] x86: Move the acpi table to generic global_data Simon Glass
2021-12-01 16:02 ` [PATCH 04/40] arm: Allow supporting ACPI-table generation Simon Glass
2021-12-01 16:49   ` Mark Kettenis
2021-12-01 17:10     ` Tom Rini
2021-12-01 17:45       ` François Ozog
2021-12-01 18:02         ` Simon Glass
2022-01-23 21:54         ` Simon Glass
2021-12-01 16:02 ` [PATCH 05/40] x86: Tidy up use of CONFIG_ACPIGEN Simon Glass
2021-12-01 16:02 ` [PATCH 06/40] sandbox: Allow building with GENERATE_ACPI_TABLE Simon Glass
2021-12-01 18:14   ` Heinrich Schuchardt
2021-12-01 19:32     ` Simon Glass
2022-01-23 21:54     ` Simon Glass
2021-12-01 16:02 ` [PATCH 07/40] efi: Correct call to write_acpi_tables() Simon Glass
2021-12-01 17:59   ` Heinrich Schuchardt
2021-12-01 19:32     ` Simon Glass
2021-12-01 19:57       ` Heinrich Schuchardt
2021-12-01 21:12         ` Simon Glass
2021-12-02  5:00           ` Heinrich Schuchardt
2021-12-02 13:42             ` Simon Glass
2022-01-23 21:54             ` Simon Glass
2021-12-01 16:02 ` [PATCH 08/40] efi: Correct address handling with ACPI tables Simon Glass
2021-12-01 18:12   ` Heinrich Schuchardt
2021-12-01 19:32     ` Simon Glass [this message]
2022-01-23 21:53     ` Simon Glass
2021-12-01 16:02 ` [PATCH 09/40] acpi: Use finer-grained control of ACPI-table generation Simon Glass
2021-12-01 16:02 ` [PATCH 10/40] acpi: Allow include files within the board directory Simon Glass
2021-12-01 16:02 ` [PATCH 11/40] acpi: Move acpi_fill_header() to the generic header Simon Glass
2021-12-01 16:02 ` [PATCH 12/40] acpi: Add a table start Simon Glass
2021-12-01 16:02 ` [PATCH 13/40] acpi: Add a linker list for ACPI tables Simon Glass
2021-12-01 16:02 ` [PATCH 14/40] x86: acpi: Split out context creation from base tables Simon Glass
2021-12-01 16:02 ` [PATCH 15/40] x86: Use the ACPI table writer Simon Glass
2021-12-01 16:02 ` [PATCH 16/40] x86: Move base tables to a writer function Simon Glass
2021-12-01 16:02 ` [PATCH 17/40] x86: Move FACS table " Simon Glass
2021-12-01 16:02 ` [PATCH 18/40] x86: Move DSDT " Simon Glass
2021-12-01 16:02 ` [PATCH 19/40] x86: Move GNVS " Simon Glass
2021-12-01 16:02 ` [PATCH 20/40] x86: Move FADT " Simon Glass
2021-12-01 16:02 ` [PATCH 21/40] x86: Move FACP table into separate functions Simon Glass
2021-12-01 16:02 ` [PATCH 22/40] x86: Move SSDT table to a writer function Simon Glass
2021-12-01 16:02 ` [PATCH 23/40] x86: Move TPM2 " Simon Glass
2021-12-01 16:02 ` [PATCH 24/40] x86: Move MADT " Simon Glass
2021-12-01 16:02 ` [PATCH 25/40] x86: Move TCPA " Simon Glass
2021-12-01 16:03 ` [PATCH 26/40] x86: Move CSRT " Simon Glass
2021-12-01 16:03 ` [PATCH 27/40] x86: acpi: Update acpi_fill_csrt() to use acpi_ctx Simon Glass
2021-12-01 16:03 ` [PATCH 28/40] x86: Move device-specific ACPI tables to a writer function Simon Glass
2021-12-01 16:03 ` [PATCH 29/40] x86: Move acpi_get_rsdp_addr() ACPI tables to the writer Simon Glass
2021-12-01 16:03 ` [PATCH 30/40] acpi: Collect tables in the acpi_item list Simon Glass
2021-12-01 16:03 ` [PATCH 31/40] acpi: Tidy up the item list Simon Glass
2021-12-01 16:03 ` [PATCH 32/40] acpi: Tidy up the table list Simon Glass
2021-12-01 16:03 ` [PATCH 33/40] doc: Add usage information for the acpi command Simon Glass
2021-12-01 16:03 ` [PATCH 34/40] acpi: Add some tables needed by ARM devices Simon Glass
2021-12-01 16:03 ` [PATCH 35/40] acpi: Add myself as maintainer Simon Glass
2021-12-01 16:03 ` [PATCH 36/40] WIP: Add debugging for ACPI emission Simon Glass
2021-12-01 16:03 ` [PATCH 37/40] RFC: Allow passing ACPI tables to bootefi Simon Glass
2021-12-01 16:03 ` [PATCH 38/40] WIP: Add ASL files from tianocore Simon Glass
2021-12-01 16:03 ` [PATCH 39/40] WIP: Bring in some header " Simon Glass
2021-12-01 16:03 ` [PATCH 40/40] RFC: rpi: Enable booting with ACPI tables Simon Glass
2021-12-01 16:24   ` Andy Shevchenko
2021-12-01 19:30     ` Simon Glass
2021-12-01 17:09 ` [PATCH 00/40] RFC: rpi: Enable ACPI booting on ARM with Raspberry Pi 4 Andy Shevchenko
2021-12-01 17:50   ` François Ozog
2021-12-01 18:23     ` Tom Rini
2021-12-15  3:28 ` Simon Glass
2022-01-22 22:48   ` Simon Glass
2022-01-23 21:53 ` [PATCH 35/40] acpi: Add myself as maintainer Simon Glass
2022-01-23 21:53 ` [PATCH 33/40] doc: Add usage information for the acpi command Simon Glass
2022-01-23 21:53 ` [PATCH 34/40] acpi: Add some tables needed by ARM devices Simon Glass
2022-01-23 21:53 ` [PATCH 32/40] acpi: Tidy up the table list Simon Glass
2022-01-23 21:53 ` [PATCH 31/40] acpi: Tidy up the item list Simon Glass
2022-01-23 21:53 ` [PATCH 29/40] x86: Move acpi_get_rsdp_addr() ACPI tables to the writer Simon Glass
2022-01-23 21:53 ` [PATCH 30/40] acpi: Collect tables in the acpi_item list Simon Glass
2022-01-23 21:53 ` [PATCH 28/40] x86: Move device-specific ACPI tables to a writer function Simon Glass
2022-01-23 21:53 ` [PATCH 27/40] x86: acpi: Update acpi_fill_csrt() to use acpi_ctx Simon Glass
2022-01-23 21:53 ` [PATCH 26/40] x86: Move CSRT table to a writer function Simon Glass
2022-01-23 21:53 ` [PATCH 24/40] x86: Move MADT " Simon Glass
2022-01-23 21:53 ` [PATCH 25/40] x86: Move TCPA " Simon Glass
2022-01-23 21:53 ` [PATCH 22/40] x86: Move SSDT " Simon Glass
2022-01-23 21:53 ` [PATCH 23/40] x86: Move TPM2 " Simon Glass
2022-01-23 21:53 ` [PATCH 21/40] x86: Move FACP table into separate functions Simon Glass
2022-01-23 21:53 ` [PATCH 20/40] x86: Move FADT table to a writer function Simon Glass
2022-01-23 21:53 ` [PATCH 19/40] x86: Move GNVS " Simon Glass
2022-01-23 21:53 ` [PATCH 17/40] x86: Move FACS " Simon Glass
2022-01-23 21:53 ` [PATCH 18/40] x86: Move DSDT " Simon Glass
2022-01-23 21:53 ` [PATCH 16/40] x86: Move base tables " Simon Glass
2022-01-23 21:53 ` [PATCH 15/40] x86: Use the ACPI table writer Simon Glass
2022-01-23 21:53 ` [PATCH 13/40] acpi: Add a linker list for ACPI tables Simon Glass
2022-01-23 21:53 ` [PATCH 14/40] x86: acpi: Split out context creation from base tables Simon Glass
2022-01-23 21:53 ` [PATCH 12/40] acpi: Add a table start Simon Glass
2022-01-23 21:53 ` [PATCH 10/40] acpi: Allow include files within the board directory Simon Glass
2022-01-23 21:53 ` [PATCH 11/40] acpi: Move acpi_fill_header() to the generic header Simon Glass
2022-01-23 21:54 ` [PATCH 05/40] x86: Tidy up use of CONFIG_ACPIGEN Simon Glass
2022-01-23 21:54 ` [PATCH 02/40] x86: Allow any arch to generate ACPI tables Simon Glass
2022-01-23 21:54 ` [PATCH 03/40] x86: Move the acpi table to generic global_data Simon Glass

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=CAPnjgZ2xPxpfQFWcNHSQnU-ymwqoFs2sh7HfPgj7Mp0CtpMhhw@mail.gmail.com \
    --to=sjg@chromium.org \
    --cc=agraf@csgraf.de \
    --cc=bmeng.cn@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.