From nobody Mon Feb 9 22:19:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+44032+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44032+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563523798; cv=none; d=zoho.com; s=zohoarc; b=EHu/XfU9r83aQJzzJHsVhNMSHuatAxNJWwIhrKJhJpTJvY5NIckz5cqXulYeAH6iA/a2YTlsD89X65/UsI6B1By+xzuUnih/LlLj3BCAFT7u5KFDx2se1dO1nlRY0tW5YWgwH5MB5FJoxRWDYZpTdtBOMSLMISwjdwKEpHGhams= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563523798; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=lVNx/qMOyAcGfKxvLBk6fIVc08cj7t6tqoVKtPRoGvI=; b=abxyHr+MWxoV+i5kRS7ZDbUePsZqZX63jnybjjZroERLUvkAh9FSL0nehIDSUoTf56ghx/zLhddVysHe6XJlL1i0LuKv5TSwLkLXPPpWM6L2X0PqnIm83YZwJhQzPlNpGteq09KQqCwwUIP3RKgCFjGsuZ8DCSZQgGq+0UpL6tI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44032+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563523798229265.9252042952169; Fri, 19 Jul 2019 01:09:58 -0700 (PDT) Return-Path: X-Received: from mga04.intel.com (mga04.intel.com []) by groups.io with SMTP; Fri, 19 Jul 2019 01:09:57 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2019 01:09:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,281,1559545200"; d="scan'208";a="187951073" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 19 Jul 2019 01:09:55 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming gao , Sean Brogan , Michael Turner , Bret Barkelew , Laszlo Ersek Subject: [edk2-devel] [PATCH V2 4/4] MdeModulePkg/CapsuleRuntimeDxe: Implement RuntimeServicesSupported Date: Fri, 19 Jul 2019 16:09:21 +0800 Message-Id: <20190719080921.17516-5-zhichao.gao@intel.com> In-Reply-To: <20190719080921.17516-1-zhichao.gao@intel.com> References: <20190719080921.17516-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563523797; bh=jz875bokk7Kux50uT6QGtYGBUw97fW4ihK+LWLbKFo0=; h=Cc:Date:From:Reply-To:Subject:To; b=f7LGLLvj7SPg9D3ppmZkcvTmxNJxzNP242JO9eZ9Akqyr7Bw7FrV+a4QvRL+SRTju2A nfHRgokbO61lcGgrjeu66sKNqzTbjHLC3XgjdgULwFOEOQ5qMTfSHUFQ1doRL3Caf0R8j PhVXceJEsONSz4Cy0UYu/rHShcg7PLFucTw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1907 Control the capsule services supported at runtime base on the variable L"RuntimeServicesSupported". It would update a global variable mRuntimeServicesSupported at ExitBootServices event. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Laszlo Ersek Signed-off-by: Zhichao Gao --- .../CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf | 2 + .../CapsuleRuntimeDxe/CapsuleService.c | 68 +++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf= b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf index 9da450722b..15d498863a 100644 --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf @@ -72,6 +72,8 @@ ## SOMETIMES_PRODUCES ## Variable:L"CapsuleLongModeBuffer" # The long = mode buffer used by IA32 Capsule PEIM to call X64 CapsuleCoalesce code to h= andle >4GB capsule blocks gEfiCapsuleVendorGuid gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ##= GUID # FMP capsule GUID + gEfiGlobalVariableGuid ## CONSUMES ##= Variable L"RuntimeServicesSupported" + gEfiEventExitBootServicesGuid ## CONSUMES =20 [Protocols] gEfiCapsuleArchProtocolGuid ## PRODUCES diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/Md= eModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c index 77b8f00062..e4e700764b 100644 --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c @@ -24,6 +24,13 @@ UINTN mTimes =3D 0; UINT32 mMaxSizePopulateCapsule =3D 0; UINT32 mMaxSizeNonPopulateCapsule =3D 0; =20 +// +// Runtime Services Supported Flag +// Initialize it to 0x3FFF to indicate it is all supported before runtime +// +static UINT16 mRuntimeServicesSupported =3D 0x3FFF; + + /** Passes capsules to the firmware with both virtual and physical mapping. = Depending on the intended consumption, the firmware may process the capsule immediately. If the pa= yload should persist @@ -71,6 +78,10 @@ UpdateCapsule ( CHAR16 CapsuleVarName[30]; CHAR16 *TempVarName; =20 + if (!(mRuntimeServicesSupported | EFI_RT_SUPPORTED_UPDATE_CAPSULE)) { + return EFI_UNSUPPORTED; + } + // // Check if platform support Capsule In RAM or not. // Platform could choose to drop CapsulePei/CapsuleX64 and do not suppor= t Capsule In RAM. @@ -259,6 +270,10 @@ QueryCapsuleCapabilities ( EFI_CAPSULE_HEADER *CapsuleHeader; BOOLEAN NeedReset; =20 + if (!(mRuntimeServicesSupported | EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABIL= ITIES)) { + return EFI_UNSUPPORTED; + } + // // Capsule Count can't be less than one. // @@ -343,6 +358,48 @@ QueryCapsuleCapabilities ( return EFI_SUCCESS; } =20 +/** + ExitBootServices Event to update the mRuntimeServicesSupported to + affect the runtime services. + + @param[in] Event Event whose notification function is being invoked + @param[in] Context Pointer to the notification function's context +**/ +static +VOID +EFIAPI +UpdateRuntimeServicesSupported ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + UINT16 RuntimeServicesSupported; + UINT32 Attributes; + UINTN DataSize; + + Attributes =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_AC= CESS; + DataSize =3D sizeof (UINT16); + Status =3D gRT->GetVariable ( + L"RuntimeServicesSupported", + &gEfiGlobalVariableGuid, + &Attributes, + &DataSize, + &RuntimeServicesSupported + ); + + if (!EFI_ERROR (Status)) { + mRuntimeServicesSupported =3D RuntimeServicesSupported; + } else if (Status =3D=3D EFI_NOT_FOUND) { + mRuntimeServicesSupported =3D 0x3FFF; + } else { + // + // Should never arrive here. + // + ASSERT_EFI_ERROR (Status); + } +} + =20 /** =20 @@ -362,6 +419,7 @@ CapsuleServiceInitialize ( ) { EFI_STATUS Status; + EFI_EVENT Event; =20 mMaxSizePopulateCapsule =3D PcdGet32(PcdMaxSizePopulateCapsule); mMaxSizeNonPopulateCapsule =3D PcdGet32(PcdMaxSizeNonPopulateCapsule); @@ -381,6 +439,16 @@ CapsuleServiceInitialize ( gRT->UpdateCapsule =3D UpdateCapsule; gRT->QueryCapsuleCapabilities =3D QueryCapsuleCapabilities; =20 + Status =3D gBS->CreateEventEx( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + UpdateRuntimeServicesSupported, + NULL, + &gEfiEventExitBootServicesGuid, + &Event + ); + ASSERT_EFI_ERROR (Status); + // // Install the Capsule Architectural Protocol on a new handle // to signify the capsule runtime services are ready. --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#44032): https://edk2.groups.io/g/devel/message/44032 Mute This Topic: https://groups.io/mt/32524672/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-