Re: [PATCH] pstore: Add boot loader log messages support
On Fri, 15 Feb 2019 12:01:30 +0800 Yue Hu wrote: > On Tue, 12 Feb 2019 12:43:36 -0800 > Kees Cook wrote: > > > On Fri, Feb 1, 2019 at 12:30 AM Yue Hu wrote: > > > > > > From bac8bbcd6081b967422dc82074a41098a0cf5180 Mon Sep 17 00:00:00 2001 > > > From: Yue Hu > > > Date: Tue, 29 Jan 2019 11:42:27 +0800 > > > Subject: [PATCH] pstore: Add boot loader log messages support > > > > > > Sometimes we hope to check boot loader log messages (e.g. Android > > > Verified Boot status) when kernel is coming up. Generally it does > > > depend on serial device, but it will be removed for the hardware > > > shipping to market by most of manufacturers. In that case better > > > solder and proper serial cable for different interface (e.g. Type-C > > > or microUSB) are needed. That is inconvenient and even wasting much > > > time on it. > > > > > > Therefore, let's add a logging support: PSTORE_TYPE_XBL. > > > > > > Signed-off-by: Yue Hu > > > --- > > > fs/pstore/Kconfig | 10 > > > fs/pstore/platform.c | 16 + > > > fs/pstore/ram.c| 64 > > > -- > > > include/linux/pstore.h | 21 + > > > 4 files changed, 104 insertions(+), 7 deletions(-) > > > > > > diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig > > > index 0d19d19..ef4a2dc 100644 > > > --- a/fs/pstore/Kconfig > > > +++ b/fs/pstore/Kconfig > > > @@ -137,6 +137,16 @@ config PSTORE_FTRACE > > > > > > If unsure, say N. > > > > > > +config PSTORE_XBL > > > + bool "Log bootloader messages" > > > + depends on PSTORE > > > + help > > > + When the option is enabled, pstore will log boot loader > > > + messages to /sys/fs/pstore/xbl-ramoops-[ID] after reboot. > > > + Boot loader needs to support log buffer reserved. > > > + > > > + If unsure, say N. > > > + > > > config PSTORE_RAM > > > tristate "Log panic/oops to a RAM buffer" > > > depends on PSTORE > > > diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c > > > index 0ca7657..7486e48 100644 > > > --- a/fs/pstore/platform.c > > > +++ b/fs/pstore/platform.c > > > @@ -66,6 +66,7 @@ > > > "mce", > > > "console", > > > "ftrace", > > > + "xbl", > > > "rtas", > > > "powerpc-ofw", > > > "powerpc-common", > > > @@ -532,6 +533,19 @@ static void pstore_register_console(void) {} > > > static void pstore_unregister_console(void) {} > > > #endif > > > > > > +#ifdef CONFIG_PSTORE_XBL > > > +static void pstore_register_xbl(void) > > > +{ > > > + struct pstore_record record; > > > + > > > + pstore_record_init(, psinfo); > > > + record.type = PSTORE_TYPE_XBL; > > > + psinfo->write(); > > > +} > > > > This writes a zero-length record at registration time. Why? > > It's related to interact with boot loader. Write callback will get the > real record size which is set by boot loader. > > > > > > +#else > > > +static void pstore_register_xbl(void) {} > > > +#endif > > > + > > > static int pstore_write_user_compat(struct pstore_record *record, > > > const char __user *buf) > > > { > > > @@ -618,6 +632,8 @@ int pstore_register(struct pstore_info *psi) > > > pstore_register_ftrace(); > > > if (psi->flags & PSTORE_FLAGS_PMSG) > > > pstore_register_pmsg(); > > > + if (psi->flags & PSTORE_FLAGS_XBL) > > > + pstore_register_xbl(); > > > > > > /* Start watching for new records, if desired. */ > > > if (pstore_update_ms >= 0) { > > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > > > index ca01778..0bb086b 100644 > > > --- a/fs/pstore/ram.c > > > +++ b/fs/pstore/ram.c > > > @@ -56,6 +56,10 @@ > > > module_param_named(pmsg_size, ramoops_pmsg_size, ulong, 0400); > > > MODULE_PARM_DESC(pmsg_size, "size of user space message log"); > > > > >
Re: [PATCH] pstore: Add boot loader log messages support
On Thu, Feb 14, 2019 at 8:01 PM Yue Hu wrote: > Yes, boot loader will did the _write_. When booting from power on, the first > phase > is boot loader, it will log to specific reserver memory. Then kernel/pstore is > coming up, pstore will copy the log generated by boot loader to xbl zone. The > xbl > memory zone layout like below: > > +-+- > |dest | > |-| xbl zone > |src | > +-+- > > Anyway, i think it is a useful debug feature. Ah-ha, interesting. Okay, please mention this (and how the boot loader knows to write in the area) in v2. Thanks! -- Kees Cook
Re: [PATCH] pstore: Add boot loader log messages support
On Fri, Feb 1, 2019 at 12:30 AM Yue Hu wrote: > > From bac8bbcd6081b967422dc82074a41098a0cf5180 Mon Sep 17 00:00:00 2001 > From: Yue Hu > Date: Tue, 29 Jan 2019 11:42:27 +0800 > Subject: [PATCH] pstore: Add boot loader log messages support > > Sometimes we hope to check boot loader log messages (e.g. Android > Verified Boot status) when kernel is coming up. Generally it does > depend on serial device, but it will be removed for the hardware > shipping to market by most of manufacturers. In that case better > solder and proper serial cable for different interface (e.g. Type-C > or microUSB) are needed. That is inconvenient and even wasting much > time on it. > > Therefore, let's add a logging support: PSTORE_TYPE_XBL. > > Signed-off-by: Yue Hu > --- > fs/pstore/Kconfig | 10 > fs/pstore/platform.c | 16 + > fs/pstore/ram.c| 64 > -- > include/linux/pstore.h | 21 + > 4 files changed, 104 insertions(+), 7 deletions(-) > > diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig > index 0d19d19..ef4a2dc 100644 > --- a/fs/pstore/Kconfig > +++ b/fs/pstore/Kconfig > @@ -137,6 +137,16 @@ config PSTORE_FTRACE > > If unsure, say N. > > +config PSTORE_XBL > + bool "Log bootloader messages" > + depends on PSTORE > + help > + When the option is enabled, pstore will log boot loader > + messages to /sys/fs/pstore/xbl-ramoops-[ID] after reboot. > + Boot loader needs to support log buffer reserved. > + > + If unsure, say N. > + > config PSTORE_RAM > tristate "Log panic/oops to a RAM buffer" > depends on PSTORE > diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c > index 0ca7657..7486e48 100644 > --- a/fs/pstore/platform.c > +++ b/fs/pstore/platform.c > @@ -66,6 +66,7 @@ > "mce", > "console", > "ftrace", > + "xbl", > "rtas", > "powerpc-ofw", > "powerpc-common", > @@ -532,6 +533,19 @@ static void pstore_register_console(void) {} > static void pstore_unregister_console(void) {} > #endif > > +#ifdef CONFIG_PSTORE_XBL > +static void pstore_register_xbl(void) > +{ > + struct pstore_record record; > + > + pstore_record_init(, psinfo); > + record.type = PSTORE_TYPE_XBL; > + psinfo->write(); > +} This writes a zero-length record at registration time. Why? > +#else > +static void pstore_register_xbl(void) {} > +#endif > + > static int pstore_write_user_compat(struct pstore_record *record, > const char __user *buf) > { > @@ -618,6 +632,8 @@ int pstore_register(struct pstore_info *psi) > pstore_register_ftrace(); > if (psi->flags & PSTORE_FLAGS_PMSG) > pstore_register_pmsg(); > + if (psi->flags & PSTORE_FLAGS_XBL) > + pstore_register_xbl(); > > /* Start watching for new records, if desired. */ > if (pstore_update_ms >= 0) { > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index ca01778..0bb086b 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -56,6 +56,10 @@ > module_param_named(pmsg_size, ramoops_pmsg_size, ulong, 0400); > MODULE_PARM_DESC(pmsg_size, "size of user space message log"); > > +static ulong ramoops_xbl_size = MIN_MEM_SIZE; > +module_param_named(xbl_size, ramoops_xbl_size, ulong, 0400); > +MODULE_PARM_DESC(xbl_size, "size of boot loader log"); > + > static unsigned long long mem_address; > module_param_hw(mem_address, ullong, other, 0400); > MODULE_PARM_DESC(mem_address, > @@ -88,6 +92,7 @@ struct ramoops_context { > struct persistent_ram_zone *cprz; /* Console zone */ > struct persistent_ram_zone **fprzs; /* Ftrace zones */ > struct persistent_ram_zone *mprz; /* PMSG zone */ > + struct persistent_ram_zone *bprz; /* XBL zone */ > phys_addr_t phys_addr; > unsigned long size; > unsigned int memtype; > @@ -95,6 +100,7 @@ struct ramoops_context { > size_t console_size; > size_t ftrace_size; > size_t pmsg_size; > + size_t xbl_size; > int dump_oops; > u32 flags; > struct persistent_ram_ecc_info ecc_info; > @@ -106,6 +112,7 @@ struct ramoops_context { > unsigned int max_ftrace_cnt; > unsigned int ftrace_read_cnt; > unsigned int pmsg_read_cnt; > + unsigned int xbl_read_cnt; >