1 cleanup/consolidate above 4G memory parsing (Alex Williamson)
3 Signed-off-by: Alex Williamson <alex.williamson@hp.com>
4 Signed-off-by: Avi Kivity <avi@redhat.com>
5 Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
7 Index: bochs/bios/rombios32.c
8 ===================================================================
9 --- bochs.orig/bios/rombios32.c
10 +++ bochs/bios/rombios32.c
11 @@ -427,7 +427,7 @@ uint32_t cpuid_signature;
12 uint32_t cpuid_features;
13 uint32_t cpuid_ext_features;
14 unsigned long ram_size;
15 -uint64_t above4g_ram_size;
17 uint8_t bios_uuid[16];
18 #ifdef BX_USE_EBDA_TABLES
19 unsigned long ebda_cur_addr;
20 @@ -562,9 +562,9 @@ void setup_mtrr(void)
21 wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800);
24 - for (vbase = 1ull << 32; i < vcnt && vbase < above4g_ram_size; ++i) {
25 + for (vbase = 1ull << 32; i < vcnt && vbase < ram_end; ++i) {
26 vmask = (1ull << 40) - 1;
27 - while (vbase + vmask + 1 > above4g_ram_size)
28 + while (vbase + vmask + 1 > ram_end)
30 wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6);
31 wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800);
32 @@ -582,18 +582,19 @@ void ram_probe(void)
33 ram_size = (cmos_readb(0x30) | (cmos_readb(0x31) << 8)) * 1024 +
35 if (cmos_readb(0x5b) | cmos_readb(0x5c) | cmos_readb(0x5d))
36 - above4g_ram_size = ((uint64_t)cmos_readb(0x5b) << 16) |
37 - ((uint64_t)cmos_readb(0x5c) << 24) | ((uint64_t)cmos_readb(0x5d) << 32);
38 + ram_end = (((uint64_t)cmos_readb(0x5b) << 16) |
39 + ((uint64_t)cmos_readb(0x5c) << 24) |
40 + ((uint64_t)cmos_readb(0x5d) << 32)) + (1ull << 32);
44 - if (above4g_ram_size)
45 - above4g_ram_size += 1ull << 32;
46 + BX_INFO("end of ram=%ldMB\n", ram_end >> 20);
48 BX_INFO("ram_size=0x%08lx\n", ram_size);
49 #ifdef BX_USE_EBDA_TABLES
50 ebda_cur_addr = ((*(uint16_t *)(0x40e)) << 4) + 0x380;
51 BX_INFO("ebda_cur_addr: 0x%08lx\n", ebda_cur_addr);
53 - BX_INFO("top of ram %ldMB\n", above4g_ram_size >> 20);