From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 822579417CF for ; Wed, 24 Jan 2024 12:52:33 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=8HUWebaeTMk/ldRcRnuZYM1dRf73U+BDtCA891kJQlI=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706100752; v=1; b=QSNDb7j+Be2olsvfIbIw6uDoeLKZnfhxnkTuHKqy3Wn0rhZYlwsmkt5cxoit76/ndZdZIW9L kAme8mY5WkECKIMXbC6q9RzV0Sf4yi+ohhTbqyY0U7int9h0AZLI3COthI3F5fVvTEVFsxPED7v 4JP3qkK9mnzyApAHsga11oqQ= X-Received: by 127.0.0.2 with SMTP id 7Or8YY7687511xtSuagfTzU8; Wed, 24 Jan 2024 04:52:32 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.21738.1706100751560686456 for ; Wed, 24 Jan 2024 04:52:31 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-sZEch7Z4O1OHM6LpFxEFNQ-1; Wed, 24 Jan 2024 07:52:27 -0500 X-MC-Unique: sZEch7Z4O1OHM6LpFxEFNQ-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 067B4101A526; Wed, 24 Jan 2024 12:52:27 +0000 (UTC) X-Received: from [10.39.195.127] (unknown [10.39.195.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4925B200A7B4; Wed, 24 Jan 2024 12:52:26 +0000 (UTC) Message-ID: Date: Wed, 24 Jan 2024 13:52:25 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v3 3/5] MdeModulePkg: Do nothing on NestedInterruptRestoreTPL(TPL_HIGH_LEVEL) To: Michael Brown , devel@edk2.groups.io Cc: Ray Ni , Gerd Hoffmann References: <17ACFF3FDD20CD9A.13754@groups.io> <20240123153104.2451759-1-mcb30@ipxe.org> <0102018d36f278b0-4977df10-4482-4420-bee2-0dee150a9df0-000000@eu-west-1.amazonses.com> <0102018d374367e0-ac396f00-34fb-40ab-8fe6-f68d0458d373-000000@eu-west-1.amazonses.com> From: "Laszlo Ersek" In-Reply-To: <0102018d374367e0-ac396f00-34fb-40ab-8fe6-f68d0458d373-000000@eu-west-1.amazonses.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: lR2qqdSyiozZZjUuVmCuzyFrx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=QSNDb7j+; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 1/23/24 17:59, Michael Brown wrote: > On 23/01/2024 16:32, Laszlo Ersek wrote: >> On 1/23/24 16:31, Michael Brown wrote: >>> At TPL_HIGH_LEVEL, CPU interrupts are disabled (as per the UEFI >>> specification) and so we should never encounter a situation in which >>> an interrupt occurs at TPL_HIGH_LEVEL. >>> >>> Restoring TPL to TPL_HIGH_LEVEL is always a no-op.  Return immediately >>> from NestedInterruptRestoreTPL(TPL_HIGH_LEVEL), so that we do not need >>> to consider the effect of this possible invariant violation on the >>> remainder of the logic. >> >> Feels like the handling logic might as well be "panic" here (except edk2 >> does not have a central panic API that's suitable for all platforms). I >> probably missed the previous discussion that led to this patch. Either >> way, it seems reasonable. >> >> Acked-by: Laszlo Ersek > > Thank you.  We can't panic because there are some bootloaders (*cough* > Microsoft *cough*) that illegally call RaiseTPL(TPL_HIGH_LEVEL) and then > even more illegally enable interrupts via STI.  Gerd tracked this down > before, which lead to commit > >   https://github.com/tianocore/edk2/commit/bee67e0c1 > > I found another way to trigger a RestoreTPL(TPL_HIGH_LEVEL) while I was > testing the self-tests by deliberately breaking > DisableInterruptsOnIret() to fail to disable interrupts.  This also > induces a situation in which we end up at TPL_HIGH_LEVEL with interrupts > enabled. > > This ended up triggering an assertion (due to the invariant violation) > in NestedInterruptRestoreTPL() before reaching the point in the > self-test that would have reported a more meaningful error message. > > Adding the bypass is justifiable on its own merits (as per the reasoning > in the commit), and it avoids needing to add clutter to the complex > logic in NestedInterruptRestoreTPL() just to ensure that the self-test > fails on the desired ASSERT(). > > I decided against trying to explain all that in the commit message, but > I can have a go if you think it needs to be captured.  :) Ugh, no, thanks :) This should suffice! :) Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114286): https://edk2.groups.io/g/devel/message/114286 Mute This Topic: https://groups.io/mt/103911606/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-