From patchwork Fri Apr 8 14:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 558809 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp366105map; Fri, 8 Apr 2022 07:21:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBEduxJgOLMquWZC4o+/mA7cGfhXB6o08NiTG2qLmJopvj0zV7lXAHSZd9uKync1bF5xCN X-Received: by 2002:a25:abed:0:b0:641:19bc:b03c with SMTP id v100-20020a25abed000000b0064119bcb03cmr216440ybi.483.1649427676249; Fri, 08 Apr 2022 07:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649427676; cv=none; d=google.com; s=arc-20160816; b=kPgMuE3/Uq2Ykw6vFmx0WAvyE6tzDHHficlx3JYDdq2AXsQajar3h4Iznj1CJKHNZj +R//BT5D7OQ5a5wquR96VxccHZSzlBTcXjbkP0fm4GCYFGbvXv93i81PLqPH5+BM2isL 7TyO0W52Oi14sPZvkWXfxkpnsgmjBTFIXQWm/W1m3hue+o5Y/q4quKmwG8eD/qKGnn9V 86G4Jxey2mvOfyXzrtBThsGiqbTfFtSHILiLAh3LM1RbfteIS08dtSqlLd57ftNzbhX4 7Qk91t42P3Wa/tSZ8ZIbGBUlUu61S20RwC3hKByYodTb5hWQGUpjRf1qoBZ/Kz07p5C6 QTzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=kl+2ZVJ+6xTCifWmFmG6E383UT0qNH2bxah0KF3V4pw=; b=GoD20HwgZr0CzkfWWWfKrasJtGHk6qjTA22QolsofvyiAdn/lItKDTJOZlXj6EZ56i OJpDyUBv7GJfxNQBGfQ96vAmmAfI17qwXXT/qrZoLP3+zhg91u7I0vKFNWVXNxGaA4/6 +xScYJj82dCOkiZU5FC6zNQ61iPhP/7eW1BaU1kMajg+SOnkKo4/p4ljDW9KJ6d+pKnQ XW4mtXML/TGj0lGC3MwUIuWtaqOLqUbiJrEp0n040bvI8288caBQUEw/zMt09aLzEeSc 0LV7DVTBxMTC29KfgNEcSUrpa1g7H1QTrIMik1KInjTFH2i4Ab2vKlUdxbcLG5X6CUC7 09bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UvuViJ6H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m7-20020a81d247000000b002e5bb9dca58si563706ywl.225.2022.04.08.07.21.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Apr 2022 07:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UvuViJ6H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncpUB-0006CJ-NL for patch@linaro.org; Fri, 08 Apr 2022 10:21:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncpPB-0006jy-6g for qemu-devel@nongnu.org; Fri, 08 Apr 2022 10:16:05 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:42852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncpP7-0002Ex-B1 for qemu-devel@nongnu.org; Fri, 08 Apr 2022 10:16:04 -0400 Received: by mail-wm1-x333.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so4106526wmn.1 for ; Fri, 08 Apr 2022 07:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kl+2ZVJ+6xTCifWmFmG6E383UT0qNH2bxah0KF3V4pw=; b=UvuViJ6HrsF9PkyUGVohQvmwYPOmZ6yWSgOSwjfO5ZxJhLcow/WOYHKqd5temBg4Yf AXupkhUY8utXvMbGEOqhO277Mj/8S4Y1UdZRKwXha2+TV9O/61g0vIVFmae+c3O+kkkD ztcgNe5xXhCIk7tR7sCdFl4hboYdu1Eae/+p1H+x2SePT1QlYXcV6Uo+HVA63hREaBLk AMyx6MZ3UyMJmKbfGkUwTl+4ZYQ60qqX/nQPrcNHZgTpxt8b6PcUIauSMSm3yZAhpwtU 42k3LrW3WjJTjJACgnTfhsbd+VxNxG3rxde54Mx5Ng5Q0ocvTVU10+mcCamMMHvjEXKv h6lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kl+2ZVJ+6xTCifWmFmG6E383UT0qNH2bxah0KF3V4pw=; b=o2T/dmaAIlSfhLj5Eq6ckiz90TwgvhGy4TVlcftrcKnhqegyTocbB3J2wLHc0OkoKD Qlu7ace2BzTEFA3nEFd/rowamtI2gW/oohyXcypSv/lh5lng6vhtzpqLQ7uqGZJN1cOV Ihz8FZZCEI4wXutIALBR9dwSXAMjt5BlikLpr4cgapcoA/YLK+PEIKrK4qVLBF7O3sOO GrN0ZOLGAiRTgrrTRZx2VOcs+1KxJZza00VWZWk+DCftVWh6yGD+iVLSZPnHWzqoX/PI HHdeQ8OX0nJi7RzGw5tDwzwjr0k4Hk9kIZTFCi0vC+zBJucJPMLj6iAIvQDPz5c/vZ5m 7RRw== X-Gm-Message-State: AOAM530YNbDJbfUTJDjtwfa1Z9z9U+aGrq6S78wgxDflP0V48ZSrD+mI JQ3Jfqz8cStrjrezPN0TDBbW1wYxJlMzSQ== X-Received: by 2002:a05:600c:3b99:b0:38e:aa31:a864 with SMTP id n25-20020a05600c3b9900b0038eaa31a864mr1661901wms.108.1649427359902; Fri, 08 Apr 2022 07:15:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id i3-20020adffc03000000b0020616ee90dbsm11498849wrr.42.2022.04.08.07.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 07:15:59 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 06/41] hw/intc/arm_gicv3_its: Factor out "is intid a valid LPI ID?" Date: Fri, 8 Apr 2022 15:15:15 +0100 Message-Id: <20220408141550.1271295-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220408141550.1271295-1-peter.maydell@linaro.org> References: <20220408141550.1271295-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In process_mapti() we check interrupt IDs to see whether they are in the valid LPI range. Factor this out into its own utility function, as we're going to want it elsewhere too for GICv4. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/intc/arm_gicv3_its.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index f8467b61ec5..400cdf83794 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -79,6 +79,12 @@ typedef enum ItsCmdResult { CMD_CONTINUE = 1, } ItsCmdResult; +static inline bool intid_in_lpi_range(uint32_t id) +{ + return id >= GICV3_LPI_INTID_START && + id < (1ULL << (GICD_TYPER_IDBITS + 1)); +} + static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) { uint64_t result = 0; @@ -410,7 +416,6 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, uint32_t devid, eventid; uint32_t pIntid = 0; uint64_t num_eventids; - uint32_t num_intids; uint16_t icid = 0; DTEntry dte; ITEntry ite; @@ -438,7 +443,6 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, return CMD_STALL; } num_eventids = 1ULL << (dte.size + 1); - num_intids = 1ULL << (GICD_TYPER_IDBITS + 1); if (icid >= s->ct.num_entries) { qemu_log_mask(LOG_GUEST_ERROR, @@ -460,7 +464,7 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, return CMD_CONTINUE; } - if (pIntid < GICV3_LPI_INTID_START || pIntid >= num_intids) { + if (!intid_in_lpi_range(pIntid)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid interrupt ID 0x%x\n", __func__, pIntid); return CMD_CONTINUE;