diff mbox series

[U-Boot,v9,10/18] sandbox: Try to start the RAM buffer at a particular address

Message ID 20180808095433.230882-11-sjg@chromium.org
State Superseded, archived
Delegated to: Alexander Graf
Headers show
Series efi: Enable sandbox support for EFI loader | expand

Commit Message

Simon Glass Aug. 8, 2018, 9:54 a.m. UTC
Use a starting address of 256MB which should be available. This helps to
make sandbox RAM buffers pointers more recognisable.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Alexander Graf Aug. 26, 2018, 5:01 p.m. UTC | #1
On 08.08.18 11:54, Simon Glass wrote:
> Use a starting address of 256MB which should be available. This helps to
> make sandbox RAM buffers pointers more recognisable.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Is this really necessary still?


Alex

> ---
> 
> Changes in v9: None
> Changes in v8: None
> Changes in v7: None
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  arch/sandbox/cpu/os.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
> index a1a982af2de..1553aa687df 100644
> --- a/arch/sandbox/cpu/os.c
> +++ b/arch/sandbox/cpu/os.c
> @@ -145,7 +145,12 @@ void *os_malloc(size_t length)
>  	struct os_mem_hdr *hdr;
>  	int page_size = getpagesize();
>  
> -	hdr = mmap(NULL, length + page_size,
> +	/*
> +	 * Use an address that is hopefully available to us so that pointers
> +	 * to this memory are fairly obvious. If we end up with a different
> +	 * address, that's fine too.
> +	 */
> +	hdr = mmap((void *)0x10000000, length + page_size,
>  		   PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>  	if (hdr == MAP_FAILED)
>  		return NULL;
>
Simon Glass Sept. 14, 2018, 3:46 p.m. UTC | #2
Hi Alex,

On 26 August 2018 at 19:01, Alexander Graf <agraf@suse.de> wrote:
>
>
> On 08.08.18 11:54, Simon Glass wrote:
>> Use a starting address of 256MB which should be available. This helps to
>> make sandbox RAM buffers pointers more recognisable.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Is this really necessary still?

It was never necessary, but it seems like a useful thing to do. It
makes all the pointers smaller (the first 32 bits are 0 which makes
them easier to read).

Regards,
Simon
Simon Glass Oct. 15, 2018, 8:07 p.m. UTC | #3
On 14 September 2018 at 09:46, Simon Glass <sjg@chromium.org> wrote:
> Hi Alex,
>
> On 26 August 2018 at 19:01, Alexander Graf <agraf@suse.de> wrote:
>>
>>
>> On 08.08.18 11:54, Simon Glass wrote:
>>> Use a starting address of 256MB which should be available. This helps to
>>> make sandbox RAM buffers pointers more recognisable.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>
>> Is this really necessary still?
>
> It was never necessary, but it seems like a useful thing to do. It
> makes all the pointers smaller (the first 32 bits are 0 which makes
> them easier to read).

Applied to u-boot-dm.
diff mbox series

Patch

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index a1a982af2de..1553aa687df 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -145,7 +145,12 @@  void *os_malloc(size_t length)
 	struct os_mem_hdr *hdr;
 	int page_size = getpagesize();
 
-	hdr = mmap(NULL, length + page_size,
+	/*
+	 * Use an address that is hopefully available to us so that pointers
+	 * to this memory are fairly obvious. If we end up with a different
+	 * address, that's fine too.
+	 */
+	hdr = mmap((void *)0x10000000, length + page_size,
 		   PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 	if (hdr == MAP_FAILED)
 		return NULL;