Skip to contentSkip to conversation

qemu-kvm: Fix segfault on -no-kvm startup

PATCH Applied Jan Kiszka 4 participants 5 messages Sep 25, 2009 – Sep 27, 2009 KVM

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 qemu-kvm: Fix segfault on -no-kvm startup

The check for in-kernel irqchip must be protected by kvm_enabled, and we have a different wrapper for it.

---

 hw/apic.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/apic.c +2 -1
index 3a2e128..01ac174 100644
@@ -509,9 +509,10 @@ void apic_init_reset(CPUState *env)
 
     env->halted = !(s->apicbase & MSR_IA32_APICBASE_BSP);
 #ifdef KVM_CAP_MP_STATE
-    if (kvm_irqchip_in_kernel(kvm_context))
+    if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
         env->mp_state
             = env->halted ? KVM_MP_STATE_UNINITIALIZED : KVM_MP_STATE_RUNNABLE;
+    }
 #endif
 }
 
#1 lore raw
Quoted 3 lines · Jan Kiszka

The check for in-kernel irqchip must be protected by kvm_enabled, and we have a different wrapper for it.

Why not move kvm_enabled() into kvm_irqchip_in_kernel()? It will return false if !kvm_enabled().

Quoted 23 lines

---

 hw/apic.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/apic.c +2 -2
index 3a2e128..01ac174 100644
@@ -509,9 +509,10 @@ void apic_init_reset(CPUState *env)
 
     env->halted = !(s->apicbase & MSR_IA32_APICBASE_BSP);
 #ifdef KVM_CAP_MP_STATE
-    if (kvm_irqchip_in_kernel(kvm_context))
+    if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
         env->mp_state
             = env->halted ? KVM_MP_STATE_UNINITIALIZED : KVM_MP_STATE_RUNNABLE;
+    }
 #endif
 }
 
--
Quoted 3 lines

To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Gleb.

#2 lore raw
Quoted 6 lines · Gleb Natapov
Quoted 3 lines · Jan Kiszka

The check for in-kernel irqchip must be protected by kvm_enabled, and we have a different wrapper for it.

Why not move kvm_enabled() into kvm_irqchip_in_kernel()? It will return false if !kvm_enabled().

Yes, possible. But I'm not sure if it's worth to refactor at this level.

I think the whole irqchip interface has to go through some broader refactoring when pushing it upstream. The result should either be a specific, in-kernel-irqchip apic device or generic wrapper services that cover all cases, is easily compiled away in the absence of KVM and avoid #ifdefs like below.

Jan

Quoted 23 lines
Quoted 23 lines

---

 hw/apic.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/apic.c +2 -1
index 3a2e128..01ac174 100644
@@ -509,9 +509,10 @@ void apic_init_reset(CPUState *env)
 
     env->halted = !(s->apicbase & MSR_IA32_APICBASE_BSP);
 #ifdef KVM_CAP_MP_STATE
-    if (kvm_irqchip_in_kernel(kvm_context))
+    if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
         env->mp_state
             = env->halted ? KVM_MP_STATE_UNINITIALIZED : KVM_MP_STATE_RUNNABLE;
+    }
 #endif
 }
 
Applied
#4 lore raw
In reply to Jan Kiszka
Quoted 4 lines · Jan Kiszka

The check for in-kernel irqchip must be protected by kvm_enabled, and we have a different wrapper for it.

Applied, thanks.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#3 lore raw
In reply to Jan Kiszka
Quoted 4 lines · Jan Kiszka
Quoted 2 lines · Gleb Natapov

On Fri, Sep 25, 2009 at 06:05:49PM +0200, Jan Kiszka wrote:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

The check for in-kernel irqchip must be protected by kvm_enabled, and we have a different wrapper for it.

Why not move kvm_enabled() into kvm_irqchip_in_kernel()? It will return false if !kvm_enabled().

Yes, possible. But I'm not sure if it's worth to refactor at this level.

In any case, fix bugs first, refactor later.

Quoted 6 lines

I think the whole irqchip interface has to go through some broader refactoring when pushing it upstream. The result should either be a specific, in-kernel-irqchip apic device or generic wrapper services that cover all cases, is easily compiled away in the absence of KVM and avoid #ifdefs like below.

s/when/before/

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.