From: Keir Fraser Date: Fri, 20 Jan 2012 10:13:55 +0000 (+0000) Subject: xen: Simplify callers of boot_vcpu(). In VCPUOP_up, check X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~9222 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2d7d54adfddce658c056a8c87dd74b3766db01a3;p=xen.git xen: Simplify callers of boot_vcpu(). In VCPUOP_up, check is_initialised under the per-domain lock. Signed-off-by: Keir Fraser --- 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) )