KVM: Don't assume that mpstate exists with in-kernel PIC always
PATCH 1/1 KVM: Don't assume that mpstate exists with in-kernel PIC always
On PPC, we don't support MP state. So far it's not necessary and I'm not convinced yet that we really need to support it ever.
However, the current idle logic in QEMU assumes that an in-kernel PIC also means we support MP state. This assumption is not true anymore.
Let's split up the two cases into two different variables. That way PPC can expose an in-kernel PIC, while not implementing MP state.
---
v1 -> v2:
- use kvm_halt_in_kernel() instead
--- cpus.c | 2 +- include/sysemu/kvm.h | 10 ++++++++++ kvm-all.c | 2 ++ 3 files changed, 13 insertions(+), 1 deletions(-)
cpus.c +1 -1
@@ -73,7 +73,7 @@ static bool cpu_thread_is_idle(CPUArchState *env)return true; }if (!cpu->halted ||qemu_cpu_has_work (cpu) || -kvm_async_interrupts_enabled ()) { +kvm_halt_in_kernel ()) {return false; }return true;
include/sysemu/kvm.h +10 -0
@@ -42,6 +42,7 @@extern bool kvm_allowed;extern bool kvm_kernel_irqchip;extern bool kvm_async_interrupts_allowed; +extern bool kvm_halt_in_kernel_allowed;extern bool kvm_irqfds_allowed;extern bool kvm_msi_via_irqfd_allowed;extern bool kvm_gsi_routing_allowed;
@@ -72,6 +73,14 @@ extern bool kvm_gsi_routing_allowed;#define kvm_async_interrupts_enabled () (kvm_async_interrupts_allowed)/** +* kvm_supports_mpstate: +* +* Returns: true if the kvm side supports MP states which is +* required to indicate to kvm that a vcpu is currently halted +*/ +#define kvm_halt_in_kernel () (kvm_halt_in_kernel_allowed) + +/** * kvm_irqfds_enabled: * * Returns: true if we can use irqfds to inject interrupts into
@@ -101,6 +110,7 @@ extern bool kvm_gsi_routing_allowed;#define kvm_enabled () (0)#define kvm_irqchip_in_kernel () (false)#define kvm_async_interrupts_enabled () (false) +#define kvm_halt_in_kernel () (false)#define kvm_irqfds_enabled () (false)#define kvm_msi_via_irqfd_enabled () (false)#define kvm_gsi_routing_allowed () (false)
kvm-all.c +2 -0
@@ -106,6 +106,7 @@ struct KVMStateKVMState *kvm_state;bool kvm_kernel_irqchip;bool kvm_async_interrupts_allowed; +bool kvm_halt_in_kernel_allowed;bool kvm_irqfds_allowed;bool kvm_msi_via_irqfd_allowed;bool kvm_gsi_routing_allowed;
@@ -1219,6 +1220,7 @@ static int kvm_irqchip_create(KVMState *s)* interrupt delivery (though the reverse is not necessarily true) */ kvm_async_interrupts_allowed = true; + kvm_halt_in_kernel_allowed = true;kvm_init_irq_routing (s);
Signature · 1 line
1.6.0.2
Quoted 49 lines · Alexander Graf
On PPC, we don't support MP state. So far it's not necessary and I'm not convinced yet that we really need to support it ever.
However, the current idle logic in QEMU assumes that an in-kernel PIC also means we support MP state. This assumption is not true anymore.
Let's split up the two cases into two different variables. That way PPC can expose an in-kernel PIC, while not implementing MP state.
Signed-off-by Alexander Graf <[email protected]>CC Jan Kiszka <[email protected]>---
v1 -> v2:
- use
kvm_halt_in_kernel()instead--- cpus.c | 2 +- include/sysemu/kvm.h | 10 ++++++++++ kvm-all.c | 2 ++ 3 files changed, 13 insertions(+), 1 deletions(-)cpus.c +1
-1@@ -73,7 +73,7 @@ static bool cpu_thread_is_idle(CPUArchState *env)return true; }if (!cpu->halted ||qemu_cpu_has_work (cpu) || -kvm_async_interrupts_enabled ()) { +kvm_halt_in_kernel ()) {return false; }return true;include/sysemu/kvm.h +1
-0@@ -42,6 +42,7 @@extern bool kvm_allowed;extern bool kvm_kernel_irqchip;extern bool kvm_async_interrupts_allowed; +extern bool kvm_halt_in_kernel_allowed;extern bool kvm_irqfds_allowed;extern bool kvm_msi_via_irqfd_allowed;extern bool kvm_gsi_routing_allowed;
include/sysemu/kvm.h extern bool kvm_gsi_routing_allowed; · line 79
Quoted 7 lines
include/sysemu/kvm.h +4
-0@@ -72,6 +73,14 @@ extern bool kvm_gsi_routing_allowed;#define kvm_async_interrupts_enabled () (kvm_async_interrupts_allowed)/** +* kvm_supports_mpstate: +* +* Returns: true if the kvm side supports MP states which is +* required to indicate to kvm that a vcpu is currently halted
"...and make KVM wait for resumption inside the kernel instead for reporting halt to userspace." Or so.
That's why I asked for calling this helper differently: to express the concept behind it, not the implementation detail "mpstate" (which is an x86-caused misnomer).
Quoted 29 lines
include/sysemu/kvm.h +5
-0+*/ +#define kvm_halt_in_kernel () (kvm_halt_in_kernel_allowed) + +/** * kvm_irqfds_enabled: * * Returns: true if we can use irqfds to inject interrupts into @@ -101,6 +110,7 @@ extern bool kvm_gsi_routing_allowed;#define kvm_enabled () (0)#define kvm_irqchip_in_kernel () (false)#define kvm_async_interrupts_enabled () (false) +#define kvm_halt_in_kernel () (false)#define kvm_irqfds_enabled () (false)#define kvm_msi_via_irqfd_enabled () (false)#define kvm_gsi_routing_allowed () (false)kvm-all.c +1
-0@@ -106,6 +106,7 @@ struct KVMStateKVMState *kvm_state;bool kvm_kernel_irqchip;bool kvm_async_interrupts_allowed; +bool kvm_halt_in_kernel_allowed;bool kvm_irqfds_allowed;bool kvm_msi_via_irqfd_allowed;bool kvm_gsi_routing_allowed;
kvm-all.c static int kvm_irqchip_create(KVMState *s) · line 1226
Quoted 7 lines
kvm-all.c +1
-0@@ -1219,6 +1220,7 @@ static int kvm_irqchip_create(KVMState *s)* interrupt delivery (though the reverse is not necessarily true) */ kvm_async_interrupts_allowed = true; + kvm_halt_in_kernel_allowed = true;kvm_init_irq_routing (s);
The code looks good to me.
Jan
Quoted 61 lines · Jan Kiszka
Quoted 49 lines · Alexander Graf
On PPC, we don't support MP state. So far it's not necessary and I'm not convinced yet that we really need to support it ever.
However, the current idle logic in QEMU assumes that an in-kernel PIC also means we support MP state. This assumption is not true anymore.
Let's split up the two cases into two different variables. That way PPC can expose an in-kernel PIC, while not implementing MP state.
Signed-off-by Alexander Graf <[email protected]>CC Jan Kiszka <[email protected]>---
v1 -> v2:
- use
kvm_halt_in_kernel()instead
---cpus.c | 2 +- include/sysemu/kvm.h | 10 ++++++++++ kvm-all.c | 2 ++ 3 files changed, 13 insertions(+), 1 deletions(-)cpus.c +1
-1@@ -73,7 +73,7 @@ static bool cpu_thread_is_idle(CPUArchState *env)return true; }if (!cpu->halted ||qemu_cpu_has_work (cpu) || -kvm_async_interrupts_enabled ()) { +kvm_halt_in_kernel ()) {return false; }return true;include/sysemu/kvm.h +1
-0@@ -42,6 +42,7 @@extern bool kvm_allowed;extern bool kvm_kernel_irqchip;extern bool kvm_async_interrupts_allowed; +extern bool kvm_halt_in_kernel_allowed;extern bool kvm_irqfds_allowed;extern bool kvm_msi_via_irqfd_allowed;extern bool kvm_gsi_routing_allowed;include/sysemu/kvm.h extern bool kvm_gsi_routing_allowed; · line 79
Quoted 7 lines
include/sysemu/kvm.h +4
-0@@ -72,6 +73,14 @@ extern bool kvm_gsi_routing_allowed;#define kvm_async_interrupts_enabled () (kvm_async_interrupts_allowed)/** +* kvm_supports_mpstate: +* +* Returns: true if the kvm side supports MP states which is +* required to indicate to kvm that a vcpu is currently halted "...and make KVM wait for resumption inside the kernel instead for reporting halt to userspace." Or so.
Quoted 3 lines
That's why I asked for calling this helper differently: to express the concept behind it, not the implementation detail "mpstate" (which is an x86-caused misnomer).
It's not exactly a misnomer. It's a concept that is required to implement the logic. I've updated the comment accordingly :).
Alex
Quoted 64 lines · Alexander Graf
Quoted 61 lines · Jan Kiszka
Quoted 49 lines · Alexander Graf
On PPC, we don't support MP state. So far it's not necessary and I'm not convinced yet that we really need to support it ever.
However, the current idle logic in QEMU assumes that an in-kernel PIC also means we support MP state. This assumption is not true anymore.
Let's split up the two cases into two different variables. That way PPC can expose an in-kernel PIC, while not implementing MP state.
Signed-off-by Alexander Graf <[email protected]>CC Jan Kiszka <[email protected]>---
v1 -> v2:
- use
kvm_halt_in_kernel()instead
---cpus.c | 2 +- include/sysemu/kvm.h | 10 ++++++++++ kvm-all.c | 2 ++ 3 files changed, 13 insertions(+), 1 deletions(-)cpus.c +1
-1@@ -73,7 +73,7 @@ static bool cpu_thread_is_idle(CPUArchState *env)return true; }if (!cpu->halted ||qemu_cpu_has_work (cpu) || -kvm_async_interrupts_enabled ()) { +kvm_halt_in_kernel ()) {return false; }return true;include/sysemu/kvm.h +1
-0@@ -42,6 +42,7 @@extern bool kvm_allowed;extern bool kvm_kernel_irqchip;extern bool kvm_async_interrupts_allowed; +extern bool kvm_halt_in_kernel_allowed;extern bool kvm_irqfds_allowed;extern bool kvm_msi_via_irqfd_allowed;extern bool kvm_gsi_routing_allowed;include/sysemu/kvm.h extern bool kvm_gsi_routing_allowed; · line 79
Quoted 7 lines
include/sysemu/kvm.h +4
-0@@ -72,6 +73,14 @@ extern bool kvm_gsi_routing_allowed;#define kvm_async_interrupts_enabled () (kvm_async_interrupts_allowed)/** +* kvm_supports_mpstate: +* +* Returns: true if the kvm side supports MP states which is +* required to indicate to kvm that a vcpu is currently halted "...and make KVM wait for resumption inside the kernel instead for reporting halt to userspace." Or so.
Quoted 5 lines
Quoted 3 lines
That's why I asked for calling this helper differently: to express the concept behind it, not the implementation detail "mpstate" (which is an x86-caused misnomer).
It's not exactly a misnomer. It's a concept that is required to implement the logic. I've updated the comment accordingly :).
AFAIK, the concept ("multi-processor state") was introduced for and named after x86 properties.
Jan