debuggers.hg

view xen/common/compat/domain.c @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 5c0bf00e371d
line source
1 /******************************************************************************
2 * domain.c
3 *
4 */
6 #include <xen/config.h>
7 #include <xen/lib.h>
8 #include <xen/sched.h>
9 #include <xen/domain.h>
10 #include <xen/guest_access.h>
11 #include <xen/hypercall.h>
12 #include <compat/vcpu.h>
14 #define xen_vcpu_set_periodic_timer vcpu_set_periodic_timer
15 CHECK_vcpu_set_periodic_timer;
16 #undef xen_vcpu_set_periodic_timer
18 int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
19 {
20 struct domain *d = current->domain;
21 struct vcpu *v;
22 int rc = 0;
24 if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) )
25 return -EINVAL;
27 if ( (v = d->vcpu[vcpuid]) == NULL )
28 return -ENOENT;
30 switch ( cmd )
31 {
32 case VCPUOP_initialise:
33 {
34 struct compat_vcpu_guest_context *cmp_ctxt;
36 if ( (cmp_ctxt = xmalloc(struct compat_vcpu_guest_context)) == NULL )
37 {
38 rc = -ENOMEM;
39 break;
40 }
42 if ( copy_from_guest(cmp_ctxt, arg, 1) )
43 {
44 xfree(cmp_ctxt);
45 rc = -EFAULT;
46 break;
47 }
49 domain_lock(d);
50 rc = -EEXIST;
51 if ( !v->is_initialised )
52 rc = boot_vcpu(d, vcpuid, cmp_ctxt);
53 domain_unlock(d);
55 xfree(cmp_ctxt);
56 break;
57 }
59 case VCPUOP_up:
60 case VCPUOP_down:
61 case VCPUOP_is_up:
62 case VCPUOP_set_periodic_timer:
63 case VCPUOP_stop_periodic_timer:
64 case VCPUOP_stop_singleshot_timer:
65 case VCPUOP_send_nmi:
66 rc = do_vcpu_op(cmd, vcpuid, arg);
67 break;
69 case VCPUOP_get_runstate_info:
70 {
71 union {
72 struct vcpu_runstate_info nat;
73 struct compat_vcpu_runstate_info cmp;
74 } runstate;
76 vcpu_runstate_get(v, &runstate.nat);
77 xlat_vcpu_runstate_info(&runstate.nat);
78 if ( copy_to_guest(arg, &runstate.cmp, 1) )
79 rc = -EFAULT;
80 break;
81 }
83 case VCPUOP_set_singleshot_timer:
84 {
85 struct compat_vcpu_set_singleshot_timer cmp;
86 struct vcpu_set_singleshot_timer *nat;
88 if ( copy_from_guest(&cmp, arg, 1) )
89 return -EFAULT;
90 nat = (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id);
91 XLAT_vcpu_set_singleshot_timer(nat, &cmp);
92 rc = do_vcpu_op(cmd, vcpuid, guest_handle_from_ptr(nat, void));
93 break;
94 }
96 default:
97 rc = arch_compat_vcpu_op(cmd, v, arg);
98 break;
99 }
101 return rc;
102 }
104 /*
105 * Local variables:
106 * mode: C
107 * c-set-style: "BSD"
108 * c-basic-offset: 4
109 * tab-width: 4
110 * indent-tabs-mode: nil
111 * End:
112 */