diff mbox series

[RFC] sandbox: Enable 1:1 map

Message ID 20180614231316.14201-1-agraf@suse.de
State New
Headers show
Series [RFC] sandbox: Enable 1:1 map | expand

Commit Message

Alexander Graf June 14, 2018, 11:13 p.m. UTC
So far we've always had a split address space situation with
"U-Boot addresses" (a number space starting from 0) and "host
virtual addresses" (128MB mapped randomly in address space).

This meant that we had to make sure all code is properly aware that
addresses and pointers are not the same thing, so they must not cast
between the two.

However, most real boards do actually have a 1:1 map. So it's
much easier to just expose the same in sandbox.

So this patch maps sandbox RAM from 0x8000000-0x10000000. This
address range fits just fine on both 32bit and 64bit systems.

---

The patch is on top of my "efi-sandbox-v3" tree. But I'm sure
it easily applies on vanilla too.

I also don't know if this really is the best path forward, but
at least it's one that gets rid of the one awkward target that
does not have a 1:1 map ;)
---
 arch/sandbox/cpu/cpu.c             | 18 ++----------------
 arch/sandbox/cpu/state.c           |  4 ++--
 arch/sandbox/cpu/u-boot.lds        |  3 +++
 arch/sandbox/include/asm/io.h      | 17 +++++------------
 common/board_f.c                   |  4 +++-
 configs/sandbox64_defconfig        |  6 +++---
 configs/sandbox_defconfig          |  6 +++---
 configs/sandbox_flattree_defconfig |  4 ++--
 configs/sandbox_noblk_defconfig    |  4 ++--
 configs/sandbox_spl_defconfig      |  4 ++--
 include/configs/sandbox.h          | 22 +++++++++++-----------
 11 files changed, 38 insertions(+), 54 deletions(-)

Comments

Simon Glass June 20, 2018, 5:51 p.m. UTC | #1
Hi Alex,

On 14 June 2018 at 17:13, Alexander Graf <agraf@suse.de> wrote:
> So far we've always had a split address space situation with
> "U-Boot addresses" (a number space starting from 0) and "host
> virtual addresses" (128MB mapped randomly in address space).
>
> This meant that we had to make sure all code is properly aware that
> addresses and pointers are not the same thing, so they must not cast
> between the two.
>
> However, most real boards do actually have a 1:1 map. So it's
> much easier to just expose the same in sandbox.
>
> So this patch maps sandbox RAM from 0x8000000-0x10000000. This
> address range fits just fine on both 32bit and 64bit systems.
>
> ---
>
> The patch is on top of my "efi-sandbox-v3" tree. But I'm sure
> it easily applies on vanilla too.
>
> I also don't know if this really is the best path forward, but
> at least it's one that gets rid of the one awkward target that
> does not have a 1:1 map ;)
> ---
>  arch/sandbox/cpu/cpu.c             | 18 ++----------------
>  arch/sandbox/cpu/state.c           |  4 ++--
>  arch/sandbox/cpu/u-boot.lds        |  3 +++
>  arch/sandbox/include/asm/io.h      | 17 +++++------------
>  common/board_f.c                   |  4 +++-
>  configs/sandbox64_defconfig        |  6 +++---
>  configs/sandbox_defconfig          |  6 +++---
>  configs/sandbox_flattree_defconfig |  4 ++--
>  configs/sandbox_noblk_defconfig    |  4 ++--
>  configs/sandbox_spl_defconfig      |  4 ++--
>  include/configs/sandbox.h          | 22 +++++++++++-----------
>  11 files changed, 38 insertions(+), 54 deletions(-)

NAK, as discussed.

Just to repeat myself, I do not want to change how sandbox works at
this stage. We will always have some need for mapping, even if only to
make PCI work.

Once we have EFI working and have more test coverage in U-Boot itself
we can revisit this. But this change is not necessary to make EFI
work.

Regards,
Simon
Heinrich Schuchardt June 21, 2018, 1:23 a.m. UTC | #2
On 06/20/2018 07:51 PM, Simon Glass wrote:
> Hi Alex,
> 
> On 14 June 2018 at 17:13, Alexander Graf <agraf@suse.de> wrote:
>> So far we've always had a split address space situation with
>> "U-Boot addresses" (a number space starting from 0) and "host
>> virtual addresses" (128MB mapped randomly in address space).
>>
>> This meant that we had to make sure all code is properly aware that
>> addresses and pointers are not the same thing, so they must not cast
>> between the two.
>>
>> However, most real boards do actually have a 1:1 map. So it's
>> much easier to just expose the same in sandbox.
>>
>> So this patch maps sandbox RAM from 0x8000000-0x10000000. This
>> address range fits just fine on both 32bit and 64bit systems.
>>
>> ---
>>
>> The patch is on top of my "efi-sandbox-v3" tree. But I'm sure
>> it easily applies on vanilla too.
>>
>> I also don't know if this really is the best path forward, but
>> at least it's one that gets rid of the one awkward target that
>> does not have a 1:1 map ;)
>> ---
>>  arch/sandbox/cpu/cpu.c             | 18 ++----------------
>>  arch/sandbox/cpu/state.c           |  4 ++--
>>  arch/sandbox/cpu/u-boot.lds        |  3 +++
>>  arch/sandbox/include/asm/io.h      | 17 +++++------------
>>  common/board_f.c                   |  4 +++-
>>  configs/sandbox64_defconfig        |  6 +++---
>>  configs/sandbox_defconfig          |  6 +++---
>>  configs/sandbox_flattree_defconfig |  4 ++--
>>  configs/sandbox_noblk_defconfig    |  4 ++--
>>  configs/sandbox_spl_defconfig      |  4 ++--
>>  include/configs/sandbox.h          | 22 +++++++++++-----------
>>  11 files changed, 38 insertions(+), 54 deletions(-)
> 
> NAK, as discussed.
> 
> Just to repeat myself, I do not want to change how sandbox works at
> this stage. We will always have some need for mapping, even if only to
> make PCI work.
> 
> Once we have EFI working and have more test coverage in U-Boot itself
> we can revisit this. But this change is not necessary to make EFI
> work.

Hi Simon,

unfortunately I have not seen that your patches make EFI work on the
sandbox. bootefi selftest always failed. Now you even explicitly exclude
all tests
(https://lists.denx.de/pipermail/u-boot/2018-June/332133.html). With
Alex patch series the existing tests work fine.

I see no point in merging patches for the Sandbox which ignore the
existing tests.

Regards

Heinrich
Simon Glass June 21, 2018, 2:01 a.m. UTC | #3
Hi Heinrich,

On 20 June 2018 at 19:23, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> On 06/20/2018 07:51 PM, Simon Glass wrote:
>> Hi Alex,
>>
>> On 14 June 2018 at 17:13, Alexander Graf <agraf@suse.de> wrote:
>>> So far we've always had a split address space situation with
>>> "U-Boot addresses" (a number space starting from 0) and "host
>>> virtual addresses" (128MB mapped randomly in address space).
>>>
>>> This meant that we had to make sure all code is properly aware that
>>> addresses and pointers are not the same thing, so they must not cast
>>> between the two.
>>>
>>> However, most real boards do actually have a 1:1 map. So it's
>>> much easier to just expose the same in sandbox.
>>>
>>> So this patch maps sandbox RAM from 0x8000000-0x10000000. This
>>> address range fits just fine on both 32bit and 64bit systems.
>>>
>>> ---
>>>
>>> The patch is on top of my "efi-sandbox-v3" tree. But I'm sure
>>> it easily applies on vanilla too.
>>>
>>> I also don't know if this really is the best path forward, but
>>> at least it's one that gets rid of the one awkward target that
>>> does not have a 1:1 map ;)
>>> ---
>>>  arch/sandbox/cpu/cpu.c             | 18 ++----------------
>>>  arch/sandbox/cpu/state.c           |  4 ++--
>>>  arch/sandbox/cpu/u-boot.lds        |  3 +++
>>>  arch/sandbox/include/asm/io.h      | 17 +++++------------
>>>  common/board_f.c                   |  4 +++-
>>>  configs/sandbox64_defconfig        |  6 +++---
>>>  configs/sandbox_defconfig          |  6 +++---
>>>  configs/sandbox_flattree_defconfig |  4 ++--
>>>  configs/sandbox_noblk_defconfig    |  4 ++--
>>>  configs/sandbox_spl_defconfig      |  4 ++--
>>>  include/configs/sandbox.h          | 22 +++++++++++-----------
>>>  11 files changed, 38 insertions(+), 54 deletions(-)
>>
>> NAK, as discussed.
>>
>> Just to repeat myself, I do not want to change how sandbox works at
>> this stage. We will always have some need for mapping, even if only to
>> make PCI work.
>>
>> Once we have EFI working and have more test coverage in U-Boot itself
>> we can revisit this. But this change is not necessary to make EFI
>> work.
>
> Hi Simon,
>
> unfortunately I have not seen that your patches make EFI work on the
> sandbox. bootefi selftest always failed. Now you even explicitly exclude
> all tests
> (https://lists.denx.de/pipermail/u-boot/2018-June/332133.html). With
> Alex patch series the existing tests work fine.
>
> I see no point in merging patches for the Sandbox which ignore the
> existing tests.

My original goal (with the series) was to enable basic EFI support in
sandbox, enough to run the hello world app.

That was (I think) a reasonable step forward. Future work could then
have enabled selftest.

But it seems that both you and Alex want everything done in one huge
series, so that we go from no EFI support on sandbox, to enough
support to run selftest. That is obviously more work, more complex,
etc. But that is what I have done with the latest series.

For me, selftest runs fine with my series. What error do you see?

Regards,
Simon
Simon Glass June 21, 2018, 2:55 a.m. UTC | #4
Hi Heinrich,

On 20 June 2018 at 20:01, Simon Glass <sjg@chromium.org> wrote:
> Hi Heinrich,
>
> On 20 June 2018 at 19:23, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>> On 06/20/2018 07:51 PM, Simon Glass wrote:
>>> Hi Alex,
>>>
>>> On 14 June 2018 at 17:13, Alexander Graf <agraf@suse.de> wrote:
>>>> So far we've always had a split address space situation with
>>>> "U-Boot addresses" (a number space starting from 0) and "host
>>>> virtual addresses" (128MB mapped randomly in address space).
>>>>
>>>> This meant that we had to make sure all code is properly aware that
>>>> addresses and pointers are not the same thing, so they must not cast
>>>> between the two.
>>>>
>>>> However, most real boards do actually have a 1:1 map. So it's
>>>> much easier to just expose the same in sandbox.
>>>>
>>>> So this patch maps sandbox RAM from 0x8000000-0x10000000. This
>>>> address range fits just fine on both 32bit and 64bit systems.
>>>>
>>>> ---
>>>>
>>>> The patch is on top of my "efi-sandbox-v3" tree. But I'm sure
>>>> it easily applies on vanilla too.
>>>>
>>>> I also don't know if this really is the best path forward, but
>>>> at least it's one that gets rid of the one awkward target that
>>>> does not have a 1:1 map ;)
>>>> ---
>>>>  arch/sandbox/cpu/cpu.c             | 18 ++----------------
>>>>  arch/sandbox/cpu/state.c           |  4 ++--
>>>>  arch/sandbox/cpu/u-boot.lds        |  3 +++
>>>>  arch/sandbox/include/asm/io.h      | 17 +++++------------
>>>>  common/board_f.c                   |  4 +++-
>>>>  configs/sandbox64_defconfig        |  6 +++---
>>>>  configs/sandbox_defconfig          |  6 +++---
>>>>  configs/sandbox_flattree_defconfig |  4 ++--
>>>>  configs/sandbox_noblk_defconfig    |  4 ++--
>>>>  configs/sandbox_spl_defconfig      |  4 ++--
>>>>  include/configs/sandbox.h          | 22 +++++++++++-----------
>>>>  11 files changed, 38 insertions(+), 54 deletions(-)
>>>
>>> NAK, as discussed.
>>>
>>> Just to repeat myself, I do not want to change how sandbox works at
>>> this stage. We will always have some need for mapping, even if only to
>>> make PCI work.
>>>
>>> Once we have EFI working and have more test coverage in U-Boot itself
>>> we can revisit this. But this change is not necessary to make EFI
>>> work.
>>
>> Hi Simon,
>>
>> unfortunately I have not seen that your patches make EFI work on the
>> sandbox. bootefi selftest always failed. Now you even explicitly exclude
>> all tests
>> (https://lists.denx.de/pipermail/u-boot/2018-June/332133.html). With
>> Alex patch series the existing tests work fine.
>>
>> I see no point in merging patches for the Sandbox which ignore the
>> existing tests.
>
> My original goal (with the series) was to enable basic EFI support in
> sandbox, enough to run the hello world app.
>
> That was (I think) a reasonable step forward. Future work could then
> have enabled selftest.
>
> But it seems that both you and Alex want everything done in one huge
> series, so that we go from no EFI support on sandbox, to enough
> support to run selftest. That is obviously more work, more complex,
> etc. But that is what I have done with the latest series.
>
> For me, selftest runs fine with my series. What error do you see?

You can test the tree at u-boot-dm/efi-working

This is what I get:

$ crosfw -b sandbox
$ /tmp/b/sandbox/u-boot -c "bootefi selftest"


U-Boot 2018.07-rc2-00030-ge3b8a5d (Jun 20 2018 - 20:54:15 -0600)

DRAM:  128 MiB
MMC:
In:    serial
Out:   serial
Err:   serial
SCSI:  Net:   No ethernet found.
IDE:   Bus 0: not available
Found 0 disks
WARNING: booting without device tree

Testing EFI API implementation

Number of tests to execute: 18

Setting up 'block device'
Setting up 'block device' succeeded

Executing 'block device'
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_block_device.c(378):
TODO: Wrong volume label 'xxa1', expected 'U-BOOT TEST'
map_to_sysmem: Added map from 00007fffc2de8190 to 8000000
phys_to_virt: Used map from 8000000 to 00007fffc2de8190
Executing 'block device' succeeded

Tearing down 'block device'
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_block_device.c(261):
TODO: Failed to uninstall block I/O protocol
Tearing down 'block device' succeeded

Setting up 'controllers'
Setting up 'controllers' succeeded

Executing 'controllers'
Executing 'controllers' succeeded

Setting up 'device path'
Setting up 'device path' succeeded

Executing 'device path'
Installed device path protocols:
/MemoryMapped(0x0,0x4684e9,0x4684e9)
/VenHw(dbca4c98-6cb0-694d-0872-819c650cb7b8)/HD(1,MBR,0xd1535d21,0x1,0x7f)
/VenHw(dbca4c98-6cb0-694d-0872-819c650cbbb1)
/VenHw(dbca4c98-6cb0-694d-0872-819c650cbbb1)/VenHw(dbca4c98-6cb0-694d-0872-819c650cbba2)
/VenHw(dbca4c98-6cb0-694d-0872-819c650cbbb1)/VenHw(dbca4c98-6cb0-694d-0872-819c650cbba2)/VenHw(dbca4c98-6cb0-694d-0872-819c650cbbc3)
Executing 'device path' succeeded

Tearing down 'device path'
Tearing down 'device path' succeeded

Setting up 'device path utilities protocol'
Setting up 'device path utilities protocol' succeeded

Executing 'device path utilities protocol'
Executing 'device path utilities protocol' succeeded

Setting up 'event groups'
Setting up 'event groups' succeeded

Executing 'event groups'
Executing 'event groups' succeeded

Setting up 'event services'
Setting up 'event services' succeeded

Executing 'event services'
Executing 'event services' succeeded

Tearing down 'event services'
Tearing down 'event services' succeeded

Setting up 'graphical output'
Graphical output protocol is not available.
Setting up 'graphical output' succeeded

Executing 'graphical output'
Executing 'graphical output' succeeded

Tearing down 'graphical output'
Tearing down 'graphical output' succeeded

Setting up 'manage protocols'
Setting up 'manage protocols' succeeded

Executing 'manage protocols'
Executing 'manage protocols' succeeded

Tearing down 'manage protocols'
Tearing down 'manage protocols' succeeded

Setting up 'simple network protocol'
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_snp.c(209):
ERROR: Failed to locate simple network protocol
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest.c(84):
ERROR: Setting up 'simple network protocol' failed

Tearing down 'simple network protocol'
Tearing down 'simple network protocol' succeeded

Executing 'text output'

Color palette
00000000000000000000000000000010000000000000002000000000000000300000000000000040000000000000005000000000000000600000000000000070
00000000000000010000000000000011000000000000002100000000000000310000000000000041000000000000005100000000000000610000000000000071
00000000000000020000000000000012000000000000002200000000000000320000000000000042000000000000005200000000000000620000000000000072
00000000000000030000000000000013000000000000002300000000000000330000000000000043000000000000005300000000000000630000000000000073
00000000000000040000000000000014000000000000002400000000000000340000000000000044000000000000005400000000000000640000000000000074
00000000000000050000000000000015000000000000002500000000000000350000000000000045000000000000005500000000000000650000000000000075
00000000000000060000000000000016000000000000002600000000000000360000000000000046000000000000005600000000000000660000000000000076
00000000000000070000000000000017000000000000002700000000000000370000000000000047000000000000005700000000000000670000000000000077
00000000000000080000000000000018000000000000002800000000000000380000000000000048000000000000005800000000000000680000000000000078
00000000000000090000000000000019000000000000002900000000000000390000000000000049000000000000005900000000000000690000000000000079
000000000000000a000000000000001a000000000000002a000000000000003a000000000000004a000000000000005a000000000000006a000000000000007a
000000000000000b000000000000001b000000000000002b000000000000003b000000000000004b000000000000005b000000000000006b000000000000007b
000000000000000c000000000000001c000000000000002c000000000000003c000000000000004c000000000000005c000000000000006c000000000000007c
000000000000000d000000000000001d000000000000002d000000000000003d000000000000004d000000000000005d000000000000006d000000000000007d
000000000000000e000000000000001e000000000000002e000000000000003e000000000000004e000000000000005e000000000000006e000000000000007e
000000000000000f000000000000001f000000000000002f000000000000003f000000000000004f000000000000005f000000000000006f000000000000007f
Testing cursor column update

ð‘€…ð‘€¢3
Executing 'text output' succeeded

Setting up 'task priority levels'
Setting up 'task priority levels' succeeded

Executing 'task priority levels'
Executing 'task priority levels' succeeded

Tearing down 'task priority levels'
Tearing down 'task priority levels' succeeded

Setting up 'variables'
Setting up 'variables' succeeded

Executing 'variables'
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_variables.c(62):
TODO: QueryVariableInfo failed
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_variables.c(133):
TODO: GetVariable returned wrong length 7
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_variables.c(135):
TODO: GetVariable returned wrong value
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_variables.c(146):
TODO: GetNextVariableName failed
/scratch/sglass/cosarm/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_variables.c(158):
TODO: GetNextVariableName did not return all variables
Executing 'variables' succeeded

Setting up 'watchdog timer'
Setting up 'watchdog timer' succeeded

Executing 'watchdog timer'
Executing 'watchdog timer' succeeded

Tearing down 'watchdog timer'
Tearing down 'watchdog timer' succeeded

Setting up 'ExitBootServices'
Setting up 'ExitBootServices' succeeded

Boot services terminated

Executing 'ExitBootServices'

Boot services terminated
Executing 'ExitBootServices' succeeded

Tearing down 'ExitBootServices'
Tearing down 'ExitBootServices' succeeded

Summary: 1 failures

Preparing for reset. Press any key...


Regards,
Simon
diff mbox series

Patch

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 23d8b70648..5f5d6c9158 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -58,16 +58,6 @@  int cleanup_before_linux_select(int flags)
 	return 0;
 }
 
