public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: "Gao, Zhichao" <zhichao.gao@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>,
	"Wu, Hao A" <hao.a.wu@intel.com>, "Ni, Ray" <ray.ni@intel.com>,
	"Zeng, Star" <star.zeng@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>,
	Sean Brogan <sean.brogan@microsoft.com>,
	Michael Turner <Michael.Turner@microsoft.com>,
	Bret Barkelew <Bret.Barkelew@microsoft.com>,
	Laszlo Ersek <lersek@redhat.com>
Subject: Re: [edk2-devel] [PATCH V2 4/4] MdeModulePkg/CapsuleRuntimeDxe: Implement RuntimeServicesSupported
Date: Mon, 22 Jul 2019 03:39:17 +0000	[thread overview]
Message-ID: <E92EE9817A31E24EB0585FDF735412F5B9D7AE3A@ORSMSX113.amr.corp.intel.com> (raw)
In-Reply-To: <3CE959C139B4C44DBEA1810E3AA6F9000B809356@SHSMSX101.ccr.corp.intel.com>

The UefiRuntimeLib has an EfiAtRuntime() service.  Pease
use that instead.  The CapsuleRuntimeDxe module is already
using the UefiRuntimeLib library.  The patch below adds a
2nd ExitBootServices event and global that is not needed.

Thanks,

Mike

