From patchwork Tue Mar 25 16:55:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 27050 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E0FDE20539 for ; Tue, 25 Mar 2014 16:57:22 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id n16sf2886902oag.1 for ; Tue, 25 Mar 2014 09:57:21 -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:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=dnCgxz977TUEDNC+RU2CpAVyc1CST0Aa0VkwF/zL3P4=; b=Rbt+lRQsti712NzRx58mkd6I0leeYAUSmOED3iw19kVCGtAj/Fe7obU99Nttwo0H4c s9AhDNc6vjCkXTKYQngeE2YVeKdqUsfK+1ugxztKd/TNwzl75aLYY4rm3eRidjyZq2f7 t78+GO+Ioeo5671bZ7TExhdNdCRYktHgqI2lFEIROzvAnyvXBuQ0ZaCrG3R7UvbFWJIz p1KrxQCodwNK60ljjwk1S8GShZgB4btysQFH2nqK9LSofZHoUgcMFrLanGxN98purCxG oPED3MxEMrlBRvsMGMdNjhidMS+gDFrOSdpH5mVp15/oUL3W6aqR2Es6HSVCF/MhodUm dnEg== X-Gm-Message-State: ALoCoQmYGMbDrQKfAkra+NOnMPQ7zrStp2fc95G28fpergtMNDT3ISu7IbKZek6gUVy3IFNbSGNR X-Received: by 10.50.47.6 with SMTP id z6mr8355430igm.4.1395766641796; Tue, 25 Mar 2014 09:57:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.133 with SMTP id v5ls267963qgv.23.gmail; Tue, 25 Mar 2014 09:57:21 -0700 (PDT) X-Received: by 10.52.138.112 with SMTP id qp16mr762546vdb.40.1395766641679; Tue, 25 Mar 2014 09:57:21 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id wy9si2610206vdc.127.2014.03.25.09.57.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 09:57:21 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ik5so917923vcb.14 for ; Tue, 25 Mar 2014 09:57:21 -0700 (PDT) X-Received: by 10.221.22.71 with SMTP id qv7mr821773vcb.34.1395766641600; Tue, 25 Mar 2014 09:57:21 -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 i9csp320305vck; Tue, 25 Mar 2014 09:57:21 -0700 (PDT) X-Received: by 10.224.115.68 with SMTP id h4mr83597837qaq.35.1395766641097; Tue, 25 Mar 2014 09:57:21 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id p59si8892278qga.125.2014.03.25.09.57.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 25 Mar 2014 09:57:21 -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 1WSUeA-0008UT-Ua; Tue, 25 Mar 2014 16:56:18 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WSUe9-0008SG-6K for xen-devel@lists.xenproject.org; Tue, 25 Mar 2014 16:56:17 +0000 Received: from [193.109.254.147:9882] by server-15.bemta-14.messagelabs.com id 8D/BB-15813-035B1335; Tue, 25 Mar 2014 16:56:16 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-14.tower-27.messagelabs.com!1395766575!4060719!1 X-Originating-IP: [74.125.83.51] 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 22575 invoked from network); 25 Mar 2014 16:56:15 -0000 Received: from mail-ee0-f51.google.com (HELO mail-ee0-f51.google.com) (74.125.83.51) by server-14.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 25 Mar 2014 16:56:15 -0000 Received: by mail-ee0-f51.google.com with SMTP id c13so684260eek.24 for ; Tue, 25 Mar 2014 09:56:15 -0700 (PDT) X-Received: by 10.14.115.1 with SMTP id d1mr70662651eeh.30.1395766575631; Tue, 25 Mar 2014 09:56:15 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id h47sm33377501eey.13.2014.03.25.09.56.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2014 09:56:14 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 25 Mar 2014 16:55:20 +0000 Message-Id: <1395766541-23979-14-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> References: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [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: , MIME-Version: 1.0 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.220.169 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: 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. 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 --- xen/arch/arm/gic.c | 7 ++++--- xen/include/asm-arm/gic.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 0095b97..41142a5 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -481,7 +481,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); @@ -501,7 +502,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); @@ -511,7 +512,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 071280b..968125d 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -205,6 +205,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);