|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 13/13] x86/domctl: use domain_vcpu() to handle various sub-ops
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -573,11 +573,10 @@ long arch_do_domctl(
case XEN_DOMCTL_sendtrigger:
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, domctl->u.sendtrigger.vcpu);
ret = -ESRCH;
- if ( domctl->u.sendtrigger.vcpu >= d->max_vcpus ||
- (v = d->vcpu[domctl->u.sendtrigger.vcpu]) == NULL )
+ if ( !v )
break;
switch ( domctl->u.sendtrigger.trigger )
@@ -789,11 +788,10 @@ long arch_do_domctl(
case XEN_DOMCTL_get_ext_vcpucontext:
{
struct xen_domctl_ext_vcpucontext *evc = &domctl->u.ext_vcpucontext;
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, evc->vcpu);
ret = -ESRCH;
- if ( (evc->vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[evc->vcpu]) == NULL) )
+ if ( !v )
break;
if ( domctl->cmd == XEN_DOMCTL_get_ext_vcpucontext )
@@ -912,15 +910,14 @@ long arch_do_domctl(
case XEN_DOMCTL_debug_op:
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, domctl->u.debug_op.vcpu);
ret = -EOPNOTSUPP;
if ( !IS_ENABLED(CONFIG_HVM) )
break;
ret = -EINVAL;
- if ( (domctl->u.debug_op.vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[domctl->u.debug_op.vcpu]) == NULL) )
+ if ( !v )
break;
ret = -EINVAL;
@@ -943,15 +940,14 @@ long arch_do_domctl(
case XEN_DOMCTL_getvcpuextstate:
{
struct xen_domctl_vcpuextstate *evc = &domctl->u.vcpuextstate;
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, evc->vcpu);
uint32_t offset = 0;
#define PV_XSAVE_HDR_SIZE (2 * sizeof(uint64_t))
#define PV_XSAVE_SIZE(xcr0) (PV_XSAVE_HDR_SIZE +
xstate_uncompressed_size(xcr0))
ret = -ESRCH;
- if ( (evc->vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[evc->vcpu]) == NULL) )
+ if ( !v )
goto vcpuextstate_out;
ret = -EINVAL;
@@ -1148,7 +1144,7 @@ long arch_do_domctl(
{
struct xen_domctl_vcpu_msrs *vmsrs = &domctl->u.vcpu_msrs;
struct xen_domctl_vcpu_msr msr = {};
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, vmsrs->vcpu);
static const uint32_t msrs_to_send[] = {
MSR_SPEC_CTRL,
MSR_INTEL_MISC_FEATURES_ENABLES,
@@ -1161,8 +1157,7 @@ long arch_do_domctl(
uint32_t nr_msrs = ARRAY_SIZE(msrs_to_send);
ret = -ESRCH;
- if ( (vmsrs->vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[vmsrs->vcpu]) == NULL) )
+ if ( !v )
break;
ret = -EINVAL;
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |