mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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>
This commit is contained in:
1 parent
2d94bc491a
commit
2d7d54adfd
3 files changed
+17
-22
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+15
-12
@@ -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) )
|
||||
|
||||