* pre-preparation for in-kernel device model
@ 2007-06-05 9:28 Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A018E0662-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Dong, Eddie @ 2007-06-05 9:28 UTC (permalink / raw)
To: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 1201 bytes --]
When in kernel device model is introduced, the guest interrupt status
may get changed when after it injected an IRQ and thus guest see a
messed interrupt state. This patch tries to disable irq at that window
to avoid the confusion.
Signed-off-by: Yaozu (Eddie) Dong <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index ef9e32b..0cf6ea7 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1977,9 +1977,6 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
int r;
preempted:
- if (!vcpu->mmio_read_completed)
- do_interrupt_requests(vcpu, kvm_run);
-
if (vcpu->guest_debug.enabled)
kvm_guest_debug_pre(vcpu);
@@ -1996,9 +1993,16 @@ again:
*/
vmcs_writel(HOST_CR0, read_cr0());
+ /*
+ * Disable interrupt to avoid future in kernel
+ * APIC interrupt state confuse.
+ */
+ asm ( "pushf; cli \n\t");
+ if (!vcpu->mmio_read_completed)
+ do_interrupt_requests(vcpu, kvm_run);
+
asm (
/* Store host registers */
- "pushf \n\t"
#ifdef CONFIG_X86_64
"push %%rax; push %%rbx; push %%rdx;"
"push %%rsi; push %%rdi; push %%rbp;"
[-- Attachment #2: cli.patch --]
[-- Type: application/octet-stream, Size: 822 bytes --]
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index ef9e32b..0cf6ea7 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1977,9 +1977,6 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
int r;
preempted:
- if (!vcpu->mmio_read_completed)
- do_interrupt_requests(vcpu, kvm_run);
-
if (vcpu->guest_debug.enabled)
kvm_guest_debug_pre(vcpu);
@@ -1996,9 +1993,16 @@ again:
*/
vmcs_writel(HOST_CR0, read_cr0());
+ /*
+ * Disable interrupt to avoid future in kernel
+ * APIC interrupt state confuse.
+ */
+ asm ( "pushf; cli \n\t");
+ if (!vcpu->mmio_read_completed)
+ do_interrupt_requests(vcpu, kvm_run);
+
asm (
/* Store host registers */
- "pushf \n\t"
#ifdef CONFIG_X86_64
"push %%rax; push %%rbx; push %%rdx;"
"push %%rsi; push %%rdi; push %%rbp;"
[-- Attachment #3: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- 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] 3+ messages in thread
* Re: pre-preparation for in-kernel device model
[not found] ` <10EA09EFD8728347A513008B6B0DA77A018E0662-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-06-05 11:32 ` Avi Kivity
0 siblings, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2007-06-05 11:32 UTC (permalink / raw)
To: Dong, Eddie; +Cc: kvm-devel
Dong, Eddie wrote:
> When in kernel device model is introduced, the guest interrupt status
> may get changed when after it injected an IRQ and thus guest see a
> messed interrupt state. This patch tries to disable irq at that window
> to avoid the confusion.
>
>
> Signed-off-by: Yaozu (Eddie) Dong <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
>
>
> diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
> index ef9e32b..0cf6ea7 100644
> --- a/drivers/kvm/vmx.c
> +++ b/drivers/kvm/vmx.c
> @@ -1977,9 +1977,6 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu,
> struct kvm_run *kvm_run)
> int r;
>
> preempted:
> - if (!vcpu->mmio_read_completed)
> - do_interrupt_requests(vcpu, kvm_run);
> -
> if (vcpu->guest_debug.enabled)
> kvm_guest_debug_pre(vcpu);
>
> @@ -1996,9 +1993,16 @@ again:
> */
> vmcs_writel(HOST_CR0, read_cr0());
>
> + /*
> + * Disable interrupt to avoid future in kernel
> + * APIC interrupt state confuse.
> + */
> + asm ( "pushf; cli \n\t");
> + if (!vcpu->mmio_read_completed)
> + do_interrupt_requests(vcpu, kvm_run);
> +
>
This is broken. pushf changes %rsp, and if the compiler uses %rsp based
addressing (-fomit-frame-pointer), it will use the wrong addresses for
variables.
Suggest using local_irq_disable()/local_irq_enable() (and removing
pushf/popf from the entry/exit sequence).
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: pre-preparation for in-kernel device model
@ 2007-06-05 12:13 Gregory Haskins
0 siblings, 0 replies; 3+ messages in thread
From: Gregory Haskins @ 2007-06-05 12:13 UTC (permalink / raw)
To: eddie.dong-ral2JQCrhuEAvxtiuMwx3w, avi-atKUWr5tajBWk0Htik3J/w
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Note that we already disable interrupts before getting here once the APIC series is applied, so this patch is either not necessary, or someone needs to merge this into the lapic branch and clean it up.
Regards,
-Greg
>>> Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> 06/05/07 7:32 AM >>>
Dong, Eddie wrote:
> When in kernel device model is introduced, the guest interrupt status
> may get changed when after it injected an IRQ and thus guest see a
> messed interrupt state. This patch tries to disable irq at that window
> to avoid the confusion.
>
>
> Signed-off-by: Yaozu (Eddie) Dong <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
>
>
> diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
> index ef9e32b..0cf6ea7 100644
> --- a/drivers/kvm/vmx.c
> +++ b/drivers/kvm/vmx.c
> @@ -1977,9 +1977,6 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu,
> struct kvm_run *kvm_run)
> int r;
>
> preempted:
> - if (!vcpu->mmio_read_completed)
> - do_interrupt_requests(vcpu, kvm_run);
> -
> if (vcpu->guest_debug.enabled)
> kvm_guest_debug_pre(vcpu);
>
> @@ -1996,9 +1993,16 @@ again:
> */
> vmcs_writel(HOST_CR0, read_cr0());
>
> + /*
> + * Disable interrupt to avoid future in kernel
> + * APIC interrupt state confuse.
> + */
> + asm ( "pushf; cli \n\t");
> + if (!vcpu->mmio_read_completed)
> + do_interrupt_requests(vcpu, kvm_run);
> +
>
This is broken. pushf changes %rsp, and if the compiler uses %rsp based
addressing (-fomit-frame-pointer), it will use the wrong addresses for
variables.
Suggest using local_irq_disable()/local_irq_enable() (and removing
pushf/popf from the entry/exit sequence).
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-06-05 12:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-05 9:28 pre-preparation for in-kernel device model Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A018E0662-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-06-05 11:32 ` Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2007-06-05 12:13 Gregory Haskins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox