[x86 setup] Handle case of improperly terminated E820 chain

At least one system (a Geode system with a Digital Logic BIOS) has
been found which suddenly stops reporting the SMAP signature when
reading the E820 memory chain. We can't know what, exactly, broke in
the BIOS, so if we detect this situation, declare the E820 data
unusable and fall back to E801.

Also, revert to original behavior of always probing all memory
methods; that way all the memory information is available to the
kernel.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jordan Crouse <jordan.crouse@amd.com>
Cc: Joerg Pommnitz <pommnitz@yahoo.com>

+23 -7
+23 -7
arch/i386/boot/memory.c
··· 20 21 static int detect_memory_e820(void) 22 { 23 u32 next = 0; 24 u32 size, id; 25 u8 err; ··· 34 "=m" (*desc) 35 : "D" (desc), "a" (0xe820)); 36 37 - if (err || id != SMAP) 38 break; 39 40 - boot_params.e820_entries++; 41 desc++; 42 - } while (next && boot_params.e820_entries < E820MAX); 43 44 - return boot_params.e820_entries; 45 } 46 47 static int detect_memory_e801(void) ··· 100 101 int detect_memory(void) 102 { 103 if (detect_memory_e820() > 0) 104 - return 0; 105 106 if (!detect_memory_e801()) 107 - return 0; 108 109 - return detect_memory_88(); 110 }
··· 20 21 static int detect_memory_e820(void) 22 { 23 + int count = 0; 24 u32 next = 0; 25 u32 size, id; 26 u8 err; ··· 33 "=m" (*desc) 34 : "D" (desc), "a" (0xe820)); 35 36 + /* Some BIOSes stop returning SMAP in the middle of 37 + the search loop. We don't know exactly how the BIOS 38 + screwed up the map at that point, we might have a 39 + partial map, the full map, or complete garbage, so 40 + just return failure. */ 41 + if (id != SMAP) { 42 + count = 0; 43 + break; 44 + } 45 + 46 + if (err) 47 break; 48 49 + count++; 50 desc++; 51 + } while (next && count < E820MAX); 52 53 + return boot_params.e820_entries = count; 54 } 55 56 static int detect_memory_e801(void) ··· 89 90 int detect_memory(void) 91 { 92 + int err = -1; 93 + 94 if (detect_memory_e820() > 0) 95 + err = 0; 96 97 if (!detect_memory_e801()) 98 + err = 0; 99 100 + if (!detect_memory_88()) 101 + err = 0; 102 + 103 + return err; 104 }