From patchwork Thu Jan 20 12:36:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 533591 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp73374imr; Thu, 20 Jan 2022 10:59:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNiTOLovh5MoFajXM/iLTdjR3/EGyv/uLzvGkyY0a9wXzWbTWRqvC9b7rQbG8dIImn9pP4 X-Received: by 2002:a25:b683:: with SMTP id s3mr615462ybj.293.1642705179668; Thu, 20 Jan 2022 10:59:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642705179; cv=none; d=google.com; s=arc-20160816; b=E8W26NPBQVtorPBXYKAxljFAyMW+7oATa7T0nNgBnQrKiFo5PI1EcBz+36R0bCDEAA GKpVeM9KL4tZsKomT5lxiejPAagXithl5E8p8Mi1L2+HurhMqoEd3DQvrKvt8uJL5X1d 9qnKJP6iXGyHakO/oqZ9IBtxCK1RVWoWqx2mAatTCR6EWkqkC0A1ZihfR1l8PbUCgaHO 4afwJoqU3cajWyggNAQhKWNQEHtx3pa4O3dXn6CPLlq4/WBXFVZaw2yob9ooz0W6m9aX eBjoGwdJ/1FFPGTczpvbDHfioN1bKpZ2EC1DXhttH1HcR+hKJOs/STYDZfMausk0eGxi UYxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=7nY0b1HBA88jl9CMGGuocMVxAzKzMYWQu1cE8ZasydY=; b=QgKzSzWOSj3LMQg/ePdcSDFNMdC3ZE1K7d5rG0mEnJTLCPjgJ8+Z+FbTqSOZQCwYus jVctGmhiFF3yFfzuw4mdnjQ3BaRiKdwrVVVGDFsJZ1scLsd74rhCpJRgUvSkSJqtqu2u X5Yalbnva0fmy30IY9K3BeyLY+5293KHEyq8qtK3Bta3CQdwIhdytmoQ9TGvZN9YtL9O cHw7N+AjUpIzv4YftU/Bn2Zf3CC9wt1J7SrMnBxFdUa09Q281H253uDO+ZpEQlJp/OKu mjLXRX5/TKHEIpbwfCPSz2oUsWVtjkJd3HYQd65nFHaHQOA/pfPirF+HLg5cklerIZbI flJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pHLdSz+Z; 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 v192si3808503ybb.542.2022.01.20.10.59.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Jan 2022 10:59:39 -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=pass header.i=@linaro.org header.s=google header.b=pHLdSz+Z; 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]:41692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAcep-0004ru-4V for patch@linaro.org; Thu, 20 Jan 2022 13:59:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAWgm-0004Jo-1H for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:37:16 -0500 Received: from [2a00:1450:4864:20::333] (port=45853 helo=mail-wm1-x333.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAWgi-0003Ji-BX for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:37:15 -0500 Received: by mail-wm1-x333.google.com with SMTP id j5-20020a05600c1c0500b0034d2e956aadso13332088wms.4 for ; Thu, 20 Jan 2022 04:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7nY0b1HBA88jl9CMGGuocMVxAzKzMYWQu1cE8ZasydY=; b=pHLdSz+Z2SIihC83B0T6o8VKtH04rkbW7yOb9Fza740qSuxIuSUbjatDMFDG6DaLsV 61ZEYR9Rz2Sp5anw90Y4922J9SO9nTSvrKPe0P9jPA5yMqmN9J6gylPxKoRehW1grGgG 4pyebBrBGcpNFODtArlZvUCOuFpokN5kugY01MKxZ0g7TYXvy4BWCFlwtjjBAXCvFlUh WPAyCyRroq17tIfRvCzXLpYMXbhQ0SkPQZgPSBkQ00oowbEzWkEbfo4SQJfgHYSVNZSV U3M7vf9J0KG+aW+Cc624LHNlCamNKUJPq6zaGxiW1Uws/3o3HJ58sJBnDc0r3PtI/q5K ESiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7nY0b1HBA88jl9CMGGuocMVxAzKzMYWQu1cE8ZasydY=; b=VrXKGCqXNEFFDQLAgOPt5n+qF5Mx4dctU3u51AB3cGypgt6VpvRHgnwPy0lntFy/Ab nm0C2OsX+Jut/RX2QVdS2CxOyFsnL2yjbVxHaiWItvHnqfxlTT1ZN/Lfr2sRaTWdKW3h bmXgitszIb5hBSkVi+AD7rTtG/cMpUW4GEUmRh+x7/BoiW6y/4bVoQ9CPjUo0dMTXOa7 Gv+DiFRzxm9SNmNq2axGsymIL39dlTNatjL6gEbkLjAdRSTJWOvkCKDQ1DPpvBjQcFV8 X6jtE7QCWhysGa2gg0ZpHZh8RS0oavH7eeaQ5r91USkukllnSGHLJF3fRCrbVOWI3qnN xByQ== X-Gm-Message-State: AOAM532OhmbJrwXXqYy6Px3V86v/VwjzHHqxIazcjMDdsYTm/88i9JOM 2WFB1V1orcxczLCWjQLaX6SAyeyrXXe32Q== X-Received: by 2002:a5d:5601:: with SMTP id l1mr33999802wrv.213.1642682227156; Thu, 20 Jan 2022 04:37:07 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t8sm7993324wmq.43.2022.01.20.04.37.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 04:37:06 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 32/38] hw/intc/arm_gicv3_its: Fix return codes in process_mapti() Date: Thu, 20 Jan 2022 12:36:24 +0000 Message-Id: <20220120123630.267975-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120123630.267975-1-peter.maydell@linaro.org> References: <20220120123630.267975-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::333 (failed) 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: -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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Fix process_mapti() to consistently return CMD_STALL for memory errors and CMD_CONTINUE for parameter errors, as we claim in the comments that we do. Signed-off-by: Peter Maydell Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Message-id: 20220111171048.3545974-9-peter.maydell@linaro.org --- hw/intc/arm_gicv3_its.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index 5dc6846fe3f..010779a9fdc 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -357,7 +357,7 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, MemTxResult res = MEMTX_OK; uint16_t icid = 0; uint64_t dte = 0; - ItsCmdResult result = CMD_STALL; + IteEntry ite = {}; devid = ((value & DEVID_MASK) >> DEVID_SHIFT); offset += NUM_BYTES_IN_DW; @@ -365,7 +365,7 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, MEMTXATTRS_UNSPECIFIED, &res); if (res != MEMTX_OK) { - return result; + return CMD_STALL; } eventid = (value & EVENTID_MASK); @@ -381,7 +381,7 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, MEMTXATTRS_UNSPECIFIED, &res); if (res != MEMTX_OK) { - return result; + return CMD_STALL; } icid = value & ICID_MASK; @@ -389,7 +389,7 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, dte = get_dte(s, devid, &res); if (res != MEMTX_OK) { - return result; + return CMD_STALL; } dte_valid = FIELD_EX64(dte, DTE, VALID); num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); @@ -409,19 +409,17 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, * we ignore this command and move onto the next * command in the queue */ - } else { - /* add ite entry to interrupt translation table */ - 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); - 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); - - result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; + return CMD_CONTINUE; } - return result; + /* add ite entry to interrupt translation table */ + ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid); + ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL); + 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); + + return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; } static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,