WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH] fix deadlock of ptc.ga emulation

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH] fix deadlock of ptc.ga emulation
From: Kouya SHIMURA <kouya@xxxxxxxxxxxxxx>
Date: Wed, 16 May 2007 17:35:27 +0900
Delivery-date: Wed, 16 May 2007 01:34:29 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
Sorry, my previous patch implies a bug.

ptc_ga_remote_func() might be invoked by IPI with a schedule_lock
that is acquired. (e.g., inside of vcpu_migrate())
It will cause a deadlock.

-- Kouya

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>

diff -r 94cce9a51540 xen/arch/ia64/vmx/vmmu.c
--- a/xen/arch/ia64/vmx/vmmu.c  Mon May 14 12:54:26 2007 -0600
+++ b/xen/arch/ia64/vmx/vmmu.c  Wed May 16 15:49:33 2007 +0900
@@ -567,13 +567,16 @@ static void ptc_ga_remote_func (void *va
     struct ptc_ga_args *args = (struct ptc_ga_args *)varg;
     VCPU *v = args->vcpu;
     vadr = args->vadr;
+    int cpu = v->processor;
 
     /* Try again if VCPU has migrated. */
-    if (v->processor != current->processor)
+    if (cpu != current->processor)
         return;
-    vcpu_schedule_lock_irqsave(v, flags);
-    if (v->processor != current->processor)
-        goto bail;
+    local_irq_save(flags);
+    if (!spin_trylock(&per_cpu(schedule_data, cpu).schedule_lock))
+        goto bail2;
+    if (v->processor != cpu)
+        goto bail1;
     oldrid = VMX(v, vrr[0]);
     VMX(v, vrr[0]) = args->rid;
     oldpsbits = VMX(v, psbits[0]);
@@ -591,8 +594,10 @@ static void ptc_ga_remote_func (void *va
     ia64_set_pta(mpta);
     ia64_dv_serialize_data();
     args->vcpu = NULL;
-bail:
-    vcpu_schedule_unlock_irqrestore(v, flags);
+  bail1:
+    spin_unlock(&per_cpu(schedule_data, cpu).schedule_lock);
+  bail2:
+    local_irq_restore(flags);
 }
 
 
@@ -602,7 +607,7 @@ IA64FAULT vmx_vcpu_ptc_ga(VCPU *vcpu, u6
     struct domain *d = vcpu->domain;
     struct vcpu *v;
     struct ptc_ga_args args;
-    int proc;
+    int cpu;
 
     args.vadr = va;
     vcpu_get_rr(vcpu, va, &args.rid);
@@ -618,13 +623,15 @@ IA64FAULT vmx_vcpu_ptc_ga(VCPU *vcpu, u6
 
         args.vcpu = v;
         do {
-            proc = v->processor;
-            if (proc != vcpu->processor)
+            cpu = v->processor;
+            if (cpu != current->processor) {
+                spin_unlock_wait(&per_cpu(schedule_data, cpu).schedule_lock);
                 /* Flush VHPT on remote processors. */
-                smp_call_function_single(proc, &ptc_ga_remote_func,
+                smp_call_function_single(cpu, &ptc_ga_remote_func,
                                          &args, 0, 1);
-            else
+            } else {
                 ptc_ga_remote_func(&args);
+            }
         } while (args.vcpu != NULL);
     }
     return IA64_NO_FAULT;
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>