ia64/xen-unstable

view xen/common/compat/domain.c @ 17062:0769835cf50f

x86 shadow: Reduce scope of shadow lock.

emulate_map_dest doesn't require holding lock, since
only shadow related operation possibly involved is to
remove shadow which is less frequent and can acquire
lock inside. Rest are either guest table walk or
per-vcpu monitor table manipulation

Signed-off-by Kevin Tian <kevin.tian@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 14 10:33:12 2008 +0000 (2008-02-14)
parents 183a2d6eaadf
children 7fc474368ba8
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 int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
15 {
16 struct domain *d = current->domain;
17 struct vcpu *v;
18 long rc = 0;
20 if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) )
21 return -EINVAL;
23 if ( (v = d->vcpu[vcpuid]) == NULL )
24 return -ENOENT;
26 switch ( cmd )
27 {
28 case VCPUOP_initialise:
29 {
30 struct compat_vcpu_guest_context *cmp_ctxt;
32 if ( (cmp_ctxt = xmalloc(struct compat_vcpu_guest_context)) == NULL )
33 {
34 rc = -ENOMEM;
35 break;
36 }
38 if ( copy_from_guest(cmp_ctxt, arg, 1) )
39 {
40 xfree(cmp_ctxt);
41 rc = -EFAULT;
42 break;
43 }
45 LOCK_BIGLOCK(d);
46 rc = -EEXIST;
47 if ( !v->is_initialised )
48 rc = boot_vcpu(d, vcpuid, cmp_ctxt);
49 UNLOCK_BIGLOCK(d);
51 xfree(cmp_ctxt);
52 break;
53 }
55 case VCPUOP_up:
56 case VCPUOP_down:
57 case VCPUOP_is_up:
58 case VCPUOP_set_periodic_timer:
59 case VCPUOP_stop_periodic_timer:
60 case VCPUOP_set_singleshot_timer:
61 case VCPUOP_stop_singleshot_timer:
62 case VCPUOP_send_nmi:
63 rc = do_vcpu_op(cmd, vcpuid, arg);
64 break;
66 case VCPUOP_get_runstate_info:
67 {
68 union {
69 struct vcpu_runstate_info nat;
70 struct compat_vcpu_runstate_info cmp;
71 } runstate;
73 vcpu_runstate_get(v, &runstate.nat);
74 xlat_vcpu_runstate_info(&runstate.nat);
75 if ( copy_to_guest(arg, &runstate.cmp, 1) )
76 rc = -EFAULT;
77 break;
78 }
80 default:
81 rc = arch_compat_vcpu_op(cmd, v, arg);
82 break;
83 }
85 return rc;
86 }
88 /*
89 * Local variables:
90 * mode: C
91 * c-set-style: "BSD"
92 * c-basic-offset: 4
93 * tab-width: 4
94 * indent-tabs-mode: nil
95 * End:
96 */