All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 03/13] efi: sandbox: Adjust memory usage for sandbox
Date: Thu, 14 Jun 2018 15:41:52 +0200	[thread overview]
Message-ID: <5f59f274-c997-7281-0511-039a7f7744c2@suse.de> (raw)
In-Reply-To: <CAPnjgZ3m3vJJxe-Gypp+k26CLa7H8O7SB+JcOvY1iheZbB5FXw@mail.gmail.com>

On 06/14/2018 02:58 PM, Simon Glass wrote:
> Hi Alex,
>
> On 14 June 2018 at 04:12, Alexander Graf <agraf@suse.de> wrote:
>> On 06/13/2018 04:37 AM, Simon Glass wrote:
>>> With sandbox the U-Boot code is not mapped into the sandbox memory range
>>> so does not need to be excluded when allocating EFI memory. Update the EFI
>>> memory init code to take account of that.
>>>
>>> Also use mapmem instead of a cast to convert a memory address to a
>>> pointer.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>> Changes in v6: None
>>> Changes in v5: None
>>> Changes in v4: None
>>> Changes in v3: None
>>> Changes in v2:
>>> - Update to use mapmem instead of a cast
>>>
>>>    lib/efi_loader/efi_memory.c | 31 ++++++++++++++++++-------------
>>>    1 file changed, 18 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
>>> index ec66af98ea..210e49ee8b 100644
>>> --- a/lib/efi_loader/efi_memory.c
>>> +++ b/lib/efi_loader/efi_memory.c
>>> @@ -9,6 +9,7 @@
>>>    #include <efi_loader.h>
>>>    #include <inttypes.h>
>>>    #include <malloc.h>
>>> +#include <mapmem.h>
>>>    #include <watchdog.h>
>>>    #include <linux/list_sort.h>
>>>    @@ -393,7 +394,7 @@ efi_status_t efi_allocate_pool(int pool_type,
>>> efi_uintn_t size, void **buffer)
>>>                                 &t);
>>>          if (r == EFI_SUCCESS) {
>>> -               struct efi_pool_allocation *alloc = (void *)(uintptr_t)t;
>>> +               struct efi_pool_allocation *alloc = map_sysmem(t, size);
>>
>> This is still the wrong spot. We don't want the conversion to happen when
>> going from an EFI internal address to an allocation, but when determining
>> which addresses are usable in the first place.
> There seem to be two ways to do this:
>
> 1. Record addresses (ulong) in the EFI tables and use map_sysmem()
> before returning an address in the allocator
> 2. Store pointers in the EFI tables using map_sysmem(), then do no
> mapping in the allocator
>
> I've gone with option 1 since:
>
> - the EFI addresses are not pointers
> - it makes sandbox consistent with other architectures which use an
> address rather than a pointer in EFI tables
> - we don't normally do pointer arithmetic on the results of map_sysmem()
> - we normally map the memory when it is used rather than when it is set up
>
> I think you are asking for option 2. I think that would get very
> confusing. The addresses where things actually end up in sandbox are
> best kept to sandbox.
>
> Overall I feel that you are either missing the point of sandbox
> addressing, or don't agree with how it is done. But it does work
> pretty well and we don't get a lot of confusion with sandbox pointers
> since we typically use the address until the last moment.

I've assembled a quick tree for version 2. With that I'm able to run a 
simple hello world efi application. Grub refuses to start because it 
wants memory in the low 32bit and also emits random PIO accessing 
functions, which obviously don't work work from user space.

But overall, I think this is the right path to tackle this:

   https://github.com/agraf/u-boot/tree/efi-sandbox


Alex

  reply	other threads:[~2018-06-14 13:41 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-13  2:37 [U-Boot] [PATCH v6 00/13] efi: Enable basic sandbox support for EFI loader Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 01/13] efi: Don't allow CMD_BOOTEFI_SELFTEST on sandbox Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 02/13] efi: Init the 'rows' and 'cols' variables Simon Glass
2018-06-14 10:11   ` Alexander Graf
2018-06-14 12:58     ` Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 03/13] efi: sandbox: Adjust memory usage for sandbox Simon Glass
2018-06-14 10:12   ` Alexander Graf
2018-06-14 12:58     ` Simon Glass
2018-06-14 13:41       ` Alexander Graf [this message]
2018-06-14 14:12         ` Simon Glass
2018-06-14 14:22           ` Alexander Graf
2018-06-14 15:43             ` Simon Glass
2018-06-14 15:47               ` Alexander Graf
2018-06-14 15:53                 ` Simon Glass
2018-06-14 16:07                   ` Alexander Graf
2018-06-14 16:13                     ` Simon Glass
2018-06-14 16:26                       ` Alexander Graf
2018-06-14 16:33                         ` Simon Glass
2018-06-14 16:42                           ` Alexander Graf
2018-06-14 16:55                             ` Simon Glass
2018-06-14 17:08                               ` Alexander Graf
2018-06-14 17:15                                 ` Simon Glass
2018-06-14 18:05                                   ` Alexander Graf
2018-06-14 19:02                                     ` Simon Glass
2018-06-14 19:32                                       ` Alexander Graf
2018-06-20 17:51                                         ` Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 04/13] sandbox: smbios: Update to support sandbox Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 05/13] efi: sandbox: Add distroboot support Simon Glass
2018-06-14 10:13   ` Alexander Graf
2018-06-13  2:37 ` [U-Boot] [PATCH v6 06/13] efi: sandbox: Add relocation constants Simon Glass
2018-06-14 10:14   ` Alexander Graf
2018-06-13  2:37 ` [U-Boot] [PATCH v6 07/13] efi: Add a comment about duplicated ELF constants Simon Glass
2018-06-14 10:15   ` Alexander Graf
2018-06-13  2:37 ` [U-Boot] [PATCH v6 08/13] efi: sandbox: Enable EFI loader builder for sandbox Simon Glass
2018-06-14 10:19   ` Alexander Graf
2018-06-13  2:37 ` [U-Boot] [PATCH v6 09/13] efi: Split out test init/uninit into functions Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 10/13] efi: sandbox: Add a simple 'bootefi test' command Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 11/13] efi: Create a function to set up for running EFI code Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 12/13] efi: Rename bootefi_test_finish() to bootefi_run_finish() Simon Glass
2018-06-13  2:37 ` [U-Boot] [PATCH v6 13/13] Revert "buildman: Extract environment as part of each build" Simon Glass
2018-06-13  2:41   ` 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=5f59f274-c997-7281-0511-039a7f7744c2@suse.de \
    --to=agraf@suse.de \
    --cc=u-boot@lists.denx.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.