From patchwork Wed Mar 26 09:57:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 27097 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BDFBB20062 for ; Wed, 26 Mar 2014 09:59:28 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf6628244oac.3 for ; Wed, 26 Mar 2014 02:59:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:references:in-reply-to:cc:subject:precedence :list-id:list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=fuEuX5b6Ue9L/px1TMT1XOrlXfqc0NIsoJB2dqhTxP8=; b=XO93v9jVYxvfokPqqG17WXAWee4z/gcUJX9Pyyg5ie7AsSfrGDIDFy7uENRd3zbjNc x1E1Qw7WAw2hLqy2sbs9lNXRIJNyJ/+gSsSoPpb8KT+PmBjen4pSEP+25nKIZzdvrqNN ypbxRcCDpVjfkO8lbs+jDvYcuD+YcYUO5vo2g9cnifA+j+mwcfxYk06xuO9EBUMwfaoG 41kFC1Zf2Giza297aDrdP+PsTQlFzdcgzx1dZYhpOzW5Ze+v9Pt8pjJIVJqI/l8DIl+r mgMyvWvGIePWGPRAp6TT7aMn61oBXxrL+bxlmma8h0oZAkG3txJn+uOlxoHz4EEdpfOr 0i3w== X-Gm-Message-State: ALoCoQlRsTew3Wl15SHB9rHylnWAzr5MeLTqA7sGqqsGkDno/Cm+VnUc1EmpgTT5oFHBZ+0nAeJY X-Received: by 10.42.13.198 with SMTP id e6mr26637714ica.21.1395827968273; Wed, 26 Mar 2014 02:59:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.33 with SMTP id c30ls608079qge.9.gmail; Wed, 26 Mar 2014 02:59:28 -0700 (PDT) X-Received: by 10.52.99.168 with SMTP id er8mr8917333vdb.26.1395827968162; Wed, 26 Mar 2014 02:59:28 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id y16si4344827vct.102.2014.03.26.02.59.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 02:59:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so1967787veb.22 for ; Wed, 26 Mar 2014 02:59:28 -0700 (PDT) X-Received: by 10.52.18.70 with SMTP id u6mr51599814vdd.11.1395827968069; Wed, 26 Mar 2014 02:59:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp33084vck; Wed, 26 Mar 2014 02:59:27 -0700 (PDT) X-Received: by 10.220.109.1 with SMTP id h1mr14606557vcp.20.1395827967614; Wed, 26 Mar 2014 02:59:27 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id b2si4350355vcy.10.2014.03.26.02.59.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 26 Mar 2014 02:59:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WSkah-0003zP-RV; Wed, 26 Mar 2014 09:57:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WSkag-0003zH-L2 for xen-devel@lists.xenproject.org; Wed, 26 Mar 2014 09:57:46 +0000 Received: from [85.158.137.68:45260] by server-1.bemta-3.messagelabs.com id 6D/66-11134-994A2335; Wed, 26 Mar 2014 09:57:45 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-31.messagelabs.com!1395827864!3002201!1 X-Originating-IP: [209.85.215.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28057 invoked from network); 26 Mar 2014 09:57:45 -0000 Received: from mail-la0-f47.google.com (HELO mail-la0-f47.google.com) (209.85.215.47) by server-11.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 26 Mar 2014 09:57:45 -0000 Received: by mail-la0-f47.google.com with SMTP id y1so1279940lam.20 for ; Wed, 26 Mar 2014 02:57:44 -0700 (PDT) X-Received: by 10.152.1.8 with SMTP id 8mr53416800lai.1.1395827864457; Wed, 26 Mar 2014 02:57:44 -0700 (PDT) Received: from [192.168.0.24] (cpc8-cmbg15-2-0-cust169.5-4.cable.virginm.net. [86.30.140.170]) by mx.google.com with ESMTPSA id eo12sm6743059lbb.13.2014.03.26.02.57.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 02:57:43 -0700 (PDT) Message-ID: <5332A496.8060506@linaro.org> Date: Wed, 26 Mar 2014 09:57:42 +0000 From: Julien Grall User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Ian Campbell References: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> <1395766541-23979-14-git-send-email-julien.grall@linaro.org> <53320FFC.4060707@linaro.org> <1395824590.29683.24.camel@dagon.hellion.org.uk> In-Reply-To: <1395824590.29683.24.camel@dagon.hellion.org.uk> Cc: xen-devel@lists.xenproject.org, tim@xen.org, stefano.stabellini@citrix.com, Stefano Stabellini Subject: Re: [Xen-devel] [PATCH 13/34] xen/arm: gic: Introduce GIC_SGI_MAX X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: On 26/03/14 09:03, Ian Campbell wrote: > Does ASSERT(sgi < GIC_SGI_MAX) not compiler without warnings? I reworked this patch (see below): commit a07ef8994c10ae45c0fa42040e802006f7a510c6 Author: Julien Grall Date: Wed Mar 19 20:51:51 2014 +0000 xen/arm: gic: Introduce GIC_SGI_MAX All the functions that send an SGI takes an enum. Therefore checking everytime if the value is in the range is not correct. Introduce GIC_SGI_MAX to check the enum will never reach more than 16 values and use it to check if the developper will use a wrong SGI by mistake. This is fix the compilation with Clang 3.5: gic.c:515:15: error: comparison of constant 16 with expression of type 'enum gic_sgi' is always true [-Werror,-Wtautological-constant-out-of-range-compare] ASSERT(sgi < 16); /* There are only 16 SGIs */ ~~~ ^ ~~ xen/xen/include/xen/lib.h:43:26: note: expanded from macro 'ASSERT' do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0) ^ xen/xen/include/xen/compiler.h:11:41: note: expanded from macro 'unlikely' #define unlikely(x) __builtin_expect((x),0) Signed-off-by: Julien Grall Cc: Ian Campbell Cc: Stefano Stabellini Cc: Tim Deegan --- Changes in v2: - Replace ASSERT(sgi != GIC_SGI_MAX) by ASSERT(sgi < GIC_SGI_MAX) Acked-by: Stefano Stabellini diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index b03f2c2..2b9cdc5 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -473,7 +473,8 @@ void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) unsigned int mask = 0; cpumask_t online_mask; - ASSERT(sgi < 16); /* There are only 16 SGIs */ + BUILD_BUG_ON(GIC_SGI_MAX >= 16); + ASSERT(sgi < GIC_SGI_MAX); cpumask_and(&online_mask, cpumask, &cpu_online_map); mask = gic_cpu_mask(&online_mask); @@ -493,7 +494,7 @@ void send_SGI_one(unsigned int cpu, enum gic_sgi sgi) void send_SGI_self(enum gic_sgi sgi) { - ASSERT(sgi < 16); /* There are only 16 SGIs */ + ASSERT(sgi < GIC_SGI_MAX); dsb(sy); @@ -503,7 +504,7 @@ void send_SGI_self(enum gic_sgi sgi) void send_SGI_allbutself(enum gic_sgi sgi) { - ASSERT(sgi < 16); /* There are only 16 SGIs */ + ASSERT(sgi < GIC_SGI_MAX); dsb(sy); diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 76586ab..a4e513f 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -198,6 +198,8 @@ enum gic_sgi { GIC_SGI_EVENT_CHECK = 0, GIC_SGI_DUMP_STATE = 1, GIC_SGI_CALL_FUNCTION = 2, + /* GIC_SGI_MAX must be the last type of the enum */ + GIC_SGI_MAX, }; extern void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi); extern void send_SGI_one(unsigned int cpu, enum gic_sgi sgi);