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 E8914740041 for ; Tue, 23 Jan 2024 15:31:24 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=3YGTU+eLfjSGME/MT/7XyjFG/gnRQZTTTvb3OL4jxEE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Feedback-ID:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1706023883; v=1; b=rFzuwuGp8envrRKhYl+Jbr55TzlJB90YkR22V01AD4LjjBaEreJi4InotvDIaopqRES7bZvC cYG5XaxexZXP7EA+ajqRjjSdqL3AEWO+C+T59t9n86/wUJF1YvAE+3H2MYbW2Dgwrsv7PV+p4Ut D7+QnAjFY3RDQ8eHUfYoHGsk= X-Received: by 127.0.0.2 with SMTP id IhRvYY7687511xeNR698cHi3; Tue, 23 Jan 2024 07:31:23 -0800 X-Received: from a7-11.smtp-out.eu-west-1.amazonses.com (a7-11.smtp-out.eu-west-1.amazonses.com [54.240.7.11]) by mx.groups.io with SMTP id smtpd.web10.15405.1706023882911454888 for ; Tue, 23 Jan 2024 07:31:23 -0800 From: "Michael Brown" To: devel@edk2.groups.io Cc: Ray Ni , Gerd Hoffmann , Laszlo Ersek , Michael Brown , Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 5/5] MdeModulePkg: Extend NestedInterruptTplLib to support Arm CPUs Date: Tue, 23 Jan 2024 15:31:21 +0000 Message-ID: <0102018d36f28a0d-300f8626-f368-49ab-b5e3-3c4edf84ce7e-000000@eu-west-1.amazonses.com> In-Reply-To: <20240123153104.2451759-1-mcb30@ipxe.org> References: <17ACFF3FDD20CD9A.13754@groups.io> <20240123153104.2451759-1-mcb30@ipxe.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_DBL_BLOCKED_OPENDNS,URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on blyat.fensystems.co.uk Feedback-ID: 1.eu-west-1.fspj4M/5bzJ9NLRzJP0PaxRwxrpZqiDQJ1IF94CF2TA=:AmazonSES X-SES-Outgoing: 2024.01.23-54.240.7.11 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,mcb30@ipxe.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: hq2duBcFS2AoMD3BS2c2pbL2x7686176AA= 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=rFzuwuGp; dmarc=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 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 --- 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 (#114211): https://edk2.groups.io/g/devel/message/114211 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] -=-=-=-=-=-=-=-=-=-=-=-