* [PATCH 2/2] make the injection of interrupts run at sleepable mode.
@ 2007-10-15 21:25 Izik Eidus
[not found] ` <4713DAD3.90904-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Izik Eidus @ 2007-10-15 21:25 UTC (permalink / raw)
To: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0013-this-patch-make-the-injection-of-interrupts-run-at-s.patch --]
[-- Type: text/x-patch, Size: 3780 bytes --]
>From c5761ef6c1333062a7cd9d5b0003955bc7b7a93e Mon Sep 17 00:00:00 2001
From: Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Date: Mon, 15 Oct 2007 23:16:42 +0200
Subject: [PATCH] this patch make the injection of interrupts run at sleepable mode.
Signed-off-by: Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
---
drivers/kvm/kvm.h | 3 +++
drivers/kvm/kvm_main.c | 20 ++++++++++++++++++--
drivers/kvm/svm.c | 1 +
drivers/kvm/vmx.c | 6 ++++--
4 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 74b427f..0b12a98 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -68,6 +68,7 @@
* vcpu->requests bit members
*/
#define KVM_TLB_FLUSH 0
+#define VMX_INJECT_RMODE_IRQ 1
/*
* Address types:
@@ -319,6 +320,7 @@ struct kvm_vcpu {
int guest_mode;
unsigned long requests;
unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */
+ int inject_rmode_irq;
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() */
@@ -520,6 +522,7 @@ struct kvm_x86_ops {
void (*inject_pending_irq)(struct kvm_vcpu *vcpu);
void (*inject_pending_vectors)(struct kvm_vcpu *vcpu,
struct kvm_run *run);
+ void (*vmx_inject_rmode_irq)(struct kvm_vcpu *vcpu, int irq);
};
extern struct kvm_x86_ops *kvm_x86_ops;
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index f58d49b..0e2bbe5 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2178,6 +2178,10 @@ again:
if (unlikely(r))
goto out;
+vmx_inject_rmode:
+ if (test_and_clear_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests))
+ kvm_x86_ops->vmx_inject_rmode_irq(vcpu, vcpu->inject_rmode_irq);
+
preempt_disable();
kvm_x86_ops->prepare_guest_switch(vcpu);
@@ -2194,10 +2198,22 @@ again:
goto out;
}
- if (irqchip_in_kernel(vcpu->kvm))
+ if (irqchip_in_kernel(vcpu->kvm)) {
kvm_x86_ops->inject_pending_irq(vcpu);
- else if (!vcpu->mmio_read_completed)
+ if (test_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests)) {
+ local_irq_enable();
+ preempt_enable();
+ goto vmx_inject_rmode;
+ }
+ }
+ else if (!vcpu->mmio_read_completed) {
kvm_x86_ops->inject_pending_vectors(vcpu, kvm_run);
+ if (test_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests)) {
+ local_irq_enable();
+ preempt_enable();
+ goto vmx_inject_rmode;
+ }
+ }
vcpu->guest_mode = 1;
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index f643379..77b19be 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1732,6 +1732,7 @@ static struct kvm_x86_ops svm_x86_ops = {
.set_irq = svm_set_irq,
.inject_pending_irq = svm_intr_assist,
.inject_pending_vectors = do_interrupt_requests,
+ .vmx_inject_rmode_irq = NULL,
};
static int __init svm_init(void)
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 2d75599..f014971 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1678,10 +1678,11 @@ static void inject_rmode_irq(struct kvm_vcpu *vcpu, int irq)
vmcs_writel(GUEST_RSP, (vmcs_readl(GUEST_RSP) & ~0xffff) | (sp - 6));
}
-static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq)
+void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq)
{
if (vcpu->rmode.active) {
- inject_rmode_irq(vcpu, irq);
+ vcpu->inject_rmode_irq = irq;
+ set_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests);
return;
}
vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
@@ -2539,6 +2540,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
.set_irq = vmx_inject_irq,
.inject_pending_irq = vmx_intr_assist,
.inject_pending_vectors = do_interrupt_requests,
+ .vmx_inject_rmode_irq = inject_rmode_irq,
};
static int __init vmx_init(void)
--
1.5.2.4
[-- Attachment #3: Type: text/plain, Size: 314 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread[parent not found: <4713DAD3.90904-atKUWr5tajBWk0Htik3J/w@public.gmane.org>]
* Re: [PATCH 2/2] make the injection of interrupts run at sleepable mode. [not found] ` <4713DAD3.90904-atKUWr5tajBWk0Htik3J/w@public.gmane.org> @ 2007-10-16 1:31 ` Glauber de Oliveira Costa [not found] ` <5d6222a80710151831p7ad47090qb478b304f6478859-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2007-10-16 9:41 ` Avi Kivity 2007-10-17 2:00 ` [PATCH 2/2] make the injection of interrupts run atsleepable mode Dong, Eddie 2 siblings, 1 reply; 6+ messages in thread From: Glauber de Oliveira Costa @ 2007-10-16 1:31 UTC (permalink / raw) To: Izik Eidus; +Cc: kvm-devel On 10/15/07, Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote: I just took a quick overview on it, but to start with, why does it use a vmx specific naming ? -- Glauber de Oliveira Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act." ------------------------------------------------------------------------- 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] 6+ messages in thread
[parent not found: <5d6222a80710151831p7ad47090qb478b304f6478859-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 2/2] make the injection of interrupts run at sleepable mode. [not found] ` <5d6222a80710151831p7ad47090qb478b304f6478859-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2007-10-16 6:32 ` Izik Eidus 0 siblings, 0 replies; 6+ messages in thread From: Izik Eidus @ 2007-10-16 6:32 UTC (permalink / raw) To: Glauber de Oliveira Costa; +Cc: kvm-devel Glauber de Oliveira Costa wrote: > On 10/15/07, Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote: > > I just took a quick overview on it, but to start with, why does it use > a vmx specific naming ? > > beacuse the problem is in the emulator function that the vmx have to run inside unsleepable mode for real mode. svm have no such problem ------------------------------------------------------------------------- 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] 6+ messages in thread
* Re: [PATCH 2/2] make the injection of interrupts run at sleepable mode. [not found] ` <4713DAD3.90904-atKUWr5tajBWk0Htik3J/w@public.gmane.org> 2007-10-16 1:31 ` Glauber de Oliveira Costa @ 2007-10-16 9:41 ` Avi Kivity 2007-10-17 2:00 ` [PATCH 2/2] make the injection of interrupts run atsleepable mode Dong, Eddie 2 siblings, 0 replies; 6+ messages in thread From: Avi Kivity @ 2007-10-16 9:41 UTC (permalink / raw) To: Izik Eidus; +Cc: kvm-devel Izik Eidus wrote: > diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h > index 74b427f..0b12a98 100644 > --- a/drivers/kvm/kvm.h > +++ b/drivers/kvm/kvm.h > @@ -68,6 +68,7 @@ > * vcpu->requests bit members > */ > #define KVM_TLB_FLUSH 0 > +#define VMX_INJECT_RMODE_IRQ 1 > > /* > * Address types: > @@ -319,6 +320,7 @@ struct kvm_vcpu { > int guest_mode; > unsigned long requests; > unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */ > + int inject_rmode_irq; > 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() */ > @@ -520,6 +522,7 @@ struct kvm_x86_ops { > void (*inject_pending_irq)(struct kvm_vcpu *vcpu); > void (*inject_pending_vectors)(struct kvm_vcpu *vcpu, > struct kvm_run *run); > + void (*vmx_inject_rmode_irq)(struct kvm_vcpu *vcpu, int irq); > }; > > extern struct kvm_x86_ops *kvm_x86_ops; > diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c > index f58d49b..0e2bbe5 100644 > --- a/drivers/kvm/kvm_main.c > +++ b/drivers/kvm/kvm_main.c > @@ -2178,6 +2178,10 @@ again: > if (unlikely(r)) > goto out; > > +vmx_inject_rmode: > + if (test_and_clear_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests)) > + kvm_x86_ops->vmx_inject_rmode_irq(vcpu, vcpu->inject_rmode_irq); > + > preempt_disable(); > > kvm_x86_ops->prepare_guest_switch(vcpu); > @@ -2194,10 +2198,22 @@ again: > goto out; > } > > - if (irqchip_in_kernel(vcpu->kvm)) > + if (irqchip_in_kernel(vcpu->kvm)) { > kvm_x86_ops->inject_pending_irq(vcpu); > - else if (!vcpu->mmio_read_completed) > + if (test_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests)) { > + local_irq_enable(); > + preempt_enable(); > + goto vmx_inject_rmode; > + } > + } > + else if (!vcpu->mmio_read_completed) { > kvm_x86_ops->inject_pending_vectors(vcpu, kvm_run); > + if (test_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests)) { > + local_irq_enable(); > + preempt_enable(); > + goto vmx_inject_rmode; > + } > + } > > This exposes a minor implementation details (how real mode irqs are injected on intel) to the core code. How about we move all interrupt injection out of the critical section? That will improve latency as well. -- 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] 6+ messages in thread
* Re: [PATCH 2/2] make the injection of interrupts run atsleepable mode. [not found] ` <4713DAD3.90904-atKUWr5tajBWk0Htik3J/w@public.gmane.org> 2007-10-16 1:31 ` Glauber de Oliveira Costa 2007-10-16 9:41 ` Avi Kivity @ 2007-10-17 2:00 ` Dong, Eddie [not found] ` <10EA09EFD8728347A513008B6B0DA77A023A7914-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> 2 siblings, 1 reply; 6+ messages in thread From: Dong, Eddie @ 2007-10-17 2:00 UTC (permalink / raw) To: Izik Eidus, kvm-devel Not quit understand the following code. If we just set a vcpu request bits w/o real irq injection, we can't resume to guest? Othrewise, the guest is in interruptable state and can see irq pending, but it doesn't get the interrupt. Something missing? thx,eddie --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c @@ -1678,10 +1678,11 @@ static void inject_rmode_irq(struct kvm_vcpu *vcpu, int irq) vmcs_writel(GUEST_RSP, (vmcs_readl(GUEST_RSP) & ~0xffff) | (sp - 6)); } -static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq) +void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq) { if (vcpu->rmode.active) { - inject_rmode_irq(vcpu, irq); + vcpu->inject_rmode_irq = irq; + set_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests); return; } vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, ------------------------------------------------------------------------- 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] 6+ messages in thread
[parent not found: <10EA09EFD8728347A513008B6B0DA77A023A7914-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>]
* Re: [PATCH 2/2] make the injection of interrupts run atsleepable mode. [not found] ` <10EA09EFD8728347A513008B6B0DA77A023A7914-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> @ 2007-10-17 6:54 ` Izik Eidus 0 siblings, 0 replies; 6+ messages in thread From: Izik Eidus @ 2007-10-17 6:54 UTC (permalink / raw) To: Dong, Eddie; +Cc: kvm-devel Dong, Eddie wrote: > Not quit understand the following code. If we just set > a vcpu request bits w/o real irq injection, we can't resume > to guest? Othrewise, the guest is in interruptable state and can > see irq pending, but it doesn't get the interrupt. > > Something missing? > thx,eddie > > > --- a/drivers/kvm/vmx.c > +++ b/drivers/kvm/vmx.c > @@ -1678,10 +1678,11 @@ static void inject_rmode_irq(struct kvm_vcpu > *vcpu, int irq) > vmcs_writel(GUEST_RSP, (vmcs_readl(GUEST_RSP) & ~0xffff) | (sp - > 6)); > } > > -static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq) > +void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq) > { > if (vcpu->rmode.active) { > - inject_rmode_irq(vcpu, irq); > + vcpu->inject_rmode_irq = irq; > + set_bit(VMX_INJECT_RMODE_IRQ, &vcpu->requests); > return; > } > vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, > > this come wont be applied anyway, avi wrote a better solution that was applied. ------------------------------------------------------------------------- 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] 6+ messages in thread
end of thread, other threads:[~2007-10-17 6:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-15 21:25 [PATCH 2/2] make the injection of interrupts run at sleepable mode Izik Eidus
[not found] ` <4713DAD3.90904-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-16 1:31 ` Glauber de Oliveira Costa
[not found] ` <5d6222a80710151831p7ad47090qb478b304f6478859-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-10-16 6:32 ` Izik Eidus
2007-10-16 9:41 ` Avi Kivity
2007-10-17 2:00 ` [PATCH 2/2] make the injection of interrupts run atsleepable mode Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A023A7914-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-17 6:54 ` Izik Eidus
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox