aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@hp.com>2008-09-17 11:51:12 -0600
committerAvi Kivity <avi@redhat.com>2008-09-23 12:14:00 +0300
commit243bec98f7660826306e34f0c8633c215af2e211 (patch)
treeb4964193c5243ad9ec545aa1a989ee7b6788e3b8 /kvm/bios/rombios32.c
parentDo not allow AIO to be inited multiple times (diff)
downloadqemu-kvm-243bec98f7660826306e34f0c8633c215af2e211.tar.gz
qemu-kvm-243bec98f7660826306e34f0c8633c215af2e211.tar.bz2
qemu-kvm-243bec98f7660826306e34f0c8633c215af2e211.zip
kvm: bios: extend MTRRs to above 4G
When I try to boot guests using a recent Linux kernel (2.6.26+), memory above 3.5G gets thrown away with an error like this: WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 4608MB of RAM. This extends MTRRs to cover all of memory. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'kvm/bios/rombios32.c')
-rwxr-xr-xkvm/bios/rombios32.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/kvm/bios/rombios32.c b/kvm/bios/rombios32.c
index 2dc1d2569..c57e96785 100755
--- a/kvm/bios/rombios32.c
+++ b/kvm/bios/rombios32.c
@@ -416,6 +416,7 @@ uint32_t cpuid_signature;
uint32_t cpuid_features;
uint32_t cpuid_ext_features;
unsigned long ram_size;
+uint64_t above4g_ram_size;
uint8_t bios_uuid[16];
#ifdef BX_USE_EBDA_TABLES
unsigned long ebda_cur_addr;
@@ -530,6 +531,14 @@ void setup_mtrr(void)
wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800);
vbase += vmask + 1;
}
+ for (vbase = 1ull << 32; i < vcnt && vbase < above4g_ram_size; ++i) {
+ vmask = (1ull << 40) - 1;
+ while (vbase + vmask + 1 > above4g_ram_size)
+ vmask >>= 1;
+ wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6);
+ wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800);
+ vbase += vmask + 1;
+ }
wrmsr_smp(MSR_MTRRdefType, 0xc00);
}
@@ -540,10 +549,19 @@ void ram_probe(void)
16 * 1024 * 1024;
else
ram_size = (cmos_readb(0x17) | (cmos_readb(0x18) << 8)) * 1024;
+
+ if (cmos_readb(0x5b) | cmos_readb(0x5c) | cmos_readb(0x5d))
+ above4g_ram_size = ((uint64_t)cmos_readb(0x5b) << 16) |
+ ((uint64_t)cmos_readb(0x5c) << 24) | ((uint64_t)cmos_readb(0x5d) << 32);
+
+ if (above4g_ram_size)
+ above4g_ram_size += 1ull << 32;
+
#ifdef BX_USE_EBDA_TABLES
ebda_cur_addr = ((*(uint16_t *)(0x40e)) << 4) + 0x380;
#endif
BX_INFO("ram_size=0x%08lx\n", ram_size);
+ BX_INFO("top of ram %ldMB\n", above4g_ram_size >> 20);
setup_mtrr();
}