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-devel

Re: [Xen-devel] [PATCH] kexec: framework and i386 (Take X)

Hi, Horms

When I tried your patch, I had compile errors.
If you use xchg(), you should get return value of xchg().
The above compile error occurre at the below part.

+void crash_kexec(struct cpu_user_regs *regs)
+{
+    int locked;
+
+    locked = xchg(&kexec_crash_lock, 1);
+    if (locked)
+        return;
+    __crash_kexec(regs);
+    xchg(&kexec_crash_lock, 0); <-------------this one
+}
+
+static int get_crash_note(int vcpuid, XEN_GUEST_HANDLE(void) uarg)
+{
+    struct domain *domain = current->domain;
+    unsigned long crash_note;
+    struct vcpu *vcpu;
+    int locked;
+
+    if (vcpuid < 0 || vcpuid > MAX_VIRT_CPUS)
+       return -EINVAL;
+
+    if ( ! (vcpu = domain->vcpu[vcpuid]) )
+       return -EINVAL;
+
+    locked = xchg(&kexec_crash_lock, 1);
+    if (locked)
+    {
+       printk("do_kexec: (CMD_kexec_crash_note): dump is locked\n");
+       return -EFAULT;
+    }
+    crash_note = __pa((unsigned long)per_cpu(crash_notes, vcpu->
processor));
+    xchg(&kexec_crash_lock, 0); <-------------this one
+
+    if ( unlikely(copy_to_guest(uarg, &crash_note, 1) != 0) )
+    {
+        printk("do_kexec: (CMD_kexec_crash_note): copy_to_guest failed
\n");
+        return -EFAULT;
+    }
+    
+    return 0;
+}
+
+int do_kexec(unsigned long op, int arg1, XEN_GUEST_HANDLE(void) uarg)
+{
+    xen_kexec_image_t *image;
+    int locked;
+    int *image_set;
+    int status = -EINVAL;
+
+    if ( !IS_PRIV(current->domain) )  
+        return -EPERM;
+
+    switch (op)
+    {
+    case KEXEC_CMD_kexec_crash_note:
+        return get_crash_note(arg1, uarg);
+    case KEXEC_CMD_kexec_reserve:
+       return get_reserve(uarg);
+    }
+
+    /* For all other ops, arg1 is the type of kexec, that is
+     * KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH */
+    if (arg1 == KEXEC_TYPE_CRASH)
+    {
+        image = &kexec_crash_image;
+        image_set = &kexec_crash_image_set;
+        locked = xchg(&kexec_crash_lock, 1);
+        if (locked)
+        {
+           printk("do_kexec: dump is locked\n");
+           return -EFAULT;
+        }
+    }
+    else
+    {
+        image = &kexec_image;
+        image_set = &kexec_image_set;
+    }
+
+    switch(op) {
+    case KEXEC_CMD_kexec:
+        BUG_ON(!*image_set);
+       status = __do_kexec(arg1, uarg, image);
+        break;
+    case KEXEC_CMD_kexec_load:
+        BUG_ON(*image_set);
+        if ( unlikely(copy_from_guest(image, uarg, 1) != 0) )
+        {
+            printk("do_kexec (CMD_kexec_load): copy_from_guest failed\n
");
+            status = -EFAULT;
+           break;
+        }
+        *image_set = 1;
+        status = machine_kexec_load(arg1, image);
+        break;
+    case KEXEC_CMD_kexec_unload:
+        BUG_ON(!*image_set);
+        *image_set = 0;
+        machine_kexec_unload(arg1, image);
+        status = 0;
+        break;
+    }
+
+    if (arg1 == KEXEC_TYPE_CRASH)
+        xchg(&kexec_crash_lock, 0);  <-------------this one
+    return status;
+}
+


Best Regards,

Akio Takebe


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [Xen-devel] [PATCH] kexec: framework and i386 (Take X), Akio Takebe <=