]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
x86/setup: Avoid OoB E820 lookup when calculating the L1TF safe address
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 14 Sep 2018 11:04:07 +0000 (13:04 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 14 Sep 2018 11:04:07 +0000 (13:04 +0200)
A number of corner cases (most obviously, no-real-mode and no Multiboot memory
map) can end up with e820_raw.nr_map being 0, at which point the L1TF
calculation will underflow.

Spotted by Coverity.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
master commit: 3e4ec07e14bce81f6ae22c31ff1302d1f297a226
master date: 2018-08-16 18:10:07 +0100

xen/arch/x86/setup.c

index 3cd3e81b30da3796c9d074dceef451789003fd86..2860c425efc2e69079ea374eaa2dfc2a467d3a62 100644 (file)
@@ -912,7 +912,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     /* Sanitise the raw E820 map to produce a final clean version. */
     max_page = raw_max_page = init_e820(memmap_type, &e820_raw);
 
-    if ( !efi_enabled(EFI_BOOT) )
+    if ( !efi_enabled(EFI_BOOT) && e820_raw.nr_map >= 1 )
     {
         /*
          * Supplement the heuristics in l1tf_calculations() by assuming that