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 8BC4894182C for ; Tue, 23 Jan 2024 15:51:59 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=eUMGVMTSMEXpAv5FE2ICU4khacCiyHmhxNcOe5iCY9g=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1706025118; v=1; b=q7yCRfO+gX1my1xCLsNYcTN1tXaiRGXF2dqSKHIxJtok/34wt73umBIcTUQ4TRDdchblbjZO m4CWnXheP0zqeL3N2W8a5hF2WCxXRbwgdFhkaQ6C3e6ENCRdLsUtx0//4darzHkxbAI6u3fQId9 qpTq6MKjp78kFrliz6SA1u9I= X-Received: by 127.0.0.2 with SMTP id JP2JYY7687511xlwKyo2HmYP; Tue, 23 Jan 2024 07:51:58 -0800 X-Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by mx.groups.io with SMTP id smtpd.web10.16023.1706025117223717758 for ; Tue, 23 Jan 2024 07:51:57 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 3B355CE2F25 for ; Tue, 23 Jan 2024 15:51:54 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66D07C433F1 for ; Tue, 23 Jan 2024 15:51:53 +0000 (UTC) X-Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2cc9fa5e8e1so48116741fa.3 for ; Tue, 23 Jan 2024 07:51:53 -0800 (PST) X-Gm-Message-State: qzCRIEen2YYzdcVz0OsOTMmtx7686176AA= X-Google-Smtp-Source: AGHT+IGZtTd9aTF7US6fB7uuSMSsfJOKDkVIIdOZCp9i0BKpEDS7uu3Py8Do7Pp92DgIqxCqc4ixz4pizNZjlUMT0IY= X-Received: by 2002:a2e:bcc2:0:b0:2ce:34d2:b9eb with SMTP id z2-20020a2ebcc2000000b002ce34d2b9ebmr2765903ljp.90.1706025111585; Tue, 23 Jan 2024 07:51:51 -0800 (PST) MIME-Version: 1.0 References: <17ACFF3FDD20CD9A.13754@groups.io> <20240123153104.2451759-1-mcb30@ipxe.org> <0102018d36f28a0d-300f8626-f368-49ab-b5e3-3c4edf84ce7e-000000@eu-west-1.amazonses.com> In-Reply-To: <0102018d36f28a0d-300f8626-f368-49ab-b5e3-3c4edf84ce7e-000000@eu-west-1.amazonses.com> From: "Ard Biesheuvel" Date: Tue, 23 Jan 2024 16:51:40 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v3 5/5] MdeModulePkg: Extend NestedInterruptTplLib to support Arm CPUs To: Michael Brown Cc: devel@edk2.groups.io, Ray Ni , Gerd Hoffmann , Laszlo Ersek 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,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=q7yCRfO+; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (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 Tue, 23 Jan 2024 at 16:31, Michael Brown wrote: > > The only architecture-specific portion of NestedInterruptTplLib is in > Iret.c, which must manipulate the interrupt stack frame such that the > return-from-interrupt instruction will not re-enable interrupts. The > remaining logic in Tpl.c is architecture-agnostic. > > Add implementations of DisableInterruptsOnIret() for MDE_CPU_ARM and > MDE_CPU_AARCH64. In both cases, the saved IRQs-disabled and > FIQs-disabled flags are set in the stored processor status register > (matching the behaviour of DisableInterrupts(), which also sets both > flags). > > Tested by patching ArmPkg's TimerDxe to use NestedInterruptTplLib and > verifying that ArmVirtQemu passes the NestedInterruptTplLib self-tests > for both ARM and AARCH64. > > Cc: Ard Biesheuvel > Signed-off-by: Michael Brown Thanks for this. You can drop the FIQ bits, though: anything that can run Tianocore will have the FIQs routed to the secure world, and all of the higher level en/disable interrupt code only reasons about the IRQ line. With that, Acked-by: Ard Biesheuvel > --- > MdeModulePkg/MdeModulePkg.dsc | 2 +- > .../NestedInterruptTplLib.inf | 3 +++ > .../Library/NestedInterruptTplLib/Iret.c | 18 ++++++++++++++++++ > 3 files changed, 22 insertions(+), 1 deletion(-) > > diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc > index 5b9ddfd26e75..4565b8e1b6e7 100644 > --- a/MdeModulePkg/MdeModulePkg.dsc > +++ b/MdeModulePkg/MdeModulePkg.dsc > @@ -462,6 +462,7 @@ [Components.IA32, Components.X64, Components.AARCH64] > > [Components.IA32, Components.X64, Components.ARM, Components.AARCH64] > MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliCustomDecompressLib.inf > + MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf > MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf > MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf > MdeModulePkg/Core/Dxe/DxeMain.inf { > @@ -526,7 +527,6 @@ [Components.IA32, Components.X64] > MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.inf > MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.inf > MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTLib.inf > - MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf > > [Components.X64] > MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf > diff --git a/MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf b/MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf > index e67d899b9446..1501f067d77f 100644 > --- a/MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf > +++ b/MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf > @@ -27,6 +27,9 @@ [Packages] > MdePkg/MdePkg.dec > MdeModulePkg/MdeModulePkg.dec > > +[Packages.ARM, Packages.AARCH64] > + ArmPkg/ArmPkg.dec > + > [LibraryClasses] > BaseLib > DebugLib > diff --git a/MdeModulePkg/Library/NestedInterruptTplLib/Iret.c b/MdeModulePkg/Library/NestedInterruptTplLib/Iret.c > index f6b2c51b6cc1..87cb74566730 100644 > --- a/MdeModulePkg/Library/NestedInterruptTplLib/Iret.c > +++ b/MdeModulePkg/Library/NestedInterruptTplLib/Iret.c > @@ -9,6 +9,10 @@ > #include > #include > > +#if defined (MDE_CPU_AARCH64) || defined (MDE_CPU_ARM) > +#include > +#endif > + > #include "Iret.h" > > /** > @@ -54,6 +58,20 @@ DisableInterruptsOnIret ( > Eflags.Bits.IF = 0; > SystemContext.SystemContextIa32->Eflags = Eflags.UintN; > > + #elif defined (MDE_CPU_AARCH64) > + > + // > + // Set IRQ-disabled and FIQ-disabled flags. > + // > + SystemContext.SystemContextAArch64->SPSR |= (SPSR_I | SPSR_F); > + > + #elif defined (MDE_CPU_ARM) > + > + // > + // Set IRQ-disabled and FIQ-disabled flags. > + // > + SystemContext.SystemContextArm->CPSR |= (CPSR_IRQ | CPSR_FIQ); > + > #else > > #error "Unsupported CPU" > -- > 2.43.0 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114212): https://edk2.groups.io/g/devel/message/114212 Mute This Topic: https://groups.io/mt/103911611/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-