diff mbox series

[10/11] efi_loader: Pass virtual address to fs_read()

Message ID 20180614163334.46827-11-agraf@suse.de
State New
Headers show
Series sandbox: efi_loader support | expand

Commit Message

Alexander Graf June 14, 2018, 4:33 p.m. UTC
The fs_read() function wants to get a virtual (u-boot address space
in sandbox) address rather than a physical (host address space in
sandbox) one.

So let's convert from the real pointer back a the physical address
to make efi_loader on sandbox happier.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Simon Glass June 14, 2018, 4:55 p.m. UTC | #1
Hi Alex,

On 14 June 2018 at 10:33, Alexander Graf <agraf@suse.de> wrote:
> The fs_read() function wants to get a virtual (u-boot address space
> in sandbox) address rather than a physical (host address space in
> sandbox) one.
>

The terminology is wrong here. It is not about virtual and physical
addresses - that's an MMU concept.

It's about sandbox using a special memory buffer to emulate U-Boot
memory access.

The code is correct but the comment and commit message will cause
great confusion, so please fix.

It is document in a few READMEs, but perhaps I should add some
comments to mapmem.h ?

Regards,
Simon
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index e6a15bcb52..ecf174a3dd 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -232,8 +232,10 @@  static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size,
 		void *buffer)
 {
 	loff_t actread;
+	/* fs_read expects buffer as virtual address */
+	uintptr_t buffer_addr = (uintptr_t)map_to_sysmem((uintptr_t)buffer);
 
-	if (fs_read(fh->path, (ulong)buffer, fh->offset,
+	if (fs_read(fh->path, buffer_addr, fh->offset,
 		    *buffer_size, &actread))
 		return EFI_DEVICE_ERROR;