* [PATCH] Hoist push_irq/pop_irq into kvm.h
@ 2007-08-01 0:11 Rusty Russell
[not found] ` <1185927064.6131.108.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Rusty Russell @ 2007-08-01 0:11 UTC (permalink / raw)
To: kvm-devel
Everyone can use push_irq() and pop_irq(), so move them to common code.
Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
diff -r f48242856f1c drivers/kvm/kvm.h
--- a/drivers/kvm/kvm.h Wed Aug 01 09:57:03 2007 +1000
+++ b/drivers/kvm/kvm.h Wed Aug 01 10:06:10 2007 +1000
@@ -716,6 +716,24 @@ static inline u32 get_rdx_init_val(void)
return 0x600; /* P6 family */
}
+static inline u8 kvm_pop_irq(struct kvm_vcpu *vcpu)
+{
+ int word_index = __ffs(vcpu->irq_summary);
+ int bit_index = __ffs(vcpu->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);
+ return irq;
+}
+
+static inline void kvm_push_irq(struct kvm_vcpu *vcpu, u8 irq)
+{
+ set_bit(irq, vcpu->irq_pending);
+ set_bit(irq / BITS_PER_LONG, &vcpu->irq_summary);
+}
+
#define ASM_VMX_VMCLEAR_RAX ".byte 0x66, 0x0f, 0xc7, 0x30"
#define ASM_VMX_VMLAUNCH ".byte 0x0f, 0x01, 0xc2"
#define ASM_VMX_VMRESUME ".byte 0x0f, 0x01, 0xc3"
diff -r f48242856f1c drivers/kvm/kvm_main.c
--- a/drivers/kvm/kvm_main.c Wed Aug 01 09:57:03 2007 +1000
+++ b/drivers/kvm/kvm_main.c Wed Aug 01 10:06:10 2007 +1000
@@ -2232,10 +2232,7 @@ static int kvm_vcpu_ioctl_interrupt(stru
if (irq->irq < 0 || irq->irq >= 256)
return -EINVAL;
vcpu_load(vcpu);
-
- set_bit(irq->irq, vcpu->irq_pending);
- set_bit(irq->irq / BITS_PER_LONG, &vcpu->irq_summary);
-
+ kvm_push_irq(vcpu, irq->irq);
vcpu_put(vcpu);
return 0;
diff -r f48242856f1c drivers/kvm/svm.c
--- a/drivers/kvm/svm.c Wed Aug 01 09:57:03 2007 +1000
+++ b/drivers/kvm/svm.c Wed Aug 01 10:06:29 2007 +1000
@@ -110,24 +110,6 @@ static unsigned get_addr_size(struct vcp
return (cs_attrib & SVM_SELECTOR_L_MASK) ? 8 :
(cs_attrib & SVM_SELECTOR_DB_MASK) ? 4 : 2;
-}
-
-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 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);
- 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);
}
static inline void clgi(void)
@@ -936,7 +918,7 @@ static int pf_interception(struct vcpu_s
int r;
if (is_external_interrupt(exit_int_info))
- push_irq(&svm->vcpu, exit_int_info & SVM_EVTINJ_VEC_MASK);
+ kvm_push_irq(&svm->vcpu, exit_int_info & SVM_EVTINJ_VEC_MASK);
mutex_lock(&kvm->lock);
@@ -1424,7 +1406,7 @@ static inline void inject_irq(struct vcp
struct vmcb_control_area *control;
control = &svm->vmcb->control;
- control->int_vector = pop_irq(&svm->vcpu);
+ control->int_vector = kvm_pop_irq(&svm->vcpu);
control->int_ctl &= ~V_INTR_PRIO_MASK;
control->int_ctl |= V_IRQ_MASK |
((/*control->int_vector >> 4*/ 0xf) << V_INTR_PRIO_SHIFT);
@@ -1436,7 +1418,7 @@ static void reput_irq(struct vcpu_svm *s
if (control->int_ctl & V_IRQ_MASK) {
control->int_ctl &= ~V_IRQ_MASK;
- push_irq(&svm->vcpu, control->int_vector);
+ kvm_push_irq(&svm->vcpu, control->int_vector);
}
svm->vcpu.interrupt_window_open =
diff -r f48242856f1c drivers/kvm/vmx.c
--- a/drivers/kvm/vmx.c Wed Aug 01 09:57:03 2007 +1000
+++ b/drivers/kvm/vmx.c Wed Aug 01 10:06:10 2007 +1000
@@ -1578,13 +1578,7 @@ static void inject_rmode_irq(struct kvm_
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 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);
+ int irq = kvm_pop_irq(vcpu);
if (vcpu->rmode.active) {
inject_rmode_irq(vcpu, irq);
@@ -1675,11 +1669,8 @@ static int handle_exception(struct kvm_v
"intr info 0x%x\n", __FUNCTION__, vect_info, intr_info);
}
- if (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);
- }
+ if (is_external_interrupt(vect_info))
+ kvm_push_irq(vcpu, vect_info & VECTORING_INFO_VECTOR_MASK);
if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == 0x200) { /* nmi */
asm ("int $2");
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Hoist push_irq/pop_irq into kvm.h
[not found] ` <1185927064.6131.108.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2007-08-01 18:39 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2007-08-01 18:39 UTC (permalink / raw)
To: Rusty Russell; +Cc: kvm-devel
Rusty Russell wrote:
> Everyone can use push_irq() and pop_irq(), so move them to common code.
>
>
This area is a bit raw right now due to the lapic branch, so I'll drop
this for now. Sorry as it is obviously a good one.
We'll revisit this once that branch is merged.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-01 18:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-01 0:11 [PATCH] Hoist push_irq/pop_irq into kvm.h Rusty Russell
[not found] ` <1185927064.6131.108.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-08-01 18:39 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox