Skip to contentSkip to conversation

qemu-kvm: Switch to upstream TPR optimization

PATCH Applied Jan Kiszka 3 participants 5 messages Mar 9, 2012 – Apr 27, 2012

Subsystems (2)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 qemu-kvm: Switch to upstream TPR optimization

From: Jan Kiszka <[email protected]>

The upstream version is feature-equivalent and covers more corner cases.

---

As the upstream merge was not successful, this also unbreaks XP etc. over current qemu-kvm.

 .gitignore                 |    1 -
 Makefile                   |    1 -
 Makefile.target            |    3 -
 hw/pc.c                    |    6 -
 kvm-tpr-opt.c              |  380 --------------------------------------------
 pc-bios/optionrom/Makefile |    2 -
 pc-bios/optionrom/vapic.S  |  341 ---------------------------------------
 pc-bios/vapic.bin          |  Bin 8960 -> 0 bytes
 qemu-kvm-x86.c             |   33 ----
 qemu-kvm.h                 |    5 -
 target-i386/kvm.c          |   15 --
 11 files changed, 0 insertions(+), 787 deletions(-)
 delete mode 100644 kvm-tpr-opt.c
 delete mode 100644 pc-bios/optionrom/vapic.S
 delete mode 100755 pc-bios/vapic.bin
.gitignore +0 -1
index af5fb3c..81b1510 100644
@@ -77,7 +77,6 @@ pc-bios/vgabios-pq/status
 pc-bios/optionrom/linuxboot.bin
 pc-bios/optionrom/multiboot.bin
 pc-bios/optionrom/multiboot.raw
-pc-bios/optionrom/vapic.bin
 pc-bios/optionrom/kvmvapic.bin
 .stgit-*
 cscope.*
Makefile +0 -1
index 35c30f9..2765dcb 100644
@@ -260,7 +260,6 @@ multiboot.bin linuxboot.bin kvmvapic.bin \
 s390-zipl.rom \
 spapr-rtas.bin slof.bin \
 palcode-clipper
-BLOBS += vapic.bin
 else
 BLOBS=
 endif
Makefile.target +0 -3
index 6b490f0..ae04331 100644
@@ -86,9 +86,6 @@ libobj-y += cpuid.o
 endif
 libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
-
-libobj-$(CONFIG_KVM) += kvm-tpr-opt.o
-
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 ifeq ($(TARGET_BASE_ARCH), sparc)
 libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
hw/pc.c +0 -6
index 6dcf6df..74c19b9 100644
@@ -60,8 +60,6 @@
 #define DPRINTF(fmt, ...)
 #endif
 
-#define VAPIC_FILENAME "vapic.bin"
-
 /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables.  */
 #define ACPI_DATA_SIZE       0x10000
 #define BIOS_CFG_IOPORT 0x510
@@ -1022,10 +1020,6 @@ void pc_memory_init(MemoryRegion *system_memory,
                                         option_rom_mr,
                                         1);
 
-    option_rom[nb_option_roms].name = g_strdup(VAPIC_FILENAME);
-    option_rom[nb_option_roms].bootindex = -1;
-    nb_option_roms++;
-
     fw_cfg = bochs_bios_init();
     rom_set_fw(fw_cfg);
 
kvm-tpr-opt.c deleted +0 -380

380 lines not on this page · raw message

pc-bios/optionrom/Makefile +0 -2
index ceb04d1..f6b4027 100644
@@ -16,8 +16,6 @@ QEMU_CFLAGS = $(CFLAGS)
 
 build-all: multiboot.bin linuxboot.bin kvmvapic.bin
 
-build-all: vapic.bin
-
 # suppress auto-removal of intermediate files
 .SECONDARY:
 
pc-bios/optionrom/vapic.S deleted +0 -341

341 lines not on this page · raw message

pc-bios/vapic.bin deleted binary +0 -0
deleted file mode 100755
index 35f0cf2a38451f59bbf425c392e69d11ce5c2add..0000000000000000000000000000000000000000
GIT binary patch
qemu-kvm-x86.c +0 -33
index 2dad5af..159779c 100644
@@ -45,25 +45,6 @@ int kvm_create_pit(KVMState *s)
     return 0;
 }
 
