[PATCH 29/54] KVM: Portability: Create kvm_arch_vcpu_runnable() function

From: Avi Kivity
Date: Tue Jan 01 2008 - 10:44:36 EST


From: Hollis Blanchard <hollisb@xxxxxxxxxx>

This abstracts the detail of x86 hlt and INIT modes into a function.

Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
Acked-by: Carsten Otte <cotte@xxxxxxxxxx>
Signed-off-by: Avi Kivity <avi@xxxxxxxxxxxx>
---
drivers/kvm/kvm_main.c | 3 +--
drivers/kvm/x86.h | 7 +++++++
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 7785c90..3d1023c 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -643,8 +643,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
*/
while (!kvm_cpu_has_interrupt(vcpu)
&& !signal_pending(current)
- && vcpu->mp_state != VCPU_MP_STATE_RUNNABLE
- && vcpu->mp_state != VCPU_MP_STATE_SIPI_RECEIVED) {
+ && !kvm_arch_vcpu_runnable(vcpu)) {
set_current_state(TASK_INTERRUPTIBLE);
vcpu_put(vcpu);
schedule();
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index 4b7acc7..eed7964 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -471,4 +471,11 @@ static inline u32 get_rdx_init_val(void)
#define TSS_IOPB_SIZE (65536 / 8)
#define TSS_REDIRECTION_SIZE (256 / 8)
#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
+
+static inline int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
+{
+ return vcpu->mp_state == VCPU_MP_STATE_RUNNABLE
+ || vcpu->mp_state == VCPU_MP_STATE_SIPI_RECEIVED;
+}
+
#endif
--
1.5.3.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/