From: Zhang Xiantao <[EMAIL PROTECTED]> Date: Thu, 13 Dec 2007 23:59:18 +0800 Subject: [PATCH] kvm: Portability : Moving irq-related fields to arch.
This patches moves irq_pending, irq_summary, and interrupt_
window_open fields to arch.
Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]>
---
drivers/kvm/svm.c | 38 +++++++++++++++++++-------------------
drivers/kvm/vmx.c | 30 +++++++++++++++---------------
drivers/kvm/x86.c | 26 +++++++++++++-------------
drivers/kvm/x86.h | 6 +++---
4 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index c56e29b..1b24808 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -99,20 +99,20 @@ static inline u32 svm_has(u32 feat)
static inline u8 pop_irq(struct kvm_vcpu *vcpu)
{
- int word_index = __ffs(vcpu->irq_summary);
- int bit_index = __ffs(vcpu->irq_pending[word_index]);
+ int word_index = __ffs(vcpu->arch.irq_summary);
+ int bit_index = __ffs(vcpu->arch.irq_pending[word_index]);
int irq = word_index * BITS_PER_LONG + bit_index;
- clear_bit(bit_index, &vcpu->irq_pending[word_index]);
- if (!vcpu->irq_pending[word_index])
- clear_bit(word_index, &vcpu->irq_summary);
+ clear_bit(bit_index, &vcpu->arch.irq_pending[word_index]);
+ if (!vcpu->arch.irq_pending[word_index])
+ clear_bit(word_index, &vcpu->arch.irq_summary);
return irq;
}
static inline void push_irq(struct kvm_vcpu *vcpu, u8 irq)
{
- set_bit(irq, vcpu->irq_pending);
- set_bit(irq / BITS_PER_LONG, &vcpu->irq_summary);
+ set_bit(irq, vcpu->arch.irq_pending);
+ set_bit(irq / BITS_PER_LONG, &vcpu->arch.irq_summary);
}
static inline void clgi(void)
@@ -230,7 +230,7 @@ static void skip_emulated_instruction(struct
kvm_vcpu *vcpu)
vcpu->rip = svm->vmcb->save.rip = svm->next_rip;
svm->vmcb->control.int_state &= ~SVM_INTERRUPT_SHADOW_MASK;
- vcpu->interrupt_window_open = 1;
+ vcpu->arch.interrupt_window_open = 1;
}
static int has_svm(void)
@@ -1205,7 +1205,7 @@ static int interrupt_window_interception(struct
vcpu_svm *svm,
* possible
*/
if (kvm_run->request_interrupt_window &&
- !svm->vcpu.irq_summary) {
+ !svm->vcpu.arch.irq_summary) {
++svm->vcpu.stat.irq_window_exits;
kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
return 0;
@@ -1382,20 +1382,20 @@ static void kvm_reput_irq(struct vcpu_svm *svm)
push_irq(&svm->vcpu, control->int_vector);
}
- svm->vcpu.interrupt_window_open =
+ svm->vcpu.arch.interrupt_window_open =
!(control->int_state & SVM_INTERRUPT_SHADOW_MASK);
}
static void svm_do_inject_vector(struct vcpu_svm *svm)
{
struct kvm_vcpu *vcpu = &svm->vcpu;
- int word_index = __ffs(vcpu->irq_summary);
- int bit_index = __ffs(vcpu->irq_pending[word_index]);
+ int word_index = __ffs(vcpu->arch.irq_summary);
+ int bit_index = __ffs(vcpu->arch.irq_pending[word_index]);
int irq = word_index * BITS_PER_LONG + bit_index;
- clear_bit(bit_index, &vcpu->irq_pending[word_index]);
- if (!vcpu->irq_pending[word_index])
- clear_bit(word_index, &vcpu->irq_summary);
+ clear_bit(bit_index, &vcpu->arch.irq_pending[word_index]);
+ if (!vcpu->arch.irq_pending[word_index])
+ clear_bit(word_index, &vcpu->arch.irq_summary);
svm_inject_irq(svm, irq);
}
@@ -1405,11 +1405,11 @@ static void do_interrupt_requests(struct
kvm_vcpu *vcpu,
struct vcpu_svm *svm = to_svm(vcpu);
struct vmcb_control_area *control = &svm->vmcb->control;
- svm->vcpu.interrupt_window_open =
+ svm->vcpu.arch.interrupt_window_open =
(!(control->int_state & SVM_INTERRUPT_SHADOW_MASK) &&
(svm->vmcb->save.rflags & X86_EFLAGS_IF));
- if (svm->vcpu.interrupt_window_open && svm->vcpu.irq_summary)
+ if (svm->vcpu.arch.interrupt_window_open &&
svm->vcpu.arch.irq_summary)
/*
* If interrupts enabled, and not blocked by sti or mov
ss. Good.
*/
@@ -1418,8 +1418,8 @@ static void do_interrupt_requests(struct kvm_vcpu
*vcpu,
/*
* Interrupts blocked. Wait for unblock.
*/
- if (!svm->vcpu.interrupt_window_open &&
- (svm->vcpu.irq_summary ||
kvm_run->request_interrupt_window))
+ if (!svm->vcpu.arch.interrupt_window_open &&
+ (svm->vcpu.arch.irq_summary ||
kvm_run->request_interrupt_window))
control->intercept |= 1ULL << INTERCEPT_VINTR;
else
control->intercept &= ~(1ULL << INTERCEPT_VINTR);
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 7710ba1..05b03db 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -592,7 +592,7 @@ static void skip_emulated_instruction(struct
kvm_vcpu *vcpu)
if (interruptibility & 3)
vmcs_write32(GUEST_INTERRUPTIBILITY_INFO,
interruptibility & ~3);
- vcpu->interrupt_window_open = 1;
+ vcpu->arch.interrupt_window_open = 1;
}
static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
@@ -1734,13 +1734,13 @@ static void vmx_inject_irq(struct kvm_vcpu
*vcpu, int irq)
static void kvm_do_inject_irq(struct kvm_vcpu *vcpu)
{
- int word_index = __ffs(vcpu->irq_summary);
- int bit_index = __ffs(vcpu->irq_pending[word_index]);
+ int word_index = __ffs(vcpu->arch.irq_summary);
+ int bit_index = __ffs(vcpu->arch.irq_pending[word_index]);
int irq = word_index * BITS_PER_LONG + bit_index;
- clear_bit(bit_index, &vcpu->irq_pending[word_index]);
- if (!vcpu->irq_pending[word_index])
- clear_bit(word_index, &vcpu->irq_summary);
+ clear_bit(bit_index, &vcpu->arch.irq_pending[word_index]);
+ if (!vcpu->arch.irq_pending[word_index])
+ clear_bit(word_index, &vcpu->arch.irq_summary);
vmx_inject_irq(vcpu, irq);
}
@@ -1750,12 +1750,12 @@ static void do_interrupt_requests(struct
kvm_vcpu *vcpu,
{
u32 cpu_based_vm_exec_control;
- vcpu->interrupt_window_open =
+ vcpu->arch.interrupt_window_open =
((vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_IF) &&
(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3) == 0);
- if (vcpu->interrupt_window_open &&
- vcpu->irq_summary &&
+ if (vcpu->arch.interrupt_window_open &&
+ vcpu->arch.irq_summary &&
!(vmcs_read32(VM_ENTRY_INTR_INFO_FIELD) &
INTR_INFO_VALID_MASK))
/*
* If interrupts enabled, and not blocked by sti or mov
ss. Good.
@@ -1763,8 +1763,8 @@ static void do_interrupt_requests(struct kvm_vcpu
*vcpu,
kvm_do_inject_irq(vcpu);
cpu_based_vm_exec_control =
vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
- if (!vcpu->interrupt_window_open &&
- (vcpu->irq_summary || kvm_run->request_interrupt_window))
+ if (!vcpu->arch.interrupt_window_open &&
+ (vcpu->arch.irq_summary ||
kvm_run->request_interrupt_window))
/*
* Interrupts blocked. Wait for unblock.
*/
@@ -1843,8 +1843,8 @@ static int handle_exception(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
if (!irqchip_in_kernel(vcpu->kvm) &&
is_external_interrupt(vect_info)) {
int irq = vect_info & VECTORING_INFO_VECTOR_MASK;
- set_bit(irq, vcpu->irq_pending);
- set_bit(irq / BITS_PER_LONG, &vcpu->irq_summary);
+ set_bit(irq, vcpu->arch.irq_pending);
+ set_bit(irq / BITS_PER_LONG, &vcpu->arch.irq_summary);
}
if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == 0x200) /* nmi */
@@ -2110,7 +2110,7 @@ static int handle_interrupt_window(struct kvm_vcpu
*vcpu,
* possible
*/
if (kvm_run->request_interrupt_window &&
- !vcpu->irq_summary) {
+ !vcpu->arch.irq_summary) {
kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
++vcpu->stat.irq_window_exits;
return 0;
@@ -2455,7 +2455,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
if (vmx->rmode.irq.pending)
fixup_rmode_irq(vmx);
- vcpu->interrupt_window_open =
+ vcpu->arch.interrupt_window_open =
(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3) == 0;
asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 32a5686..330fafd 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -1047,8 +1047,8 @@ static int kvm_vcpu_ioctl_interrupt(struct
kvm_vcpu *vcpu,
return -ENXIO;
vcpu_load(vcpu);
- set_bit(irq->irq, vcpu->irq_pending);
- set_bit(irq->irq / BITS_PER_LONG, &vcpu->irq_summary);
+ set_bit(irq->irq, vcpu->arch.irq_pending);
+ set_bit(irq->irq / BITS_PER_LONG, &vcpu->arch.irq_summary);
vcpu_put(vcpu);
@@ -2376,9 +2376,9 @@ EXPORT_SYMBOL_GPL(kvm_emulate_cpuid);
static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
{
- return (!vcpu->irq_summary &&
+ return (!vcpu->arch.irq_summary &&
kvm_run->request_interrupt_window &&
- vcpu->interrupt_window_open &&
+ vcpu->arch.interrupt_window_open &&
(kvm_x86_ops->get_rflags(vcpu) & X86_EFLAGS_IF));
}
@@ -2392,8 +2392,8 @@ static void post_kvm_run_save(struct kvm_vcpu
*vcpu,
kvm_run->ready_for_interrupt_injection = 1;
else
kvm_run->ready_for_interrupt_injection =
- (vcpu->interrupt_window_open &&
- vcpu->irq_summary == 0);
+
(vcpu->arch.interrupt_window_open &&
+ vcpu->arch.irq_summary == 0);
}
static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
@@ -2692,7 +2692,7 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu
*vcpu,
set_bit(pending_vec,
(unsigned long
*)sregs->interrupt_bitmap);
} else
- memcpy(sregs->interrupt_bitmap, vcpu->irq_pending,
+ memcpy(sregs->interrupt_bitmap, vcpu->arch.irq_pending,
sizeof sregs->interrupt_bitmap);
vcpu_put(vcpu);
@@ -2749,12 +2749,12 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct
kvm_vcpu *vcpu,
kvm_mmu_reset_context(vcpu);
if (!irqchip_in_kernel(vcpu->kvm)) {
- memcpy(vcpu->irq_pending, sregs->interrupt_bitmap,
- sizeof vcpu->irq_pending);
- vcpu->irq_summary = 0;
- for (i = 0; i < ARRAY_SIZE(vcpu->irq_pending); ++i)
- if (vcpu->irq_pending[i])
- __set_bit(i, &vcpu->irq_summary);
+ memcpy(vcpu->arch.irq_pending, sregs->interrupt_bitmap,
+ sizeof vcpu->arch.irq_pending);
+ vcpu->arch.irq_summary = 0;
+ for (i = 0; i < ARRAY_SIZE(vcpu->arch.irq_pending); ++i)
+ if (vcpu->arch.irq_pending[i])
+ __set_bit(i, &vcpu->arch.irq_summary);
} else {
max_bits = (sizeof sregs->interrupt_bitmap) << 3;
pending_vec = find_first_bit(
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index 5fb2df3..188ff5a 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -94,13 +94,13 @@ enum {
struct kvm_vcpu_arch {
u64 host_tsc;
+ int interrupt_window_open;
+ unsigned long irq_summary; /* bit vector: 1 per word in
irq_pending */
+ DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS);
};
struct kvm_vcpu {
KVM_VCPU_COMM;
- int interrupt_window_open;
- unsigned long irq_summary; /* bit vector: 1 per word in
irq_pending */
- DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS);
unsigned long regs[NR_VCPU_REGS]; /* for rsp:
vcpu_load_rsp_rip() */
unsigned long rip; /* needs vcpu_load_rsp_rip() */
--
1.5.1.2
0002-kvm-Portability-Moving-irq-related-fields-to-arch.patch
Description: 0002-kvm-Portability-Moving-irq-related-fields-to-arch.patch
------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________ kvm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kvm-devel
