linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, Jaxson.Han@arm.com,
	robin.murphy@arm.com, vladimir.murzin@arm.com, Wei.Chen@arm.com
Subject: Re: [bootwrapper PATCH v2 11/13] Announce locations of memory objects
Date: Mon, 17 Jan 2022 14:59:00 +0000	[thread overview]
Message-ID: <20220117145901.483ec044@donnerap.cambridge.arm.com> (raw)
In-Reply-To: <20220114105653.3003399-12-mark.rutland@arm.com>

On Fri, 14 Jan 2022 10:56:51 +0000
Mark Rutland <mark.rutland@arm.com> wrote:

Hi Mark,

> To make it easier to debug boot failures, log the location of memory
> objects at boot time.
> 
> This is logged to the serial console as:
> 
> | Boot-wrapper v0.2
> | Entered at EL3
> | Memory layout:
> | [0000000080000000..0000000080001f90] => boot-wrapper
> | [000000008000fff8..0000000080010000] => mbox
> | [0000000080200000..00000000822af200] => kernel
> | [0000000088000000..0000000088002857] => dtb

That looks indeed very useful!

> Signed-off-by: Mark Rutland <mark.rutland@arm.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> ---
>  common/init.c      | 27 +++++++++++++++++++++++++++
>  common/platform.c  | 13 +++++++++++++
>  include/platform.h |  2 ++
>  model.lds.S        | 20 ++++++++++++++------
>  4 files changed, 56 insertions(+), 6 deletions(-)
> 
> diff --git a/common/init.c b/common/init.c
> index 2600f73..fc74b9e 100644
> --- a/common/init.c
> +++ b/common/init.c
> @@ -14,6 +14,32 @@ static void announce_bootwrapper(void)
>  	print_string("Boot-wrapper v0.2\r\n");
>  }
>  
> +#define announce_object(object, desc)				\
> +do {								\
> +	extern char object##__start[];				\
> +	extern char object##__end[];				\
> +	print_string("[");					\
> +	print_ulong_hex((unsigned long)object##__start);	\
> +	print_string("..");					\
> +	print_ulong_hex((unsigned long)object##__end);		\
> +	print_string("] => " desc "\r\n");			\
> +} while (0)
> +
> +static void announce_objects(void)
> +{
> +	print_string("Memory layout:\r\n");
> +	announce_object(text, "boot-wrapper");
> +	announce_object(mbox, "mbox");
> +	announce_object(kernel, "kernel");
> +#ifdef XEN
> +	announce_object(xen, "xen");
> +#endif
> +	announce_object(dtb, "dtb");
> +#ifdef USE_INITRD
> +	announce_object(filesystem, "initrd");
> +#endif
> +}
> +
>  void announce_arch(void);
>  
>  void cpu_init_bootwrapper(void)
> @@ -22,6 +48,7 @@ void cpu_init_bootwrapper(void)
>  		init_uart();
>  		announce_bootwrapper();
>  		announce_arch();
> +		announce_objects();
>  		print_string("\r\n");
>  		init_platform();
>  	}
> diff --git a/common/platform.c b/common/platform.c
> index 80d0562..26e5944 100644
> --- a/common/platform.c
> +++ b/common/platform.c
> @@ -52,6 +52,19 @@ void print_string(const char *str)
>  		print_char(*str++);
>  }
>  
> +#define HEX_CHARS_PER_LONG (2 * sizeof(long))
> +
> +void print_ulong_hex(unsigned long val)
> +{
> +	const char hex_chars[16] = "0123456789abcdef";
> +	int i;
> +
> +	for (i = HEX_CHARS_PER_LONG - 1; i >= 0; i--) {
> +		int v = (val >> (4 * i)) & 0xf;
> +		print_char(hex_chars[v]);
> +	}
> +}
> +
>  void init_uart(void)
>  {
>  	/*
> diff --git a/include/platform.h b/include/platform.h
> index 237b481..c88e124 100644
> --- a/include/platform.h
> +++ b/include/platform.h
> @@ -11,6 +11,8 @@
>  
>  void print_char(char c);
>  void print_string(const char *str);
> +void print_ulong_hex(unsigned long val);
> +
>  void init_uart(void);
>  
>  void init_platform(void);
> diff --git a/model.lds.S b/model.lds.S
> index d4e7e13..dacaa25 100644
> --- a/model.lds.S
> +++ b/model.lds.S
> @@ -35,46 +35,54 @@ SECTIONS
>  	 * the boot section's *(.data)
>  	 */
>  	.kernel (PHYS_OFFSET + KERNEL_OFFSET): {
> -		kernel = .;
> +		kernel__start = .;
>  		KERNEL
> +		kernel__end = .;
>  	}
>  
>  #ifdef XEN
>  	.xen (PHYS_OFFSET + XEN_OFFSET): {
> -		xen = .;
> +		xen__start = .;
>  		XEN
> +		xen__end = .;
>  	}
>  
> -	entrypoint = xen;
> +	entrypoint = xen__start;
>  #else
> -	entrypoint = kernel;
> +	entrypoint = kernel__start;
>  #endif
>  
>  	.dtb (PHYS_OFFSET + FDT_OFFSET): {
> +		dtb__start = .;
>  		dtb = .;
>  		./fdt.dtb
> +		dtb__end = .;
>  	}
>  
>  #ifdef USE_INITRD
>  	.filesystem (PHYS_OFFSET + FS_OFFSET): {
> -		filesystem = .;
> +		filesystem__start = .;
>  		FILESYSTEM
> -		fs_size = . - filesystem;
> +		filesystem__end = .;
>  	}
>  #endif
>  
>  	.boot PHYS_OFFSET: {
> +		text__start = .;
>  		*(.init)
>  		*(.text*)
>  		*(.data* .rodata* .bss* COMMON)
>  		*(.vectors)
>  		*(.stack)
>  		PROVIDE(etext = .);
> +		text__end = .;
>  	}
>  
>  	.mbox (PHYS_OFFSET + MBOX_OFFSET): {
> +		mbox__start = .;
>  		mbox = .;
>  		QUAD(0x0)
> +		mbox__end = .;
>  	}
>  
>  	ASSERT(etext <= (PHYS_OFFSET + TEXT_LIMIT), ".text overflow!")


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-01-17 15:03 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14 10:56 [bootwrapper PATCH v2 00/13] Cleanups and improvements Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 01/13] Document entry requirements Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 02/13] Add bit-field macros Mark Rutland
2022-01-17 12:11   ` Steven Price
2022-01-17 13:28     ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 03/13] aarch64: add system register accessors Mark Rutland
2022-01-14 15:32   ` Andre Przywara
2022-01-14 10:56 ` [bootwrapper PATCH v2 04/13] aarch32: add coprocessor accessors Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 05/13] aarch64: add mov_64 macro Mark Rutland
2022-01-14 15:50   ` Andre Przywara
2022-01-14 10:56 ` [bootwrapper PATCH v2 06/13] aarch64: initialize SCTLR_ELx for the boot-wrapper Mark Rutland
2022-01-14 18:12   ` Andre Przywara
2022-01-17 12:15     ` Mark Rutland
2022-01-17 13:05       ` Mark Rutland
2022-01-18 12:37         ` Andre Przywara
2022-01-25 13:32           ` Mark Rutland
2022-01-19 12:42       ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 07/13] Rework common init C code Mark Rutland
2022-01-17 16:23   ` Andre Przywara
2022-01-14 10:56 ` [bootwrapper PATCH v2 08/13] Announce boot-wrapper mode / exception level Mark Rutland
2022-01-17 14:39   ` Andre Przywara
2022-01-17 15:50     ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 09/13] aarch64: move the bulk of EL3 initialization to C Mark Rutland
2022-01-17 14:31   ` Andre Przywara
2022-01-17 18:08     ` Mark Rutland
2022-01-17 18:31       ` Andre Przywara
2022-01-18 16:50         ` Mark Brown
2022-01-19 15:22           ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 10/13] aarch32: move the bulk of Secure PL1 " Mark Rutland
2022-01-17 14:52   ` Andre Przywara
2022-01-14 10:56 ` [bootwrapper PATCH v2 11/13] Announce locations of memory objects Mark Rutland
2022-01-14 15:30   ` Andre Przywara
2022-01-14 16:04     ` Robin Murphy
2022-01-14 16:30       ` Mark Rutland
2022-01-14 16:21     ` Mark Rutland
2022-01-17 14:59   ` Andre Przywara [this message]
2022-01-14 10:56 ` [bootwrapper PATCH v2 12/13] Rework bootmethod initialization Mark Rutland
2022-01-17 17:43   ` Andre Przywara
2022-01-25 14:00     ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 13/13] Unify start_el3 & start_no_el3 Mark Rutland
2022-01-17 17:43   ` Andre Przywara
2022-01-14 15:09 ` [bootwrapper PATCH v2 00/13] Cleanups and improvements Andre Przywara
2022-01-14 15:23   ` Mark Rutland

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=20220117145901.483ec044@donnerap.cambridge.arm.com \
    --to=andre.przywara@arm.com \
    --cc=Jaxson.Han@arm.com \
    --cc=Wei.Chen@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=robin.murphy@arm.com \
    --cc=vladimir.murzin@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).