x86/setup: Avoid OoB E820 lookup when calculating the L1TF safe address
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Aug 2018 15:26:22 +0000 (16:26 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Aug 2018 17:10:07 +0000 (18:10 +0100)
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>
xen/arch/x86/setup.c

index 727dad4dc3613c3c50587790a4eaad29db81b483..8d0f6f14e3e91c292a48c6c5f3a855641df4e104 100644 (file)
@@ -913,7 +913,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