aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-03-28 16:53:26 -0400
committerH. Peter Anvin <hpa@zytor.com>2009-03-28 21:20:07 -0400
commitc549e71d073a6e9a4847497344db28a784061455 (patch)
tree60c41d640ecf696d0534f744fafe8bf2023c4254 /arch
parent32ec7fd08b597586774b92ac1cd2678021ccac1b (diff)
x86, setup: ACPI 3, BIOS workaround for E820-probing code
Impact: ACPI 3 spec compliance, BIOS bug workaround The ACPI 3 spec added another field to the E820 buffer -- which is backwards incompatible, since it contains a validity bit. Furthermore, there has been at least one report of a BIOS which assumes that the buffer it is pointed at is the same buffer as for the previous E820 call. Therefore, read the data into a temporary buffer and copy the standard part of it if and only if the valid bit is set. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/boot/memory.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
index fcdb10add9c8..d5d2360763dc 100644
--- a/arch/x86/boot/memory.c
+++ b/arch/x86/boot/memory.c
@@ -2,6 +2,7 @@
2 * 2 *
3 * Copyright (C) 1991, 1992 Linus Torvalds 3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved 4 * Copyright 2007 rPath, Inc. - All Rights Reserved
5 * Copyright 2009 Intel Corporation; author H. Peter Anvin
5 * 6 *
6 * This file is part of the Linux kernel, and is made available under 7 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2. 8 * the terms of the GNU General Public License version 2.
@@ -16,6 +17,11 @@
16 17
17#define SMAP 0x534d4150 /* ASCII "SMAP" */ 18#define SMAP 0x534d4150 /* ASCII "SMAP" */
18 19
20struct e820_ext_entry {
21 struct e820entry std;
22 u32 ext_flags;
23} __attribute__((packed));
24
19static int detect_memory_e820(void) 25static int detect_memory_e820(void)
20{ 26{
21 int count = 0; 27 int count = 0;
@@ -23,9 +29,10 @@ static int detect_memory_e820(void)
23 u32 size, id, edi; 29 u32 size, id, edi;
24 u8 err; 30 u8 err;
25 struct e820entry *desc = boot_params.e820_map; 31 struct e820entry *desc = boot_params.e820_map;
32 static struct e820_ext_entry buf; /* static so it is zeroed */
26 33
27 do { 34 do {
28 size = sizeof(struct e820entry); 35 size = sizeof buf;
29 36
30 /* Important: %edx and %esi are clobbered by some BIOSes, 37 /* Important: %edx and %esi are clobbered by some BIOSes,
31 so they must be either used for the error output 38 so they must be either used for the error output
@@ -33,8 +40,8 @@ static int detect_memory_e820(void)
33 is something out there clobbering %ebp and %edi, too. */ 40 is something out there clobbering %ebp and %edi, too. */
34 asm("pushl %%ebp; int $0x15; popl %%ebp; setc %0" 41 asm("pushl %%ebp; int $0x15; popl %%ebp; setc %0"
35 : "=d" (err), "+b" (next), "=a" (id), "+c" (size), 42 : "=d" (err), "+b" (next), "=a" (id), "+c" (size),
36 "=D" (edi), "=m" (*desc) 43 "=D" (edi), "+m" (buf)
37 : "D" (desc), "d" (SMAP), "a" (0xe820) 44 : "D" (&buf), "d" (SMAP), "a" (0xe820)
38 : "esi"); 45 : "esi");
39 46
40 /* BIOSes which terminate the chain with CF = 1 as opposed 47 /* BIOSes which terminate the chain with CF = 1 as opposed
@@ -53,8 +60,14 @@ static int detect_memory_e820(void)
53 break; 60 break;
54 } 61 }
55 62
63 /* ACPI 3.0 added the extended flags support. If bit 0
64 in the extended flags is zero, we're supposed to simply
65 ignore the entry -- a backwards incompatible change! */
66 if (size > 20 && !(buf.ext_flags & 1))
67 continue;
68
69 *desc++ = buf.std;
56 count++; 70 count++;
57 desc++;
58 } while (next && count < ARRAY_SIZE(boot_params.e820_map)); 71 } while (next && count < ARRAY_SIZE(boot_params.e820_map));
59 72
60 return boot_params.e820_entries = count; 73 return boot_params.e820_entries = count;