From patchwork Thu Jan 11 11:04:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 761821 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2337546wrz; Thu, 11 Jan 2024 03:10:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFka7eA3gQAp418U+RY8y99SF3I8D5J2YUH5ymZSzwFD3JrF2naMF3nY91fg63OmqGKBXie X-Received: by 2002:a05:620a:347:b0:783:18c7:2809 with SMTP id t7-20020a05620a034700b0078318c72809mr1131918qkm.16.1704971450540; Thu, 11 Jan 2024 03:10:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704971450; cv=none; d=google.com; s=arc-20160816; b=uGvtL8GWM4KBykpn5fZcIm1gEISt5hcpNpCcAtqQFBo27xsqEocAVPMHtj1EDyXHZF sKr+20GzMOuRW5hB9XKLQUMI5NFG6I0RZVgAYDK70Yv4ak2f0ZjqpG+/9GavYlUbduFS rveobQ3qLzJ4EJjBiKqe3APET0925XIvj3e4qqtpKes9u8QhkPslt48N8aHGSE7zzRw5 si1UxtkO3HcGNJAW7/IOlWXP0WyRTDG76yImpXaboO5+jK4UON/bredSE9jzO6FlH0f+ c2UIbWCeHJC/VeWj/6O6uIbJTmFe5ezfTPgV0st44zHUeyzwPAihcGGedta6ZfQUH3ng diag== 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=oeCuiQBz7GI2Tnh0N3wKJtjrrHPQdjyFY69+nM/wilI=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=HHYhwd2VZ9JG7Xv2CGqrgpaWv0lEhzTfgb0tYk0ZruP6yiG5Xl3MBPF9NTR9jRXqS8 qcdDyCBnqKzvTtpTApU7hVF9RxOnvW0RIGW3CHbW0ZMPNtwYVsQAbJ3rencRp/Ap7Y3Z 60zU+vV+LrWtaGaGH0STdznEYtY+fx38JDWBFvCtGSKXTYEJTB/GK7IFBcYrkrLFVO/d J0gnDkm2eibr/Lz0mvWVohnOkxqIEUD321267eNlumJ4V5OyNXn8S6jbVp1i3yRLhaca yjOvkYg6sy9o2/oxjSSiNTmlmrrSW7ZRj/o4L4MK47+fR/StAOgawQjK+RH6bmOQeMpV 62rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xYUDu7tt; 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 l5-20020a37f505000000b0078310e092bfsi666857qkk.678.2024.01.11.03.10.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 03:10:50 -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=xYUDu7tt; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNssh-0001c8-2Z; Thu, 11 Jan 2024 06:05:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNss6-0001Kt-UW for qemu-devel@nongnu.org; Thu, 11 Jan 2024 06:05:15 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNss5-0004PC-2H for qemu-devel@nongnu.org; Thu, 11 Jan 2024 06:05:14 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3366e78d872so5439888f8f.3 for ; Thu, 11 Jan 2024 03:05:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704971111; x=1705575911; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oeCuiQBz7GI2Tnh0N3wKJtjrrHPQdjyFY69+nM/wilI=; b=xYUDu7ttRpqKdcq3zGrKmP3Uno/mykpbIc3M67Bwig0pquz6wgR/w9VX/XE5s9XGBQ 3YaDoM2Yvuz0U3hygb5g7NVQIkD0FUB9mc5NFesVvwaObrn++mEJCrx/EJCo+6O55GHb VjZAt+JSZuihNHw+EfI8kztMpOhJgDX4dBQysBkVPTkGDFohbmzDmsbZnNy/TDMvBm8b is28vHsuJRVtu75nREjl5gQugHaUKOzwqiiGp2Ve6O5+4qv9jz2DWTHLpzF4q+uJHFux 1+iYHaRz5C9NAU8n3COXcYDQ5iKuKDwWjzrXbJUwGl00y+AuvTBIO9cYbyjU7gFGmLcO l2mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704971111; x=1705575911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oeCuiQBz7GI2Tnh0N3wKJtjrrHPQdjyFY69+nM/wilI=; b=Adx8WIh7MF+6hvGPPQqTDKp+4S7GbDSX8tn4+FD7sDLwJ63bpWklxPz+gQbQnIs1E7 G4widuNj/gjc2Q2KOrBNdnN69QhUX0rXls5aDI81KYw6Nv3lHYwM5nVbfZPAjJU0brW+ eEIHTcExfeaZP5J3RrRvfG3GzPfcfOaSnPEF2CaDTytuKKbkmBx+/9z0iv7zkWC1vdwI obDgwlnnqXen7u/fMlzv7KoZjiOgC+B3b7sS41A6/e1m7YwWJFrY2DtRV6vPuHtOf32Z m+TgdwatdY8CpcnVtrt/bHO32DfUbMAZxcG1PlXnW8vQDd3hVH6yUoUxPhU/94OMOqfW qPLA== X-Gm-Message-State: AOJu0YzOW+HYPVHwgGVpOJnWMSDAQzdDNBvXY7bJknaH+J2Z2yadY1G6 qggM+KKBgiDVeb9WtWXBSXyyO8eg0FzEsTZbbfuMpsJxiD4= X-Received: by 2002:adf:e3c7:0:b0:337:427f:e993 with SMTP id k7-20020adfe3c7000000b00337427fe993mr309982wrm.85.1704971111005; Thu, 11 Jan 2024 03:05:11 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v30-20020adf8b5e000000b0033690139ea5sm951323wra.44.2024.01.11.03.05.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:05:10 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/41] hw/intc/arm_gicv3_cpuif: handle LPIs in in the list registers Date: Thu, 11 Jan 2024 11:04:33 +0000 Message-Id: <20240111110505.1563291-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240111110505.1563291-1-peter.maydell@linaro.org> References: <20240111110505.1563291-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The hypervisor can deliver (virtual) LPIs to a guest by setting up a list register to have an intid which is an LPI. The GIC has to treat these a little differently to standard interrupt IDs, because LPIs have no Active state, and so the guest will only EOI them, it will not also deactivate them. So icv_eoir_write() must do two things: * if the LPI ID is not in any list register, we drop the priority but do not increment the EOI count * if the LPI ID is in a list register, we immediately deactivate it, regardless of the split-drop-and-deactivate control This can be seen in the VirtualWriteEOIR0() and VirtualWriteEOIR1() pseudocode in the GICv3 architecture specification. Without this fix, potentially a hypervisor guest might stall because LPIs get stuck in a bogus Active+Pending state. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Miguel Luis --- hw/intc/arm_gicv3_cpuif.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index 77c2a6dd3b6..6ac90536402 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -1434,16 +1434,25 @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri, idx = icv_find_active(cs, irq); if (idx < 0) { - /* No valid list register corresponding to EOI ID */ - icv_increment_eoicount(cs); + /* + * No valid list register corresponding to EOI ID; if this is a vLPI + * not in the list regs then do nothing; otherwise increment EOI count + */ + if (irq < GICV3_LPI_INTID_START) { + icv_increment_eoicount(cs); + } } else { uint64_t lr = cs->ich_lr_el2[idx]; int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0; int lr_gprio = ich_lr_prio(lr) & icv_gprio_mask(cs, grp); if (thisgrp == grp && lr_gprio == dropprio) { - if (!icv_eoi_split(env, cs)) { - /* Priority drop and deactivate not split: deactivate irq now */ + if (!icv_eoi_split(env, cs) || irq >= GICV3_LPI_INTID_START) { + /* + * Priority drop and deactivate not split: deactivate irq now. + * LPIs always get their active state cleared immediately + * because no separate deactivate is expected. + */ icv_deactivate_irq(cs, idx); } }