-int kvm_handle_tpr_access(CPUState *env)
-{
-    struct kvm_run *run = env->kvm_run;
-    kvm_tpr_access_report(env,
-                          run->tpr_access.rip,
-                          run->tpr_access.is_write);
-    return 1;
-}
-
-
-int kvm_enable_vapic(CPUState *env, uint64_t vapic)
-{
-    struct kvm_vapic_addr va = {
-        .vapic_addr = vapic,
-    };
-
-    return kvm_vcpu_ioctl(env, KVM_SET_VAPIC_ADDR, &va);
-}
-
 int kvm_get_pit(KVMState *s, struct kvm_pit_state *pit_state)
 {
     if (!kvm_irqchip_in_kernel()) {
@@ -96,24 +77,10 @@ int kvm_set_pit2(KVMState *s, struct kvm_pit_state2 *ps2)
     return kvm_vm_ioctl(s, KVM_SET_PIT2, ps2);
 }
 
-static int kvm_enable_tpr_access_reporting(CPUState *env)
-{
-    int r;
-    struct kvm_tpr_access_ctl tac = { .enabled = 1 };
-
-    r = kvm_ioctl(env->kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_VAPIC);
-    if (r <= 0) {
-        return -ENOSYS;
-    }
-    return kvm_vcpu_ioctl(env, KVM_TPR_ACCESS_REPORTING, &tac);
-}
-
 static int _kvm_arch_init_vcpu(CPUState *env)
 {
     kvm_arch_reset_vcpu(env);
 
-    kvm_enable_tpr_access_reporting(env);
-
     return kvm_update_ioport_access(env);
 }
 
qemu-kvm.h +0 -5
index 3c4f023..db44019 100644
@@ -180,8 +180,6 @@ struct kvm_pit_state {
 void kvm_hpet_enable_kpit(void);
 void kvm_hpet_disable_kpit(void);
 
-void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write);
-
 int kvm_add_ioport_region(unsigned long start, unsigned long size,
                           bool is_hot_plug);
 int kvm_remove_ioport_region(unsigned long start, unsigned long size,
@@ -196,7 +194,4 @@ int kvm_create_pit(KVMState *s);
 extern int kvm_pit_reinject;
 extern unsigned int kvm_shadow_memory;
 
-int kvm_handle_tpr_access(CPUState *env);
-void kvm_tpr_enable_vapic(CPUState *env);
-
 #endif
target-i386/kvm.c +0 -15
index e1bf254..461734d 100644
@@ -583,18 +583,8 @@ int kvm_arch_init_vcpu(CPUState *env)
     return 0;
 }
 
-static void kvm_clear_vapic(CPUState *env)
-{
-    struct kvm_vapic_addr va = {
-        .vapic_addr = 0,
-    };
-
-    kvm_vcpu_ioctl(env, KVM_SET_VAPIC_ADDR, &va);
-}
-
 void kvm_arch_reset_vcpu(CPUState *env)
 {
-    kvm_clear_vapic(env);
     env->exception_injected = -1;
     env->interrupt_injected = -1;
     env->xcr0 = 1;
@@ -1583,9 +1573,6 @@ int kvm_arch_put_registers(CPUState *env, int level)
     if (ret < 0) {
         return ret;
     }
-    if (level == KVM_PUT_FULL_STATE) {
-        kvm_tpr_enable_vapic(env);
-    }
     /* must be last */
     ret = kvm_guest_debug_workarounds(env);
     if (ret < 0) {
@@ -1774,7 +1761,6 @@ static int kvm_handle_halt(CPUState *env)
     return 0;
 }
 
-#ifdef KVM_UPSTREAM
 static int kvm_handle_tpr_access(CPUState *env)
 {
     struct kvm_run *run = env->kvm_run;
@@ -1784,7 +1770,6 @@ static int kvm_handle_tpr_access(CPUState *env)
                                                            : TPR_ACCESS_READ);
     return 1;
 }
-#endif
 
 int kvm_arch_insert_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp)
 {
Signature · 1 line
1.7.3.4
author
#1 lore raw

PATCH 1/1 qemu-kvm: Eliminate _kvm_arch_init_vcpu

From: Jan Kiszka <[email protected]>

There is no need for an explicit kvm_arch_reset_vcpu on arch cpu init anymore, kvm_init_vcpu does it already. Call the remaining kvm_update_ioport_access directly from kvm_arch_init_vcpu.

---

This depends on the TPR switch-over patch.

 qemu-kvm-x86.c    |    7 -------
 target-i386/kvm.c |    4 +---
 2 files changed, 1 insertions(+), 10 deletions(-)
qemu-kvm-x86.c +0 -7
index 159779c..7de51dc 100644
@@ -77,13 +77,6 @@ int kvm_set_pit2(KVMState *s, struct kvm_pit_state2 *ps2)
     return kvm_vm_ioctl(s, KVM_SET_PIT2, ps2);
 }
 
-static int _kvm_arch_init_vcpu(CPUState *env)
-{
-    kvm_arch_reset_vcpu(env);
-
-    return kvm_update_ioport_access(env);
-}
-
 #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 int kvm_arch_set_ioport_access(unsigned long start, unsigned long size,
                                bool enable)
target-i386/kvm.c +1 -3
index 461734d..91110c1 100644
@@ -345,8 +345,6 @@ static void cpu_update_state(void *opaque, int running, RunState state)
     }
 }
 
-static int _kvm_arch_init_vcpu(CPUState *env);
-
 int kvm_arch_init_vcpu(CPUState *env)
 {
     struct {
@@ -360,7 +358,7 @@ int kvm_arch_init_vcpu(CPUState *env)
     uint32_t signature[3];
     int r;
 
-    r = _kvm_arch_init_vcpu(env);
+    r = kvm_update_ioport_access(env);
     if (r < 0) {
         return r;
     }
#2 lore raw

Re: [PATCH] qemu-kvm: Eliminate _kvm_arch_init_vcpu

Quoted 47 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

There is no need for an explicit kvm_arch_reset_vcpu on arch cpu init anymore, kvm_init_vcpu does it already. Call the remaining kvm_update_ioport_access directly from kvm_arch_init_vcpu.

---

This depends on the TPR switch-over patch.

 qemu-kvm-x86.c    |    7 -------
 target-i386/kvm.c |    4 +---
 2 files changed, 1 insertions(+), 10 deletions(-)
qemu-kvm-x86.c +0 -7
index 159779c..7de51dc 100644
@@ -77,13 +77,6 @@ int kvm_set_pit2(KVMState *s, struct kvm_pit_state2 *ps2)
     return kvm_vm_ioctl(s, KVM_SET_PIT2, ps2);
 }
 
-static int _kvm_arch_init_vcpu(CPUState *env)
-{
-    kvm_arch_reset_vcpu(env);
-
-    return kvm_update_ioport_access(env);
-}
-
 #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 int kvm_arch_set_ioport_access(unsigned long start, unsigned long size,
                                bool enable)
target-i386/kvm.c +0 -2
index 461734d..91110c1 100644
@@ -345,8 +345,6 @@ static void cpu_update_state(void *opaque, int running, RunState state)
     }
 }
 
-static int _kvm_arch_init_vcpu(CPUState *env);
-
 int kvm_arch_init_vcpu(CPUState *env)
 {
     struct {

target-i386/kvm.c int kvm_arch_init_vcpu(CPUState *env) · line 364

Quoted 8 lines
target-i386/kvm.c +1 -1
@@ -360,7 +358,7 @@ int kvm_arch_init_vcpu(CPUState *env)
     uint32_t signature[3];
     int r;
 
-    r = _kvm_arch_init_vcpu(env);
+    r = kvm_update_ioport_access(env);
     if (r < 0) {
         return r;
     }

Marcelo, what is the state of understanding why this change can cause troubles in autotest? As I wrote offlist, I can neither reproduce nor understand how it can cause any regression (I suspect it rather triggers a so far hidden issue).

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#3 lore raw

Re: [PATCH] qemu-kvm: Eliminate _kvm_arch_init_vcpu

Quoted 62 lines · Jan Kiszka
Quoted 47 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

There is no need for an explicit kvm_arch_reset_vcpu on arch cpu init anymore, kvm_init_vcpu does it already. Call the remaining kvm_update_ioport_access directly from kvm_arch_init_vcpu.

---

This depends on the TPR switch-over patch.

 qemu-kvm-x86.c    |    7 -------
 target-i386/kvm.c |    4 +---
 2 files changed, 1 insertions(+), 10 deletions(-)
qemu-kvm-x86.c +0 -7
index 159779c..7de51dc 100644
@@ -77,13 +77,6 @@ int kvm_set_pit2(KVMState *s, struct kvm_pit_state2 *ps2)
     return kvm_vm_ioctl(s, KVM_SET_PIT2, ps2);
 }
 
-static int _kvm_arch_init_vcpu(CPUState *env)
-{
-    kvm_arch_reset_vcpu(env);
-
-    return kvm_update_ioport_access(env);
-}
-
 #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 int kvm_arch_set_ioport_access(unsigned long start, unsigned long size,
                                bool enable)
target-i386/kvm.c +0 -2
index 461734d..91110c1 100644
@@ -345,8 +345,6 @@ static void cpu_update_state(void *opaque, int running, RunState state)
     }
 }
 
-static int _kvm_arch_init_vcpu(CPUState *env);
-
 int kvm_arch_init_vcpu(CPUState *env)
 {
     struct {

target-i386/kvm.c int kvm_arch_init_vcpu(CPUState *env) · line 364

Quoted 8 lines
target-i386/kvm.c +1 -1
@@ -360,7 +358,7 @@ int kvm_arch_init_vcpu(CPUState *env)
     uint32_t signature[3];
     int r;
 
-    r = _kvm_arch_init_vcpu(env);
+    r = kvm_update_ioport_access(env);
     if (r < 0) {
         return r;
     }

Marcelo, what is the state of understanding why this change can cause troubles in autotest? As I wrote offlist, I can neither reproduce nor understand how it can cause any regression (I suspect it rather triggers a so far hidden issue).

Quoted 1 line

Jan

Still no understanding of previous failures, but results are consistently OK now. Maybe the gods are happy with us now :)

Applied, thanks.