From patchwork Sat Dec 11 19:11:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 523089 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp4119110imb; Sat, 11 Dec 2021 11:47:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8J8Fg+rTs02eGjZB5oMpiyGXhnR0b28NSmIUPrftd7qcehsNZe2dpnIYh+41ipT3O6E8h X-Received: by 2002:a25:157:: with SMTP id 84mr21594835ybb.4.1639252031812; Sat, 11 Dec 2021 11:47:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639252031; cv=none; d=google.com; s=arc-20160816; b=gNSGSYeZ5gIv4BhyVOp8ZysFYuTKhozroZihsnolDYQ3pSQBvy2nVHhl7/elYYuSd9 WLpzEqBkdmbxbXSvipXJ6H6a3kMXQ2RlMlIDkpKZ+tZMUjuxsmsTFZGYx2Onm/f2uv38 b2hfBOLLz9hm42fIaqiX5kjujvtcTaF/AWu3X7a/2FYILxYTv7X4T0v6eAsqKgooWa3M ddVxJthSGph/Tr9az5gVall+lbU+BLVZDigszKP8GNiq0T4ykDzvyDhc3UtnEUgZBbSZ H2kWR/e8bEAbMOV+WwiEfnoMfBCR2viXFcwKafOodwVsnBVNKdgf/R3pikboEJjoOaMo zoOg== 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=RZRdimySV2tzC3ZHoL/w1SnZpTEUgmFudXJ6uGktXNE=; b=FItQ42BLFH9UCPan4pBGwebZyK6fb7i03JW5RDfoU2/ASF+//8SynPjtaCF7DkXaS3 jXlws37ecEZV7AnH48dPMdjUsQbKsExfzfq55GhWtv2+KAd6NDQGJD1OnP7AIwTAXwPj r5M8kA0qlQwcFhW12w9mlAW/+6lzSWo98XxNQW4rSTXk2X90+FVL0PU6nMrmoQJ5zWrl hgwM9tvuiEX9HCKP1Nknqagz+VwqHgfnqQGXLg2YKZlSwFBeSPXkrEBjs7YabV4IBkE9 +twENAemuJDbnKvntKVOYr96IflJFoENut3bAlhvvTEHyvw7Z/wutf4t9dRLtByuKcU4 HD6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="YCoP3t/d"; 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 o5si13298771ybu.338.2021.12.11.11.47.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 11 Dec 2021 11:47:11 -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="YCoP3t/d"; 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]:54418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mw8Kt-0002wF-AZ for patch@linaro.org; Sat, 11 Dec 2021 14:47:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mw7n2-0005HW-Ac for qemu-devel@nongnu.org; Sat, 11 Dec 2021 14:12:16 -0500 Received: from [2a00:1450:4864:20::42b] (port=44583 helo=mail-wr1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mw7mq-0006I7-Rq for qemu-devel@nongnu.org; Sat, 11 Dec 2021 14:12:05 -0500 Received: by mail-wr1-x42b.google.com with SMTP id t18so20291629wrg.11 for ; Sat, 11 Dec 2021 11:11:56 -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=RZRdimySV2tzC3ZHoL/w1SnZpTEUgmFudXJ6uGktXNE=; b=YCoP3t/dzGidjiJUkM3yK3uA5zmXuWnDqPBJPT/QCzpo/8n0vHlwoe1sc8cYlky0mE 8vWDy03rqc5i9J20dOnsf03Ax4gPT5sR6SlneZhnwNN/xZNVgZFBoPEHVUoLDldgHNNF iVWn/3gLnFfwlys3cd7kO+p2qwY5isE24mZO2S+k/gE8y8alVg0I/6ta6Z+ixfL8/V+6 LMpOY05gM/Qnv68dfSTghIrG8gvv+CwiuaRkigzY78cNE+Vs3+cfnf289UMKYFPMPa/h 7QgTia22M9i91hA3QYcX2WL32sbq8spqaPeAGB22mXcSrZweAPzjGoiQKyTsGLmoGl8T SMlQ== 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=RZRdimySV2tzC3ZHoL/w1SnZpTEUgmFudXJ6uGktXNE=; b=RP+ZdR4QfT7jhUVDTUS1XMo4l86bSLsLd3FzeZtWTSKKsETugN8IX5Xi6+5gWHafDC qz3PF+/Zb3Z6LgQ27paFajuHVhf/dGg3rIGZkrSibMQkwrK0lxqDt8DqIp975nJ25BXH CmXSm+Wt7ScobyO3m9JL0A/FX/+NOQiBYLEetYitem5AL+SmGxqWyhDRYIyJpfl4lNzl ya5RGzoUD4tzPsx/dcbpSTID3DUsdGlQEA/sykaFAILBHUBiqhCh8GF1/MGihIDzliHT XYYcHAWvyPMvdMPMzl2Ku1uS7Gav90wxsmZV/vXTy4lDQwkKvvEcUvVOELlWId9Vzbs+ wV7w== X-Gm-Message-State: AOAM533NU2jdU7FYGL2QFVTsxIM3In744iDKLaDnAA86d3HPBlZ3t4oV LqGteSffAMVyGEMCgrlaiSHKqg== X-Received: by 2002:a05:6000:2c2:: with SMTP id o2mr21791800wry.360.1639249914991; Sat, 11 Dec 2021 11:11:54 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Dec 2021 11:11:54 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 23/26] hw/intc/arm_gicv3_its: Fix return codes in process_mapti() Date: Sat, 11 Dec 2021 19:11:32 +0000 Message-Id: <20211211191135.1764649-24-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::42b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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, 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: , Cc: Shashi Mallela , =?utf-8?q?Alex_Benn=C3=A9e?= 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: Richard Henderson Reviewed-by: Alex Bennée --- 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 275af620058..5b25347de12 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -355,7 +355,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; @@ -363,7 +363,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); @@ -379,7 +379,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; @@ -387,7 +387,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); @@ -407,19 +407,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,