UefiCpuPkg/MicrocodeUpdate: Add MP support.
Support the case that BSP and AP are using different Microcode. The previous logic validates new MCU on BSP only. The enhanced logic will validate MCU on every BSP and AP. As long as one processor loads the MCU successfully, it will be updated. Cc: Jeff Fan <jeff.fan@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com>
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
#include <Guid/MicrocodeFmp.h>
|
||||
|
||||
#include <Protocol/FirmwareManagement.h>
|
||||
#include <Protocol/MpService.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
@ -56,6 +57,19 @@ typedef struct {
|
||||
BOOLEAN InUse;
|
||||
} MICROCODE_INFO;
|
||||
|
||||
typedef struct {
|
||||
UINTN CpuIndex;
|
||||
UINT32 ProcessorSignature;
|
||||
UINT8 PlatformId;
|
||||
UINT32 MicrocodeRevision;
|
||||
UINTN MicrocodeIndex;
|
||||
} PROCESSOR_INFO;
|
||||
|
||||
typedef struct {
|
||||
UINT64 Address;
|
||||
UINT32 Revision;
|
||||
} MICROCODE_LOAD_BUFFER;
|
||||
|
||||
struct _MICROCODE_FMP_PRIVATE_DATA {
|
||||
UINT32 Signature;
|
||||
EFI_FIRMWARE_MANAGEMENT_PROTOCOL Fmp;
|
||||
@ -68,6 +82,10 @@ struct _MICROCODE_FMP_PRIVATE_DATA {
|
||||
UINT32 PackageVersion;
|
||||
CHAR16 *PackageVersionName;
|
||||
MICROCODE_FMP_LAST_ATTEMPT_VARIABLE LastAttempt;
|
||||
EFI_MP_SERVICES_PROTOCOL *MpService;
|
||||
UINTN BspIndex;
|
||||
UINTN ProcessorCount;
|
||||
PROCESSOR_INFO *ProcessorInfo;
|
||||
};
|
||||
|
||||
typedef struct _MICROCODE_FMP_PRIVATE_DATA MICROCODE_FMP_PRIVATE_DATA;
|
||||
@ -107,11 +125,26 @@ GetMicrocodeRegion (
|
||||
OUT UINTN *MicrocodePatchRegionSize
|
||||
);
|
||||
|
||||
/**
|
||||
Collect processor information.
|
||||
The function prototype for invoking a function on an Application Processor.
|
||||
|
||||
@param[in,out] Buffer The pointer to private data buffer.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
CollectProcessorInfo (
|
||||
IN OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Get current Microcode information.
|
||||
|
||||
NOTE: The DescriptorCount/ImageDescriptor/MicrocodeInfo in MicrocodeFmpPrivate
|
||||
are not avaiable in this function.
|
||||
The ProcessorInformation (BspIndex/ProcessorCount/ProcessorInfo)
|
||||
in MicrocodeFmpPrivate must be initialized.
|
||||
|
||||
The MicrocodeInformation (DescriptorCount/ImageDescriptor/MicrocodeInfo)
|
||||
in MicrocodeFmpPrivate may not be avaiable in this function.
|
||||
|
||||
@param[in] MicrocodeFmpPrivate The Microcode driver private data
|
||||
@param[in] DescriptorCount The count of Microcode ImageDescriptor allocated.
|
||||
@ -128,6 +161,40 @@ GetMicrocodeInfo (
|
||||
OUT MICROCODE_INFO *MicrocodeInfo OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Verify Microcode.
|
||||
|
||||
Caution: This function may receive untrusted input.
|
||||
|
||||
@param[in] MicrocodeFmpPrivate The Microcode driver private data
|
||||
@param[in] Image The Microcode image buffer.
|
||||
@param[in] ImageSize The size of Microcode image buffer in bytes.
|
||||
@param[in] TryLoad Try to load Microcode or not.
|
||||
@param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
|
||||
@param[out] AbortReason A pointer to a pointer to a null-terminated string providing more
|
||||
details for the aborted operation. The buffer is allocated by this function
|
||||
with AllocatePool(), and it is the caller's responsibility to free it with a
|
||||
call to FreePool().
|
||||
@param[in, out] TargetCpuIndex On input, the index of target CPU which tries to match the Microcode. (UINTN)-1 means to try all.
|
||||
On output, the index of target CPU which matches the Microcode.
|
||||
|
||||
@retval EFI_SUCCESS The Microcode image passes verification.
|
||||
@retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt.
|
||||
@retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect.
|
||||
@retval EFI_UNSUPPORTED The Microcode ProcessorSignature or ProcessorFlags is incorrect.
|
||||
@retval EFI_SECURITY_VIOLATION The Microcode image fails to load.
|
||||
**/
|
||||
EFI_STATUS
|
||||
VerifyMicrocode (
|
||||
IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate,
|
||||
IN VOID *Image,
|
||||
IN UINTN ImageSize,
|
||||
IN BOOLEAN TryLoad,
|
||||
OUT UINT32 *LastAttemptStatus,
|
||||
OUT CHAR16 **AbortReason, OPTIONAL
|
||||
IN OUT UINTN *TargetCpuIndex OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Write Microcode.
|
||||
|
||||
@ -157,6 +224,16 @@ MicrocodeWrite (
|
||||
OUT CHAR16 **AbortReason
|
||||
);
|
||||
|
||||
/**
|
||||
Dump private information.
|
||||
|
||||
@param[in] MicrocodeFmpPrivate private data structure.
|
||||
**/
|
||||
VOID
|
||||
DumpPrivateInfo (
|
||||
IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate
|
||||
);
|
||||
|
||||
/**
|
||||
Returns information about the current firmware image(s) of the device.
|
||||
|
||||
|
Reference in New Issue
Block a user