aboutsummaryrefslogtreecommitdiffstats
path: root/xen
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2012-01-20 10:13:55 +0000
committerKeir Fraser <keir@xen.org>2012-01-20 10:13:55 +0000
commit2d7d54adfddce658c056a8c87dd74b3766db01a3 (patch)
tree0e79e37e1d532fed7b2bef0cd55cede2fea76c0a /xen
parent2d94bc491a586d28d00575b52ea60cc08c71f7b6 (diff)
downloadxen-2d7d54adfddce658c056a8c87dd74b3766db01a3.tar.gz
xen-2d7d54adfddce658c056a8c87dd74b3766db01a3.tar.bz2
xen-2d7d54adfddce658c056a8c87dd74b3766db01a3.zip
xen: Simplify callers of boot_vcpu(). In VCPUOP_up, check
is_initialised under the per-domain lock. Signed-off-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen')
-rw-r--r--xen/arch/x86/hvm/hvm.c6
-rw-r--r--xen/common/compat/domain.c6
-rw-r--r--xen/common/domain.c27
3 files changed, 17 insertions, 22 deletions
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 01c1411e0b..554afa3ac9 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -685,11 +685,7 @@ static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
}
/* Need to init this vcpu before loading its contents */
- rc = 0;
- domain_lock(d);
- if ( !v->is_initialised )
- rc = boot_vcpu(d, vcpuid, NULL);
- domain_unlock(d);
+ rc = boot_vcpu(d, vcpuid, NULL);
if ( rc != 0 )
return rc;
diff --git a/xen/common/compat/domain.c b/xen/common/compat/domain.c
index 67e0e5e316..cf8c6df254 100644
--- a/xen/common/compat/domain.c
+++ b/xen/common/compat/domain.c
@@ -46,11 +46,7 @@ int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
break;
}
- domain_lock(d);
- rc = -EEXIST;
- if ( !v->is_initialised )
- rc = boot_vcpu(d, vcpuid, cmp_ctxt);
- domain_unlock(d);
+ rc = boot_vcpu(d, vcpuid, cmp_ctxt);
xfree(cmp_ctxt);
break;
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 52a63efb82..2cc6ab150c 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -781,10 +781,13 @@ void domain_unpause_by_systemcontroller(struct domain *d)
int boot_vcpu(struct domain *d, int vcpuid, vcpu_guest_context_u ctxt)
{
struct vcpu *v = d->vcpu[vcpuid];
+ int rc;
- BUG_ON(v->is_initialised);
+ domain_lock(d);
+ rc = v->is_initialised ? -EEXIST : arch_set_info_guest(v, ctxt);
+ domain_unlock(d);
- return arch_set_info_guest(v, ctxt);
+ return rc;
}
void vcpu_reset(struct vcpu *v)
@@ -844,23 +847,23 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
return -EFAULT;
}
- domain_lock(d);
- rc = -EEXIST;
- if ( !v->is_initialised )
- rc = boot_vcpu(d, vcpuid, ctxt);
- domain_unlock(d);
+ rc = boot_vcpu(d, vcpuid, ctxt);
free_vcpu_guest_context(ctxt);
break;
- case VCPUOP_up:
+ case VCPUOP_up: {
+ bool_t wake = 0;
+ domain_lock(d);
if ( !v->is_initialised )
- return -EINVAL;
-
- if ( test_and_clear_bit(_VPF_down, &v->pause_flags) )
+ rc = -EINVAL;
+ else
+ wake = test_and_clear_bit(_VPF_down, &v->pause_flags);
+ domain_unlock(d);
+ if ( wake )
vcpu_wake(v);
-
break;
+ }
case VCPUOP_down:
if ( !test_and_set_bit(_VPF_down, &v->pause_flags) )