From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LP6QZ-00005n-Tc for qemu-devel@nongnu.org; Mon, 19 Jan 2009 21:33:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LP6QZ-00005G-CT for qemu-devel@nongnu.org; Mon, 19 Jan 2009 21:33:19 -0500 Received: from [199.232.76.173] (port=36808 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LP6QZ-000057-4W for qemu-devel@nongnu.org; Mon, 19 Jan 2009 21:33:19 -0500 Received: from mx2.redhat.com ([66.187.237.31]:39327) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LP6QY-0001S6-Lt for qemu-devel@nongnu.org; Mon, 19 Jan 2009 21:33:19 -0500 Message-Id: <20090120023057.943759262@amt.cnet> Date: Tue, 20 Jan 2009 00:30:47 -0200 From: Marcelo Tosatti References: <20090120023040.623163208@amt.cnet> Content-Disposition: inline; filename=0008_mtrr_default.patch Subject: [Qemu-devel] [patch 7/9] kvm: bios: switch MTRRs to cover only the PCI range and default to WB Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, bochs-developers@lists.sourceforge.net Cc: Anthony Liguori , Avi Kivity , Alex Williamson This matches how some bare metal machines report MTRRs and avoids the problem of running out of MTRRs to cover all of RAM. Signed-off-by: Alex Williamson Signed-off-by: Avi Kivity From: Alex Williamson Index: bochs/bios/rombios32.c =================================================================== --- bochs.orig/bios/rombios32.c +++ bochs/bios/rombios32.c @@ -525,7 +525,6 @@ void setup_mtrr(void) uint8_t valb[8]; uint64_t val; } u; - uint64_t vbase, vmask; mtrr_cap = rdmsr(MSR_MTRRcap); vcnt = mtrr_cap & 0xff; @@ -552,25 +551,10 @@ void setup_mtrr(void) wrmsr_smp(MSR_MTRRfix4K_E8000, 0); wrmsr_smp(MSR_MTRRfix4K_F0000, 0); wrmsr_smp(MSR_MTRRfix4K_F8000, 0); - vbase = 0; - --vcnt; /* leave one mtrr for VRAM */ - for (i = 0; i < vcnt && vbase < ram_size; ++i) { - vmask = (1ull << 40) - 1; - while (vbase + vmask + 1 > ram_size) - vmask >>= 1; - wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6); - wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); - vbase += vmask + 1; - } - for (vbase = 1ull << 32; i < vcnt && vbase < ram_end; ++i) { - vmask = (1ull << 40) - 1; - while (vbase + vmask + 1 > ram_end) - 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); + /* Mark 3.5-4GB as UC, anything not specified defaults to WB */ + wrmsr_smp(MTRRphysBase_MSR(0), 0xe0000000ull | 0); + wrmsr_smp(MTRRphysMask_MSR(0), ~(0x20000000ull - 1) | 0x800); + wrmsr_smp(MSR_MTRRdefType, 0xc06); } void ram_probe(void)