[edk2-devel] [PATCH v5 0/6] Microcode related optimizations

Wu, Hao A posted 6 patches 4 years, 3 months ago
Failed in applying to current master (apply log)
UefiCpuPkg/UefiCpuPkg.dec                     |   3 +
UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf |   1 +
UefiCpuPkg/Include/Guid/MicrocodePatchHob.h   |  44 +++
UefiCpuPkg/Library/MpInitLib/MpLib.h          |  59 +++-
UefiCpuPkg/Library/MpInitLib/Microcode.c      | 351 ++++++++++++++++++--
UefiCpuPkg/Library/MpInitLib/MpLib.c          | 110 +++---
UefiCpuPkg/Library/MpInitLib/PeiMpLib.c       |  55 +++
7 files changed, 513 insertions(+), 110 deletions(-)
create mode 100644 UefiCpuPkg/Include/Guid/MicrocodePatchHob.h
[edk2-devel] [PATCH v5 0/6] Microcode related optimizations
Posted by Wu, Hao A 4 years, 3 months ago
Series is also available at:
https://github.com/hwu25/edk2/tree/mpinitlib_opt_v5

V5 changes:
A. For patch 2, address a typo to resolve enlarging the microcode patch
   information buffer too early when it is not full;
B. For patch 4, relocate the logic of storing detected microcode patch
   before the application of microcode patch.

V4 history:
A. For patch 2, keep the calling sequence of functions:
   MicrocodeDetect() and MtrrGetAllMtrrs() unchanged for BSP.
B. For patch 2, in function LoadMicrocodePatch(), add the missing logic
   that handles the Extended Signature Table of a microcode patch.


V3 history:
For patch 3, correct license information for newly added header file.

V2 history:
A. For patch 2, rename function parameters and variables to better reflect
   their usage;
B. For patch 2, remove unneeded check in LoadMicrocodePatchWorker();
C. For patch 3, rename a couple of fields in the HOB structure;
D. For patch 3, update the 'ProcessorSpecificPatchOffset' field to point
   to the microcode patch header instead of microcode patch data;
E. Add a new patch 5 to address an issue that certain fields in the
   CPU_MP_DATA structure cannot be passed from PEI phase to DXE phase;
F. Add a new patch 6 to remove the redundant microcode related fields in
   the CPU_MP_DATA structure.

V1 history:
This series will introduce a couple of optimizations to the MpInitLib with
regard to microcode:

A. Reduce the copy size when loading the microcode patches data from flash
   into memory;
B. Produce a HOB to contain microcode patches information for subsequent
   consumers of the microcode patches during the boot flow.

Uni-test done for the series:
A. System boot to OS/Shell successfully on a real platform;
B. Add debug message to verify the same microcode patch is applied to each
   processor before and after the series.


Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>

Hao A Wu (6):
  UefiCpuPkg/MpInitLib: Collect processors' CPUID & Platform ID info
  UefiCpuPkg/MpInitLib: Reduce the size when loading microcode patches
  UefiCpuPkg: Add definitions for EDKII microcode patch HOB
  UefiCpuPkg/MpInitLib: Produce EDKII microcode patch HOB
  UefiCpuPkg/MpInitLib: Relocate microcode patch fields in CPU_MP_DATA
  UefiCpuPkg/MpInitLib: Remove redundant microcode fields in CPU_MP_DATA

 UefiCpuPkg/UefiCpuPkg.dec                     |   3 +
 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf |   1 +
 UefiCpuPkg/Include/Guid/MicrocodePatchHob.h   |  44 +++
 UefiCpuPkg/Library/MpInitLib/MpLib.h          |  59 +++-
 UefiCpuPkg/Library/MpInitLib/Microcode.c      | 351 ++++++++++++++++++--
 UefiCpuPkg/Library/MpInitLib/MpLib.c          | 110 +++---
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c       |  55 +++
 7 files changed, 513 insertions(+), 110 deletions(-)
 create mode 100644 UefiCpuPkg/Include/Guid/MicrocodePatchHob.h

-- 
2.12.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52613): https://edk2.groups.io/g/devel/message/52613
Mute This Topic: https://groups.io/mt/69341881/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
Posted by Ni, Ray 4 years, 3 months ago
Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao
> A
> Sent: Tuesday, December 31, 2019 8:49 AM
> To: devel@edk2.groups.io
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Dong, Eric <eric.dong@intel.com>; Ni,
> Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Zeng, Star
> <star.zeng@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Kinney, Michael
> D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
> 
> Series is also available at:
> https://github.com/hwu25/edk2/tree/mpinitlib_opt_v5
> 
> V5 changes:
> A. For patch 2, address a typo to resolve enlarging the microcode patch
>    information buffer too early when it is not full;
> B. For patch 4, relocate the logic of storing detected microcode patch
>    before the application of microcode patch.
> 
> V4 history:
> A. For patch 2, keep the calling sequence of functions:
>    MicrocodeDetect() and MtrrGetAllMtrrs() unchanged for BSP.
> B. For patch 2, in function LoadMicrocodePatch(), add the missing logic
>    that handles the Extended Signature Table of a microcode patch.
> 
> 
> V3 history:
> For patch 3, correct license information for newly added header file.
> 
> V2 history:
> A. For patch 2, rename function parameters and variables to better reflect
>    their usage;
> B. For patch 2, remove unneeded check in LoadMicrocodePatchWorker();
> C. For patch 3, rename a couple of fields in the HOB structure;
> D. For patch 3, update the 'ProcessorSpecificPatchOffset' field to point
>    to the microcode patch header instead of microcode patch data;
> E. Add a new patch 5 to address an issue that certain fields in the
>    CPU_MP_DATA structure cannot be passed from PEI phase to DXE phase;
> F. Add a new patch 6 to remove the redundant microcode related fields in
>    the CPU_MP_DATA structure.
> 
> V1 history:
> This series will introduce a couple of optimizations to the MpInitLib with
> regard to microcode:
> 
> A. Reduce the copy size when loading the microcode patches data from flash
>    into memory;
> B. Produce a HOB to contain microcode patches information for subsequent
>    consumers of the microcode patches during the boot flow.
> 
> Uni-test done for the series:
> A. System boot to OS/Shell successfully on a real platform;
> B. Add debug message to verify the same microcode patch is applied to each
>    processor before and after the series.
> 
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> 
> Hao A Wu (6):
>   UefiCpuPkg/MpInitLib: Collect processors' CPUID & Platform ID info
>   UefiCpuPkg/MpInitLib: Reduce the size when loading microcode patches
>   UefiCpuPkg: Add definitions for EDKII microcode patch HOB
>   UefiCpuPkg/MpInitLib: Produce EDKII microcode patch HOB
>   UefiCpuPkg/MpInitLib: Relocate microcode patch fields in CPU_MP_DATA
>   UefiCpuPkg/MpInitLib: Remove redundant microcode fields in
> CPU_MP_DATA
> 
>  UefiCpuPkg/UefiCpuPkg.dec                     |   3 +
>  UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf |   1 +
>  UefiCpuPkg/Include/Guid/MicrocodePatchHob.h   |  44 +++
>  UefiCpuPkg/Library/MpInitLib/MpLib.h          |  59 +++-
>  UefiCpuPkg/Library/MpInitLib/Microcode.c      | 351 ++++++++++++++++++-
> -
>  UefiCpuPkg/Library/MpInitLib/MpLib.c          | 110 +++---
>  UefiCpuPkg/Library/MpInitLib/PeiMpLib.c       |  55 +++
>  7 files changed, 513 insertions(+), 110 deletions(-)
>  create mode 100644 UefiCpuPkg/Include/Guid/MicrocodePatchHob.h
> 
> --
> 2.12.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52640): https://edk2.groups.io/g/devel/message/52640
Mute This Topic: https://groups.io/mt/69341881/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
Posted by Wu, Hao A 4 years, 3 months ago
Ray and Eric, thanks a lot for the review.

Hello Laszlo,
It seems that you are out of office, I plan to push the series without your
comments first. If you have feedbacks/comments with regard to the series, I
will follow up for the potential refine/revert of the series.

Best Regards,
Hao Wu


