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 93A5CD81163 for ; Tue, 23 Jan 2024 15:31:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+anx4BTa/Sdm5mCpFvBi2wVn/uq2GarhvTiXq8xRjec=; 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=1706023875; v=1; b=XdRqXab7C5OKrelwvX7G5BiNJvfiDD/BioOHrIw7kfnJGrilp6FnEk4TaQiIF8u62Z7YlWFS vHgXeabNKZKQEl4xqMi7XK0OTJDhMPU7Xcm1/eQynIuRcRFssSXtPSRaviHOJsTDf1o7bvqWFR/ ThYxFIuvaKbxnkvoOMLHLEv8= X-Received: by 127.0.0.2 with SMTP id EXqaYY7687511x8Rl6IdP4dE; Tue, 23 Jan 2024 07:31:15 -0800 X-Received: from a7-17.smtp-out.eu-west-1.amazonses.com (a7-17.smtp-out.eu-west-1.amazonses.com [54.240.7.17]) by mx.groups.io with SMTP id smtpd.web11.15654.1706023874339360896 for ; Tue, 23 Jan 2024 07:31:14 -0800 From: "Michael Brown" To: devel@edk2.groups.io Cc: Ray Ni , Gerd Hoffmann , Laszlo Ersek , Michael Brown , Michael D Kinney Subject: [edk2-devel] [PATCH v3 1/5] MdeModulePkg: Move NestedInterruptTplLib to MdeModulePkg Date: Tue, 23 Jan 2024 15:31:12 +0000 Message-ID: <0102018d36f26808-2dde2cd9-2b68-4e87-9357-7f63c1071f03-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.17 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: 6wUgYCl06ZKASS3TBC6w3DfUx7686176AA= 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=XdRqXab7; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none NestedInterruptTplLib provides a way for timer interrupt handlers (which must support nested interrupts) to prevent unbounded stack consumption. The underlying issue was first observed in OvmfPkg, since interrupt storms can arise more easily in virtual machines due to CPU starvation. However, careful investigation shows that the unbounded stack consumption can also occur in physical machines. Move NestedInterruptTplLib from OvmfPkg to MdeModulePkg so that it can more easily be consumed by drivers outside of OvmfPkg. Add NestedInterruptTplLib to the MdeModulePkg component build list for IA32 and X64 only, since those are the only two architectures for which DisableInterruptsOnIret() is currently supported. Cc: Ray Ni Cc: Laszlo Ersek Cc: Gerd Hoffmann Cc: Michael D Kinney Reviewed-by: Laszlo Ersek Signed-off-by: Michael Brown --- MdeModulePkg/MdeModulePkg.dec | 4 ++++ OvmfPkg/OvmfPkg.dec | 4 ---- MdeModulePkg/MdeModulePkg.dsc | 1 + OvmfPkg/AmdSev/AmdSevX64.dsc | 2 +- OvmfPkg/CloudHv/CloudHvX64.dsc | 2 +- OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 +- OvmfPkg/Microvm/MicrovmX64.dsc | 2 +- OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- OvmfPkg/OvmfXen.dsc | 2 +- UefiPayloadPkg/UefiPayloadPkg.dsc | 2 +- .../Library/NestedInterruptTplLib/NestedInterruptTplLib.inf | 2 +- OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf | 2 +- .../Include/Library/NestedInterruptTplLib.h | 0 .../Library/NestedInterruptTplLib/Iret.h | 0 .../Library/NestedInterruptTplLib/Iret.c | 0 {OvmfPkg => MdeModulePkg}/Library/NestedInterruptTplLib/Tpl.c | 0 18 files changed, 16 insertions(+), 15 deletions(-) rename {OvmfPkg => MdeModulePkg}/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf (91%) rename {OvmfPkg => MdeModulePkg}/Include/Library/NestedInterruptTplLib.h (100%) rename {OvmfPkg => MdeModulePkg}/Library/NestedInterruptTplLib/Iret.h (100%) rename {OvmfPkg => MdeModulePkg}/Library/NestedInterruptTplLib/Iret.c (100%) rename {OvmfPkg => MdeModulePkg}/Library/NestedInterruptTplLib/Tpl.c (100%) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index a2cd83345f5b..d6fb729af5a7 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -169,6 +169,10 @@ [LibraryClasses] # ImagePropertiesRecordLib|Include/Library/ImagePropertiesRecordLib.h + ## @libraryclass Handle TPL changes within nested interrupt handlers + # + NestedInterruptTplLib|Include/Library/NestedInterruptTplLib.h + [Guids] ## MdeModule package token space guid # Include/Guid/MdeModulePkgTokenSpace.h diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index b44fa039f76c..05d43d5a6861 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -41,10 +41,6 @@ [LibraryClasses] # MemEncryptTdxLib|Include/Library/MemEncryptTdxLib.h - ## @libraryclass Handle TPL changes within nested interrupt handlers - # - NestedInterruptTplLib|Include/Library/NestedInterruptTplLib.h - ## @libraryclass Save and restore variables using a file # NvVarsFileLib|Include/Library/NvVarsFileLib.h diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 6b3052ff4614..5b9ddfd26e75 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -526,6 +526,7 @@ [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/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index a31a89344a60..80456f878a22 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -354,7 +354,7 @@ [LibraryClasses.common.DXE_DRIVER] !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc index b522fa10594d..9c6c68ae2c35 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.dsc +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc @@ -394,7 +394,7 @@ [LibraryClasses.common.DXE_DRIVER] !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc index 82e3e41cfc57..5270c59e1279 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -310,7 +310,7 @@ [LibraryClasses.common.DXE_DRIVER] LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc index 063324cd0572..8ec00eaf2015 100644 --- a/OvmfPkg/Microvm/MicrovmX64.dsc +++ b/OvmfPkg/Microvm/MicrovmX64.dsc @@ -393,7 +393,7 @@ [LibraryClasses.common.DXE_DRIVER] PciPcdProducerLib|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 28379961a78e..154afbbaf45d 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -401,7 +401,7 @@ [LibraryClasses.common.DXE_DRIVER] !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 5e9eee628aea..0f6173607759 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -407,7 +407,7 @@ [LibraryClasses.common.DXE_DRIVER] !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index bf4c7906c460..93e7e9a18cd0 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -427,7 +427,7 @@ [LibraryClasses.common.DXE_DRIVER] !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 976b795d41c9..c2472aca38aa 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -340,7 +340,7 @@ [LibraryClasses.common.DXE_DRIVER] !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf [LibraryClasses.common.UEFI_APPLICATION] diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 4f195c1e5212..51f18b5c0c2f 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -687,7 +687,7 @@ [Components.X64] !elseif $(TIMER_SUPPORT) == "LAPIC" OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf { - NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf + NestedInterruptTplLib|MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf } !else !error "Invalid TIMER_SUPPORT" diff --git a/OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf b/MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf similarity index 91% rename from OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf rename to MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf index 5eafb4197842..1e03e1364e0f 100644 --- a/OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf +++ b/MdeModulePkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf @@ -24,7 +24,7 @@ [Sources] [Packages] MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec + MdeModulePkg/MdeModulePkg.dec [LibraryClasses] BaseLib diff --git a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf index b85965c75ea3..6dc5ec9bf4aa 100644 --- a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf +++ b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf @@ -20,8 +20,8 @@ [Defines] [Packages] MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec UefiCpuPkg/UefiCpuPkg.dec - OvmfPkg/OvmfPkg.dec [LibraryClasses] UefiBootServicesTableLib diff --git a/OvmfPkg/Include/Library/NestedInterruptTplLib.h b/MdeModulePkg/Include/Library/NestedInterruptTplLib.h similarity index 100% rename from OvmfPkg/Include/Library/NestedInterruptTplLib.h rename to MdeModulePkg/Include/Library/NestedInterruptTplLib.h diff --git a/OvmfPkg/Library/NestedInterruptTplLib/Iret.h b/MdeModulePkg/Library/NestedInterruptTplLib/Iret.h similarity index 100% rename from OvmfPkg/Library/NestedInterruptTplLib/Iret.h rename to MdeModulePkg/Library/NestedInterruptTplLib/Iret.h diff --git a/OvmfPkg/Library/NestedInterruptTplLib/Iret.c b/MdeModulePkg/Library/NestedInterruptTplLib/Iret.c similarity index 100% rename from OvmfPkg/Library/NestedInterruptTplLib/Iret.c rename to MdeModulePkg/Library/NestedInterruptTplLib/Iret.c diff --git a/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c b/MdeModulePkg/Library/NestedInterruptTplLib/Tpl.c similarity index 100% rename from OvmfPkg/Library/NestedInterruptTplLib/Tpl.c rename to MdeModulePkg/Library/NestedInterruptTplLib/Tpl.c -- 2.43.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114207): https://edk2.groups.io/g/devel/message/114207 Mute This Topic: https://groups.io/mt/103911603/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-