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>
Subject: [Qemu-devel] [patch 4/9] kvm: bios: smp mtrr support
Date: Tue, 20 Jan 2009 00:30:44 -0200 [thread overview]
Message-ID: <20090120023057.721733697@amt.cnet> (raw)
In-Reply-To: 20090120023040.623163208@amt.cnet
[-- Attachment #1: 0005_mtrr_smp.patch --]
[-- Type: text/plain, Size: 3414 bytes --]
Signed-off-by: Avi Kivity <avi@qumranet.com>
From: Avi Kivity <avi@qumranet.com>
Index: bochs/bios/rombios.h
===================================================================
--- bochs.orig/bios/rombios.h
+++ bochs/bios/rombios.h
@@ -56,6 +56,7 @@
#define ACPI_DATA_SIZE 0x00010000L
#define PM_IO_BASE 0xb000
#define SMB_IO_BASE 0xb100
+#define SMP_MSR_ADDR 0xf010
// Define the application NAME
#if defined(BX_QEMU)
Index: bochs/bios/rombios32.c
===================================================================
--- bochs.orig/bios/rombios32.c
+++ bochs/bios/rombios32.c
@@ -472,6 +472,23 @@ void qemu_cfg_read(uint8_t *buf, int len
}
#endif
+void init_smp_msrs(void)
+{
+ *(uint32_t *)SMP_MSR_ADDR = 0;
+}
+
+void wrmsr_smp(uint32_t index, uint64_t val)
+{
+ static struct { uint32_t ecx, eax, edx; } *p = (void *)SMP_MSR_ADDR;
+
+ wrmsr(index, val);
+ p->ecx = index;
+ p->eax = val;
+ p->edx = val >> 32;
+ ++p;
+ p->ecx = 0;
+}
+
void uuid_probe(void)
{
#ifdef BX_QEMU
@@ -519,32 +536,32 @@ void setup_mtrr(void)
for (i = 0; i < 8; ++i)
if (ram_size >= 65536 * (i + 1))
u.valb[i] = 6;
- wrmsr(MSR_MTRRfix64K_00000, u.val);
+ wrmsr_smp(MSR_MTRRfix64K_00000, u.val);
u.val = 0;
for (i = 0; i < 8; ++i)
if (ram_size >= 65536 * 8 + 16384 * (i + 1))
u.valb[i] = 6;
- wrmsr(MSR_MTRRfix16K_80000, u.val);
- wrmsr(MSR_MTRRfix16K_A0000, 0);
- wrmsr(MSR_MTRRfix4K_C0000, 0);
- wrmsr(MSR_MTRRfix4K_C8000, 0);
- wrmsr(MSR_MTRRfix4K_D0000, 0);
- wrmsr(MSR_MTRRfix4K_D8000, 0);
- wrmsr(MSR_MTRRfix4K_E0000, 0);
- wrmsr(MSR_MTRRfix4K_E8000, 0);
- wrmsr(MSR_MTRRfix4K_F0000, 0);
- wrmsr(MSR_MTRRfix4K_F8000, 0);
+ wrmsr_smp(MSR_MTRRfix16K_80000, u.val);
+ wrmsr_smp(MSR_MTRRfix16K_A0000, 0);
+ wrmsr_smp(MSR_MTRRfix4K_C0000, 0);
+ wrmsr_smp(MSR_MTRRfix4K_C8000, 0);
+ wrmsr_smp(MSR_MTRRfix4K_D0000, 0);
+ wrmsr_smp(MSR_MTRRfix4K_D8000, 0);
+ wrmsr_smp(MSR_MTRRfix4K_E0000, 0);
+ 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(MTRRphysBase_MSR(i), vbase | 6);
- wrmsr(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800);
+ wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6);
+ wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800);
vbase += vmask + 1;
}
- wrmsr(MSR_MTRRdefType, 0xc00);
+ wrmsr_smp(MSR_MTRRdefType, 0xc00);
}
void ram_probe(void)
@@ -2263,6 +2280,8 @@ void rombios32_init(uint32_t *s3_resume_
qemu_cfg_port = qemu_cfg_port_probe();
#endif
+ init_smp_msrs();
+
ram_probe();
cpu_probe();
Index: bochs/bios/rombios32start.S
===================================================================
--- bochs.orig/bios/rombios32start.S
+++ bochs/bios/rombios32start.S
@@ -49,6 +49,18 @@ _start:
smp_ap_boot_code_start:
xor %ax, %ax
mov %ax, %ds
+
+ mov $SMP_MSR_ADDR, %ebx
+11:
+ mov 0(%ebx), %ecx
+ test %ecx, %ecx
+ jz 12f
+ mov 4(%ebx), %eax
+ mov 8(%ebx), %edx
+ wrmsr
+ add $12, %ebx
+ jmp 11b
+12:
lock incw smp_cpus
1:
hlt
next prev parent reply other threads:[~2009-01-20 2:32 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 ` Marcelo Tosatti [this message]
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 ` [Qemu-devel] [patch 7/9] kvm: bios: switch MTRRs to cover only the PCI range and default to WB Marcelo Tosatti
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.721733697@amt.cnet \
--to=mtosatti@redhat.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.