> -----Original Message-----
> From: Ni, Ray
> Sent: Thursday, January 02, 2020 10:40 AM
> To: devel@edk2.groups.io; Wu, Hao A
> Cc: Dong, Eric; Laszlo Ersek; Zeng, Star; Fu, Siyuan; Kinney, Michael D
> Subject: RE: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
> 
> Reviewed-by: Ray Ni <ray.ni@intel.com>
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu,
> Hao
> > A
> > Sent: Tuesday, December 31, 2019 8:49 AM
> > To: devel@edk2.groups.io
> > Cc: Wu, Hao A <hao.a.wu@intel.com>; Dong, Eric <eric.dong@intel.com>;
> Ni,
> > Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Zeng, Star
> > <star.zeng@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Kinney,
> Michael
> > D <michael.d.kinney@intel.com>
> > Subject: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
> >
> > Series is also available at:
> > https://github.com/hwu25/edk2/tree/mpinitlib_opt_v5
> >
> > V5 changes:
> > A. For patch 2, address a typo to resolve enlarging the microcode patch
> >    information buffer too early when it is not full;
> > B. For patch 4, relocate the logic of storing detected microcode patch
> >    before the application of microcode patch.
> >
> > V4 history:
> > A. For patch 2, keep the calling sequence of functions:
> >    MicrocodeDetect() and MtrrGetAllMtrrs() unchanged for BSP.
> > B. For patch 2, in function LoadMicrocodePatch(), add the missing logic
> >    that handles the Extended Signature Table of a microcode patch.
> >
> >
> > V3 history:
> > For patch 3, correct license information for newly added header file.
> >
> > V2 history:
> > A. For patch 2, rename function parameters and variables to better reflect
> >    their usage;
> > B. For patch 2, remove unneeded check in LoadMicrocodePatchWorker();
> > C. For patch 3, rename a couple of fields in the HOB structure;
> > D. For patch 3, update the 'ProcessorSpecificPatchOffset' field to point
> >    to the microcode patch header instead of microcode patch data;
> > E. Add a new patch 5 to address an issue that certain fields in the
> >    CPU_MP_DATA structure cannot be passed from PEI phase to DXE phase;
> > F. Add a new patch 6 to remove the redundant microcode related fields in
> >    the CPU_MP_DATA structure.
> >
> > V1 history:
> > This series will introduce a couple of optimizations to the MpInitLib with
> > regard to microcode:
> >
> > A. Reduce the copy size when loading the microcode patches data from
> flash
> >    into memory;
> > B. Produce a HOB to contain microcode patches information for
> subsequent
> >    consumers of the microcode patches during the boot flow.
> >
> > Uni-test done for the series:
> > A. System boot to OS/Shell successfully on a real platform;
> > B. Add debug message to verify the same microcode patch is applied to
> each
> >    processor before and after the series.
> >
> >
> > Cc: Eric Dong <eric.dong@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Laszlo Ersek <lersek@redhat.com>
> > Cc: Star Zeng <star.zeng@intel.com>
> > Cc: Siyuan Fu <siyuan.fu@intel.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> >
> > Hao A Wu (6):
> >   UefiCpuPkg/MpInitLib: Collect processors' CPUID & Platform ID info
> >   UefiCpuPkg/MpInitLib: Reduce the size when loading microcode patches
> >   UefiCpuPkg: Add definitions for EDKII microcode patch HOB
> >   UefiCpuPkg/MpInitLib: Produce EDKII microcode patch HOB
> >   UefiCpuPkg/MpInitLib: Relocate microcode patch fields in CPU_MP_DATA
> >   UefiCpuPkg/MpInitLib: Remove redundant microcode fields in
> > CPU_MP_DATA
> >
> >  UefiCpuPkg/UefiCpuPkg.dec                     |   3 +
> >  UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf |   1 +
> >  UefiCpuPkg/Include/Guid/MicrocodePatchHob.h   |  44 +++
> >  UefiCpuPkg/Library/MpInitLib/MpLib.h          |  59 +++-
> >  UefiCpuPkg/Library/MpInitLib/Microcode.c      | 351
> ++++++++++++++++++-
> > -
> >  UefiCpuPkg/Library/MpInitLib/MpLib.c          | 110 +++---
> >  UefiCpuPkg/Library/MpInitLib/PeiMpLib.c       |  55 +++
> >  7 files changed, 513 insertions(+), 110 deletions(-)
> >  create mode 100644 UefiCpuPkg/Include/Guid/MicrocodePatchHob.h
> >
> > --
> > 2.12.0.windows.1
> >
> >
> > 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52641): https://edk2.groups.io/g/devel/message/52641
Mute This Topic: https://groups.io/mt/69341881/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
Posted by Laszlo Ersek 4 years, 3 months ago
On 01/02/20 04:12, Wu, Hao A wrote:
> Ray and Eric, thanks a lot for the review.
> 
> Hello Laszlo,
> It seems that you are out of office, I plan to push the series without your
> comments first. If you have feedbacks/comments with regard to the series, I
> will follow up for the potential refine/revert of the series.

Just returned today. I'm now working to regain control of my mailbox.

The above procedure works fine for me; in fact I would have suggested it
myself. In case I encounter a regression with OVMF, I'll report it.

Thank you!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52654): https://edk2.groups.io/g/devel/message/52654
Mute This Topic: https://groups.io/mt/69341881/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
Posted by Laszlo Ersek 4 years, 3 months ago
Hello Hao,

On 01/02/20 16:07, Laszlo Ersek wrote:
> On 01/02/20 04:12, Wu, Hao A wrote:
>> Ray and Eric, thanks a lot for the review.
>>
>> Hello Laszlo,
>> It seems that you are out of office, I plan to push the series without your
>> comments first. If you have feedbacks/comments with regard to the series, I
>> will follow up for the potential refine/revert of the series.
> 
> Just returned today. I'm now working to regain control of my mailbox.
> 
> The above procedure works fine for me; in fact I would have suggested it
> myself. In case I encounter a regression with OVMF, I'll report it.

I've now run some regression tests [*], with OVMF built at commit
b948a496150f ("UefiCpuPkg/PiSmmCpuDxeSmm: Pre-allocate PROCEDURE_TOKEN
buffer", 2020-01-02). At that stage, the tree contains your present
patch series too (which ends at commit fd30b0070773).

[*] Including, but a bit more than,
<https://github.com/tianocore/tianocore.github.io/wiki/Testing-SMM-with-QEMU,-KVM-and-libvirt#tests-to-perform-in-the-installed-guest-fedora-26-guest>.
Basically my usual Linux guest tests.


I haven't noticed any regressions.

Thanks!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52844): https://edk2.groups.io/g/devel/message/52844
Mute This Topic: https://groups.io/mt/69341881/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
Posted by Wu, Hao A 4 years, 3 months ago
> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Saturday, January 04, 2020 4:09 AM
> To: Wu, Hao A; Ni, Ray; Dong, Eric; devel@edk2.groups.io
> Cc: Zeng, Star; Fu, Siyuan; Kinney, Michael D
> Subject: Re: [edk2-devel] [PATCH v5 0/6] Microcode related optimizations
> 
> Hello Hao,
> 
> On 01/02/20 16:07, Laszlo Ersek wrote:
> > On 01/02/20 04:12, Wu, Hao A wrote:
> >> Ray and Eric, thanks a lot for the review.
> >>
> >> Hello Laszlo,
> >> It seems that you are out of office, I plan to push the series without your
> >> comments first. If you have feedbacks/comments with regard to the
> series, I
> >> will follow up for the potential refine/revert of the series.
> >
> > Just returned today. I'm now working to regain control of my mailbox.
> >
> > The above procedure works fine for me; in fact I would have suggested it
> > myself. In case I encounter a regression with OVMF, I'll report it.
> 
> I've now run some regression tests [*], with OVMF built at commit
> b948a496150f ("UefiCpuPkg/PiSmmCpuDxeSmm: Pre-allocate
> PROCEDURE_TOKEN
> buffer", 2020-01-02). At that stage, the tree contains your present
> patch series too (which ends at commit fd30b0070773).
> 
> [*] Including, but a bit more than,
> <https://github.com/tianocore/tianocore.github.io/wiki/Testing-SMM-with-
> QEMU,-KVM-and-libvirt#tests-to-perform-in-the-installed-guest-fedora-26-
> guest>.
> Basically my usual Linux guest tests.
> 
> 
> I haven't noticed any regressions.


Got it, thanks a lot for the testing effort.

Best Regards,
Hao Wu


> 
> Thanks!
> Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52855): https://edk2.groups.io/g/devel/message/52855
Mute This Topic: https://groups.io/mt/69341881/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-