From patchwork Sat Jan 18 15:39:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 11340141 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56F1C17EA for ; Sat, 18 Jan 2020 15:40:44 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C8DE20728 for ; Sat, 18 Jan 2020 15:40:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C8DE20728 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isqCA-0002Js-NX; Sat, 18 Jan 2020 15:39:30 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isqC9-0002Jn-Eb for xen-devel@lists.xenproject.org; Sat, 18 Jan 2020 15:39:29 +0000 X-Inumbo-ID: b5cfc1e4-3a08-11ea-b74a-12813bfff9fa Received: from mail-wr1-f65.google.com (unknown [209.85.221.65]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b5cfc1e4-3a08-11ea-b74a-12813bfff9fa; Sat, 18 Jan 2020 15:39:27 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id c14so25394986wrn.7 for ; Sat, 18 Jan 2020 07:39:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SU5vRiHtz0LXgwj6/4FgHV0+8NkUOLc0keDDb9+i/ak=; b=Vxg5staP2x67gP7eKpqcZlC+c2ABxloWG3T0u1azJ0JBorPBSPJA7pCWuvRNPvdCaI i3KYyI/l1BwtefngMAZtvx2Gq7cnWpe3+7QfrwNAhruWioyInKQAcapR0WxtwT1vTZ3i OWy4K5U93LUODLLU4QZeRWISNxQb6tloL+2DGwluUWA8s49xZqSmgoDzgTPYrHXCnS/Q 4TuDo+8uxP4itCfLZ6RQmMxDawDZ/vik0t9x1T69Ei0Efr3s1OrIVyZl3GuA3x97zMIi EJDxb1EWudRYdeDgrn9fxe+RyjNZPUVdDt37IOHztrLTfXWt3fAPYwwLsg5JVuAczW+R QmPA== X-Gm-Message-State: APjAAAV+L91zt/4FgJn4LgNWU/Zn7s0TMtsk4H331axwXN1NxpPdsQPe i5qqPTM7qS9WCp4mR9d8+rI4IBwEBobufw== X-Google-Smtp-Source: APXvYqxLErFM49esb6u/4FEvt6xbC2kpw0UrcNXii8P2QyAxv30fgFLk0zGlwjnnwPAigc5du/7JZA== X-Received: by 2002:adf:dd46:: with SMTP id u6mr8711249wrm.13.1579361966646; Sat, 18 Jan 2020 07:39:26 -0800 (PST) Received: from ufe34d9ed68d054.ant.amazon.com (54-240-197-235.amazon.com. [54.240.197.235]) by smtp.gmail.com with ESMTPSA id f1sm39985114wrp.93.2020.01.18.07.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jan 2020 07:39:26 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Sat, 18 Jan 2020 15:39:24 +0000 Message-Id: <20200118153924.10878-1-julien@xen.org> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH] xen/arm: gic: Remove pointless assertion against enum gic_sgi X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Andrii Anisov MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The Arm Compiler will complain that the assertions ASSERT(sgi < 16) is always true. This is because sgi is a item of the enum gic_sgi and should always contain less than 16 SGIs. Rather than using ASSERTs, introduce a new item in the num that could be checked against a build time. Take the opportunity to remove the specific assigned values for each items. This is fine because enum always starts at zero and values will be assigned by increment of one. None of our code also rely on hardcoded value. Signed-off-by: Julien Grall CC: Andrii Anisov Reviewed-by: Stefano Stabellini --- xen/arch/arm/gic.c | 12 ++++++------ xen/include/asm-arm/gic.h | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 113655a789..d623c57cb9 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -44,6 +44,12 @@ DEFINE_PER_CPU(uint64_t, lr_mask); const struct gic_hw_operations *gic_hw_ops; +static void __init __maybe_unused build_assertions(void) +{ + /* Check our enum gic_sgi only covers SGIs */ + BUILD_BUG_ON(GIC_SGI_MAX > NR_GIC_SGI); +} + void register_gic_ops(const struct gic_hw_operations *ops) { gic_hw_ops = ops; @@ -294,8 +300,6 @@ void __init gic_init(void) void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) { - ASSERT(sgi < 16); /* There are only 16 SGIs */ - gic_hw_ops->send_SGI(sgi, SGI_TARGET_LIST, cpumask); } @@ -306,15 +310,11 @@ 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 */ - gic_hw_ops->send_SGI(sgi, SGI_TARGET_SELF, NULL); } void send_SGI_allbutself(enum gic_sgi sgi) { - ASSERT(sgi < 16); /* There are only 16 SGIs */ - gic_hw_ops->send_SGI(sgi, SGI_TARGET_OTHERS, NULL); } diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 793d324b33..ba870523bb 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -277,9 +277,10 @@ extern void gic_restore_state(struct vcpu *v); /* SGI (AKA IPIs) */ enum gic_sgi { - GIC_SGI_EVENT_CHECK = 0, - GIC_SGI_DUMP_STATE = 1, - GIC_SGI_CALL_FUNCTION = 2, + GIC_SGI_EVENT_CHECK, + GIC_SGI_DUMP_STATE, + GIC_SGI_CALL_FUNCTION, + GIC_SGI_MAX, }; /* SGI irq mode types */