x86: assert MBI is large enough in pvh-boot.c
PATCH 1/1 x86: assert MBI is large enough in pvh-boot.c
The relocation code in __start_xen requires one extra element in the MBI structure. By the looks of it the temporary MBI array is already large enough. Add an assertion to catch any issue in the future.
--- xen/arch/x86/guest/pvh-boot.c | 7 +++++++ 1 file changed, 7 insertions(+)
xen/arch/x86/guest/pvh-boot.c +7 -0
@@ -44,6 +44,13 @@ static void __init convert_pvh_info(void)ASSERT (pvh_info->magic ==XEN_HVM_START_MAGIC_VALUE ); +/* +* Temporary MBI 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(). +*/ +ASSERT (ARRAY_SIZE (pvh_mbi_mods) > pvh_info->nr_modules); +/* * Turn hvm_start_info into mbi. Luckily all modules are placed under 4GB * boundary on x86.
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 5 lines · Wei Liu
The relocation code in
__start_xenrequires one extra element in the MBI structure. By the looks of it the temporary MBI array is already large enough. Add an assertion to catch any issue in the future.Signed-off-by Wei Liu <[email protected]>
While this is all well and good, the ASSERT() never actually gets out onto the console. This is because, when a failure occurs, the console hasn't been configured yet.
For development purposes I use:
xen/drivers/char/console.c +0 -0
@@ -91,7 +91,7 @@ static uint32_t conringc, conringp;
static int __read_mostly sercon_handle = -1;
#ifdef CONFIG_X86
-static bool __read_mostly opt_console_xen; /* console=xen */ +static bool __read_mostly opt_console_xen = true; /* console=xen */ #endif
static DEFINE_SPINLOCK(console_lock);
which gets the details out into the L0 log.
As an addendum, might it be worth having opt_console_xen be tristate, and enabled by the start of the PVH path, so log messages before the command line is parsed end up being emitted?
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 27 lines · Andrew Cooper
Quoted 5 lines · Wei Liu
The relocation code in
__start_xenrequires one extra element in the MBI structure. By the looks of it the temporary MBI array is already large enough. Add an assertion to catch any issue in the future.Signed-off-by Wei Liu <[email protected]>While this is all well and good, the
ASSERT()never actually gets out onto the console. This is because, when a failure occurs, the console hasn't been configured yet.For development purposes I use:
xen/drivers/char/console.c +0
-0@@ -91,7 +91,7 @@ static uint32_t conringc, conringp; static int __read_mostly sercon_handle = -1;
#ifdefCONFIG_X86xen/drivers/char/console.c +1
-1-static bool __read_mostly opt_console_xen;/* console=xen */ +static bool __read_mostly opt_console_xen = true;/* console=xen */ #endif
staticDEFINE_SPINLOCK(console_lock);
Quoted 5 lines
which gets the details out into the L0 log.
As an addendum, might it be worth having
opt_console_xenbe tristate, and enabled by the start of the PVH path, so log messages before the command line is parsed end up being emitted?
This is fine by me.
Wei.
Quoted 2 lines
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
xen/arch/x86/guest/pvh-boot.c static void __init convert_pvh_info(void) · line 52
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:00, <[email protected]> wrote:
xen/arch/x86/guest/pvh-boot.c +6
-0@@ -44,6 +44,13 @@ static void __init convert_pvh_info(void)ASSERT (pvh_info->magic ==XEN_HVM_START_MAGIC_VALUE ); +/* +* Temporary MBI 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(). +*/ +ASSERT (ARRAY_SIZE (pvh_mbi_mods) > pvh_info->nr_modules);
Are ASSERT()s (also the other one in context) actually the right thing here? I think we'd better panic(): That'll also cover release builds and is imo more appropriate for data coming from the outside.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:00, <[email protected]> wrote:
xen/arch/x86/guest/pvh-boot.c +0
-0@@ -44,6 +44,13 @@ static void __init convert_pvh_info(void)ASSERT (pvh_info->magic ==XEN_HVM_START_MAGIC_VALUE );
Quoted 10 lines
xen/arch/x86/guest/pvh-boot.c static void __init convert_pvh_info(void) · line 52
Quoted 6 lines
xen/arch/x86/guest/pvh-boot.c +6
-0+/* +* Temporary MBI 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(). +*/ +ASSERT (ARRAY_SIZE (pvh_mbi_mods) > pvh_info->nr_modules);Are ASSERT()s (also the other one in context) actually the right thing here? I think we'd better
panic(): That'll also cover release builds and is imo more appropriate for data coming from the outside.
Okay.
Wei.
Quoted 4 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel