From patchwork Sat Dec 11 19:11:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 523088 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp4116937imb; Sat, 11 Dec 2021 11:43:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxc2KLn7upF1eo4DTsYafvZN08JY7dFjE8sNpu+LoFAm/HnBhhsQ1k+8P6Uk1GShVEDWdAZ X-Received: by 2002:a05:620a:856:: with SMTP id u22mr26605459qku.141.1639251831331; Sat, 11 Dec 2021 11:43:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639251831; cv=none; d=google.com; s=arc-20160816; b=oQOed6BGyqR7a3fWgP8rIvr0ulLijDovml77zQ1j/qd9+xGyvH877pLEe2sw/JmNgq YPJEhlgZGMQTkD3ADPzBTiF2eLRniqOyToybRWAqfO1N6FquywGzXPZI7nk15MDU/vtn xBrAEgrHlcs3HpS7c3ImSzD6a1y5CvXpiR8lliXDziXddiVDnVmrLbg0bwDwaS4WvIUw FUfY85E1y3oTzs7TWNwJsyiMlb0y0+/XBHMM8grKhVunKLBth15pxuQkdvB4HFAozVuy 26O2UXjCTw+ZaLX2/elQYD15I20M8bIrnv+knLCDuZEupllXVFlLgHVTq6NZlxFOkVv7 uKXg== 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=uBlXpUi7Hc739T7tIMt8EUkZsoHbYKvygpVzCX6VAv0=; b=ZBxAyu2z9TtAzuteez0QiDYR0xwJOz0bOOLYqpuYVzLzR88+Do9nIT4mZ+yR4+EolY yHx6x0+iafmlFzWJb2wwwU321zQe2NmQobesw0BAljndHuHGq3hDXkiGGmT6nx+4OHG4 u262/DFKIEHOldgupcomDANNhEB2FlNHHwSV8natsXEN0d7Bi0pYgaB/IhMfaHK+FyAj EhXmQ7phdSBcf3bzE26vMaFUnlkOa9futzwNgrVnO3TySpETGzvlzHtj9k1jE6jMvjSm ZY3lSJZNFutSnTqdbhRRjr7If6F4tCIfNFU0nyyaTZYeSFNypVS2DB5jrFHXP5Nq4ctk zX4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="oQg/6Rud"; 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=fail (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 j13si8344537qkp.536.2021.12.11.11.43.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 11 Dec 2021 11:43:51 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b="oQg/6Rud"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mw8He-0007fq-QO for patch@linaro.org; Sat, 11 Dec 2021 14:43:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mw7mo-00050j-Tz for qemu-devel@nongnu.org; Sat, 11 Dec 2021 14:11:58 -0500 Received: from [2a00:1450:4864:20::434] (port=34745 helo=mail-wr1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mw7mc-0006EE-Vz for qemu-devel@nongnu.org; Sat, 11 Dec 2021 14:11:55 -0500 Received: by mail-wr1-x434.google.com with SMTP id j3so20403901wrp.1 for ; Sat, 11 Dec 2021 11:11:46 -0800 (PST) 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=uBlXpUi7Hc739T7tIMt8EUkZsoHbYKvygpVzCX6VAv0=; b=oQg/6RudXIkBQ3sX/9WqZX9vpDw8N98BBqqt1Z9z74BWHN7QfbI2n+uv/T6I8rgnWz AjfJALJt3h3uZBJS4Sed090WPqQHpXkk+EUE4iCY2GlJN6TeH14iPFl7hhsL1PEq/pDu lBnz0NvvROBe7hj4WzvCfSoyEnxaRMCd/7ZavJyfkQdITV3Nw60Kkfi/4rbAa5f0QSYu O3klkX4hisf9vFTgSoyFmvbt9I3zaKTbVdOyKMWjArxjQkoCTJTjq1ovd9J3aldmK+12 s489apBy4mJ0KaMCcPCyo04HiK9nymGggEPH1vAeJFf5GMLUFWGc019UAEEaMejcrOFK Ik8A== 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=uBlXpUi7Hc739T7tIMt8EUkZsoHbYKvygpVzCX6VAv0=; b=AY/KmqZxNnjmgenmVcVpBeGXUod+Fi5bX6Lv+oR3c1no0/Tv0ebYWLDydMAbnG8sBs a/vqPd0XhBnF6dFmKB6Vq26KCGDKI+jI+t+pHaXxr0eBuHC8sBNhy17z4rJ1Kk/9wisY N2Dty5L/PxZyqWKAYvVUaDOHW6Za3TPAm9bOFjqTlOru3hovqty/ELdPdRnZP+Gv5oam 6vzR0wRa8UOKXWZggWAAA0ZZ+sX5ySDpIk1r0bjggBUSnOg6lAWvKGTOxIBlrlUIoqyd hUnMgSadCif1IHOD76zkrVLE187KqDXyc7J5qW2hmy9rWE3+1cWHou+XMC8AIJbYk60t 2Phw== X-Gm-Message-State: AOAM5339WEGeX71gdcJRtFiqTrGOl6JpviH1vAPEk/hY4mIFcJYplAdt QbmUG8rkT29ifVsb/8GjyKZ02w== X-Received: by 2002:a05:6000:120a:: with SMTP id e10mr21795346wrx.156.1639249905650; Sat, 11 Dec 2021 11:11:45 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id m20sm2205300wmq.11.2021.12.11.11.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Dec 2021 11:11:45 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 09/26] hw/intc/arm_gicv3_its: Correct handling of MAPI Date: Sat, 11 Dec 2021 19:11:18 +0000 Message-Id: <20211211191135.1764649-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211211191135.1764649-1-peter.maydell@linaro.org> References: <20211211191135.1764649-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::434 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Shashi Mallela , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The MAPI command takes arguments DeviceID, EventID, ICID, and is defined to be equivalent to MAPTI DeviceID, EventID, EventID, ICID. (That is, where MAPTI takes an explicit pINTID, MAPI uses the EventID as the pINTID.) We didn't quite get this right. In particular the error checks for MAPI include "EventID does not specify a valid LPI identifier", which is the same as MAPTI's error check for the pINTID field. QEMU's code skips the pINTID error check entirely in the MAPI case. We can fix this bug and in the process simplify the code by switching to the obvious implementation of setting pIntid = eventid early if ignore_pInt is true. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée --- hw/intc/arm_gicv3_its.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index 15eb72a0a15..6f21c56fba2 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -354,7 +354,9 @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, eventid = (value & EVENTID_MASK); - if (!ignore_pInt) { + if (ignore_pInt) { + pIntid = eventid; + } else { pIntid = ((value & pINTID_MASK) >> pINTID_SHIFT); } @@ -377,14 +379,12 @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, max_eventid = (1UL << (((dte >> 1U) & SIZE_MASK) + 1)); - if (!ignore_pInt) { - max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1; - } + max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1; if ((devid > s->dt.max_ids) || (icid > s->ct.max_ids) || !dte_valid || (eventid > max_eventid) || - (!ignore_pInt && (((pIntid < GICV3_LPI_INTID_START) || - (pIntid > max_Intid)) && (pIntid != INTID_SPURIOUS)))) { + (((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) && + (pIntid != INTID_SPURIOUS))) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid command attributes " "devid %d or icid %d or eventid %d or pIntid %d or" @@ -400,11 +400,7 @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, IteEntry ite = {}; ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid); ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL); - if (ignore_pInt) { - ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, eventid); - } else { - ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid); - } + ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid); ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS); ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);