Skip to contentSkip to conversation

Further integration with qemu.git

PATCH Applied Glauber Costa 3 participants 6 messages Oct 19, 2009 – Oct 20, 2009 KVM

lore
Share & tools
lore
#0 lore raw

cover Further integration with qemu.git

A couple of more functions are used from qemu.git. Merging keeps going...

#1 lore raw

PATCH 1/3 use handle_io upstream version.

We can use upstream version of handle_io, there called kvm_handle_io()

---
 kvm-all.c  |    2 ++
 qemu-kvm.c |   58 +++++-----------------------------------------------------
 2 files changed, 7 insertions(+), 53 deletions(-)
kvm-all.c +2 -0
index 5ea999e..5a7be5b 100644
@@ -520,6 +520,7 @@ err:
 
     return ret;
 }
+#endif
 
 static int kvm_handle_io(uint16_t port, void *data, int direction, int size,
                          uint32_t count)
@@ -560,6 +561,7 @@ static int kvm_handle_io(uint16_t port, void *data, int direction, int size,
     return 1;
 }
 
+#ifdef KVM_UPSTREAM
 static void kvm_run_coalesced_mmio(CPUState *env, struct kvm_run *run)
 {
 #ifdef KVM_CAP_COALESCED_MMIO
qemu-kvm.c +5 -53

70 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#2 lore raw

PATCH 2/3 change pre and post kvm_run signatures.

Intention is to merge with upstream version in the following patch. Doing as a separate step to help identify any further issues.

---
 qemu-kvm-x86.c |    6 ++++--
 qemu-kvm.c     |    4 ++--
 qemu-kvm.h     |    4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)
qemu-kvm-x86.c +4 -2
index 350e5fd..b9ffabb 100644
@@ -1329,13 +1329,14 @@ int kvm_arch_halt(CPUState *env)
     return 1;
 }
 
-void kvm_arch_pre_kvm_run(void *opaque, CPUState *env)
+int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
 {
     if (!kvm_irqchip_in_kernel())
 	kvm_set_cr8(env, cpu_get_apic_tpr(env));
+    return 0;
 }
 
-void kvm_arch_post_kvm_run(void *opaque, CPUState *env)
+int kvm_arch_post_run(CPUState *env, struct kvm_run *run)
 {
     cpu_single_env = env;
 
@@ -1344,6 +1345,7 @@ void kvm_arch_post_kvm_run(void *opaque, CPUState *env)
 
     cpu_set_apic_tpr(env, kvm_get_cr8(env));
     cpu_set_apic_base(env, kvm_get_apic_base(env));
+    return 0;
 }
 
 int kvm_arch_has_work(CPUState *env)
qemu-kvm.c +2 -2
index ad00560..a883a48 100644
@@ -852,12 +852,12 @@ static inline void push_nmi(kvm_context_t kvm)
 void post_kvm_run(kvm_context_t kvm, CPUState *env)
 {
     pthread_mutex_lock(&qemu_mutex);
-    kvm_arch_post_kvm_run(kvm->opaque, env);
+    kvm_arch_post_run(env, env->kvm_run);
 }
 
 int pre_kvm_run(kvm_context_t kvm, CPUState *env)
 {
-    kvm_arch_pre_kvm_run(kvm->opaque, env);
+    kvm_arch_pre_run(env, env->kvm_run);
 
     pthread_mutex_unlock(&qemu_mutex);
     return 0;
qemu-kvm.h +2 -2
index 06507a6..b84fed1 100644
@@ -965,8 +965,8 @@ void kvm_arch_load_regs(CPUState *env);
 void kvm_arch_load_mpstate(CPUState *env);
 void kvm_arch_save_mpstate(CPUState *env);
 int kvm_arch_init_vcpu(CPUState *cenv);
-void kvm_arch_pre_kvm_run(void *opaque, CPUState *env);
-void kvm_arch_post_kvm_run(void *opaque, CPUState *env);
+int kvm_arch_pre_run(CPUState *env, struct kvm_run *run);
+int kvm_arch_post_run(CPUState *env, struct kvm_run *run);
 int kvm_arch_has_work(CPUState *env);
 void kvm_arch_process_irqchip_events(CPUState *env);
 int kvm_arch_try_push_interrupts(void *opaque);
Signature · 1 line
1.6.2.5
#3 lore raw

PATCH 3/3 use upstream version of kvm_arch_post_run

Replace ours with qemu.git version. A couple of functions go unused, and are deleted.

---
 qemu-kvm-x86.c    |   22 ----------------------
 qemu-kvm.c        |    5 -----
 qemu-kvm.h        |   11 -----------
 target-i386/kvm.c |    2 ++
 4 files changed, 2 insertions(+), 38 deletions(-)
qemu-kvm-x86.c +0 -22
index b9ffabb..db0b351 100644
@@ -515,21 +515,11 @@ void kvm_show_regs(CPUState *env)
 		sregs.efer);
 }
 