-void *phys_to_virt(phys_addr_t paddr)
-{
-	return (void *)(gd->arch.ram_buf + paddr);
-}
-
-phys_addr_t virt_to_phys(void *vaddr)
-{
-	return (phys_addr_t)((uint8_t *)vaddr - gd->arch.ram_buf);
-}
-
 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
 {
 #if defined(CONFIG_PCI) && !defined(CONFIG_SPL_BUILD)
@@ -103,11 +93,6 @@  void sandbox_set_enable_pci_map(int enable)
 	enable_pci_map = enable;
 }
 
-phys_addr_t map_to_sysmem(const void *ptr)
-{
-	return (u8 *)ptr - gd->arch.ram_buf;
-}
-
 void flush_dcache_range(unsigned long start, unsigned long stop)
 {
 }
@@ -187,7 +172,8 @@  void longjmp(jmp_buf jmp, int ret)
  */
 void efi_add_known_memory(void)
 {
-	u64 ram_start = (uintptr_t)map_sysmem(0, gd->ram_size);
+	u64 ram_start = (uintptr_t)map_sysmem(CONFIG_SYS_SDRAM_BASE,
+					      gd->ram_size);
 	u64 ram_size = gd->ram_size;
 	u64 start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
 	u64 pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index cc50819ab9..75ad564274 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -12,6 +12,7 @@ 
 /* Main state record for the sandbox */
 static struct sandbox_state main_state;
 static struct sandbox_state *state;	/* Pointer to current state record */
+static __attribute__ ((section (".ram"))) u8 sandbox_ram[CONFIG_SYS_SDRAM_SIZE];
 
 static int state_ensure_space(int extra_size)
 {
@@ -366,8 +367,7 @@  int state_init(void)
 	state = &main_state;
 
 	state->ram_size = CONFIG_SYS_SDRAM_SIZE;
-	state->ram_buf = os_malloc(state->ram_size);
-	assert(state->ram_buf);
+	state->ram_buf = sandbox_ram;
 
 	state_reset_for_test(state);
 	/*
diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
index 3a6cf55eb9..8d0dfadfe0 100644
--- a/arch/sandbox/cpu/u-boot.lds
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -47,6 +47,9 @@  SECTIONS
 		*(.__efi_runtime_rel_stop)
 	}
 
+	.ram 0x8000000 : {
+		*(.ram)
+	}
 }
 
 INSERT BEFORE .data;
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 81b7750628..fe792200a7 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -6,12 +6,6 @@ 
 #ifndef __SANDBOX_ASM_IO_H
 #define __SANDBOX_ASM_IO_H
 
-void *phys_to_virt(phys_addr_t paddr);
-#define phys_to_virt phys_to_virt
-
-phys_addr_t virt_to_phys(void *vaddr);
-#define virt_to_phys virt_to_phys
-
 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
 #define map_physmem map_physmem
 
@@ -23,20 +17,19 @@  void unmap_physmem(const void *vaddr, unsigned long flags);
 
 #include <asm-generic/io.h>
 
-/* For sandbox, we want addresses to point into our RAM buffer */
 static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
 {
-	return map_physmem(paddr, len, MAP_WRBACK);
+	return (void *)(unsigned long)paddr;
 }
 
-/* Remove a previous mapping */
 static inline void unmap_sysmem(const void *vaddr)
 {
-	unmap_physmem(vaddr, MAP_WRBACK);
 }
 
-/* Map from a pointer to our RAM buffer */
-phys_addr_t map_to_sysmem(const void *ptr);
+static inline phys_addr_t map_to_sysmem(const void *ptr)
+{
+	return (phys_addr_t)(unsigned long)ptr;
+}
 
 /* Define nops for sandbox I/O access */
 #define readb(addr) ((void)addr, 0)
diff --git a/common/board_f.c b/common/board_f.c
index e943347ce3..b06f9d30ad 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -219,7 +219,9 @@  static int setup_mon_len(void)
 {
 #if defined(__ARM__) || defined(__MICROBLAZE__)
 	gd->mon_len = (ulong)&__bss_end - (ulong)_start;
-#elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP)
+#elif defined(CONFIG_SANDBOX)
+	gd->mon_len = 0;
+#elif defined(CONFIG_EFI_APP)
 	gd->mon_len = (ulong)&_end - (ulong)_init;
 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
 	gd->mon_len = CONFIG_SYS_MONITOR_LEN;
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 20a2ab3ffb..5c47b651d4 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -1,4 +1,4 @@ 
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_SANDBOX64=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox64"
@@ -11,13 +11,13 @@  CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
 CONFIG_PRE_CONSOLE_BUFFER=y
-CONFIG_PRE_CON_BUF_ADDR=0x100000
+CONFIG_PRE_CON_BUF_ADDR=0x8100000
 CONFIG_LOG_MAX_LEVEL=6
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_CMD_CPU=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 2fc84a16c9..84828c972c 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -1,4 +1,4 @@ 
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
 CONFIG_DISTRO_DEFAULTS=y
@@ -10,13 +10,13 @@  CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
 CONFIG_PRE_CONSOLE_BUFFER=y
-CONFIG_PRE_CON_BUF_ADDR=0x100000
+CONFIG_PRE_CON_BUF_ADDR=0x8100000
 CONFIG_LOG_MAX_LEVEL=6
 CONFIG_LOG_ERROR_RETURN=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index e922c4b38f..567ec15c22 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -1,4 +1,4 @@ 
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
 CONFIG_DISTRO_DEFAULTS=y
@@ -10,7 +10,7 @@  CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
diff --git a/configs/sandbox_noblk_defconfig b/configs/sandbox_noblk_defconfig
index 8bdd4edcda..c46b0bc06c 100644
--- a/configs/sandbox_noblk_defconfig
+++ b/configs/sandbox_noblk_defconfig
@@ -1,4 +1,4 @@ 
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
 CONFIG_DISTRO_DEFAULTS=y
@@ -10,7 +10,7 @@  CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_CONSOLE_RECORD=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index fb6bb4baa2..4327e3f8b6 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -1,4 +1,4 @@ 
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
@@ -17,7 +17,7 @@  CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 1a49d1dab5..49a583fbe8 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -11,7 +11,7 @@ 
 #define CONFIG_TRACE_BUFFER_SIZE	(16 << 20)
 #define CONFIG_TRACE_EARLY_SIZE		(8 << 20)
 #define CONFIG_TRACE_EARLY
-#define CONFIG_TRACE_EARLY_ADDR		0x00100000
+#define CONFIG_TRACE_EARLY_ADDR		0x08100000
 
 #endif
 
@@ -30,7 +30,7 @@ 
 /*
  * Size of malloc() pool, before and after relocation
  */
-#define CONFIG_MALLOC_F_ADDR		0x0010000
+#define CONFIG_MALLOC_F_ADDR		0x08010000
 #define CONFIG_SYS_MALLOC_LEN		(32 << 20)	/* 32MB  */
 
 #define CONFIG_SYS_CBSIZE		1024	/* Console I/O Buffer Size */
@@ -44,15 +44,15 @@ 
 #define CONFIG_I2C_EDID
 
 /* Memory things - we don't really want a memory test */
-#define CONFIG_SYS_LOAD_ADDR		0x00000000
-#define CONFIG_SYS_MEMTEST_START	0x00100000
+#define CONFIG_SYS_LOAD_ADDR		0x08000000
+#define CONFIG_SYS_MEMTEST_START	0x08100000
 #define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_MEMTEST_START + 0x1000)
-#define CONFIG_SYS_FDT_LOAD_ADDR	        0x100
+#define CONFIG_SYS_FDT_LOAD_ADDR	0x08000100
 
 #define CONFIG_PHYSMEM
 
 /* Size of our emulated memory */
-#define CONFIG_SYS_SDRAM_BASE		0
+#define CONFIG_SYS_SDRAM_BASE		0x8000000
 #define CONFIG_SYS_SDRAM_SIZE		(128 << 20)
 #define CONFIG_SYS_MONITOR_BASE	0
 #define CONFIG_NR_DRAM_BANKS		1
@@ -104,11 +104,11 @@ 
 
 #define MEM_LAYOUT_ENV_SETTINGS \
 	"bootm_size=0x10000000\0" \
-	"kernel_addr_r=0x1000000\0" \
-	"fdt_addr_r=0xc00000\0" \
-	"ramdisk_addr_r=0x2000000\0" \
-	"scriptaddr=0x1000\0" \
-	"pxefile_addr_r=0x2000\0"
+	"kernel_addr_r=0x9000000\0" \
+	"fdt_addr_r=0x8c00000\0" \
+	"ramdisk_addr_r=0xa000000\0" \
+	"scriptaddr=0x8001000\0" \
+	"pxefile_addr_r=0x8002000\0"
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	SANDBOX_SERIAL_SETTINGS \