ia64/xen-unstable

changeset 16172:d251f99b55e7

[IA64] ti domain save/restore: libxc: add support set/get_hvmcontext support

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Sun Oct 21 14:45:20 2007 -0600 (2007-10-21)
parents e7d7a4adf357
children c1e272707063
files xen/arch/ia64/xen/dom0_ops.c
line diff
     1.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Sun Oct 21 14:39:07 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Sun Oct 21 14:45:20 2007 -0600
     1.3 @@ -24,6 +24,9 @@
     1.4  #include <xen/errno.h>
     1.5  #include <xen/nodemask.h>
     1.6  #include <asm/dom_fw_utils.h>
     1.7 +#include <asm/hvm/support.h>
     1.8 +#include <xsm/xsm.h>
     1.9 +#include <public/hvm/save.h>
    1.10  
    1.11  #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
    1.12  
    1.13 @@ -234,6 +237,112 @@ long arch_do_domctl(xen_domctl_t *op, XE
    1.14      }
    1.15      break;
    1.16  
    1.17 +    case XEN_DOMCTL_sethvmcontext:
    1.18 +    { 
    1.19 +        struct hvm_domain_context c;
    1.20 +        struct domain *d;
    1.21 +
    1.22 +        c.cur = 0;
    1.23 +        c.size = op->u.hvmcontext.size;
    1.24 +        c.data = NULL;
    1.25 +        
    1.26 +        ret = -ESRCH;
    1.27 +        d = rcu_lock_domain_by_id(op->domain);
    1.28 +        if (d == NULL)
    1.29 +            break;
    1.30 +
    1.31 +#ifdef CONFIG_X86
    1.32 +        ret = xsm_hvmcontext(d, op->cmd);
    1.33 +        if (ret)
    1.34 +            goto sethvmcontext_out;
    1.35 +#endif /* CONFIG_X86 */
    1.36 +
    1.37 +        ret = -EINVAL;
    1.38 +        if (!is_hvm_domain(d)) 
    1.39 +            goto sethvmcontext_out;
    1.40 +
    1.41 +        ret = -ENOMEM;
    1.42 +        c.data = xmalloc_bytes(c.size);
    1.43 +        if (c.data == NULL)
    1.44 +            goto sethvmcontext_out;
    1.45 +
    1.46 +        ret = -EFAULT;
    1.47 +        if (copy_from_guest(c.data, op->u.hvmcontext.buffer, c.size) != 0)
    1.48 +            goto sethvmcontext_out;
    1.49 +
    1.50 +        domain_pause(d);
    1.51 +        ret = hvm_load(d, &c);
    1.52 +        domain_unpause(d);
    1.53 +
    1.54 +    sethvmcontext_out:
    1.55 +        if (c.data != NULL)
    1.56 +            xfree(c.data);
    1.57 +
    1.58 +        rcu_unlock_domain(d);
    1.59 +    }
    1.60 +    break;
    1.61 +
    1.62 +    case XEN_DOMCTL_gethvmcontext:
    1.63 +    { 
    1.64 +        struct hvm_domain_context c;
    1.65 +        struct domain *d;
    1.66 +
    1.67 +        ret = -ESRCH;
    1.68 +        d = rcu_lock_domain_by_id(op->domain);
    1.69 +        if (d == NULL)
    1.70 +            break;
    1.71 +
    1.72 +#ifdef CONFIG_X86
    1.73 +        ret = xsm_hvmcontext(d, op->cmd);
    1.74 +        if (ret)
    1.75 +            goto gethvmcontext_out;
    1.76 +#endif /* CONFIG_X86 */
    1.77 +
    1.78 +        ret = -EINVAL;
    1.79 +        if (!is_hvm_domain(d)) 
    1.80 +            goto gethvmcontext_out;
    1.81 +
    1.82 +        c.cur = 0;
    1.83 +        c.size = hvm_save_size(d);
    1.84 +        c.data = NULL;
    1.85 +
    1.86 +        if (guest_handle_is_null(op->u.hvmcontext.buffer)) {
    1.87 +            /* Client is querying for the correct buffer size */
    1.88 +            op->u.hvmcontext.size = c.size;
    1.89 +            ret = 0;
    1.90 +            goto gethvmcontext_out;            
    1.91 +        }
    1.92 +
    1.93 +        /* Check that the client has a big enough buffer */
    1.94 +        ret = -ENOSPC;
    1.95 +        if (op->u.hvmcontext.size < c.size) 
    1.96 +            goto gethvmcontext_out;
    1.97 +
    1.98 +        /* Allocate our own marshalling buffer */
    1.99 +        ret = -ENOMEM;
   1.100 +        c.data = xmalloc_bytes(c.size);
   1.101 +        if (c.data == NULL)
   1.102 +            goto gethvmcontext_out;
   1.103 +
   1.104 +        domain_pause(d);
   1.105 +        ret = hvm_save(d, &c);
   1.106 +        domain_unpause(d);
   1.107 +
   1.108 +        op->u.hvmcontext.size = c.cur;
   1.109 +        if (copy_to_guest(op->u.hvmcontext.buffer, c.data, c.size) != 0)
   1.110 +            ret = -EFAULT;
   1.111 +
   1.112 +    gethvmcontext_out:
   1.113 +        if (copy_to_guest(u_domctl, op, 1))
   1.114 +            ret = -EFAULT;
   1.115 +
   1.116 +        if (c.data != NULL)
   1.117 +            xfree(c.data);
   1.118 +
   1.119 +        rcu_unlock_domain(d);
   1.120 +    }
   1.121 +    break;
   1.122 +
   1.123      default:
   1.124          printk("arch_do_domctl: unrecognized domctl: %d!!!\n",op->cmd);
   1.125          ret = -ENOSYS;