-static uint64_t kvm_get_apic_base(CPUState *env)
-{
-	return env->kvm_run->apic_base;
-}
-
 static void kvm_set_cr8(CPUState *env, uint64_t cr8)
 {
 	env->kvm_run->cr8 = cr8;
 }
 
-static __u64 kvm_get_cr8(CPUState *env)
-{
-	return env->kvm_run->cr8;
-}
-
 int kvm_setup_cpuid(CPUState *env, int nent,
 		    struct kvm_cpuid_entry *entries)
 {
@@ -1336,18 +1326,6 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
     return 0;
 }
 
-int kvm_arch_post_run(CPUState *env, struct kvm_run *run)
-{
-    cpu_single_env = env;
-
-    env->eflags = kvm_get_interrupt_flag(env)
-	? env->eflags | IF_MASK : env->eflags & ~IF_MASK;
-
-    cpu_set_apic_tpr(env, kvm_get_cr8(env));
-    cpu_set_apic_base(env, kvm_get_apic_base(env));
-    return 0;
-}
-
 int kvm_arch_has_work(CPUState *env)
 {
     if (((env->interrupt_request & CPU_INTERRUPT_HARD) &&
qemu-kvm.c +0 -5
index a883a48..57d8b1a 100644
@@ -863,11 +863,6 @@ int pre_kvm_run(kvm_context_t kvm, CPUState *env)
     return 0;
 }
 
-int kvm_get_interrupt_flag(CPUState *env)
-{
-    return env->kvm_run->if_flag;
-}
-
 int kvm_is_ready_for_interrupt_injection(CPUState *env)
 {
     return env->kvm_run->ready_for_interrupt_injection;
qemu-kvm.h +0 -11
index b84fed1..57c8c86 100644
@@ -190,17 +190,6 @@ void kvm_create_irqchip(kvm_context_t kvm);
 int kvm_run(CPUState *env);
 
 /*!
- * \brief Get interrupt flag from on last exit to userspace
- *
- * This gets the CPU interrupt flag as it was on the last exit to userspace.
- *
- * \param kvm Pointer to the current kvm_context
- * \param vcpu Which virtual CPU should get dumped
- * \return interrupt flag value (0 or 1)
- */
-int kvm_get_interrupt_flag(CPUState *env);
-
-/*!
  * \brief Check if a vcpu is ready for interrupt injection
  *
  * This checks if vcpu interrupts are not masked by mov ss or sti.
target-i386/kvm.c +2 -0
index 1cf0dc3..24c9903 100644
@@ -748,6 +748,7 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
 
     return 0;
 }
+#endif
 
 int kvm_arch_post_run(CPUState *env, struct kvm_run *run)
 {
@@ -762,6 +763,7 @@ int kvm_arch_post_run(CPUState *env, struct kvm_run *run)
     return 0;
 }
 
+#ifdef KVM_UPSTREAM
 static int kvm_handle_halt(CPUState *env)
 {
     if (!((env->interrupt_request & CPU_INTERRUPT_HARD) &&
Signature · 1 line
1.6.2.5
#4 lore raw
In reply to Glauber Costa
Quoted 3 lines · Glauber Costa

A couple of more functions are used from qemu.git. Merging keeps going...

Looks good.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.