Minor improvement to early boot code
v2 cover Minor improvement to early boot code
Wei Liu (2):
x86: make sure module array is large enough in pvh-boot.c
xen: initialise opt_xen_console early in PVH boot path
xen/arch/x86/guest/pvh-boot.c | 12 +++++++++++- xen/arch/x86/setup.c | 5 +++++ xen/drivers/char/console.c | 10 ++++++++-- xen/include/xen/console.h | 2 ++ 4 files changed, 26 insertions(+), 3 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/2 x86: make sure module array is large enough in pvh-boot.c
The relocation code in __start_xen requires one extra element in the module array. By the looks of it the temporary array is already large enough. Panic if that's not the case.
While at it, turn an ASSERT to panic() as well.
--- xen/arch/x86/guest/pvh-boot.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
xen/arch/x86/guest/pvh-boot.c +11 -1
@@ -42,7 +42,17 @@ static void __init convert_pvh_info(void)module_t *mod;unsigned int i; -ASSERT (pvh_info->magic ==XEN_HVM_START_MAGIC_VALUE ); +if ( pvh_info->magic !=XEN_HVM_START_MAGIC_VALUE ) +panic ("Magic value is wrong: %X\n" , pvh_info->magic); + +/* +* Temporary module array needs to be at least one element bigger than +* required. The extra element is used to aid relocation. See +* arch/x86/setup.c:__start_xen(). +*/ +if (ARRAY_SIZE (pvh_mbi_mods) <= pvh_info->nr_modules ) +panic ("The module array is too small, size %lu, requested %u.\n" , +ARRAY_SIZE (pvh_mbi_mods), pvh_info->nr_modules);/* * Turn hvm_start_info into mbi. Luckily all modules are placed under 4GB
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/2] x86: make sure module array is large enough in pvh-boot.c
xen/arch/x86/guest/pvh-boot.c static void __init convert_pvh_info(void) · line 46
Quoted 11 lines · Wei Liu
xen/arch/x86/guest/pvh-boot.c +2
-1@@ -42,7 +42,17 @@ static void __init convert_pvh_info(void)module_t *mod;unsigned int i; -ASSERT (pvh_info->magic ==XEN_HVM_START_MAGIC_VALUE ); +if ( pvh_info->magic !=XEN_HVM_START_MAGIC_VALUE ) +panic ("Magic value is wrong: %X\n" , pvh_info->magic);
%x ?
xen/arch/x86/guest/pvh-boot.c static void __init convert_pvh_info(void) · line 54
Quoted 8 lines
xen/arch/x86/guest/pvh-boot.c +8
-0+ +/* +* Temporary module array needs to be at least one element bigger than +* required. The extra element is used to aid relocation. See +* arch/x86/setup.c:__start_xen(). +*/ +if (ARRAY_SIZE (pvh_mbi_mods) <= pvh_info->nr_modules ) + panic("The module array is too small, size %lu, requested %u.\n",
%zu for size_t, and please drop the unnecessary trailing .
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
xen/arch/x86/guest/pvh-boot.c static void __init convert_pvh_info(void) · line 58
Quoted 4 lines
xen/arch/x86/guest/pvh-boot.c +1
-0+ ARRAY_SIZE(pvh_mbi_mods), pvh_info->nr_modules);/* * Turn hvm_start_info into mbi. Luckily all modules are placed under 4GB
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/2 xen: initialise opt_xen_console early in PVH boot path
In reply to Wei LiuThis helps capture issues before console is initialised.
--- xen/arch/x86/setup.c | 5 +++++ xen/drivers/char/console.c | 10 ++++++++-- xen/include/xen/console.h | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-)
xen/arch/x86/setup.c +5 -0
@@ -708,6 +708,11 @@ void __init noreturn __start_xen(unsigned long mbi_p)if ( pvh_boot ) { +/* +* Force xen console to be enabled. We will reset it later in console +* initialisation code. +*/ + opt_console_xen =-1 ;ASSERT (mbi_p ==0 ); mbi =pvh_init (); }
xen/drivers/char/console.c +8 -2
@@ -91,7 +91,8 @@ static uint32_t conringc, conringp;static int __read_mostly sercon_handle =-1 ;#ifdef CONFIG_X86 -static bool __read_mostly opt_console_xen;/* console=xen */ +/* Tristate: 0 disabled, 1 user enabled, -1 default enabled */ +int8_t __read_mostly opt_console_xen;/* console=xen */ #endif static DEFINE_SPINLOCK (console_lock);
@@ -832,7 +833,7 @@ void __init console_init_preirq(void)pv_console_init ();#ifdef CONFIG_X86 else if ( !strncmp(p, "xen", 3) ) - opt_console_xen = true; + opt_console_xen =1 ;#endif else if ( !strncmp(p, "none", 4) )continue ;
@@ -852,6 +853,11 @@ void __init console_init_preirq(void) } } +#ifdef CONFIG_X86 +if ( opt_console_xen ==-1 ) + opt_console_xen =0 ; +#endif +serial_set_rx_handler (sercon_handle, serial_rx);pv_console_set_rx_handler (serial_rx);
xen/include/xen/console.h +2 -0
@@ -43,4 +43,6 @@ void console_giveback(int id);int console_suspend (void );int console_resume (void ); +extern int8_t opt_console_xen; +#endif /* __CONSOLE_H__ */
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 2/2] xen: initialise opt_xen_console early in PVH boot path
Quoted 3 lines · Wei Liu
This helps capture issues before console is initialised.
Signed-off-by Wei Liu <[email protected]>
Much nicer behaviour.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel