From nobody Fri May 3 11:09:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+79770+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+79770+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1629819100; cv=none; d=zohomail.com; s=zohoarc; b=juV0iUUO0qTDieIqqpd3z6xbnCC7Ik98jE+PuZkUd1qTDUZzBomVvfLxvFhP7Y65OKOpm6m2ClFuW3kYsluMWIWfr+WpchAGRdXalGqMTUOKNiagN46I98QqTl4vEJnBzWRMtnTO/wEtLqdeJ8pfwCuuruyKUN5ifKZ50g/TcpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629819100; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=GAESLi+uNGyVNhsFya1RVpkZk/DvdvZivAkN5LPHinE=; b=UYMrUFVHP3jZoWaiLm4eMeWF6ooreTANjjzrfbAloHdVg66mN1Ykmf8GtHoitHQhTToUYazOCLJuM+4+jaDCX1Y0IFmFetCWgRlj++VNWGGRPu3BDL1YSsvUvDX08Z4qAaT9agMS8f/GYIgp6b/+yuiO/z99ZSMCxgv5mIpmUvk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+79770+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1629819100147589.3480431670538; Tue, 24 Aug 2021 08:31:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Kit9YY1788612xS8dloUNSGf; Tue, 24 Aug 2021 08:31:39 -0700 X-Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mx.groups.io with SMTP id smtpd.web08.161.1629819098655817578 for ; Tue, 24 Aug 2021 08:31:38 -0700 X-Received: by mail.kernel.org (Postfix) with ESMTPSA id BA67861265; Tue, 24 Aug 2021 15:31:36 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, sami.mujawar@arm.com, gaoliming@byosoft.com.cn, Ard Biesheuvel , Marc Zyngier Subject: [edk2-devel] [PATCH] ArmPkg/GicV3Dxe: Don't signal EOI on arbitrary interrupts Date: Tue, 24 Aug 2021 17:31:32 +0200 Message-Id: <20210824153132.5379-1-ardb@kernel.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org X-Gm-Message-State: sraaP8ZReTk3t4wjJlQyTIHxx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629819099; bh=I4/swz4yhyLbAB4Ogib0qtbipXFJnU/NH96VV+eBrhk=; h=Cc:Date:From:Reply-To:Subject:To; b=noUAcC8S19bxNAxvohKLtlXrBCIHBH2T7+WPJX8HIqEZ98lszR5EHD1W0N6wQFnCw0v QFDnmmErJZJC0NCVCjsempiNvynuhVG46LzB6rPXQIZFMGhKqDlX9GvAY7frZxC1/jtT8 Sy3NCVDCdUfPTzFvcCj//LbKjLrVVPdMFd0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629819101248100003 Content-Type: text/plain; charset="utf-8" Currently, at ExitBootServices() time, the GICv3 driver signals End-Of-Interrupt (EOI) on all interrupt lines that are supported by the interrupt controller. This appears to have been carried over from the GICv2 version, but has been turned into something that violates the GIC spec, and may trigger SError exceptions on some implementations. Marc puts it as follows: The GIC interrupt state machine is pretty strict. An interrupt can only be deactivated (with or without prior priority drop) if it has been acknowledged first. In GIC speak, this means that only the following sequences are valid: With EOImode=3D=3D0: x =3D ICC_IAR{0,1}_EL1; ICC_EOIR{0,1}_EL1 =3D x; With EOImode=3D=3D1: x =3D ICC_IAR{0,1}_EL1; ICC_EOIR{0,1}_EL1 =3D x; ICC_DIR_EL1 =3D x; Any write to ICC_EOIR{0,1}_EL1 that isn't the direct consequence of the same value being read from ICC_IAR{0,1}_EL1, and with the correct nesting, breaks the state machine and leads to unpredictable results that affects *all* interrupts in the system (most likely, the priority system is dead). See Figure 4-3 ("Interrupt handling state machine") in Arm IHI 0069F for a description of the acceptable transitions. Additionally, on implementations that have ICC_CTLR_EL1.SEIS=3D=3D1, a SError may be generated to signal the error. See the various IMPLEMENTATION_DEFINED "SError ...."; that are all over the pseudocode contained in the same architecture spec. Needless to say, this is pretty final for any SW that would do silly things on such implementations (which do exist). Given that in our implementation, every signalled interrupt is acked, handled and EOId in sequence, there is no reason to EOI all interrupts at ExitBootServices() time in the first place, so let's just drop this code. This fixes an issue reported by Marc where an SError is triggered by this code, bringing down the system. Reported-by: Marc Zyngier Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- This is a clear bugfix, but given how late we are in the cycle, I will leave it up to Liming to decide whether we can still take this for the upcoming stable tag. ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c b/ArmPkg/Drivers/Arm= Gic/GicV3/ArmGicV3Dxe.c index 85ee4c87b6d1..fa515d1a01ba 100644 --- a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c +++ b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c @@ -344,10 +344,6 @@ GicV3ExitBootServicesEvent ( GicV3DisableInterruptSource (&gHardwareInterruptV3Protocol, Index); } =20 - for (Index =3D 0; Index < mGicNumInterrupts; Index++) { - GicV3EndOfInterrupt (&gHardwareInterruptV3Protocol, Index); - } - // Disable Gic Interface ArmGicV3DisableInterruptInterface (); =20 --=20 2.30.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#79770): https://edk2.groups.io/g/devel/message/79770 Mute This Topic: https://groups.io/mt/85113360/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-