On 03/12/21 07:26, Ankur Arora wrote:
> Call the CPU hot-eject handler if one is installed. The condition for
> installation is (PcdCpuMaxLogicalProcessorNumber > 1), and there's
> a hot-unplug request.
> 
> The handler is called from SmmCpuFeaturesRendezvousExit(), which is
> in-turn called at the tail-end of SmiRendezvous() after the BSP has
> signalled an SMI exit via the "AllCpusInSync" loop.
> 
> Cc: Laszlo Ersek <ler...@redhat.com>
> Cc: Jordan Justen <jordan.l.jus...@intel.com>
> Cc: Ard Biesheuvel <ard.biesheu...@arm.com>
> Cc: Igor Mammedov <imamm...@redhat.com>
> Cc: Boris Ostrovsky <boris.ostrov...@oracle.com>
> Cc: Aaron Young <aaron.yo...@oracle.com>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3132
> Signed-off-by: Ankur Arora <ankur.a.ar...@oracle.com>
> ---
> 
> Notes:
>     Addresses the following comments from v8:
>     
>     (1) Add a MemoryFence() before accessing mCpuHotEjctData->Handler
>         (and comment to that effect.)
> 
>  .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c  | 34 
> ++++++++++++++++++++++
>  1 file changed, 34 insertions(+)

Reviewed-by: Laszlo Ersek <ler...@redhat.com>

Thanks
Laszlo

> diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c 
> b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
> index 5c025bc717c3..fdf2380974fa 100644
> --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
> +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
> @@ -452,6 +452,40 @@ SmmCpuFeaturesRendezvousExit (
>    IN UINTN  CpuIndex
>    )
>  {
> +  //
> +  // We only call the Handler if CPU hot-eject is enabled
> +  // (PcdCpuMaxLogicalProcessorNumber > 1), and hot-eject is needed
> +  // in this SMI exit (otherwise mCpuHotEjectData->Handler is not armed.)
> +  //
> +
> +  if (mCpuHotEjectData != NULL) {
> +    CPU_HOT_EJECT_HANDLER Handler;
> +
> +    //
> +    // As the comment above mentions, mCpuHotEjectData->Handler might be
> +    // written to on the BSP as part of handling of the CPU-ejection.
> +    //
> +    // We know that any initial assignment to mCpuHotEjectData->Handler
> +    // (on the BSP, in the CpuHotplugMmi() context) is ordered-before the
> +    // load below, since it is guaranteed to happen before the
> +    // control-dependency of the BSP's SMI exit signal -- by way of a store
> +    // to AllCpusInSync (on the BSP, in BspHandler()) and the corresponding
> +    // AllCpusInSync loop (on the APs, in SmiRendezvous()) which depends on
> +    // that store.
> +    //
> +    // This guarantees that these pieces of code can never execute
> +    // simultaneously. In addition, we ensure that the following load is
> +    // ordered-after the AllCpusInSync loop by using a MemoryFence() with
> +    // acquire semantics.
> +    //
> +    MemoryFence();
> +
> +    Handler = mCpuHotEjectData->Handler;
> +
> +    if (Handler != NULL) {
> +      Handler (CpuIndex);
> +    }
> +  }
>  }
>  
>  /**
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#72866): https://edk2.groups.io/g/devel/message/72866
Mute This Topic: https://groups.io/mt/81273609/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to