From nobody Mon Nov 25 03:06:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1717598616; cv=none; d=zohomail.com; s=zohoarc; b=MnKU6yNdUOnRbUA4htA1sAHx0uG3Jm2f7Lc50U4uZhZBT4XSeTcM+dZeGmTRJNREZb85ASwEP02k3LBKTLTMJRXd+nTNlTXcVmHA07bdXklPVhq+/CwL6GC+hbvNqAWWt0xXuDyZT4QeLDKXWJQ9IDeiUlqv1tC0ZK+zO1wB+SU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717598616; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IsVLiVuAn4sxtlhqqkPf8UmG53ookLSzBjac4UXBmbo=; b=KUypNF7/n1WGwq1SR4Q36TwR+wQjxW0DZ1nevgAn6Gso7LUf9VFSd5ND2xygDI0eZSxSD0uoG1RFgcccJALt7oT44q8amYeH1E/44xi9MCFttlslALndF2A0o9WdOg6Fu+nhNrwuBRalSaJeGWN6LVE1sqlAXB5Qa5j8+8wOawE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717598616874956.5077119981073; Wed, 5 Jun 2024 07:43:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sErr2-0000zP-5P; Wed, 05 Jun 2024 10:43:08 -0400 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 1sErr0-0000yq-Vy; Wed, 05 Jun 2024 10:43:07 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sErqy-0004PT-Se; Wed, 05 Jun 2024 10:43:06 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52b93370ad0so6333153e87.2; Wed, 05 Jun 2024 07:43:04 -0700 (PDT) Received: from gmail.com (213-67-3-247-no600.tbcn.telia.com. [213.67.3.247]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52b84d7ecbdsm1807334e87.182.2024.06.05.07.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 07:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717598583; x=1718203383; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IsVLiVuAn4sxtlhqqkPf8UmG53ookLSzBjac4UXBmbo=; b=GYZplCWNusBkvh59pERqxiIcYgJD4UoUQ2daXbzMsdIHZ5qlPCzaWHYc9Yt6sPqva/ ywgAtm+dBlosBEaJCSMcJB36XM4RJ4YmKFPW6HetvXtfqZipnqYXslq9vLs2fKaGGyHA gNN5dKUUt8/bTbE2jPT2YjCTgk40TzlTjcg1t2HRgtUn4C2FInNVaGz9DJFWqBsyp7RP hSagT3Of8AskiuzEIldOEYvWtQw4Vsq/obg23B1a3pOtY8x3YUwGaTGdOAh4IaIloEUP pNfz9fKp3nSeA6C8Nn82ugJehwEpjGIvP+lOAK+huP8MpPVg5QYnIWZpH2oa5lVCzAdD fyyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717598583; x=1718203383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IsVLiVuAn4sxtlhqqkPf8UmG53ookLSzBjac4UXBmbo=; b=f0OnIOjsR0t9Fo4j5tyD2lKEqoNK6hryU8MfBby/fsdyQxCtI1uOgFl7wWEbzaGWAh UB7tfNQ2cwFJYif31KCsEElW3G67UKqfsftGOUiPzfLlOjmCdvm8m+J5M9CUxK4ToudS xGAUwkJ9v2ld34KP0MAtdC/tofvm5SEqxZrvpWwMMGjpvjk/2JVZ+Vf5x+iyF3i1LHlK kq+0NKW7nYgB6u44aPUq0B8Ig6j2vll22NpwfdBKbCQHUXs1QsRZGc3jsnZOiomfSyJ/ waT1eOlmKyK74wD157qckcdxGruZjHEP4ChlROLfh+doFoOA9EELjL8XMLDQSSFOuP6R B68A== X-Forwarded-Encrypted: i=1; AJvYcCUqlrvcq3OaskevIhyS/xIkc5J0TB1BzM7prevjMmphl33ZybSAiKlGvD2tbnW3LwIGtE3rhAABgqdnMgO1mMeLybYaNzJ/llFHAxZK0Lur+d3jNKZLNPF80Tc= X-Gm-Message-State: AOJu0YyRExSuhC5h8nfu62cnq2Bc2CagFHi63N/pKFkjsQVzondtPaWG 1GZ2K5EadfutWdXkqIw2iHKnMKM9ZRZdJ1XkT8nnR71LEHS1AAfr X-Google-Smtp-Source: AGHT+IHdg1ocJTA9GQYAtt4yEKpYQ5V1VwQHuVObavYOMuvzHPc2hzHGD2AWPYP1mVxt3No1AVliAQ== X-Received: by 2002:a05:6512:3a8d:b0:52b:7c7c:bf4a with SMTP id 2adb3069b0e04-52bab4c9a16mr2698644e87.10.1717598582619; Wed, 05 Jun 2024 07:43:02 -0700 (PDT) From: "Edgar E. Iglesias" To: peter.maydell@linaro.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: sstabellini@kernel.org, julien@xen.org, bertrand.marquis@arm.com, edgar.iglesias@amd.com Subject: [PATCH v1 1/1] hw/intc/arm_gic: Fix deactivation of SPI lines Date: Wed, 5 Jun 2024 16:30:44 +0200 Message-Id: <20240605143044.2029444-2-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240605143044.2029444-1-edgar.iglesias@gmail.com> References: <20240605143044.2029444-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=edgar.iglesias@gmail.com; helo=mail-lf1-x136.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, FREEMAIL_FROM=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1717598618231100003 Content-Type: text/plain; charset="utf-8" From: "Edgar E. Iglesias" Julien reported that he has seen strange behaviour when running Xen on QEMU using GICv2. When Xen migrates a guest's vCPU from one pCPU to another while the vCPU is handling an interrupt, the guest is unable to properly deactivate interrupts. Looking at it a little closer, our GICv2 model treats deactivation of SPI lines as if they were PPI's, i.e banked per CPU core. The state for active interrupts should only be banked for PPI lines, not for SPI lines. Make deactivation of SPI lines unbanked, similar to how we handle writes to GICD_ICACTIVER. Reported-by: Julien Grall Signed-off-by: Edgar E. Iglesias --- hw/intc/gic_internal.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h index 8d29b40ca1..8ddbf554c6 100644 --- a/hw/intc/gic_internal.h +++ b/hw/intc/gic_internal.h @@ -280,6 +280,8 @@ static inline void gic_set_active(GICState *s, int irq,= int cpu) =20 static inline void gic_clear_active(GICState *s, int irq, int cpu) { + unsigned int cm; + if (gic_is_vcpu(cpu)) { uint32_t *entry =3D gic_get_lr_entry(s, irq, cpu); GICH_LR_CLEAR_ACTIVE(*entry); @@ -301,11 +303,13 @@ static inline void gic_clear_active(GICState *s, int = irq, int cpu) * the GIC is secure. */ if (!s->security_extn || GIC_DIST_TEST_GROUP(phys_irq, 1 << rc= pu)) { - GIC_DIST_CLEAR_ACTIVE(phys_irq, 1 << rcpu); + cm =3D phys_irq < GIC_INTERNAL ? 1 << rcpu : ALL_CPU_MASK; + GIC_DIST_CLEAR_ACTIVE(phys_irq, cm); } } } else { - GIC_DIST_CLEAR_ACTIVE(irq, 1 << cpu); + cm =3D irq < GIC_INTERNAL ? 1 << cpu : ALL_CPU_MASK; + GIC_DIST_CLEAR_ACTIVE(irq, cm); } } =20 --=20 2.40.1