All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org, bochs-developers@lists.sourceforge.net
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Avi Kivity <avi@redhat.com>,
	Alex Williamson <alex.williamson@hp.com>
Subject: [Qemu-devel] [patch 7/9] kvm: bios: switch MTRRs to cover only the PCI range and default to WB
Date: Tue, 20 Jan 2009 00:30:47 -0200	[thread overview]
Message-ID: <20090120023057.943759262@amt.cnet> (raw)
In-Reply-To: 20090120023040.623163208@amt.cnet

[-- Attachment #1: 0008_mtrr_default.patch --]
[-- Type: text/plain, Size: 1814 bytes --]

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 <alex.williamson@hp.com>
Signed-off-by: Avi Kivity <avi@redhat.com>

From: Alex Williamson <alex.williamson@hp.com>

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)

  parent reply	other threads:[~2009-01-20  2:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-20  2:30 [Qemu-devel] [patch 0/9] Bochs BIOS MTRR support + SMBIOS updates Marcelo Tosatti
2009-01-20  2:30 ` [Qemu-devel] [patch 1/9] kvm: bios: update SMBIOS table to report memory above 4G Marcelo Tosatti
2009-01-20  2:30 ` [Qemu-devel] [patch 2/9] kvm: bios: generate mptable unconditionally Marcelo Tosatti
2009-01-20  2:30 ` [Qemu-devel] [patch 3/9] kvm: bios: add mtrr support Marcelo Tosatti
2009-01-20  2:30 ` [Qemu-devel] [patch 4/9] kvm: bios: smp " Marcelo Tosatti
2009-01-20  2:30 ` [Qemu-devel] [patch 5/9] kvm: bios: extend MTRRs to above 4G Marcelo Tosatti
2009-01-20  2:30 ` [Qemu-devel] [patch 6/9] kvm: bios: cleanup/consolidate above 4G memory parsing Marcelo Tosatti
2009-01-20  2:30 ` Marcelo Tosatti [this message]
2009-01-20  2:30 ` [Qemu-devel] [patch 8/9] kvm: bios: resolve memory device roll over reporting issues with >32G guests Marcelo Tosatti
2009-01-20  2:30 ` [Qemu-devel] [patch 9/9] kvm: bios: fix smbios memory device length boundary condition Marcelo Tosatti
2009-01-21 21:47 ` [Qemu-devel] Re: [patch 0/9] Bochs BIOS MTRR support + SMBIOS updates Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090120023057.943759262@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=alex.williamson@hp.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=bochs-developers@lists.sourceforge.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.