> -----Original Message-----
> From: Gao, Zhichao
> Sent: Sunday, July 21, 2019 7:54 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>;
> devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>; Zeng,
> Star <star.zeng@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Sean Brogan
> <sean.brogan@microsoft.com>; Michael Turner
> <Michael.Turner@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>; Laszlo Ersek
> <lersek@redhat.com>
> Subject: RE: [edk2-devel] [PATCH V2 4/4]
> MdeModulePkg/CapsuleRuntimeDxe: Implement
> RuntimeServicesSupported
> 
> Hi Mike,
> 
> I agree to remove the GetVariable. But why for
> ExitBootServices? If we remove that, the services would
> be disabled at both boot phase and runtime phase.
> 
> 
> Thanks,
> Zhichao
> 
> > -----Original Message-----
> > From: Kinney, Michael D
> > Sent: Saturday, July 20, 2019 12:09 AM
> > To: devel@edk2.groups.io; Gao, Zhichao
> <zhichao.gao@intel.com>;
> > Kinney, Michael D <michael.d.kinney@intel.com>
> > Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> > <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>; Zeng,
> Star
> > <star.zeng@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Sean Brogan
> > <sean.brogan@microsoft.com>; Michael Turner
> > <Michael.Turner@microsoft.com>; Bret Barkelew
> > <Bret.Barkelew@microsoft.com>; Laszlo Ersek
> <lersek@redhat.com>
> > Subject: RE: [edk2-devel] [PATCH V2 4/4]
> MdeModulePkg/CapsuleRuntimeDxe:
> > Implement RuntimeServicesSupported
> >
> > Zhichao,
> >
> > The GetVariable and ExitBootServices events should be
> removed from
> > this patch.  I recommend RT drivers that produce RT
> services consume
> > the new PCD to determine if the services return
> EFI_UNSUPPORTED or not
> > after ExitBootServices().  This keeps RT Driver as
> simple as possible
> > and removes the need for the UEFI Variable to be in a
> known state
> > earlier in the boot and removes the need for RT Drivers
> to setup extra notification events.
> >
> > The new UEFI Variable is intended to be used by OS
> Loaders and OS
> > Kernels that call ExitBootServices() and need to know
> if specific RT
> > services are available or not after ExitBootServices().
> >
> > Thanks,
> >
> > Mike
> >
> > > -----Original Message-----
> > > From: devel@edk2.groups.io
> [mailto:devel@edk2.groups.io] On Behalf
> > > Of Gao, Zhichao
> > > Sent: Friday, July 19, 2019 1:09 AM
> > > To: devel@edk2.groups.io
> > > Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> > > <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>;
> Zeng, Star
> > > <star.zeng@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Sean
> > > Brogan <sean.brogan@microsoft.com>; Michael Turner
> > > <Michael.Turner@microsoft.com>; Bret Barkelew
> > > <Bret.Barkelew@microsoft.com>; Laszlo Ersek
> <lersek@redhat.com>
> > > Subject: [edk2-devel] [PATCH V2 4/4]
> > > MdeModulePkg/CapsuleRuntimeDxe: Implement
> RuntimeServicesSupported
> > >
> > > REF:
> https://bugzilla.tianocore.org/show_bug.cgi?id=1907
> > >
> > > 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 <jian.j.wang@intel.com>
> > > Cc: Hao A Wu <hao.a.wu@intel.com>
> > > Cc: Ray Ni <ray.ni@intel.com>
> > > Cc: Star Zeng <star.zeng@intel.com>
> > > Cc: Liming gao <liming.gao@intel.com>
> > > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > > Cc: Michael Turner <Michael.Turner@microsoft.com>
> > > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > Cc: Laszlo Ersek <lersek@redhat.com>
> > > Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> > > ---
> > >  .../CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf   |  2 +
> > >  .../CapsuleRuntimeDxe/CapsuleService.c        | 68
> > > +++++++++++++++++++
> > >  2 files changed, 70 insertions(+)
> > >
> > > diff --git
> > >
> a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntim
> > > eDxe.inf
> > >
> b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntim
> > > eDxe.inf
> > > index 9da450722b..15d498863a 100644
> > > ---
> > >
> a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntim
> > > eDxe.inf
> > > +++
> > >
> b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntim
> > > eDxe.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
> handle >4GB
> > > capsule blocks
> > >    gEfiCapsuleVendorGuid
> > >    gEfiFmpCapsuleGuid                            ##
> > > SOMETIMES_CONSUMES   ## GUID # FMP capsule GUID
> > > +  gEfiGlobalVariableGuid                        ##
> > > CONSUMES             ## Variable
> > > L"RuntimeServicesSupported"
> > > +  gEfiEventExitBootServicesGuid                 ##
> > > CONSUMES
> > >
> > >  [Protocols]
> > >    gEfiCapsuleArchProtocolGuid                   ##
> > > PRODUCES
> > > diff --git
> > >
> a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleServic
> > > e.c
> > >
> b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleServic
> > > e.c
> > > index 77b8f00062..e4e700764b 100644
> > > ---
> > >
> a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleServic
> > > e.c
> > > +++
> > >
> b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleServic
> > > e.c
> > > @@ -24,6 +24,13 @@ UINTN       mTimes      = 0;
> > >  UINT32      mMaxSizePopulateCapsule     = 0;
> > >  UINT32      mMaxSizeNonPopulateCapsule  = 0;
> > >
> > > +//
> > > +// Runtime Services Supported Flag
> > > +// Initialize it to 0x3FFF to indicate it is all
> > > supported before
> > > +runtime //
> > > +static UINT16     mRuntimeServicesSupported =
> 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 payload should persist @@ -71,6
> > > +78,10 @@ UpdateCapsule (
> > >    CHAR16                    CapsuleVarName[30];
> > >    CHAR16                    *TempVarName;
> > >
> > > +  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 support Capsule In
> RAM.
> > > @@ -259,6 +270,10 @@ QueryCapsuleCapabilities (
> > >    EFI_CAPSULE_HEADER        *CapsuleHeader;
> > >    BOOLEAN                   NeedReset;
> > >
> > > +  if (!(mRuntimeServicesSupported |
> > > EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES)) {
> > > +    return EFI_UNSUPPORTED;
> > > +  }
> > > +
> > >    //
> > >    // Capsule Count can't be less than one.
> > >    //
> > > @@ -343,6 +358,48 @@ QueryCapsuleCapabilities (
> > >    return EFI_SUCCESS;
> > >  }
> > >
> > > +/**
> > > +  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 = EFI_VARIABLE_BOOTSERVICE_ACCESS |
> > > + EFI_VARIABLE_RUNTIME_ACCESS;  DataSize = sizeof
> > > (UINT16);  Status =
> > > + gRT->GetVariable (
> > > +                  L"RuntimeServicesSupported",
> > > +                  &gEfiGlobalVariableGuid,
> > > +                  &Attributes,
> > > +                  &DataSize,
> > > +                  &RuntimeServicesSupported
> > > +                  );
> > > +
> > > +  if (!EFI_ERROR (Status)) {
> > > +    mRuntimeServicesSupported =
> > > RuntimeServicesSupported;
> > > +  } else if (Status == EFI_NOT_FOUND) {
> > > +    mRuntimeServicesSupported = 0x3FFF;
> > > +  } else {
> > > +    //
> > > +    // Should never arrive here.
> > > +    //
> > > +    ASSERT_EFI_ERROR (Status);
> > > +  }
> > > +}
> > > +
> > >
> > >  /**
> > >
> > > @@ -362,6 +419,7 @@ CapsuleServiceInitialize (
> > >    )
> > >  {
> > >    EFI_STATUS  Status;
> > > +  EFI_EVENT   Event;
> > >
> > >    mMaxSizePopulateCapsule =
> > > PcdGet32(PcdMaxSizePopulateCapsule);
> > >    mMaxSizeNonPopulateCapsule =
> > > PcdGet32(PcdMaxSizeNonPopulateCapsule);
> > > @@ -381,6 +439,16 @@ CapsuleServiceInitialize (
> > >    gRT->UpdateCapsule                    =
> > > UpdateCapsule;
> > >    gRT->QueryCapsuleCapabilities         =
> > > QueryCapsuleCapabilities;
> > >
> > > +  Status = 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.
> > > --
> > > 2.21.0.windows.1
> > >
> > >
> > > 


  reply	other threads:[~2019-07-22  3:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19  8:09 [PATCH V2 0/4] Add a pcd PcdBootManagerInBootOrder to control whether BootManager is in BootOrder Gao, Zhichao
2019-07-19  8:09 ` [PATCH V2 1/4] MdePkg/UefiSpec.h: Add define of runtime services support Gao, Zhichao
2019-07-19  8:09 ` [PATCH V2 2/4] MdePkg: Add new pcd PcdRuntimeServicesSupport Gao, Zhichao
2019-07-19  8:09 ` [PATCH V2 3/4] MdeModulePkg/RuntimeDxe: Set RuntimeServicesSupport base on Pcd Gao, Zhichao
2019-07-19 16:01   ` [edk2-devel] " Michael D Kinney
2019-07-19  8:09 ` [PATCH V2 4/4] MdeModulePkg/CapsuleRuntimeDxe: Implement RuntimeServicesSupported Gao, Zhichao
2019-07-19 16:08   ` [edk2-devel] " Michael D Kinney
2019-07-22  2:53     ` Gao, Zhichao
2019-07-22  3:39       ` Michael D Kinney [this message]
2019-07-19 14:15 ` [PATCH V2 0/4] Add a pcd PcdBootManagerInBootOrder to control whether BootManager is in BootOrder Laszlo Ersek
2019-07-22  3:17   ` [edk2-devel] " Gao, Zhichao
2019-07-22 17:28     ` Laszlo Ersek

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=E92EE9817A31E24EB0585FDF735412F5B9D7AE3A@ORSMSX113.amr.corp.intel.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