From: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
To: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: [PATCH] Hoist push_irq/pop_irq into kvm.h
Date: Wed, 01 Aug 2007 10:11:04 +1000 [thread overview]
Message-ID: <1185927064.6131.108.camel@localhost.localdomain> (raw)
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/
next reply other threads:[~2007-08-01 0:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-01 0:11 Rusty Russell [this message]
[not found] ` <1185927064.6131.108.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-08-01 18:39 ` [PATCH] Hoist push_irq/pop_irq into kvm.h Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1185927064.6131.108.camel@localhost.localdomain \
--to=rusty-8n+1lvoiyb80n/f98k4iww@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.