From patchwork Fri Apr 8 14:15:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 558817 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp371797map; Fri, 8 Apr 2022 07:27:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpPyGWcPC0OGpCNhdKybO0OhAgY4J+vcdvVy+tlIsPonyP7ld6eM1F2lBnqe6OpZMrCLTH X-Received: by 2002:a25:6642:0:b0:633:b9f4:b57d with SMTP id z2-20020a256642000000b00633b9f4b57dmr13700666ybm.394.1649428077827; Fri, 08 Apr 2022 07:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649428077; cv=none; d=google.com; s=arc-20160816; b=USJw9TJcfBqsi4IsijPEptvZR8epR0qpNcrGE+7aokcKiq/J43//ILQQjai4oJyW3S ig495SBx94wRfsuliJ5jFGSivbal3O5aG3lSDrQkLd0sz6PBqlq2s4dTQkDRwQe/GLLW Uq9diu+BH82ZAIm/Ra65HCcATkMjfRlreaDbEVwjoJ1V5jGJoZMLDa7vTp5Aqx7rokLk SnrLBxfKxRZWKpie1Wn5E18+Pvsq76uTISt/i8wGNRTwtoMiLO2asfk8ikjBBTPI8yZx gX74aUC2PMAKQpAimPLtG3GbwvivnJEl6HNliyM3b9qYnH/aC4RTe5PODld2j9l0u+g3 L9Wg== 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=esnamstNUY5Extqaiji5nDXYBcEE+qdCRY7G8wLUhCQ=; b=AafSeODh+vJzk4yaBP8OD4LxqAusbKRl375BdKEep1txw+PUFFHSJTgqZyfkA3i9XN LPOqFjgQwUPF+GRWXWNJUXaHAbUwadlQGjZcsAWHgiBtZXCId0HdSk0nXNCnlC2gLv+Y XfI9veoOe/2+pH/J3dVRJJIcrXJHGD6YIZoeX9Qd2fvB2HDdIprXKYW0JiPbhKTdqv5M a4/eymzeAf0EL8uAIFfzeKS42bgizZS/MHpq9M3TrzALlRyGFxGEeg0fcL5WocDOphd5 smVwti/b1063dCslikU9h86rmgkz6q2X+ZHNLCNL6t1OgqGWxz9YNyHv8yt6S4MpYmfS 8JLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cE7TD4Tg; 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 e73-20020a811e4c000000b002eba967ba58si480350ywe.382.2022.04.08.07.27.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Apr 2022 07:27:57 -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=cE7TD4Tg; 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]:39714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncpaf-0003ZJ-Aq for patch@linaro.org; Fri, 08 Apr 2022 10:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncpPF-0006ue-T0 for qemu-devel@nongnu.org; Fri, 08 Apr 2022 10:16:12 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:44548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncpPD-0002Hr-Ey for qemu-devel@nongnu.org; Fri, 08 Apr 2022 10:16:09 -0400 Received: by mail-wr1-x430.google.com with SMTP id b19so13037739wrh.11 for ; Fri, 08 Apr 2022 07:16:06 -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=esnamstNUY5Extqaiji5nDXYBcEE+qdCRY7G8wLUhCQ=; b=cE7TD4TgBdDNlSrCRxgZyzLAZv6DxQOufL3RDatiNUx1h4ab/qvdieAEOItz8jR3Hb j8o/+Mt/PN+WaBS8vzBSRJj96lHlsnrghtdDuMHOOhQ5rFv9nwHsENB09BD0nAVpCCxD 5cgEGS3b/O63nlCHBPjF/j0paz8Z280NLhf9XEE9RAWIRXSlcsIGZn503zqnUXr5Utjw lrTNZoaVn8E+N2bBfp3xhIu6X4ZHfMxsXsihpY/5cuDdj4AB05YGLw7zCvw4kdloOyjX Jdh5h/M5WAJ/62r/Kwwl/cbiWczBSy+y6cXELKOOHGNQxDSng7OTX5tt/TX2L2DhEaWj viWA== 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=esnamstNUY5Extqaiji5nDXYBcEE+qdCRY7G8wLUhCQ=; b=HMrDJoMNpX6Kp2ecb7qJnlPcY1I8a14RCEsueH4a5sJn7XnwOYhBx9GqFbYLA/GWa4 xSnAjBwgK5SzW746HaDZOhF0rqma6zugfOuNDsafAddlVvWjkQ7By9GOHjv9bG7SaZbF pt9bLvd62mwdN0RhQlKowgfxM5NsoB1fepeYpBcHr3xjOVM5HqG/bCooWRrILmjVKMTH 66S74uQQhekeoPvok1gmev0LfcqM2eLtKctYNSqelAUA0wysXCHntQVgGJvYg8IwW4XZ 4jSfIdwaOYsC/0V27AXTlQRJY1Ra3tvrO2aJgJFcGw7eb+puI4vxoleOFBLnPfFPDGEK DK1Q== X-Gm-Message-State: AOAM532TE7PSFUpEqVIZzGsexFDFrx4D9iJwjbUIj9zfOQ5aaeXAl7Up m9S4ZwK33P4Xw6+hFZg2lc3t3A== X-Received: by 2002:a5d:6c67:0:b0:204:ff0:87a8 with SMTP id r7-20020a5d6c67000000b002040ff087a8mr15158165wrz.627.1649427366091; Fri, 08 Apr 2022 07:16:06 -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.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 07:16:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 13/41] hw/intc/arm_gicv3_its: Split out process_its_cmd() physical interrupt code Date: Fri, 8 Apr 2022 15:15:22 +0100 Message-Id: <20220408141550.1271295-14-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::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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=ham 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" Split the part of process_its_cmd() which is specific to physical interrupts into its own function. This is the part which starts by taking the ICID and looking it up in the collection table. The handling of virtual interrupts is significantly different (involving a lookup in the vPE table) so structuring the code with one sub-function for the physical interrupt case and one for the virtual interrupt case will be clearer than putting both cases in one large function. The code for handling the "remove mapping from ITE" for the DISCARD command remains in process_its_cmd() because it is common to both virtual and physical interrupts. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/intc/arm_gicv3_its.c | 51 ++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index 2cbac76256d..8ea1fc366d3 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -397,6 +397,19 @@ static ItsCmdResult lookup_cte(GICv3ITSState *s, const char *who, return CMD_CONTINUE_OK; } +static ItsCmdResult process_its_cmd_phys(GICv3ITSState *s, const ITEntry *ite, + int irqlevel) +{ + CTEntry cte; + ItsCmdResult cmdres; + + cmdres = lookup_cte(s, __func__, ite->icid, &cte); + if (cmdres != CMD_CONTINUE_OK) { + return cmdres; + } + gicv3_redist_process_lpi(&s->gicv3->cpu[cte.rdbase], ite->intid, irqlevel); + return CMD_CONTINUE_OK; +} /* * This function handles the processing of following commands based on @@ -410,34 +423,36 @@ static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid, uint32_t eventid, ItsCmdType cmd) { DTEntry dte; - CTEntry cte; ITEntry ite; ItsCmdResult cmdres; + int irqlevel; cmdres = lookup_ite(s, __func__, devid, eventid, &ite, &dte); if (cmdres != CMD_CONTINUE_OK) { return cmdres; } - if (ite.inttype != ITE_INTTYPE_PHYSICAL) { - qemu_log_mask(LOG_GUEST_ERROR, - "%s: invalid command attributes: invalid ITE\n", - __func__); - return CMD_CONTINUE; + irqlevel = (cmd == CLEAR || cmd == DISCARD) ? 0 : 1; + + switch (ite.inttype) { + case ITE_INTTYPE_PHYSICAL: + cmdres = process_its_cmd_phys(s, &ite, irqlevel); + break; + case ITE_INTTYPE_VIRTUAL: + if (!its_feature_virtual(s)) { + /* Can't happen unless guest is illegally writing to table memory */ + qemu_log_mask(LOG_GUEST_ERROR, + "%s: invalid type %d in ITE (table corrupted?)\n", + __func__, ite.inttype); + return CMD_CONTINUE; + } + /* The GICv4 virtual interrupt handling will go here */ + g_assert_not_reached(); + default: + g_assert_not_reached(); } - cmdres = lookup_cte(s, __func__, ite.icid, &cte); - if (cmdres != CMD_CONTINUE_OK) { - return cmdres; - } - - if ((cmd == CLEAR) || (cmd == DISCARD)) { - gicv3_redist_process_lpi(&s->gicv3->cpu[cte.rdbase], ite.intid, 0); - } else { - gicv3_redist_process_lpi(&s->gicv3->cpu[cte.rdbase], ite.intid, 1); - } - - if (cmd == DISCARD) { + if (cmdres == CMD_CONTINUE_OK && cmd == DISCARD) { ITEntry ite = {}; /* remove mapping from interrupt translation table */ ite.valid = false;