From: Andrew Cooper Subject: [PATCH 4/4] xen/many: Drop redundant MAX_VIRT_CPUS bounds checks Date: Mon, 19 Jan 2015 11:21:36 +0000 Message-ID: <1421666496-10676-5-git-send-email-andrew.cooper3@citrix.com> References: <1421666496-10676-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1421666496-10676-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Keir Fraser , Ian Campbell , Andrew Cooper , Tim Deegan , Stefano Stabellini , Jan Beulich List-Id: xen-devel@lists.xenproject.org In all 4 cases, visible in the context are bounds check against d->max_vcpus. Domain building will ensure that d->max_vcpus never exceeds an appropriate bound. In the x86 case, different types of domains have different maxima for vcpus, making the checks wrong as opposed to simply redundant. For vpsci in ARM, 'vcpuid' is an unsigned type so could never be less than 0. For the common changes to do_{,compat}_vcpu_op(), these changes do result in a guest visible change, but only in so far as certain invalid vcpu ids will now fail with -ENOENT rather than -EINVAL. Signed-off-by: Andrew Cooper CC: Keir Fraser CC: Jan Beulich CC: Ian Campbell CC: Stefano Stabellini CC: Tim Deegan --- xen/arch/arm/vpsci.c | 3 --- xen/arch/x86/domctl.c | 4 ---- xen/common/compat/domain.c | 3 --- xen/common/domain.c | 3 --- 4 files changed, 13 deletions(-) diff --git a/xen/arch/arm/vpsci.c b/xen/arch/arm/vpsci.c index 3f2a482..5d899be 100644 --- a/xen/arch/arm/vpsci.c +++ b/xen/arch/arm/vpsci.c @@ -37,9 +37,6 @@ static int do_common_cpu_on(register_t target_cpu, register_t entry_point, else vcpuid = target_cpu; - if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) ) - return PSCI_INVALID_PARAMETERS; - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL ) return PSCI_INVALID_PARAMETERS; diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 82365a4..a1c5db0 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -541,10 +541,6 @@ long arch_do_domctl( { struct vcpu *v; - ret = -EINVAL; - if ( domctl->u.sendtrigger.vcpu >= MAX_VIRT_CPUS ) - break; - ret = -ESRCH; if ( domctl->u.sendtrigger.vcpu >= d->max_vcpus || (v = d->vcpu[domctl->u.sendtrigger.vcpu]) == NULL ) diff --git a/xen/common/compat/domain.c b/xen/common/compat/domain.c index 510843d..3ca4ef7 100644 --- a/xen/common/compat/domain.c +++ b/xen/common/compat/domain.c @@ -29,9 +29,6 @@ int compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) ar struct vcpu *v; int rc = 0; - if ( vcpuid >= MAX_VIRT_CPUS ) - return -EINVAL; - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL ) return -ENOENT; diff --git a/xen/common/domain.c b/xen/common/domain.c index e02823e..0b05681 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1146,9 +1146,6 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) struct vcpu_guest_context *ctxt; long rc = 0; - if ( vcpuid >= MAX_VIRT_CPUS ) - return -EINVAL; - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL ) return -ENOENT; -- 1.7.10.4