public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* Handle INIT before SIPI.
@ 2008-10-16 15:20 Gleb Natapov
  2008-10-19  9:42 ` Avi Kivity
  2008-10-21  2:34 ` Xu, Dongxiao
  0 siblings, 2 replies; 4+ messages in thread
From: Gleb Natapov @ 2008-10-16 15:20 UTC (permalink / raw)
  To: avi; +Cc: kvm


Handle INIT before SIPI.
    
If SIPI was issued before CPU handled INIT signal the CPU is not reseted.
    
Signed-off-by: Gleb Natapov <gleb@redhat.com>

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 577f2b2..dae05b0 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -349,13 +349,20 @@ static void update_regs_for_sipi(CPUState *env)
 {
     kvm_arch_update_regs_for_sipi(env);
     vcpu_info[env->cpu_index].sipi_needed = 0;
-    vcpu_info[env->cpu_index].init = 0;
 }
 
 static void update_regs_for_init(CPUState *env)
 {
+    SegmentCache cs = env->segs[R_CS];
+
     cpu_reset(env);
+
+    /* restore SIPI vector */
+    if(vcpu_info[env->cpu_index].sipi_needed)
+        env->segs[R_CS] = cs;
+
     kvm_arch_load_regs(env);
+    vcpu_info[env->cpu_index].init = 0;
 }
 
 static void setup_kernel_sigmask(CPUState *env)
@@ -411,10 +418,12 @@ static int kvm_main_loop_cpu(CPUState *env)
 	    kvm_main_loop_wait(env, 1000);
 	if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI))
 	    env->halted = 0;
-	if (!kvm_irqchip_in_kernel(kvm_context) && info->sipi_needed)
-	    update_regs_for_sipi(env);
-	if (!kvm_irqchip_in_kernel(kvm_context) && info->init)
-	    update_regs_for_init(env);
+    if (!kvm_irqchip_in_kernel(kvm_context)) {
+	    if (info->init)
+	        update_regs_for_init(env);
+	    if (info->sipi_needed)
+	        update_regs_for_sipi(env);
+    }
 	if (!env->halted && !info->init)
 	    kvm_cpu_exec(env);
 	env->interrupt_request &= ~CPU_INTERRUPT_EXIT;
--
			Gleb.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Handle INIT before SIPI.
  2008-10-16 15:20 Handle INIT before SIPI Gleb Natapov
@ 2008-10-19  9:42 ` Avi Kivity
  2008-10-21  2:34 ` Xu, Dongxiao
  1 sibling, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2008-10-19  9:42 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm

Gleb Natapov wrote:
> Handle INIT before SIPI.
>     
> If SIPI was issued before CPU handled INIT signal the CPU is not reseted.
>     
>   

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Handle INIT before SIPI.
  2008-10-16 15:20 Handle INIT before SIPI Gleb Natapov
  2008-10-19  9:42 ` Avi Kivity
@ 2008-10-21  2:34 ` Xu, Dongxiao
  2008-10-22 12:48   ` Gleb Natapov
  1 sibling, 1 reply; 4+ messages in thread
From: Xu, Dongxiao @ 2008-10-21  2:34 UTC (permalink / raw)
  To: Gleb Natapov, avi@redhat.com
  Cc: kvm@vger.kernel.org, kvm-ia64@vger.kernel.org

Hi, Gleb,
    It seems that this patch is x86 specific, and it breaks the IA-64 compilation. Do you have any good idea to solve this? Thanks!

Best Regards,
-- Dongxiao

-----Original Message-----
From: kvm-owner@vger.kernel.org [mailto:kvm-owner@vger.kernel.org] On Behalf Of Gleb Natapov
Sent: 2008年10月16日 23:21
To: avi@redhat.com
Cc: kvm@vger.kernel.org
Subject: Handle INIT before SIPI.


Handle INIT before SIPI.

If SIPI was issued before CPU handled INIT signal the CPU is not reseted.

Signed-off-by: Gleb Natapov <gleb@redhat.com>

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 577f2b2..dae05b0 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -349,13 +349,20 @@ static void update_regs_for_sipi(CPUState *env)
 {
     kvm_arch_update_regs_for_sipi(env);
     vcpu_info[env->cpu_index].sipi_needed = 0;
-    vcpu_info[env->cpu_index].init = 0;
 }

 static void update_regs_for_init(CPUState *env)
 {
+    SegmentCache cs = env->segs[R_CS];
+
     cpu_reset(env);
+
+    /* restore SIPI vector */
+    if(vcpu_info[env->cpu_index].sipi_needed)
+        env->segs[R_CS] = cs;
+
     kvm_arch_load_regs(env);
+    vcpu_info[env->cpu_index].init = 0;
 }

 static void setup_kernel_sigmask(CPUState *env)
@@ -411,10 +418,12 @@ static int kvm_main_loop_cpu(CPUState *env)
            kvm_main_loop_wait(env, 1000);
        if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI))
            env->halted = 0;
-       if (!kvm_irqchip_in_kernel(kvm_context) && info->sipi_needed)
-           update_regs_for_sipi(env);
-       if (!kvm_irqchip_in_kernel(kvm_context) && info->init)
-           update_regs_for_init(env);
+    if (!kvm_irqchip_in_kernel(kvm_context)) {
+           if (info->init)
+               update_regs_for_init(env);
+           if (info->sipi_needed)
+               update_regs_for_sipi(env);
+    }
        if (!env->halted && !info->init)
            kvm_cpu_exec(env);
        env->interrupt_request &= ~CPU_INTERRUPT_EXIT;
--
                        Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Handle INIT before SIPI.
  2008-10-21  2:34 ` Xu, Dongxiao
@ 2008-10-22 12:48   ` Gleb Natapov
  0 siblings, 0 replies; 4+ messages in thread
From: Gleb Natapov @ 2008-10-22 12:48 UTC (permalink / raw)
  To: Xu, Dongxiao
  Cc: avi@redhat.com, kvm@vger.kernel.org, kvm-ia64@vger.kernel.org

On Tue, Oct 21, 2008 at 10:34:12AM +0800, Xu, Dongxiao wrote:
> Hi, Gleb,
>     It seems that this patch is x86 specific, and it breaks the IA-64 compilation. Do you have any good idea to solve this? Thanks!
> 
Solve this by ifdefs for now. For better solution cleanup of SMP
handling is needed.

Signed-off-by: Gleb Natapov <gleb@redhat.com>

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 67d1de9..c5f3f29 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -353,16 +353,20 @@ static void update_regs_for_sipi(CPUState *env)
 
 static void update_regs_for_init(CPUState *env)
 {
+#ifdef TARGET_I386
     SegmentCache cs = env->segs[R_CS];
+#endif
 
     cpu_reset(env);
 
+#ifdef TARGET_I386
     /* restore SIPI vector */
     if(vcpu_info[env->cpu_index].sipi_needed)
         env->segs[R_CS] = cs;
 
-    kvm_arch_load_regs(env);
     vcpu_info[env->cpu_index].init = 0;
+#endif
+    kvm_arch_load_regs(env);
 }
 
 static void setup_kernel_sigmask(CPUState *env)
--
			Gleb.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-10-22 12:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-16 15:20 Handle INIT before SIPI Gleb Natapov
2008-10-19  9:42 ` Avi Kivity
2008-10-21  2:34 ` Xu, Dongxiao
2008-10-22 12:48   ` Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox