diff mbox

[v11,2/5] apic: use per CPU AS to map APIC MMIO for TCG

Message ID 73429d6177c577cb17fe07bbd446be3a7b3f8ead.1441086002.git.zhugh.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Zhu Guihua Sept. 2, 2015, 9:36 a.m. UTC
TCG supports per CPU address space, and the emulation quality is
a bit better with it.
So use per CPU address space to map APIC MMIO area. This allows the
APIC base address of each cpu to be moved indepenedent of others.

Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
---
 target-i386/cpu.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 66b6b0d..0a95162 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2881,9 +2881,18 @@  static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
         goto out;
     }
 
-    /* Map APIC MMIO area */
+    /* Map APIC MMIO area, use per-CPU address space if available (TCG
+     * supports it, KVM doesn't). This allows the APIC base address of
+     * each CPU to be moved independently.
+     */
     apic = APIC_COMMON(cpu->apic_state);
-    if (!apic_mmio_map_once) {
+    if (tcg_enabled()) {
+        memory_region_add_subregion_overlap(cpu->cpu_as_root,
+                                            apic->apicbase &
+                                            MSR_IA32_APICBASE_BASE,
+                                            &apic->io_memory,
+                                            0x1000);
+    } else if (!apic_mmio_map_once) {
         memory_region_add_subregion_overlap(get_system_memory(),
                                             apic->apicbase &
                                             MSR_IA32_APICBASE_BASE,