public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael Brown" <mcb30@ipxe.org>
To: devel@edk2.groups.io, lersek@redhat.com, kraxel@redhat.com
Cc: Oliver Steffen <osteffen@redhat.com>,
	Pawel Polawski <ppolawsk@redhat.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jordan Justen <jordan.l.justen@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg/NestedInterruptTplLib: replace ASSERT() with a warning logged.
Date: Fri, 5 May 2023 23:27:05 +0000	[thread overview]
Message-ID: <01020187ee3d92cc-eb212c44-2e49-4ca2-992c-a2d7d3b03f6f-000000@eu-west-1.amazonses.com> (raw)
In-Reply-To: <c37f7c9b-d206-542b-611e-ef7ba49d4a2c@redhat.com>

On 05/05/2023 19:56, Laszlo Ersek wrote:
> I don't like the patch. For two reasons:
> 
> (1) It papers over the actual issue. The problem should be fixed where
> it is, if possible.

Agreed, but (as you have shown in 
https://bugzilla.redhat.com/show_bug.cgi?id=2189136) the bug lies in 
Windows code rather than in EDK2 code.  If the goal is to allow these 
buggy Windows builds to still be used with OVMF, then the only option is 
to paper over the issue.  We should do this only if it can be proven 
safe to do so, of course.

> (2) With the patch applied, NestedInterruptRaiseTPL() can return
> TPL_HIGH_LEVEL (as "InterruptedTPL"). Consequently,
> TimerInterruptHandler() [OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c]
> may pass TPL_HIGH_LEVEL back to NestedInterruptRestoreTPL(), as
> "InterruptedTPL".
> 
> I believe that this in turn may invalidate at least one comment in
> NestedInterruptRestoreTPL():
> 
>      //
>      // Call RestoreTPL() to allow event notifications to be
>      // dispatched.  This will implicitly re-enable interrupts.
>      //
>      gBS->RestoreTPL (InterruptedTPL);
> 
> Restoring TPL_HIGH_LEVEL does not re-enable interrupts -- nominally anyways.

I agree that the comment is invalidated, but as far as I can tell the 
logic remains safe.

I will put together a patch to update the comments in 
NestedInterruptTplLib to address the possibility of an interrupt 
occurring (illegally) at TPL_HIGH_LEVEL.

> (a) Make LocalApicTimerDxe Xen-specific again. It's only the OVMF Xen
> platform that really *needs* NestedInterruptTplLib. (Don't get me wrong:
> NestedInterruptTplLib is technically correct in all circumstances, but
> in practice it happens to be too strict.)
> 
> (b) For the non-Xen OVMF platforms, re-create a LocalApicTimerDxe
> variant that effectively has commits a086f4a63bc0 and a24fbd606125
> reverted. (We should keep 9bf473da4c1d.) This returns us to
> pre-239b50a86370 status -- that is, a timer interrupt handler that (a)
> does not try to be smart about nested interrupts, therefore one that is
> much simpler, and (b) is more tolerant of the Windows / cdboot.efi spec
> violation, (c) is vulnerable to the timer interrupt storm seen on Xen,
> but will never run on Xen. (Only the OVMF Xen platform is supposed to be
> launched on Xen.)

I'm less keen on this because it reduces the runtime exposure of a very 
complex piece of code, and will effectively cause that code to become 
unmaintained.

It's also satisfying (to me) that NestedInterruptTplLib provides a 
provable upper bound on stack consumption due to interrupts, which can't 
be guaranteed by the simpler pre-239b50a86370 scheme.

Could we defer judgement until after I've fully reasoned through (and 
documented) how NestedInterruptTplLib will work in the presence of 
interrupts occurring at TPL_HIGH_LEVEL?

Thanks,

Michael


  reply	other threads:[~2023-05-05 23:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-03  7:19 [PATCH v2 1/1] OvmfPkg/NestedInterruptTplLib: replace ASSERT() with a warning logged Gerd Hoffmann
2023-05-05 14:10 ` [edk2-devel] " Michael Brown
2023-05-05 18:56   ` Laszlo Ersek
2023-05-05 23:27     ` Michael Brown [this message]
2023-05-05 23:57       ` Ard Biesheuvel
2023-05-08  6:45         ` Laszlo Ersek
2023-05-09  9:13           ` Ard Biesheuvel
2023-05-08  6:38       ` Laszlo Ersek
2023-05-08 21:31         ` [PATCH 0/2] OvmfPkg: Relax assertion that interrupts do not occur at TPL_HIGH_LEVEL Michael Brown
2023-05-09  7:05           ` Gerd Hoffmann
2023-05-09  8:43           ` Laszlo Ersek
2023-05-09 12:08             ` [edk2-devel] " Michael Brown
2023-05-09 13:27               ` Laszlo Ersek
     [not found]         ` <20230508213100.3949708-1-mcb30@ipxe.org>
2023-05-08 21:31           ` [PATCH 1/2] OvmfPkg: Clarify invariants for NestedInterruptTplLib Michael Brown
2023-05-08 21:31           ` [PATCH 2/2] OvmfPkg: Relax assertion that interrupts do not occur at TPL_HIGH_LEVEL Michael Brown
2023-05-09  8:35             ` Laszlo Ersek
2023-05-09  9:42               ` Gerd Hoffmann
2023-05-09 12:04               ` [edk2-devel] " Michael Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01020187ee3d92cc-eb212c44-2e49-4ca2-992c-a2d7d3b03f6f-000000@eu-west-1.amazonses.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox