From 9d0b29fa51947dbcba4bfdff93c48d1e0526000f Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Mon, 23 Feb 2026 16:11:59 +0000 Subject: [PATCH 01/22] Merged PR 14843740: Trim 32bit support. Delete MsvmPkg/CpuDxe/Ia32/CpuAsm.nasm. We do not use it. ---- #### AI description (iteration 1) #### PR Classification This pull request is a code cleanup effort that removes outdated 32-bit support. #### PR Summary The PR deletes legacy 32-bit assembly code to streamline the codebase in alignment with the cleanup work item. - `/MsvmPkg/CpuDxe/Ia32/CpuAsm.nasm` was removed. Related work items: #60275790 --- MsvmPkg/CpuDxe/Ia32/CpuAsm.nasm | 47 --------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 MsvmPkg/CpuDxe/Ia32/CpuAsm.nasm diff --git a/MsvmPkg/CpuDxe/Ia32/CpuAsm.nasm b/MsvmPkg/CpuDxe/Ia32/CpuAsm.nasm deleted file mode 100644 index 0b99e3e..0000000 --- a/MsvmPkg/CpuDxe/Ia32/CpuAsm.nasm +++ /dev/null @@ -1,47 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2016, Intel Corporation. All rights reserved.
-;* SPDX-License-Identifier: BSD-2-Clause-Patent -;* -;* CpuAsm.nasm -;* -;* Abstract: -;* -;------------------------------------------------------------------------------ - - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; SetCodeSelector ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(SetCodeSelector) -ASM_PFX(SetCodeSelector): - mov ecx, [esp+4] - sub esp, 0x10 - lea eax, [setCodeSelectorLongJump] - mov [esp], eax - mov [esp+4], cx - jmp dword far [esp] -setCodeSelectorLongJump: - add esp, 0x10 - ret - -;------------------------------------------------------------------------------ -; VOID -; SetDataSelectors ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(SetDataSelectors) -ASM_PFX(SetDataSelectors): - mov ecx, [esp+4] -o16 mov ss, cx -o16 mov ds, cx -o16 mov es, cx -o16 mov fs, cx -o16 mov gs, cx - ret - From 7f4e975dea2972530b26e4d6a67274c79b8e551d Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Mon, 23 Feb 2026 17:02:15 +0000 Subject: [PATCH 02/22] Merged PR 14844096: Clang: Remove unused statics. Clang: Remove unused statics. The following are static and not used. Clang warngs. Remove them. AziHsmDumpSqe EncodeApiRevisionResponse DecodeApiRevisionCommandResponse DecodeRequestHeader EncodeResponseHeader ReadAqaReg ReadAsqReg ReadAcqReg CreateTopMenu IsPostReadyToBoot NetvscReceive::counter `git show | findstr /b /c:+` shows no added lines, only deletes, a _sorta_ measure of a review and proof that the description is correct. This is extracted from larger work mostly by John Starks, partly by me (in this case, really, all John). Related work items: #57987809, #60275790 --- MsvmPkg/AziHsmDxe/AziHsmCp.c | 30 -- MsvmPkg/AziHsmDxe/AziHsmDdi.c | 423 ---------------------- MsvmPkg/AziHsmDxe/AziHsmHci.c | 99 ----- MsvmPkg/FrontPage/FrontPage.c | 85 ----- MsvmPkg/FrontPage/FrontPageConfigAccess.c | 34 -- MsvmPkg/FrontPage/FrontPageUi.c | 12 + MsvmPkg/FrontPage/FrontPageUi.h | 103 ------ MsvmPkg/NetvscDxe/NetvscDxe.c | 1 - MsvmPkg/VariableDxe/NvramVariableDxe.c | 6 - 9 files changed, 12 insertions(+), 781 deletions(-) diff --git a/MsvmPkg/AziHsmDxe/AziHsmCp.c b/MsvmPkg/AziHsmDxe/AziHsmCp.c index 5ed500e..846f477 100644 --- a/MsvmPkg/AziHsmDxe/AziHsmCp.c +++ b/MsvmPkg/AziHsmDxe/AziHsmCp.c @@ -12,36 +12,6 @@ #include "AziHsmAdmin.h" #include "AziHsmHci.h" -STATIC -VOID -AziHsmDumpSqe ( - AZIHSM_CP_SQE *Sqe - ) -{ - if (Sqe == NULL) { - DEBUG ((DEBUG_ERROR, "AziHsm: [%a]: Invalid SQE pointer\n", __FUNCTION__)); - return; - } - - DEBUG ((DEBUG_INFO, "AziHsm: [%a]: Dumping SQE\n", __FUNCTION__)); - DEBUG ((DEBUG_INFO, " CmdId: %d\n", Sqe->CmdId)); - DEBUG ((DEBUG_INFO, " CmdSet: %d\n", Sqe->CmdSet)); - DEBUG ((DEBUG_INFO, " OpCode: %d\n", Sqe->OpCode)); - DEBUG ((DEBUG_INFO, " Psdt: %d\n", Sqe->Psdt)); - DEBUG ((DEBUG_INFO, " SrcLen: %d\n", Sqe->SrcLen)); - DEBUG ((DEBUG_INFO, " DstLen: %d\n", Sqe->DstLen)); - DEBUG ((DEBUG_INFO, " Src.Fst: 0x%x Src.Snd: 0x%x\n", Sqe->Src.Prp.Fst, Sqe->Src.Prp.Snd)); - DEBUG ((DEBUG_INFO, " Dst.Fst: 0x%x Dst.Snd: 0x%x\n", Sqe->Dst.Prp.Fst, Sqe->Dst.Prp.Snd)); - DEBUG (( - DEBUG_INFO, - " SessionFlags: OpCode[0x%x] InSessCmd[0x%x] ShortAppIdValid[0x%x] SafeToCloseSess[0x%x]\n", - Sqe->SqeData.SqeSessionData.SessionCtrlFlags.Opcode, - Sqe->SqeData.SqeSessionData.SessionCtrlFlags.InSessionCmd, - Sqe->SqeData.SqeSessionData.SessionCtrlFlags.ShortAppIdValid, - Sqe->SqeData.SqeSessionData.SessionCtrlFlags.SafeToCloseSession - )); -} - EFI_STATUS EFIAPI AziHsmInitHsm ( diff --git a/MsvmPkg/AziHsmDxe/AziHsmDdi.c b/MsvmPkg/AziHsmDxe/AziHsmDdi.c index 011de53..1154fdf 100644 --- a/MsvmPkg/AziHsmDxe/AziHsmDdi.c +++ b/MsvmPkg/AziHsmDxe/AziHsmDdi.c @@ -103,20 +103,6 @@ EncodeCommandRequestHeader ( OUT UINTN *const EncodedSize ); -STATIC EFI_STATUS -DecodeRequestHeader ( - IN OUT AZIHSM_MBOR_DECODER *Decoder, - IN OUT AZIHSM_DDI_REQ_HDR *ReqHdr, - OUT UINTN *DecodedSize - ); - -STATIC EFI_STATUS -EncodeResponseHeader ( - IN OUT AZIHSM_MBOR_ENCODER *Encoder, - IN AZIHSM_DDI_RSP_HDR *RspHdr, - OUT UINTN *EncodedSize - ); - STATIC EFI_STATUS DecodeResponseHeader ( IN OUT AZIHSM_MBOR_DECODER *Decoder, @@ -470,82 +456,6 @@ DecodeApiRevision ( return Status; } -/** - Encodes an API revision response structure into MBOR format. - - This function encodes the API revision response structure containing minimum - and maximum API revision information into MBOR format. Each revision contains - major and minor version numbers. - - @param[in,out] Encoder Pointer to the MBOR encoder structure. - @param[in] ApiRevResponse Pointer to the API revision response structure to encode. - @param[out] EncodedSize Pointer to store the size of encoded data in bytes. - - @retval EFI_SUCCESS API revision response was successfully encoded. - @retval EFI_INVALID_PARAMETER One or more input parameters are NULL. - @retval Other Error from MBOR encoding functions. -**/ -STATIC EFI_STATUS -EncodeApiRevisionResponse ( - IN OUT AZIHSM_MBOR_ENCODER *Encoder, - IN AZIHSM_DDI_API_REV_RESPONSE *ApiRevResponse, - OUT UINTN *EncodedSize - ) -{ - EFI_STATUS Status = EFI_SUCCESS; - // Number of fields in the API revision response structure - CONST UINT8 MAX_FIELD_COUNT = AZIHSM_DDI_API_REV_RESPONSE_FIELD_COUNT; - UINT32 EncoderStartMark = 0; - UINTN TempEncodedSize = 0; - - if ((ApiRevResponse == NULL) || (Encoder == NULL) || (EncodedSize == NULL)) { - *EncodedSize = 0; // mark encoded size to 0 - return EFI_INVALID_PARAMETER; - } - - // Calculate the size of the encoded data - EncoderStartMark = Encoder->Position; - - // Encode the API revision response structure - // [FieldCount:U8:2] - // [FIELD_ID:U8:1][MIN_API_REV:AZIHSM_DDI_API_REV] - // [FIELD_ID:U8:2][MAX_API_REV:AZIHSM_DDI_API_REV] - // where AZIHSM_DDI_API_REV is [FieldCount:U8:2][FIELD_ID:U8:1][MAJOR:U32][FIELD_ID:U8:2][MINOR:U32] - - Status = AziHsmMborEncodeMap (Encoder, MAX_FIELD_COUNT); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // Encode field 1: min API revision - Status = AziHsmMborEncodeFieldId (Encoder, API_REV_RESP_MIN_FIELD_ID); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // EncodeApiRevision function for min API revision - Status = EncodeApiRevision (Encoder, &ApiRevResponse->min, &TempEncodedSize); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // Encode field 2: max API revision - Status = AziHsmMborEncodeFieldId (Encoder, API_REV_RESP_MAX_FIELD_ID); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // EncodeApiRevision function for max API revision - Status = EncodeApiRevision (Encoder, &ApiRevResponse->max, &TempEncodedSize); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - -ExitFunction: - *EncodedSize = Encoder->Position - EncoderStartMark; - return Status; -} - /** Encodes a complete API revision command request into MBOR format. @@ -852,66 +762,6 @@ DecodeApiRevisionCommandResponseData ( return Status; } -/** - Decodes a complete API revision command response from MBOR format. - - This function decodes MBOR format data into the complete DdiGetApiRevCmdResp structure - which contains: - - Response header (DdiRespHdr) with optional revision, operation code, optional session ID, status, and FIPS approval - - Response data (DdiGetApiRevResp) containing min/max API revision information - - Response extension (DdiRespExt) - optional, currently not implemented - - @param[in,out] Decoder Pointer to the MBOR decoder structure. - @param[in,out] RspHdr Pointer to the response header structure to populate. - @param[in,out] ApiRevData Pointer to the API revision response data structure to populate. - @param[out] DecodedSize Pointer to store the size of decoded data in bytes. - - @retval EFI_SUCCESS API revision response was successfully decoded. - @retval EFI_INVALID_PARAMETER One or more input parameters are NULL. - @retval EFI_PROTOCOL_ERROR Field count mismatch or invalid field structure. - @retval EFI_UNSUPPORTED Unknown field ID encountered. - @retval Other Error from MBOR decoding functions. -**/ -STATIC EFI_STATUS -DecodeApiRevisionCommandResponse ( - IN OUT AZIHSM_MBOR_DECODER *Decoder, - IN OUT AZIHSM_DDI_RSP_HDR *RspHdr, - IN OUT AZIHSM_DDI_API_REV_RESPONSE *ApiRevData, - OUT UINTN *DecodedSize - ) -{ - EFI_STATUS Status = EFI_SUCCESS; - UINTN HeaderDecodedSize = 0; - UINTN DataDecodedSize = 0; - UINT32 DecoderStartMark = 0; - - if ((RspHdr == NULL) || (ApiRevData == NULL) || (Decoder == NULL) || (DecodedSize == NULL)) { - *DecodedSize = 0; - return EFI_INVALID_PARAMETER; - } - - DecoderStartMark = Decoder->Position; - - // Step 1: Decode and validate the response header - Status = DecodeCommandResponseHeader (Decoder, RspHdr, &HeaderDecodedSize); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // Step 2: Decode the API revision response data - Status = DecodeApiRevisionCommandResponseData (Decoder, ApiRevData, &DataDecodedSize); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // TODO: Handle optional extension field if present (field ID 2) - // For now, we assume only 2 fields (header + data) are present - -ExitFunction: - *DecodedSize = Decoder->Position - DecoderStartMark; - return Status; -} - /** Decodes a complete API revision command response from MBOR format. @@ -1097,279 +947,6 @@ EncodeRequestHeader ( return Status; } -/** - Decodes a DDI request header structure from MBOR format. - - This function decodes MBOR format data into a DDI request header structure. - It validates field counts, handles optional fields (revision, session ID), - and ensures required fields (DDI operation) are present. The function sets - validity flags for optional fields based on their presence in the data. - - @param[in,out] Decoder Pointer to the MBOR decoder structure. - @param[in,out] ReqHdr Pointer to the DDI request header structure to populate. - @param[out] DecodedSize Pointer to store the size of decoded data in bytes. - - @retval EFI_SUCCESS Request header was successfully decoded. - @retval EFI_INVALID_PARAMETER One or more input parameters are NULL. - @retval EFI_PROTOCOL_ERROR Invalid field count or missing required fields. - @retval EFI_UNSUPPORTED Unknown field ID encountered. - @retval Other Error from MBOR decoding functions. -**/ -STATIC -EFI_STATUS -DecodeRequestHeader ( - IN OUT AZIHSM_MBOR_DECODER *Decoder, - IN OUT AZIHSM_DDI_REQ_HDR *ReqHdr, - OUT UINTN *DecodedSize - ) -{ - // Decode the request header - EFI_STATUS Status = EFI_SUCCESS; - - UINT8 FieldCount = 0; - UINT8 FieldId = 0; - UINT32 DecoderStartMark = Decoder->Position; - UINTN DecodedSizeTmp = 0; - - if ((Decoder == NULL) || (ReqHdr == NULL) || (DecodedSize == NULL)) { - *DecodedSize = 0; - return EFI_INVALID_PARAMETER; - } - - // Clear validity flags - ReqHdr->Revision.Valid = FALSE; - ReqHdr->SessionId.Valid = FALSE; - - // Decode field count - Status = AziHsmMborDecodeMap (Decoder, &FieldCount); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - if ((FieldCount > AZIHSM_DDI_REQ_HDR_FIELD_COUNT) || (FieldCount < MIN_REQ_HDR_FIELD_COUNT)) { - DEBUG (( - DEBUG_WARN, - "AziHsmDdi: Unexpected field count for request header %d expected <= %d\n", - FieldCount, - AZIHSM_DDI_REQ_HDR_FIELD_COUNT - )); - Status = EFI_PROTOCOL_ERROR; - goto ExitFunction; - } - - // Decode fields based on field count and expected logic - UINT32 DdiOpVal = 0; - BOOLEAN DdiOpFound = FALSE; - BOOLEAN RevisionFound = FALSE; - BOOLEAN SessionIdFound = FALSE; - - for (UINT8 i = 0; i < FieldCount; i++) { - Status = AziHsmMborDecodeFieldId (Decoder, &FieldId); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - switch (FieldId) { - case REV_FIELD_ID: - RevisionFound = TRUE; - ReqHdr->Revision.Valid = TRUE; - Status = DecodeApiRevision (Decoder, &ReqHdr->Revision.Value, &DecodedSizeTmp); - break; - case DDI_OP_FIELD_ID: - DdiOpFound = TRUE; - Status = AziHsmMborDecodeU32 (Decoder, &DdiOpVal); - if (!EFI_ERROR (Status)) { - ReqHdr->DdiOp = (DDI_OPERATION_CODE)DdiOpVal; - } - - break; - case SESSION_ID_FIELD_ID: - SessionIdFound = TRUE; - { - UINT16 SessionIdVal = 0; - Status = AziHsmMborDecodeU16 (Decoder, &SessionIdVal); - if (!EFI_ERROR (Status)) { - ReqHdr->SessionId.Valid = TRUE; - ReqHdr->SessionId.Value = SessionIdVal; - } - } - break; - default: - Status = EFI_UNSUPPORTED; - break; - } - - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - } - - // Validate field presence according to logic - if (FieldCount == 1) { - if (!DdiOpFound) { - DEBUG ((DEBUG_WARN, "AziHsmDdi: FieldCount %d but DDI_OP_FIELD_ID not present\n", FieldCount)); - Status = EFI_PROTOCOL_ERROR; - goto ExitFunction; - } - } else if (FieldCount == 2) { - if (!DdiOpFound || (!RevisionFound && !SessionIdFound)) { - DEBUG ((DEBUG_WARN, "AziHsmDdi: FieldCount %d but missing required fields\n", FieldCount)); - Status = EFI_PROTOCOL_ERROR; - goto ExitFunction; - } - } else if (FieldCount == 3) { - if (!DdiOpFound || !RevisionFound || !SessionIdFound) { - DEBUG ((DEBUG_WARN, "AziHsmDdi: FieldCount %d but not all fields present\n", FieldCount)); - Status = EFI_PROTOCOL_ERROR; - goto ExitFunction; - } - } - -ExitFunction: - *DecodedSize = Decoder->Position - DecoderStartMark; - return Status; -} - -/** - Encodes a DDI response header structure into MBOR format. - - This function encodes a DDI response header containing optional revision and - session ID, required DDI operation code, status code, and FIPS approval flag - into MBOR format. The function includes all required fields and optional fields - based on their validity flags. - - @param[in,out] Encoder Pointer to the MBOR encoder structure. - @param[in] RspHdr Pointer to the DDI response header structure to encode. - @param[out] EncodedSize Pointer to store the size of encoded data in bytes. - - @retval EFI_SUCCESS Response header was successfully encoded. - @retval EFI_INVALID_PARAMETER One or more input parameters are NULL. - @retval EFI_PROTOCOL_ERROR Field count exceeds maximum allowed. - @retval Other Error from MBOR encoding functions. -**/ -STATIC EFI_STATUS -EncodeResponseHeader ( - IN OUT AZIHSM_MBOR_ENCODER *Encoder, - IN AZIHSM_DDI_RSP_HDR *RspHdr, - OUT UINTN *EncodedSize - ) -{ - EFI_STATUS Status = EFI_SUCCESS; - UINT32 EncoderStartMark = 0; - UINT8 FieldCount = 0; - UINTN EncodedSizeTmp = 0; - - // Response header is encoded with one or more of the following fields: - // [FieldCount:U8:3/4/5] - // [RSP_HDR_FIELD_ID:U8:1] [Revision:AZIHSM_DDI_API_REV] : Optional - // [RSP_HDR_FIELD_ID:U8:2][DdiOp:DDI_OPERATION_CODE] - // [RSP_HDR_FIELD_ID:U8:3][SessionId:UINT16] : Optional - // [RSP_HDR_FIELD_ID:u8:4] [DdiStatus:UINT32] - // [RSP_HDR_FIELD_ID:u8:5] [fips_approved:BOOLEAN] - - if ((Encoder == NULL) || (RspHdr == NULL) || (EncodedSize == NULL)) { - *EncodedSize = 0; - return EFI_INVALID_PARAMETER; - } - - EncoderStartMark = Encoder->Position; - - // Count valid fields - FieldCount = 0; - if (RspHdr->Revision.Valid == TRUE) { - FieldCount++; - } - - if (RspHdr->SessionId.Valid == TRUE) { - FieldCount++; - } - - FieldCount++; // DdiOp is always present - FieldCount++; // DdiStatus is always present - FieldCount++; // FipsApproved is always present - - // Check if we exceeded the expected field count - if (FieldCount > AZIHSM_DDI_RSP_HDR_FIELD_COUNT) { - DEBUG (( - DEBUG_WARN, - "AziHsmDdi: Unexpected field count for response header %d expected <= %d\n", - FieldCount, - AZIHSM_DDI_RSP_HDR_FIELD_COUNT - )); - Status = EFI_PROTOCOL_ERROR; - goto ExitFunction; - } - - // Encode the response header - Status = AziHsmMborEncodeMap (Encoder, FieldCount); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // Encode Revision if valid - if (RspHdr->Revision.Valid == TRUE) { - Status = AziHsmMborEncodeFieldId (Encoder, RSP_REV_FIELD_ID); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - Status = EncodeApiRevision (Encoder, &RspHdr->Revision.Value, &EncodedSizeTmp); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - } - - // Encode DdiOp (always present) - Status = AziHsmMborEncodeFieldId (Encoder, RSP_DDI_OP_FIELD_ID); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - Status = AziHsmMborEncodeU32 (Encoder, (UINT32)RspHdr->DdiOp); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // Encode SessionId if valid - if (RspHdr->SessionId.Valid == TRUE) { - Status = AziHsmMborEncodeFieldId (Encoder, RSP_SESSION_ID_FIELD_ID); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - Status = AziHsmMborEncodeU16 (Encoder, RspHdr->SessionId.Value); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - } - - // Encode DdiStatus (always present) - Status = AziHsmMborEncodeFieldId (Encoder, RSP_DDI_STATUS_FIELD_ID); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - Status = AziHsmMborEncodeU32 (Encoder, RspHdr->DdiStatus); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - // Encode FipsApproved (always present) - Status = AziHsmMborEncodeFieldId (Encoder, RSP_FIPS_APPROVED_FIELD_ID); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - - Status = AziHsmMborEncodeBoolean (Encoder, RspHdr->fips_approved); - if (EFI_ERROR (Status)) { - goto ExitFunction; - } - -ExitFunction: - *EncodedSize = Encoder->Position - EncoderStartMark; - return Status; -} - /** Decodes a DDI response header structure from MBOR format. diff --git a/MsvmPkg/AziHsmDxe/AziHsmHci.c b/MsvmPkg/AziHsmDxe/AziHsmHci.c index 873b17e..e59ba8c 100644 --- a/MsvmPkg/AziHsmDxe/AziHsmHci.c +++ b/MsvmPkg/AziHsmDxe/AziHsmHci.c @@ -281,39 +281,6 @@ ReadStatusReg ( return EFI_SUCCESS; } -/** - * Read the admin queue attributes. - * - * @param[in] PciIo Pointer to the PCI I/O protocol instance. - * @param[out] AqaReg Pointer to the admin queue attributes register structure to fill. - * - * @retval EFI_SUCCESS The admin queue attributes were read successfully. - * @retval EFI_DEVICE_ERROR An error occurred while reading the admin queue attributes. - */ -STATIC EFI_STATUS -ReadAqaReg ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - OUT AZIHSM_CTRL_AQA_REG *AqaReg - ) -{ - EFI_STATUS Status; - - Status = PciIo->Mem.Read ( - PciIo, - EfiPciIoWidthUint32, - AZIHSM_CTRL_PCI_BAR_INDEX, - AZIHSM_CTRL_AQA_REG_OFFSET, - sizeof (AZIHSM_CTRL_AQA_REG) / sizeof (UINT32), - AqaReg - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "AziHsm: Failed to read admin queue attributes. Status: %r\n", Status)); - return Status; - } - - return EFI_SUCCESS; -} - /** * Write the admin queue attributes. * @@ -347,39 +314,6 @@ WriteAqaReg ( return EFI_SUCCESS; } -/** - * Read the admin submission queue base address. - * - * @param[in] PciIo Pointer to the PCI I/O protocol instance. - * @param[out] AsqReg Pointer to the admin submission queue base address register structure to fill. - * - * @retval EFI_SUCCESS The admin submission queue base address was read successfully. - * @retval EFI_DEVICE_ERROR An error occurred while reading the admin submission queue base address. - */ -STATIC EFI_STATUS -ReadAsqReg ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - OUT AZIHSM_CTRL_ASQ_REG *AsqReg - ) -{ - EFI_STATUS Status; - - Status = PciIo->Mem.Read ( - PciIo, - EfiPciIoWidthUint64, - AZIHSM_CTRL_PCI_BAR_INDEX, - AZIHSM_CTRL_ASQ_REG_OFFSET, - sizeof (AZIHSM_CTRL_ASQ_REG) / sizeof (UINT64), - AsqReg - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "AziHsm: Failed to read admin submission queue base address. Status: %r\n", Status)); - return Status; - } - - return EFI_SUCCESS; -} - /** * Write the admin submission queue base address. * @@ -413,39 +347,6 @@ WriteAsqReg ( return EFI_SUCCESS; } -/** - * Read the admin completion queue base address. - * - * @param[in] PciIo Pointer to the PCI I/O protocol instance. - * @param[out] AcqReg Pointer to the admin completion queue base address register structure to fill. - * - * @retval EFI_SUCCESS The admin completion queue base address was read successfully. - * @retval EFI_DEVICE_ERROR An error occurred while reading the admin completion queue base address. - */ -STATIC EFI_STATUS -ReadAcqReg ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - OUT AZIHSM_CTRL_ACQ_REG *AcqReg - ) -{ - EFI_STATUS Status; - - Status = PciIo->Mem.Read ( - PciIo, - EfiPciIoWidthUint64, - AZIHSM_CTRL_PCI_BAR_INDEX, - AZIHSM_CTRL_ACQ_REG_OFFSET, - sizeof (AZIHSM_CTRL_ACQ_REG) / sizeof (UINT64), - AcqReg - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "AziHsm: Failed to read admin completion queue base address. Status: %r\n", Status)); - return Status; - } - - return EFI_SUCCESS; -} - /** * Write the admin completion queue base address. * diff --git a/MsvmPkg/FrontPage/FrontPage.c b/MsvmPkg/FrontPage/FrontPage.c index d2b2c51..33b1af1 100644 --- a/MsvmPkg/FrontPage/FrontPage.c +++ b/MsvmPkg/FrontPage/FrontPage.c @@ -415,91 +415,6 @@ VOID RemoveMenuFromList (UINT16 MenuId) { } } -/** - Creates the top-level menu in the Master Frame for selecting amongst the various HII forms. - - NOTE: Selectable menu options are dependent on whether there is a System firmware password and on whether the user knows it. - - - @param OrigX Menu's origin (x-axis). - @param OrigY Menu's origin (y-axis). - @param CellWidth Menu's width. - @param CellHeight Menu's height. - @param CellTextXOffset Menu entry text indentation. - - @retval EFI_SUCCESS The operation is successful. - @retval EFI_DEVICE_ERROR Failed to create the menu. - -**/ -static -ListBox* -CreateTopMenu(IN UINT32 OrigX, - IN UINT32 OrigY, - IN UINT32 CellWidth, - IN UINT32 CellHeight, - IN UINT32 CellTextXOffset) -{ - EFI_FONT_INFO FontInfo; - - // - // Create a listbox with menu options. The contents of the menu depend on whether a system password is - // set and whether the user entered the password correctly or not. If the user cancels the password dialog - // then only a limited menu is available. - // - UINT16 Count, Index; - UINT16 MenuOptionCount = (sizeof(mFormMap) / sizeof(mFormMap[0])); - UIT_LB_CELLDATA *MenuOptions = AllocateZeroPool((MenuOptionCount + 1) * sizeof(UIT_LB_CELLDATA)); // NOTE: the list relies on a zero-initialized list terminator (hence +1). - - ASSERT (NULL != MenuOptions); - if (NULL == MenuOptions) - { - return NULL; - } - - for (Count=0 ; Count < MenuOptionCount ; Count++) - { - Index = ((FALSE == mShowFullMenu) ? mFormMap[Count].LimitedMenuIndex : mFormMap[Count].FullMenuIndex); - - if (UNUSED_INDEX != Index && Index < MenuOptionCount) - { - MenuOptions[Index].CellText = HiiGetString (gStringPackHandle, mFormMap[Count].MenuString, NULL); - } - } - - // - // Create the ListBox that encapsulates the top-level menu. - // - FontInfo.FontSize = FP_MFRAME_MENU_TEXT_FONT_HEIGHT; - FontInfo.FontStyle = EFI_HII_FONT_STYLE_NORMAL; - - ListBox *TopMenu = new_ListBox(OrigX, - OrigY, - CellWidth, - CellHeight, - 0, - &FontInfo, - CellTextXOffset, - &gMsColorTable.MasterFrameCellNormalColor, - &gMsColorTable.MasterFrameCellHoverColor, - &gMsColorTable.MasterFrameCellSelectColor, - &gMsColorTable.MasterFrameCellGrayoutColor, - MenuOptions, - NULL - ); - - // - // Free HII string buffer. - // - if (NULL != MenuOptions) - { - FreePool(MenuOptions); - } - - - return TopMenu; -} - - /** Draws the Front Page Title Bar. diff --git a/MsvmPkg/FrontPage/FrontPageConfigAccess.c b/MsvmPkg/FrontPage/FrontPageConfigAccess.c index 7114164..7099ff7 100644 --- a/MsvmPkg/FrontPage/FrontPageConfigAccess.c +++ b/MsvmPkg/FrontPage/FrontPageConfigAccess.c @@ -16,40 +16,6 @@ #include -/** - Quick helper function to see if ReadyToBoot has already been signalled. - - @retval TRUE ReadyToBoot has been signalled. - @retval FALSE Otherwise... - -**/ -STATIC -BOOLEAN -IsPostReadyToBoot ( - VOID - ) -{ - EFI_STATUS Status; - UINT32 Attributes; - PHASE_INDICATOR Indicator; - UINTN Size = sizeof( Indicator ); - static BOOLEAN Result, Initialized = FALSE; - - if (!Initialized) - { - Status = gRT->GetVariable( READY_TO_BOOT_INDICATOR_VAR_NAME, - &gMsDxePhaseVariablesGuid, - &Attributes, - &Size, - &Indicator ); - Result = (!EFI_ERROR( Status ) && Attributes == READY_TO_BOOT_INDICATOR_VAR_ATTR); - Initialized = TRUE; - } - - return Result; -} // IsPostReadyToBoot() - - /** This function allows a caller to extract the current configuration for one or more named elements from the target driver. diff --git a/MsvmPkg/FrontPage/FrontPageUi.c b/MsvmPkg/FrontPage/FrontPageUi.c index b3fd1e2..e05c28c 100644 --- a/MsvmPkg/FrontPage/FrontPageUi.c +++ b/MsvmPkg/FrontPage/FrontPageUi.c @@ -32,6 +32,18 @@ extern BOOLEAN mResetRequired; +/** + Handle a request to reboot back into FrontPage. + + @retval EFI_SUCCESS + +**/ +STATIC +EFI_STATUS +HandleRebootToFrontPage ( + IN EFI_IFR_TYPE_VALUE *Value, + OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest + ); /** This function processes the results of changes in configuration. diff --git a/MsvmPkg/FrontPage/FrontPageUi.h b/MsvmPkg/FrontPage/FrontPageUi.h index a09bc16..f2bead6 100644 --- a/MsvmPkg/FrontPage/FrontPageUi.h +++ b/MsvmPkg/FrontPage/FrontPageUi.h @@ -10,7 +10,6 @@ #define MAX_STRING_LENGTH 1024 - /** This function processes the results of changes in configuration. @@ -40,106 +39,4 @@ UiCallback ( OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest ); -STATIC -EFI_STATUS -HandleAssetTagDisplay( - IN EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ); - -STATIC -EFI_STATUS -SetSystemPassword ( - IN EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ); - -/** - Presents the user with a (hopefully) helpful dialog - with more info about a particular subject. - - NOTE: Subject is determined by the state of mCallbackKey. - - @retval EFI_SUCCESS Message successfully displayed. - @retval EFI_NOT_FOUND mCallbackKey not recognized or string could not be loaded. - @retval Others Return value of mSWMProtocol->MessageBox(). - -**/ -STATIC -EFI_STATUS -HandleInfoPopup( - IN EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ); - -STATIC -EFI_STATUS -HandleLanguage( - IN EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ); - -STATIC -EFI_STATUS -HandleBootMenu( - IN EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ); - - -/** - Handle a request to change the SecureBoot configuration. - - @retval EFI_SUCCESS Successfully installed SecureBoot default variables. - @retval Others Failed to install. SecureBoot is still disabled. - -**/ -STATIC -EFI_STATUS -HandleSecureBootChange ( - IN EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ); - - -/** - Determines the current SecureBoot state and updates the status strings accordingly. - - @param[in] RefreshScreen BOOLEAN indicating whether to force a screen refresh after updating the strings. - -**/ -VOID -UpdateSecureBootStatusStrings ( - IN BOOLEAN RefreshScreen - ); - - -/** - Handle a request to change the TPM enablement. - - @retval EFI_SUCCESS Successfully updated TPM state. - @retval Others Failed to update. TPM state remains unchanged. - -**/ -STATIC -EFI_STATUS -HandleTpmChange ( - IN EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ); - - -/** - Handle a request to reboot back into FrontPage. - - @retval EFI_SUCCESS - -**/ -STATIC -EFI_STATUS -HandleRebootToFrontPage ( - IN EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ); - #endif // _FRONT_PAGE_UI_H_ diff --git a/MsvmPkg/NetvscDxe/NetvscDxe.c b/MsvmPkg/NetvscDxe/NetvscDxe.c index ef33e02..b6c61f0 100644 --- a/MsvmPkg/NetvscDxe/NetvscDxe.c +++ b/MsvmPkg/NetvscDxe/NetvscDxe.c @@ -1092,7 +1092,6 @@ Routine Description: INT32 index; NVSP_MESSAGE message; EFI_STATUS status = EFI_SUCCESS; - static UINT32 counter; ZeroMem(&message, sizeof(NVSP_MESSAGE)); diff --git a/MsvmPkg/VariableDxe/NvramVariableDxe.c b/MsvmPkg/VariableDxe/NvramVariableDxe.c index bd9c290..092d69b 100644 --- a/MsvmPkg/VariableDxe/NvramVariableDxe.c +++ b/MsvmPkg/VariableDxe/NvramVariableDxe.c @@ -25,12 +25,6 @@ #define WITHIN_4_GB_LL (0xFFFFFFFFLL) -// -// Events this driver handles -// -static EFI_EVENT mVirtualAddressChangeEvent = NULL; - - // // Descriptor and Data buffers. // From 347d5a952b09bb08168ed25ffcf07a5015dda89d Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Mon, 23 Feb 2026 17:31:03 +0000 Subject: [PATCH 03/22] Merged PR 14847409: Clang: Fix __FUNCTION__ (not concatenatable). Clang: Fix `__FUNCTION__`. In Visual C++, `__FUNCTION__` is a concatenatable string literal. In Clang, `__FUNCTION__` is a non-concatenatable string array like standard `__func__`. ``` MsBootPolicyLib.c:48: error: expected ')' DEBUG((DEBUG_INFO,__FUNCTION__ " Checking if the following device path is permitted to boot:\n")); ^ ``` etc. Use `%a` to format it, as a separate parameter. John Starks started this and did most or all of this -- porting to Clang. Related work items: #57987809 --- MsvmPkg/FrontPage/FrontPage.c | 6 +++--- .../Library/MsBootPolicyLib/MsBootPolicyLib.c | 3 +-- .../Tcg2PreInitLib/Tcg2PreInitLibDxe.c | 8 +++---- .../Tcg2PreInitLib/Tcg2PreInitLibPei.c | 21 +++++++++---------- MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c | 6 +++--- MsvmPkg/PlatformPei/Hv.c | 6 +++--- MsvmPkg/VmMeasurementDxe/VmMeasurementDxe.c | 6 +++--- 7 files changed, 26 insertions(+), 30 deletions(-) diff --git a/MsvmPkg/FrontPage/FrontPage.c b/MsvmPkg/FrontPage/FrontPage.c index 33b1af1..bb1b329 100644 --- a/MsvmPkg/FrontPage/FrontPage.c +++ b/MsvmPkg/FrontPage/FrontPage.c @@ -468,7 +468,7 @@ RenderTitlebar(VOID) ); if (EFI_ERROR(Status)) { if (EFI_NOT_FOUND != Status) { - DEBUG((DEBUG_ERROR,__FUNCTION__ " error reading RebootReason. Code = %r\n",Status)); + DEBUG((DEBUG_ERROR, "%a error reading RebootReason. Code = %r\n", __FUNCTION__, Status)); } Parameter = 'B'; } else { @@ -484,7 +484,7 @@ RenderTitlebar(VOID) } else { Parameter = *((CHAR8 *) ImageInfo->LoadOptions); } - DEBUG((DEBUG_ERROR, __FUNCTION__ " Parameter = %c - LoadOption=%p\n",Parameter,ImageInfo->LoadOptions)); + DEBUG((DEBUG_ERROR, "%a Parameter = %c - LoadOption=%p\n", __FUNCTION__, Parameter,ImageInfo->LoadOptions)); switch (Parameter) { case 'V' : // VOL+ @@ -1053,7 +1053,7 @@ SetStringEntry ( if (IdName != HiiSetString(gFrontPagePrivate.HiiHandle, IdName, StringValue, NULL)) { - DEBUG((DEBUG_ERROR, __FUNCTION__ " - Failed to set string for %d: %s. \n", IdName, StringValue)); + DEBUG((DEBUG_ERROR, "%a - Failed to set string for %d: %s. \n", __FUNCTION__, IdName, StringValue)); Status = EFI_NO_MAPPING; } diff --git a/MsvmPkg/Library/MsBootPolicyLib/MsBootPolicyLib.c b/MsvmPkg/Library/MsBootPolicyLib/MsBootPolicyLib.c index 7133074..2826791 100644 --- a/MsvmPkg/Library/MsBootPolicyLib/MsBootPolicyLib.c +++ b/MsvmPkg/Library/MsBootPolicyLib/MsBootPolicyLib.c @@ -44,8 +44,7 @@ MsBootPolicyLibIsDevicePathBootable( BOOLEAN rc = TRUE; EFI_DEVICE_PATH_PROTOCOL *Node; - - DEBUG((DEBUG_INFO,__FUNCTION__ " Checking if the following device path is permitted to boot:\n")); + DEBUG((DEBUG_INFO, "%a Checking if the following device path is permitted to boot:\n", __FUNCTION__)); if (NULL == DevicePath) { DEBUG((DEBUG_ERROR,"NULL device path\n")); diff --git a/MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibDxe.c b/MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibDxe.c index 1bc88db..7b00ae1 100644 --- a/MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibDxe.c +++ b/MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibDxe.c @@ -47,10 +47,9 @@ MsvmTpm2InitLibConstructorDxe ( UINT64 TpmBaseAddress; UINT32 TcgProtocolVersion; - DEBUG(( DEBUG_INFO, __FUNCTION__"()\n" )); + DEBUG(( DEBUG_INFO, "%a()\n", __FUNCTION__ )); - // - // If the TPM not enabled, don't perform any more TPM init. + // If the TPM not enabled, do not perform any more TPM init. if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceNoneGuid) || CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){ DEBUG ((DEBUG_INFO, "No TPM2 instance required!\n")); @@ -60,12 +59,11 @@ MsvmTpm2InitLibConstructorDxe ( TpmBaseAddress = FixedPcdGet64(PcdTpmBaseAddress); TpmBaseAddress += PcdGetBool(PcdTpmLocalityRegsEnabled) ? 0x40 : 0; - // // Query the Tcg protocol version TcgProtocolVersion = ReadTpmPort(TpmIoGetTcgProtocolVersion); if ((TcgProtocolVersion != TcgProtocolTrEE) && (TcgProtocolVersion != TcgProtocolTcg2)) { - DEBUG(( DEBUG_ERROR, __FUNCTION__" - TPM device reports bad version! 0x%X\n", TcgProtocolVersion )); + DEBUG(( DEBUG_ERROR, "%a - TPM device reports bad version! 0x%X\n", __FUNCTION__, TcgProtocolVersion )); return EFI_DEVICE_ERROR; } diff --git a/MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibPei.c b/MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibPei.c index 0decf7e..702080e 100644 --- a/MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibPei.c +++ b/MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibPei.c @@ -48,26 +48,26 @@ MsvmTpmDeviceInitEarlyBoot( Status = PeiServicesAllocatePages(EfiRuntimeServicesData, 2, &CrBuffer); if (EFI_ERROR(Status)) { - DEBUG((DEBUG_ERROR, __FUNCTION__" - Failed to allocate CRB for TPM device!\n")); + DEBUG((DEBUG_ERROR, "%a - Failed to allocate CRB for TPM device!\n", __FUNCTION__)); return Status; } if (CrBuffer > 0xFFFFFFFFULL) { // PEI memory was published as - Base at 1MB, size max 64MB. // It is guaranteed that physical address is below 4 GB. - DEBUG((DEBUG_ERROR, __FUNCTION__" - CRB allocation for TPM device is incorrect!\n")); + DEBUG((DEBUG_ERROR, "%a - CRB allocation for TPM device is incorrect!\n", __FUNCTION__)); ASSERT(FALSE); return EFI_DEVICE_ERROR; } - DEBUG((DEBUG_VERBOSE, __FUNCTION__" - CrBuffer == 0x%016lX\n", CrBuffer)); + DEBUG((DEBUG_VERBOSE, "%a - CrBuffer == 0x%016lX\n", __FUNCTION__, CrBuffer)); ZeroMem((UINT8*)CrBuffer, 2 * EFI_PAGE_SIZE); TpmBaseAddress = FixedPcdGet64(PcdTpmBaseAddress); TpmBaseAddress += PcdGetBool(PcdTpmLocalityRegsEnabled) ? 0x40 : 0; - DEBUG((DEBUG_VERBOSE, __FUNCTION__" - TpmBaseAddress == 0x%016lX\n", TpmBaseAddress)); + DEBUG((DEBUG_VERBOSE, "%a - TpmBaseAddress == 0x%016lX\n", __FUNCTION__, TpmBaseAddress)); // // Send the request to the TPM device. @@ -83,18 +83,17 @@ MsvmTpmDeviceInitEarlyBoot( // // Couldn't establish memory mapping with device. // - DEBUG((DEBUG_ERROR, __FUNCTION__" - Couldn't establish memory mapping with device!\n")); + DEBUG((DEBUG_ERROR, "%a - Couldn't establish memory mapping with device!\n", __FUNCTION__)); return EFI_NO_MAPPING; } - DEBUG((DEBUG_VERBOSE, __FUNCTION__" - TpmIoEstablishedResponse == 0x%08X\n", TpmIoEstablishedResponse)); + DEBUG((DEBUG_VERBOSE, "%a - TpmIoEstablishedResponse == 0x%08X\n", __FUNCTION__, TpmIoEstablishedResponse)); Tpm2RegisterTpm2DeviceLib((TPM2_DEVICE_INTERFACE*)TpmBaseAddress); return Status; } // MsvmTpmDeviceInitEarlyBoot() - /** Constructor for the lib. Important that this runs prior to Tcg2Pei because it may disable some of @@ -120,7 +119,7 @@ MsvmTpm2InitLibConstructorPei ( UINTN GuidSize = sizeof( EFI_GUID ); static BOOLEAN EarlyInitComplete = FALSE; - DEBUG(( DEBUG_INFO, __FUNCTION__"()\n" )); + DEBUG(( DEBUG_INFO, "%a()\n", __FUNCTION__ )); // // If the TPM is disabled in the Hyper-V UI, don't perform @@ -129,11 +128,11 @@ MsvmTpm2InitLibConstructorPei ( // This is because of the depex on gEfiPeiMasterBootModePpiGuid. TpmEnabled = PcdGetBool( PcdTpmEnabled ); if (!TpmEnabled) { - DEBUG(( DEBUG_INFO, __FUNCTION__" - Detected a disabled TPM. Bypassing init.\n" )); + DEBUG((DEBUG_INFO, "%a - Detected a disabled TPM. Bypassing init.\n", __FUNCTION__)); Status = PcdSetPtrS( PcdTpmInstanceGuid, &GuidSize, &gEfiTpmDeviceInstanceNoneGuid ); if (EFI_ERROR(Status)) { - DEBUG((DEBUG_ERROR, __FUNCTION__" - Failed to set the PCD PcdTpmInstanceGuid::0x%x \n", Status)); + DEBUG((DEBUG_ERROR, "%a - Failed to set the PCD PcdTpmInstanceGuid::0x%x \n", __FUNCTION__, Status)); ASSERT_EFI_ERROR( Status ); } } @@ -143,7 +142,7 @@ MsvmTpm2InitLibConstructorPei ( if (TpmEnabled && !EarlyInitComplete) { Status = MsvmTpmDeviceInitEarlyBoot(); if (EFI_ERROR( Status )) { - DEBUG(( DEBUG_ERROR, __FUNCTION__" - MsvmTpmDeviceInitEarlyBoot() returned %r!\n", Status )); + DEBUG(( DEBUG_ERROR, "%a - MsvmTpmDeviceInitEarlyBoot() returned %r!\n", __FUNCTION__, Status )); ASSERT_EFI_ERROR( Status ); } EarlyInitComplete = TRUE; diff --git a/MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c b/MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c index 79a2939..9a1aa13 100644 --- a/MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c +++ b/MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c @@ -336,13 +336,13 @@ Tpm2RegisterTpm2DeviceLib ( // MS_HYP_CHANGE BEGIN mTpm2ControlArea = (FTPM_CONTROL_AREA*)Tpm2Device; - DEBUG((DEBUG_VERBOSE, __FUNCTION__" - TpmBaseAddress == 0x%016lX\n", mTpm2ControlArea)); + DEBUG((DEBUG_VERBOSE, "%a - TpmBaseAddress == 0x%016lX\n", __FUNCTION__, mTpm2ControlArea)); // If any of these values are bad, we've failed to register this library. if ((mTpm2ControlArea->CommandPALow == (UINT32)-1) || (mTpm2ControlArea->ResponsePALow == (UINT32)-1) || (mTpm2ControlArea->ResponseBufferSize == (UINT32)-1)) { - DEBUG(( DEBUG_ERROR, __FUNCTION__" - TPM MMIO Space at 0x%08X is not decoding!\tCannot register interface!\n", mTpm2ControlArea )); + DEBUG(( DEBUG_ERROR, "%a - TPM MMIO Space at 0x%08X is not decoding!\tCannot register interface!\n", __FUNCTION__, mTpm2ControlArea )); return EFI_DEVICE_ERROR; } @@ -358,7 +358,7 @@ Tpm2RegisterTpm2DeviceLib ( mResponseBuffer = (UINT8*)(UINTN)responseBufferPA.QuadPart; mResponseSize = (UINTN)mTpm2ControlArea->ResponseBufferSize; - DEBUG((DEBUG_VERBOSE, __FUNCTION__" - TPM MMIO Space at 0x%016lX, Command=0x%016lX, Response=0x%016lX, Size=0x%08X\n", mTpm2ControlArea, mCommandBuffer, mResponseBuffer, mResponseSize)); + DEBUG((DEBUG_VERBOSE, "%a - TPM MMIO Space at 0x%016lX, Command=0x%016lX, Response=0x%016lX, Size=0x%08X\n", __FUNCTION__, mTpm2ControlArea, mCommandBuffer, mResponseBuffer, mResponseSize)); return EFI_SUCCESS; // MS_HYP_CHANGE END diff --git a/MsvmPkg/PlatformPei/Hv.c b/MsvmPkg/PlatformPei/Hv.c index 65fd8ea..958cf70 100644 --- a/MsvmPkg/PlatformPei/Hv.c +++ b/MsvmPkg/PlatformPei/Hv.c @@ -51,21 +51,21 @@ Return Value: __cpuid(cpuidResult.AsUINT32, HvCpuIdFunctionVersionAndFeatures); if (!cpuidResult.VersionAndFeatures.HypervisorPresent) { - DEBUG((DEBUG_INFO, __FUNCTION__" - Hypervisor is not present \n")); + DEBUG((DEBUG_INFO, "%a - Hypervisor is not present \n", __FUNCTION__)); return; } __cpuid(cpuidResult.AsUINT32, HvCpuIdFunctionHvInterface); if (cpuidResult.HvInterface.Interface != HvMicrosoftHypervisorInterface) { - DEBUG((DEBUG_INFO, __FUNCTION__" - Hypervisor interface is not present \n")); + DEBUG((DEBUG_INFO, "%a - Hypervisor interface is not present \n", __FUNCTION__)); return; } __cpuid(cpuidResult.AsUINT32, HvCpuIdFunctionMsHvFeatures); if (!cpuidResult.MsHvFeatures.PartitionPrivileges.Isolation) { - DEBUG((DEBUG_INFO, __FUNCTION__" - Isolation is not present \n")); + DEBUG((DEBUG_INFO, "%a - Isolation is not present \n", __FUNCTION__)); return; } diff --git a/MsvmPkg/VmMeasurementDxe/VmMeasurementDxe.c b/MsvmPkg/VmMeasurementDxe/VmMeasurementDxe.c index 6c831b3..6883272 100644 --- a/MsvmPkg/VmMeasurementDxe/VmMeasurementDxe.c +++ b/MsvmPkg/VmMeasurementDxe/VmMeasurementDxe.c @@ -30,7 +30,7 @@ Routine Description: CHAR8 EventLog[64]; UINT32 EventSize; - DEBUG((DEBUG_INFO, __FUNCTION__"() - Measuring VM data to PCR[06]\n")); + DEBUG((DEBUG_INFO, "%a() - Measuring VM data to PCR[06]\n", __FUNCTION__)); // // Measure the UUID @@ -46,7 +46,7 @@ Routine Description: EventSize ); - DEBUG((DEBUG_INFO, __FUNCTION__"() - Logged %a (size=0x%x) status 0x%x\n", EventLog, EventSize, Status)); + DEBUG((DEBUG_INFO, "%a() - Logged %a (size=0x%x) status 0x%x\n", __FUNCTION__, EventLog, EventSize, Status)); // // Measure the architecture @@ -68,7 +68,7 @@ Routine Description: EventSize ); - DEBUG((DEBUG_INFO, __FUNCTION__"() - Logged %a (size=0x%x) status 0x%x\n", EventLog, EventSize, Status)); + DEBUG((DEBUG_INFO, "%a() - Logged %a (size=0x%x) status 0x%x\n", __FUNCTION__, EventLog, EventSize, Status)); return EFI_SUCCESS; } From 4c33c2e17856f17df195d17cc37fbbfce9e00a27 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Mon, 23 Feb 2026 21:45:51 +0000 Subject: [PATCH 04/22] Merged PR 14844260: Clang: Port __declspecs. Clang: Port __declspecs. `DECLSPEC_ALIGN` - `__declspec(align())` or `__attribute__((aligned))`, or perhaps `_Alignas` `DECLSPEC_CACHEALIGN` - `DECLSPEC_ALIGN (64)` or `DECLSPEC_ALIGN (128)`, to match Windows (not necessary an actual cache line size, or what is recommended, but, match Windows). (ARM64 cache lines are guaranteed to be 128 or smaller, so 128 separates caches lines, guaranteed, perhaps by a lot, but C++ uses 256 (or 128) for similar purposes). `DECLSPEC_DEPRECATED` (remove, it is not used) Related work items: #54710354, #57987809, #60275790 --- MsvmPkg/CpuDxe/CpuBd.c | 2 +- MsvmPkg/Include/DeclspecAlign.h | 15 +++++++++++++ MsvmPkg/Include/DeclspecCacheAlign.h | 21 +++++++++++++++++++ MsvmPkg/Include/Hv/HvGuestHypercall.h | 8 +++---- .../Include/Hv/HvGuestSyntheticInterrupts.h | 6 ++---- MsvmPkg/Include/Vmbus/VmbusPacketInterface.h | 7 +++---- 6 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 MsvmPkg/Include/DeclspecAlign.h create mode 100644 MsvmPkg/Include/DeclspecCacheAlign.h diff --git a/MsvmPkg/CpuDxe/CpuBd.c b/MsvmPkg/CpuDxe/CpuBd.c index 13acdd5..9a334bd 100644 --- a/MsvmPkg/CpuDxe/CpuBd.c +++ b/MsvmPkg/CpuDxe/CpuBd.c @@ -267,7 +267,7 @@ BdInitInterruptDescriptorTable ( IA32_DESCRIPTOR OldIdtPtr; IA32_IDT_GATE_DESCRIPTOR *OldIdt; UINTN OldIdtSize; - __declspec(align(16)) IA32_DESCRIPTOR IdtPtr; + DECLSPEC_ALIGN (16) IA32_DESCRIPTOR IdtPtr; UINTN Index; UINT16 CurrentCs; VOID *IntHandler; diff --git a/MsvmPkg/Include/DeclspecAlign.h b/MsvmPkg/Include/DeclspecAlign.h new file mode 100644 index 0000000..4902ab1 --- /dev/null +++ b/MsvmPkg/Include/DeclspecAlign.h @@ -0,0 +1,15 @@ +// @file +// DECLSPEC_ALIGN +// +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: BSD-2-Clause-Patent +#pragma once +#ifdef __cplusplus +#define DECLSPEC_ALIGN(n) alignas (n) +#else +#ifdef _MSC_VER +#define DECLSPEC_ALIGN(n) __declspec (align (n)) +#else +#define DECLSPEC_ALIGN(n) __attribute__ ((aligned (n))) +#endif +#endif diff --git a/MsvmPkg/Include/DeclspecCacheAlign.h b/MsvmPkg/Include/DeclspecCacheAlign.h new file mode 100644 index 0000000..ab79bf0 --- /dev/null +++ b/MsvmPkg/Include/DeclspecCacheAlign.h @@ -0,0 +1,21 @@ +// @file +// DECLSPEC_CACHEALIGN +// AMD64: DECLSPEC_ALIGN (64) +// ARM64: DECLSPEC_ALIGN (128) +// +// There are varying ways to chose these values. +// These are chosen for layout compatibility with Windows. +// See also C++: std::hardware_destructive_interference_size +// std::hardware_constructive_interference_size +// +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: BSD-2-Clause-Patent +#pragma once +#include "DeclspecAlign.h" +#if defined (MDE_CPU_X64) +#define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN (64) +#elif defined (MDE_CPU_AARCH64) +#define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN (128) +#else +#error unknown target +#endif diff --git a/MsvmPkg/Include/Hv/HvGuestHypercall.h b/MsvmPkg/Include/Hv/HvGuestHypercall.h index 1ff5a64..db9bc30 100644 --- a/MsvmPkg/Include/Hv/HvGuestHypercall.h +++ b/MsvmPkg/Include/Hv/HvGuestHypercall.h @@ -5,17 +5,15 @@ Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent --*/ - #pragma once - +#include "DeclspecAlign.h" #include - #pragma warning(disable : 4201) // // Define a 128bit type. // -typedef union __declspec(align(16)) _HV_UINT128 +typedef union DECLSPEC_ALIGN (16) _HV_UINT128 { struct { @@ -32,7 +30,7 @@ typedef union __declspec(align(16)) _HV_UINT128 // Define an alignment for structures passed via hypercall. // #define HV_CALL_ALIGNMENT 8 -#define HV_CALL_ATTRIBUTES __declspec(align(HV_CALL_ALIGNMENT)) +#define HV_CALL_ATTRIBUTES DECLSPEC_ALIGN (HV_CALL_ALIGNMENT) // // Address spaces presented by the guest. diff --git a/MsvmPkg/Include/Hv/HvGuestSyntheticInterrupts.h b/MsvmPkg/Include/Hv/HvGuestSyntheticInterrupts.h index fd6f7b4..ba1c3fd 100644 --- a/MsvmPkg/Include/Hv/HvGuestSyntheticInterrupts.h +++ b/MsvmPkg/Include/Hv/HvGuestSyntheticInterrupts.h @@ -5,11 +5,9 @@ Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent --*/ - #pragma once - +#include "DeclspecAlign.h" #include - #pragma warning(disable : 4201) // @@ -306,7 +304,7 @@ typedef struct _HV_IOMMU_FAULT_MESSAGE_PAYLOAD // to be aligned. Therefore, this structure must be 16-byte aligned. The header // is 16B already. // -typedef struct __declspec(align(16)) _HV_MESSAGE +typedef struct DECLSPEC_ALIGN (16) _HV_MESSAGE { HV_MESSAGE_HEADER Header; union diff --git a/MsvmPkg/Include/Vmbus/VmbusPacketInterface.h b/MsvmPkg/Include/Vmbus/VmbusPacketInterface.h index c2d4c38..0cf762b 100644 --- a/MsvmPkg/Include/Vmbus/VmbusPacketInterface.h +++ b/MsvmPkg/Include/Vmbus/VmbusPacketInterface.h @@ -5,9 +5,8 @@ Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent --*/ - #pragma once - +#include "DeclspecCacheAlign.h" #include #define EFI_RING_CORRUPT_ERROR ENCODE_ERROR(0x00000102L) @@ -46,7 +45,7 @@ typedef struct _PACKET_LIB_CONTEXT // Incoming loop mutable fields. Keep these on their own cache line. // - __declspec(align(64)) + DECLSPEC_CACHEALIGN UINT32 IncomingInCache; UINT32 IncomingOut; UINT32 EmptyRingBufferCount; @@ -56,7 +55,7 @@ typedef struct _PACKET_LIB_CONTEXT // Outgoing loop mutable fields. Keep these on their own cache line. // - __declspec(align(64)) + DECLSPEC_CACHEALIGN UINT32 OutgoingIn; UINT32 OutgoingOutCache; UINT32 PendingSendSize; From ab90bd8070a141db2457a25732c46b4448c76b40 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Mon, 23 Feb 2026 22:17:09 +0000 Subject: [PATCH 05/22] Merged PR 14847381: Cleanup ExcludeMainFvFromMeasurementLib.c. Cleanup ExcludeMainFvFromMeasurementLib.c. - detab (one of the best things you can do to any codebase!) - deduplicate semicolons - 4 spaces instead of 2 - space before paren - add static on kinda short extern identifier Related work items: #57987809, #60275790 --- .../ExcludeMainFvFromMeasurementLib.c | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/MsvmPkg/Library/ExcludeMainFvFromMeasurementLib/ExcludeMainFvFromMeasurementLib.c b/MsvmPkg/Library/ExcludeMainFvFromMeasurementLib/ExcludeMainFvFromMeasurementLib.c index 800a4d7..89fed6e 100644 --- a/MsvmPkg/Library/ExcludeMainFvFromMeasurementLib/ExcludeMainFvFromMeasurementLib.c +++ b/MsvmPkg/Library/ExcludeMainFvFromMeasurementLib/ExcludeMainFvFromMeasurementLib.c @@ -12,37 +12,35 @@ #include #include - +static EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI exclude = { - 1, //count - { - (EFI_PHYSICAL_ADDRESS) FixedPcdGet64(PcdFvBaseAddress), - (UINT64) FixedPcdGet32(PcdFvSize) - } + 1, //count + { + (EFI_PHYSICAL_ADDRESS) FixedPcdGet64 (PcdFvBaseAddress), + (UINT64) FixedPcdGet32 (PcdFvSize) + } }; STATIC EFI_PEI_PPI_DESCRIPTOR PpiList = { - EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, - &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid, - &exclude + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid, + &exclude }; - EFI_STATUS EFIAPI ExcludeMainFvFromMeasurementLibConstructor ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) { - EFI_STATUS Status; - Status = EFI_SUCCESS; - - if(PcdGetBool(PcdExcludeFvMainFromMeasurements)) - { - Status = PeiServicesInstallPpi(&PpiList); - ASSERT_EFI_ERROR(Status); - } - return Status;; -} \ No newline at end of file + EFI_STATUS Status = EFI_SUCCESS; + + if (PcdGetBool (PcdExcludeFvMainFromMeasurements)) + { + Status = PeiServicesInstallPpi (&PpiList); + ASSERT_EFI_ERROR (Status); + } + return Status; +} From 1fa247aa387994d5be758a3fbc4ff93b4513ba05 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Tue, 24 Feb 2026 17:34:53 +0000 Subject: [PATCH 06/22] Merged PR 14857035: Clang: static assert updates. - Use uppercase form always. - Two parameters (second can be empty string). - Sometimes, rarely, requires brac.es. Related work items: #57987809, #60275790 --- MsvmPkg/AziHsmDxe/AziHsmCp.h | 4 ++-- MsvmPkg/EmclDxe/RingBuffer.c | 2 +- MsvmPkg/EventLogDxe/EventLogger.c | 2 +- MsvmPkg/Include/Vmbus/VmbusPacketFormat.h | 2 +- MsvmPkg/Include/Vmbus/VmbusPacketInterface.h | 10 ++++---- MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c | 2 +- MsvmPkg/NetvscDxe/nvspprotocol.h | 2 +- MsvmPkg/PlatformPei/Hv.c | 8 +++---- MsvmPkg/StorvscDxe/VstorageProtocol.h | 24 +++++++++---------- MsvmPkg/VmbusDxe/ChannelMessages.h | 2 +- MsvmPkg/VpcivscDxe/wdm.h | 2 +- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/MsvmPkg/AziHsmDxe/AziHsmCp.h b/MsvmPkg/AziHsmDxe/AziHsmCp.h index 31177b4..d775b3f 100644 --- a/MsvmPkg/AziHsmDxe/AziHsmCp.h +++ b/MsvmPkg/AziHsmDxe/AziHsmCp.h @@ -81,7 +81,7 @@ typedef struct _AZIHSM_CP_SQE_ { AZIHSM_CP_CMD_SQE_SRC_DATA SqeData; } AZIHSM_CP_SQE, *PAZIHSM_CP_SQE; -static_assert ((sizeof (AZIHSM_CP_SQE) == AZIHSM_HSM_CP_SQE_SZ), "CP_SQE: Size Mismatch"); +STATIC_ASSERT ((sizeof (AZIHSM_CP_SQE) == AZIHSM_HSM_CP_SQE_SZ), "CP_SQE: Size Mismatch"); /* * Control Processor Completion Queue Entry @@ -121,7 +121,7 @@ typedef struct _AZIHSM_CP_CQE_ { } PhAndSts; } AZIHSM_CP_CQE, *PAZIHSM_CP_CQE; -static_assert (sizeof (AZIHSM_CP_CQE) == AZIHSM_HSM_CMD_CQE_SIZE, "AZIHSM_CP_CQE Size Incompatible"); +STATIC_ASSERT (sizeof (AZIHSM_CP_CQE) == AZIHSM_HSM_CMD_CQE_SIZE, "AZIHSM_CP_CQE Size Incompatible"); #pragma pack(pop) diff --git a/MsvmPkg/EmclDxe/RingBuffer.c b/MsvmPkg/EmclDxe/RingBuffer.c index 419cb6f..8af9121 100644 --- a/MsvmPkg/EmclDxe/RingBuffer.c +++ b/MsvmPkg/EmclDxe/RingBuffer.c @@ -838,7 +838,7 @@ PkGetReceiveBuffer( // offset is less than sizeof(UINT64), we don't have to worry about wrapping around the // end of the ring buffer. We assert here to keep the assertion with the relevant code. // - static_assert(OFFSET_OF(VMPACKET_DESCRIPTOR, Length8) < sizeof(UINT64), ""); + STATIC_ASSERT(OFFSET_OF(VMPACKET_DESCRIPTOR, Length8) < sizeof(UINT64), ""); // // Capture the length field and shift it to a byte count. diff --git a/MsvmPkg/EventLogDxe/EventLogger.c b/MsvmPkg/EventLogDxe/EventLogger.c index 7f32494..a452f0d 100644 --- a/MsvmPkg/EventLogDxe/EventLogger.c +++ b/MsvmPkg/EventLogDxe/EventLogger.c @@ -78,7 +78,7 @@ typedef struct // Channel Id GUID must be the first field in the EVENT_CHANNEL // as it is used as the object lookup key in the handle table. // -static_assert(OFFSET_OF(EVENT_CHANNEL,Id) == 0); +STATIC_ASSERT(OFFSET_OF(EVENT_CHANNEL,Id) == 0, ""); // // Number of bytes to increase the enumeration bounce buffer by diff --git a/MsvmPkg/Include/Vmbus/VmbusPacketFormat.h b/MsvmPkg/Include/Vmbus/VmbusPacketFormat.h index 2c89516..1fb16d5 100644 --- a/MsvmPkg/Include/Vmbus/VmbusPacketFormat.h +++ b/MsvmPkg/Include/Vmbus/VmbusPacketFormat.h @@ -57,7 +57,7 @@ typedef struct _VMRCB } VMRCB, *PVMRCB; -static_assert(OFFSET_OF(VMRCB, FeatureBits) == 64); +STATIC_ASSERT(OFFSET_OF(VMRCB, FeatureBits) == 64, ""); // // This structure defines a range in guest physical space that can be made diff --git a/MsvmPkg/Include/Vmbus/VmbusPacketInterface.h b/MsvmPkg/Include/Vmbus/VmbusPacketInterface.h index 0cf762b..62e9105 100644 --- a/MsvmPkg/Include/Vmbus/VmbusPacketInterface.h +++ b/MsvmPkg/Include/Vmbus/VmbusPacketInterface.h @@ -111,13 +111,13 @@ PkCleanup( IN PACKET_LIB_HANDLE PkLibContext ); -static_assert(OFFSET_OF(VMPACKET_DESCRIPTOR, Type) < 8, +STATIC_ASSERT(OFFSET_OF(VMPACKET_DESCRIPTOR, Type) < 8, "VMPACKET_DESCRIPTOR->Type is assumed to be within first 8 bytes of the structure."); -static_assert(OFFSET_OF(VMPACKET_DESCRIPTOR, DataOffset8) < 8, +STATIC_ASSERT(OFFSET_OF(VMPACKET_DESCRIPTOR, DataOffset8) < 8, "VMPACKET_DESCRIPTOR->DataOffset8 is assumed to be within first 8 bytes of the structure."); -static_assert(OFFSET_OF(VMPACKET_DESCRIPTOR, Length8) < 8, +STATIC_ASSERT(OFFSET_OF(VMPACKET_DESCRIPTOR, Length8) < 8, "VMPACKET_DESCRIPTOR->Length8 is assumed to be within first 8 bytes of the structure."); -static_assert(OFFSET_OF(VMPACKET_DESCRIPTOR, Flags) < 8, +STATIC_ASSERT(OFFSET_OF(VMPACKET_DESCRIPTOR, Flags) < 8, "VMPACKET_DESCRIPTOR->Flags is assumed to be within first 8 bytes of the structure."); #define PkWriteRingBuffer(_LibContext_,_Dest_,_Src_,_Length_) \ @@ -135,7 +135,7 @@ static_assert(OFFSET_OF(VMPACKET_DESCRIPTOR, Flags) < 8, #define PkWriteRingBufferField(singledest, singlesrc) \ { \ UINT64 _local_value_ = (singlesrc); \ - static_assert(sizeof((singledest)) <= 8, "PkWriteRingBufferField requires the field to be <= size 8"); \ + STATIC_ASSERT(sizeof((singledest)) <= 8, "PkWriteRingBufferField requires the field to be <= size 8"); \ PkWriteRingBuffer(PkLibContext, &(singledest), &_local_value_, sizeof((singlesrc))); \ } diff --git a/MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c b/MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c index 9a1aa13..aa10859 100644 --- a/MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c +++ b/MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.c @@ -87,7 +87,7 @@ typedef struct _FTPM_CONTROL_AREA } FTPM_CONTROL_AREA; #pragma pack(pop) -static_assert(sizeof(EFI_TPM2_ACPI_CONTROL_AREA) == sizeof(FTPM_CONTROL_AREA), "Invalid structure!"); +STATIC_ASSERT(sizeof(EFI_TPM2_ACPI_CONTROL_AREA) == sizeof(FTPM_CONTROL_AREA), "Invalid structure!"); typedef union _LARGE_INTEGER { struct { diff --git a/MsvmPkg/NetvscDxe/nvspprotocol.h b/MsvmPkg/NetvscDxe/nvspprotocol.h index 1af2c8c..ad6ba5a 100644 --- a/MsvmPkg/NetvscDxe/nvspprotocol.h +++ b/MsvmPkg/NetvscDxe/nvspprotocol.h @@ -656,6 +656,6 @@ typedef struct _NVSP_MESSAGE UINT32 Padding; } NVSP_MESSAGE, *PNVSP_MESSAGE; -static_assert(sizeof(NVSP_MESSAGE) % 8 == 0); +STATIC_ASSERT(sizeof(NVSP_MESSAGE) % 8 == 0, ""); #pragma pack(pop) diff --git a/MsvmPkg/PlatformPei/Hv.c b/MsvmPkg/PlatformPei/Hv.c index 958cf70..66cc85b 100644 --- a/MsvmPkg/PlatformPei/Hv.c +++ b/MsvmPkg/PlatformPei/Hv.c @@ -73,19 +73,19 @@ Return Value: switch (cpuidResult.MsHvIsolationConfiguration.IsolationType) { case HV_PARTITION_ISOLATION_TYPE_VBS: - static_assert(HV_PARTITION_ISOLATION_TYPE_VBS == UefiIsolationTypeVbs); + { STATIC_ASSERT(HV_PARTITION_ISOLATION_TYPE_VBS == UefiIsolationTypeVbs, ""); } mIsolationType = UefiIsolationTypeVbs; break; case HV_PARTITION_ISOLATION_TYPE_SNP: - static_assert(HV_PARTITION_ISOLATION_TYPE_SNP == UefiIsolationTypeSnp); + { STATIC_ASSERT(HV_PARTITION_ISOLATION_TYPE_SNP == UefiIsolationTypeSnp, ""); } mIsolationType = UefiIsolationTypeSnp; break; case HV_PARTITION_ISOLATION_TYPE_TDX: - static_assert(HV_PARTITION_ISOLATION_TYPE_TDX == UefiIsolationTypeTdx); + { STATIC_ASSERT(HV_PARTITION_ISOLATION_TYPE_TDX == UefiIsolationTypeTdx, ""); } mIsolationType = UefiIsolationTypeTdx; break; case HV_PARTITION_ISOLATION_TYPE_NONE: - static_assert(HV_PARTITION_ISOLATION_TYPE_NONE == UefiIsolationTypeNone); + { STATIC_ASSERT(HV_PARTITION_ISOLATION_TYPE_NONE == UefiIsolationTypeNone, ""); } return; default: ASSERT(FALSE); diff --git a/MsvmPkg/StorvscDxe/VstorageProtocol.h b/MsvmPkg/StorvscDxe/VstorageProtocol.h index 5d3d3be..9a1c263 100644 --- a/MsvmPkg/StorvscDxe/VstorageProtocol.h +++ b/MsvmPkg/StorvscDxe/VstorageProtocol.h @@ -151,15 +151,15 @@ typedef struct _VMSCSI_REQUEST UINT32 QueueSortKey; } VMSCSI_REQUEST, *PVMSCSI_REQUEST; -static_assert((sizeof(VMSCSI_REQUEST) % 4) == 0); +STATIC_ASSERT((sizeof(VMSCSI_REQUEST) % 4) == 0); #define VMSTORAGE_SIZEOF_VMSCSI_REQUEST_REVISION_1 OFFSET_OF(VMSCSI_REQUEST, Reserve) -static_assert(VMSTORAGE_SIZEOF_VMSCSI_REQUEST_REVISION_1 == 0x24); +STATIC_ASSERT(VMSTORAGE_SIZEOF_VMSCSI_REQUEST_REVISION_1 == 0x24); #define VMSTORAGE_SIZEOF_VMSCSI_REQUEST_REVISION_2 (SIZEOF_THROUGH_FIELD(VMSCSI_REQUEST, QueueSortKey)) -static_assert(VMSTORAGE_SIZEOF_VMSCSI_REQUEST_REVISION_2 == 0x34); +STATIC_ASSERT(VMSTORAGE_SIZEOF_VMSCSI_REQUEST_REVISION_2 == 0x34); // @@ -185,7 +185,7 @@ typedef struct _VMSTORAGE_CHANNEL_PROPERTIES #define STORAGE_CHANNEL_SUPPORTS_MULTI_CHANNEL 0x1 -static_assert((sizeof(VMSTORAGE_CHANNEL_PROPERTIES) % 4) == 0); +STATIC_ASSERT((sizeof(VMSTORAGE_CHANNEL_PROPERTIES) % 4) == 0); // // This structure is sent as part of the channel offer. It exists for old @@ -223,7 +223,7 @@ typedef struct _VMSTORAGE_PROTOCOL_VERSION } VMSTORAGE_PROTOCOL_VERSION, *PVMSTORAGE_PROTOCOL_VERSION; -static_assert((sizeof(VMSTORAGE_PROTOCOL_VERSION) % 4) == 0); +STATIC_ASSERT((sizeof(VMSTORAGE_PROTOCOL_VERSION) % 4) == 0); // // This structure is for fibre channel Wwn Packets. @@ -240,7 +240,7 @@ typedef struct _VMFC_WWN_PACKET INT8 SecondaryNodeWwn[8]; } VMFC_WWN_PACKET, *PVMFC_WWN_PACKET; -static_assert((sizeof(VMFC_WWN_PACKET) % 4) == 0); +STATIC_ASSERT((sizeof(VMFC_WWN_PACKET) % 4) == 0); // // Used to register or unregister Asynchronous Media Event Notification to the client @@ -252,7 +252,7 @@ typedef struct _VSTOR_CLIENT_PROPERTIES } VSTOR_CLIENT_PROPERTIES, *PVSTOR_CLIENT_PROPERTIES; -static_assert((sizeof(VSTOR_CLIENT_PROPERTIES) % 4) == 0); +STATIC_ASSERT((sizeof(VSTOR_CLIENT_PROPERTIES) % 4) == 0); typedef struct _VSTOR_ASYNC_REGISTER_PACKET { @@ -262,7 +262,7 @@ typedef struct _VSTOR_ASYNC_REGISTER_PACKET BOOLEAN Register; } VSTOR_ASYNC_REGISTER_PACKET, *PVSTOR_ASYNC_REGISTER_PACKET; -static_assert((sizeof(VSTOR_ASYNC_REGISTER_PACKET) % 4) == 0); +STATIC_ASSERT((sizeof(VSTOR_ASYNC_REGISTER_PACKET) % 4) == 0); // // Used to send notifications to StorVsc about media change events @@ -275,7 +275,7 @@ typedef struct _VSTOR_NOTIFICATION_PACKET UINT8 Flags; } VSTOR_NOTIFICATION_PACKET, *PVSTOR_NOTIFICATION_PACKET; -static_assert((sizeof(VSTOR_NOTIFICATION_PACKET) % 4) == 0); +STATIC_ASSERT((sizeof(VSTOR_NOTIFICATION_PACKET) % 4) == 0); typedef struct _VSTOR_PACKET { @@ -339,15 +339,15 @@ typedef struct _VSTOR_PACKET } VSTOR_PACKET, *PVSTOR_PACKET; -static_assert((sizeof(VSTOR_PACKET) % 8) == 0); +STATIC_ASSERT((sizeof(VSTOR_PACKET) % 8) == 0); #define VMSTORAGE_SIZEOF_VSTOR_PACKET_REVISION_1 (SIZEOF_THROUGH_FIELD(VSTOR_PACKET, Status) + VMSTORAGE_SIZEOF_VMSCSI_REQUEST_REVISION_1) -static_assert(VMSTORAGE_SIZEOF_VSTOR_PACKET_REVISION_1 == 0x30); +STATIC_ASSERT(VMSTORAGE_SIZEOF_VSTOR_PACKET_REVISION_1 == 0x30); #define VMSTORAGE_SIZEOF_VSTOR_PACKET_REVISION_2 (SIZEOF_THROUGH_FIELD(VSTOR_PACKET, Status) + VMSTORAGE_SIZEOF_VMSCSI_REQUEST_REVISION_2) -static_assert(VMSTORAGE_SIZEOF_VSTOR_PACKET_REVISION_2 == 0x40); +STATIC_ASSERT(VMSTORAGE_SIZEOF_VSTOR_PACKET_REVISION_2 == 0x40); // diff --git a/MsvmPkg/VmbusDxe/ChannelMessages.h b/MsvmPkg/VmbusDxe/ChannelMessages.h index 3c09a0a..c8e6f96 100644 --- a/MsvmPkg/VmbusDxe/ChannelMessages.h +++ b/MsvmPkg/VmbusDxe/ChannelMessages.h @@ -196,7 +196,7 @@ typedef struct _VMBUS_CHANNEL_OFFER_CHANNEL } VMBUS_CHANNEL_OFFER_CHANNEL, *PVMBUS_CHANNEL_OFFER_CHANNEL; -static_assert(sizeof(VMBUS_CHANNEL_OFFER_CHANNEL) <= MAXIMUM_SYNIC_MESSAGE_BYTES, "Offer message too large"); +STATIC_ASSERT(sizeof(VMBUS_CHANNEL_OFFER_CHANNEL) <= MAXIMUM_SYNIC_MESSAGE_BYTES, "Offer message too large"); #define VMBUS_CHANNEL_OFFER_CHANNEL_SIZE_PRE_WIN7 (UINT32)OFFSET_OF(VMBUS_CHANNEL_OFFER_CHANNEL, Windows6Offset) diff --git a/MsvmPkg/VpcivscDxe/wdm.h b/MsvmPkg/VpcivscDxe/wdm.h index a7a4e16..1a9b465 100644 --- a/MsvmPkg/VpcivscDxe/wdm.h +++ b/MsvmPkg/VpcivscDxe/wdm.h @@ -49,4 +49,4 @@ typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { #pragma pack() -static_assert(sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) == 0x14); +STATIC_ASSERT(sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) == 0x14, ""); From b947186577b617632cf613c29941f317c9a7afdb Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Tue, 24 Feb 2026 17:59:22 +0000 Subject: [PATCH 07/22] Merged PR 14858571: Clang: Switch should cover enums. bdapi.c: error: enumeration value 'BdNone' not handled in switch VideoGraphicsOutputBlt: Switch cover enum. When switching on an enum, clang warns if you do not case each member. This PR makes no judgement as to if this was a bug or what the should do. It lists the member, quiescing the warning, and maintains the old behavior as before, which is to fall out of the switch without doing anything (or going to default if there was one, not sure if Clang would warn on that or not, probably not.) ---- This pull request is a code cleanup that ensures all enum values are handled in switch statements to meet Clang's strict enum coverage requirements. The changes update switch statements to include missing enum cases, addressing Clang compatibility and cleanup work items. - `MsvmPkg/Library/BdLib/bdapi.c`: Adds a `BdNone` case and removes an unnecessary newline for proper enum handling. - `MsvmPkg/VideoDxe/VideoDxe.c`: Introduces an `EfiGraphicsOutputBltOperationMax` case and eliminates extraneous whitespace in the switch statement. Related work items: #57987809, #60275790 --- MsvmPkg/VideoDxe/VideoDxe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MsvmPkg/VideoDxe/VideoDxe.c b/MsvmPkg/VideoDxe/VideoDxe.c index 55696e5..3febdbf 100644 --- a/MsvmPkg/VideoDxe/VideoDxe.c +++ b/MsvmPkg/VideoDxe/VideoDxe.c @@ -618,7 +618,6 @@ Return Value: // switch (BltOperation) { - case EfiBltVideoToBltBuffer: for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); @@ -677,6 +676,9 @@ Return Value: BytesPerLine); } break; + + case EfiGraphicsOutputBltOperationMax: + break; } gBS->RestoreTPL (OriginalTPL); From dd09ce774e8ced0747b4aa0b317627c71d082fc7 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Tue, 24 Feb 2026 18:29:16 +0000 Subject: [PATCH 08/22] Merged PR 14858480: Clang: Initialize some local variables. Clang: Initialize some local variables. Imho we should initialize all locals variables: To in {} in C++11. {0] in C99 {} in C23 or C26 But in this case, just a few that clang warned about. HvHypercallLib.c variable 'msrIndex' is used uninitialized whenever switch default is taken. etc. ---- #### AI description (iteration 1) #### PR Classification This pull request performs a code cleanup by explicitly initializing local variables to support Clang builds. #### PR Summary This PR ensures that critical local variables are initialized to 0, addressing Clang's stricter compilation requirements as part of the work for building hyperv.uefi AARCH64 with Clang. - `MsvmPkg/PlatformPei/IgvmConfig.c`: Initializes `svsmBase` and `svsmSize` to 0. - `MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c`: Initializes `msrIndex` to 0. Related work items: #57987809 --- MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c | 2 +- MsvmPkg/PlatformPei/IgvmConfig.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c b/MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c index 5144574..b189601 100644 --- a/MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c +++ b/MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c @@ -610,7 +610,7 @@ Return Value: --*/ { - UINT32 msrIndex; + UINT32 msrIndex = 0; switch (RegisterName) { diff --git a/MsvmPkg/PlatformPei/IgvmConfig.c b/MsvmPkg/PlatformPei/IgvmConfig.c index f0f04b2..348eccd 100644 --- a/MsvmPkg/PlatformPei/IgvmConfig.c +++ b/MsvmPkg/PlatformPei/IgvmConfig.c @@ -387,8 +387,8 @@ Return Value: UEFI_CONFIG_PROCESSOR_INFORMATION processorInfo; VOID* secretsPage; EFI_STATUS status; - UINT64 svsmBase; - UINT64 svsmSize; + UINT64 svsmBase = 0; + UINT64 svsmSize = 0; // // Locate the parameter layout description at the base of the parameter From ccbcfc8ce60dc1f10b1f964d878274be101c68e8 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Tue, 24 Feb 2026 19:11:57 +0000 Subject: [PATCH 09/22] Merged PR 14862053: Clang: Remove unused static emptyName. Clang warns for this. Missed in earlier PR splitting. Related work items: #60275790, #57987809 --- MsvmPkg/VariableDxe/VariableDxe.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/MsvmPkg/VariableDxe/VariableDxe.c b/MsvmPkg/VariableDxe/VariableDxe.c index b457080..9c27c52 100644 --- a/MsvmPkg/VariableDxe/VariableDxe.c +++ b/MsvmPkg/VariableDxe/VariableDxe.c @@ -1154,8 +1154,6 @@ Routine Description: EFI_STATUS status; VARIABLE_HEADER* variable; UINT32 varNameSize; - static CHAR16 emptyName[1]; - if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) { From 97d0bece5a1b20d41401547b4bbebaaef16c993d Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Tue, 24 Feb 2026 19:39:50 +0000 Subject: [PATCH 10/22] Merged PR 14858089: Clang: Minor type changes and casts. KdDebugLib.c: Cast PCHAR8 to PUINT8. ULONG* and UINT32* are not the same, cast. netio.c: error: incompatible pointer types passing 'PUINT32' (aka 'unsigned int *') to parameter of type 'PULONG' (aka 'unsigned long *') Cast string constants to PUCHAR. Change CrashDumpBuffer from CHAR8 to UINT8. CrashDumpAgent.c error: passing 'CHAR8 [32768]' to parameter of type 'UINT8 *' AziHsmBKS3.c: cast CHAR8* to BYTE* Fix PlatformConsoleEventCallback signature, void* vs. non-void*. FrontPage\PlatformConsole.c: error: incompatible pointer types passing 'BOOLEAN (void *, const EFI_EVENT_DESCRIPTOR *, const BOOTEVENT_DEVICE_ENTRY *)' (aka 'unsigned char (void *, const EFI_EVENT_DESCRIPTOR *, const BOOTEVENT_DEVICE_ENTRY *)') to parameter of type 'EFI_EVENTLOG_ENUMERATE_CALLBACK' (aka 'unsigned char (*)(void *, const EFI_EVENT_DESCRIPTOR *, const void *)') BootDeviceEventEnumerate(PlatformConsoleEventCallback, &eventCount); Related work items: #57987809, #60275790 --- MsvmPkg/AziHsmDxe/AziHsmBKS3.c | 2 +- MsvmPkg/FrontPage/PlatformConsole.c | 4 ++-- MsvmPkg/PlatformPei/Hv.h | 14 +++++++------- MsvmPkg/PlatformPei/IgvmConfig.c | 27 ++++++++++++++++++++++++++- MsvmPkg/VpcivscDxe/VpcivscDxe.c | 4 +--- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/MsvmPkg/AziHsmDxe/AziHsmBKS3.c b/MsvmPkg/AziHsmDxe/AziHsmBKS3.c index a5f5b60..8519553 100644 --- a/MsvmPkg/AziHsmDxe/AziHsmBKS3.c +++ b/MsvmPkg/AziHsmDxe/AziHsmBKS3.c @@ -866,7 +866,7 @@ AziHsmGetTpmPlatformSecret ( // Primary Key User Data to be input to primary key creation DEBUG ((DEBUG_INFO, "AziHsm: Creating Platform hierarchy primary\n")); - Status = AziHsmCreatePlatformPrimaryKeyedHash (&PrimaryHandle, PrimaryKeyUserData, PrimaryKeyUserDataLength); + Status = AziHsmCreatePlatformPrimaryKeyedHash (&PrimaryHandle, (BYTE*)PrimaryKeyUserData, PrimaryKeyUserDataLength); AZIHSM_CHECK_RC (Status, "Primary (platform) creation failed\n"); // Step 2: HMAC KDF Derivation diff --git a/MsvmPkg/FrontPage/PlatformConsole.c b/MsvmPkg/FrontPage/PlatformConsole.c index 05f9a52..fc1110e 100644 --- a/MsvmPkg/FrontPage/PlatformConsole.c +++ b/MsvmPkg/FrontPage/PlatformConsole.c @@ -471,12 +471,11 @@ Return Value: return finishedString; } - BOOLEAN PlatformConsoleEventCallback( IN VOID *Context, IN const EFI_EVENT_DESCRIPTOR *Metadata, - IN const BOOTEVENT_DEVICE_ENTRY *Event + const VOID *VoidEvent ) /*++ @@ -500,6 +499,7 @@ Return Value: --*/ { + BOOTEVENT_DEVICE_ENTRY const * const Event = VoidEvent; CHAR16 *friendlyName = NULL; CHAR16 *statusString = NULL; UINT32 *entryNumber = ((UINT32 *)Context); // *entryNumber is a 1-based counter diff --git a/MsvmPkg/PlatformPei/Hv.h b/MsvmPkg/PlatformPei/Hv.h index 75f3ad7..4a21e1b 100644 --- a/MsvmPkg/PlatformPei/Hv.h +++ b/MsvmPkg/PlatformPei/Hv.h @@ -17,16 +17,16 @@ HvDetectIsolation( VOID ); -VOID -HvDetectSvsm( - IN VOID *SecretsPage, - OUT UINT64 *SvsmBase, - OUT UINT64 *SvsmSize - ); - typedef struct _SNP_SECRETS { UINT8 Reserved[0x140]; UINT64 SvsmBase; UINT64 SvsmSize; UINT64 SvsmCallingArea; } SNP_SECRETS, *PSNP_SECRETS; + +VOID +HvDetectSvsm( + IN PSNP_SECRETS SecretsPage, + OUT UINT64 *SvsmBase, + OUT UINT64 *SvsmSize + ); diff --git a/MsvmPkg/PlatformPei/IgvmConfig.c b/MsvmPkg/PlatformPei/IgvmConfig.c index 348eccd..152bf0f 100644 --- a/MsvmPkg/PlatformPei/IgvmConfig.c +++ b/MsvmPkg/PlatformPei/IgvmConfig.c @@ -385,7 +385,7 @@ Return Value: UEFI_CONFIG_FLAGS configFlags; UEFI_IGVM_PARAMETER_INFO *parameterInfo; UEFI_CONFIG_PROCESSOR_INFORMATION processorInfo; - VOID* secretsPage; + PSNP_SECRETS secretsPage; EFI_STATUS status; UINT64 svsmBase = 0; UINT64 svsmSize = 0; @@ -408,6 +408,31 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdHostEmulatorsWhenHardwareIsolated, TRUE)); } + { + // + // TODO: Find some way of avoiding hardcode of necessary host information + // + UINT32 i; + UINT8* azureAssetTag = (UINT8*)"7783-7084-3265-9085-8269-3286-77"; + UINT8* freeParameterMemory = (UINT8*)(parameterInfo) + sizeof(UEFI_IGVM_PARAMETER_INFO); + UINT8* smbiosAssetTag = freeParameterMemory + sizeof(GUID); + UINT64* smbiosGuid = (UINT64*)freeParameterMemory; + + // set BIOS GUID + smbiosGuid[0] = 0x7464782d7464782d; + smbiosGuid[1] = 0x7464782d7464782d; + + // set chassis asset tag to 7783-7084-3265-9085-8269-3286-77 + for (i = 0; i < 33; i++) + { + smbiosAssetTag[i] = azureAssetTag[i]; + } + + PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdBiosGuidPtr, (UINT64)smbiosGuid)); + PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosChassisAssetTagStr, (UINT64)smbiosAssetTag)); + PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosChassisAssetTagSize, 33)); + } + // // TODO: use parameters for this // Assume a single processor until VPR/VPS information can be configured diff --git a/MsvmPkg/VpcivscDxe/VpcivscDxe.c b/MsvmPkg/VpcivscDxe/VpcivscDxe.c index 78aad5d..e28d361 100644 --- a/MsvmPkg/VpcivscDxe/VpcivscDxe.c +++ b/MsvmPkg/VpcivscDxe/VpcivscDxe.c @@ -294,7 +294,7 @@ VpciChannelReceivePacketCallback( // // \return EFI_SUCCESS // -EFI_STATUS +void VpciChannelSendCompletionCallback( IN VOID *Context OPTIONAL, IN VOID *Buffer, @@ -322,8 +322,6 @@ VpciChannelSendCompletionCallback( } gBS->SignalEvent(completionContext->WaitForCompletion); - - return EFI_SUCCESS; } /// \brief Sends a synchronous packet to the VSP. From 4e4a9f1c32e9dafe3416ce9149e04dbce58022c9 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Tue, 24 Feb 2026 20:28:59 +0000 Subject: [PATCH 11/22] Merged PR 14858238: Clang: Name VMBUS_CHANNEL_MESSAGE_HEADER members. i.e. Do not use nice C language extension, that resembles a C++ base class. Related work items: #57987809, #60275790 --- MsvmPkg/VmbusDxe/ChannelMessages.h | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/MsvmPkg/VmbusDxe/ChannelMessages.h b/MsvmPkg/VmbusDxe/ChannelMessages.h index c8e6f96..950ed33 100644 --- a/MsvmPkg/VmbusDxe/ChannelMessages.h +++ b/MsvmPkg/VmbusDxe/ChannelMessages.h @@ -152,7 +152,7 @@ typedef struct _VMBUS_CHANNEL_MESSAGE_HEADER typedef struct _VMBUS_CHANNEL_OFFER_CHANNEL { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; GUID InterfaceType; GUID InterfaceInstance; @@ -203,7 +203,7 @@ STATIC_ASSERT(sizeof(VMBUS_CHANNEL_OFFER_CHANNEL) <= MAXIMUM_SYNIC_MESSAGE_BYTES // Rescind Offer parameters typedef struct _VMBUS_CHANNEL_RESCIND_OFFER { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; } VMBUS_CHANNEL_RESCIND_OFFER, *PVMBUS_CHANNEL_RESCIND_OFFER; @@ -218,7 +218,7 @@ typedef struct _VMBUS_CHANNEL_RESCIND_OFFER // Open Channel parameters typedef struct _VMBUS_CHANNEL_OPEN_CHANNEL { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; // // Identifies the specific VMBus channel that is being opened. @@ -273,7 +273,7 @@ typedef struct _VMBUS_CHANNEL_OPEN_CHANNEL // Open Channel Result parameters typedef struct _VMBUS_CHANNEL_OPEN_RESULT { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; UINT32 OpenId; UINT32 Status; @@ -282,13 +282,13 @@ typedef struct _VMBUS_CHANNEL_OPEN_RESULT // Close channel parameters; typedef struct _VMBUS_CHANNEL_CLOSE_CHANNEL { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; } VMBUS_CHANNEL_CLOSE_CHANNEL, *PVMBUS_CHANNEL_CLOSE_CHANNEL; typedef struct _VMBUS_CHANNEL_MODIFY_CHANNEL { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; // @@ -300,7 +300,7 @@ typedef struct _VMBUS_CHANNEL_MODIFY_CHANNEL typedef struct _VMBUS_CHANNEL_MODIFY_CHANNEL_RESPONSE { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; NTSTATUS Status; } VMBUS_CHANNEL_MODIFY_CHANNEL_RESPONSE, *PVMBUS_CHANNEL_MODIFY_CHANNEL_RESPONSE; @@ -314,7 +314,7 @@ typedef struct _VMBUS_CHANNEL_MODIFY_CHANNEL_RESPONSE typedef struct _VMBUS_CHANNEL_GPADL_HEADER { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; UINT32 Gpadl; UINT16 RangeBufLen; @@ -328,7 +328,7 @@ typedef struct _VMBUS_CHANNEL_GPADL_HEADER typedef struct _VMBUS_CHANNEL_GPADL_BODY { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 MessageNumber; UINT32 Gpadl; UINT64 Pfn[1]; @@ -337,7 +337,7 @@ typedef struct _VMBUS_CHANNEL_GPADL_BODY typedef struct _VMBUS_CHANNEL_GPADL_CREATED { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; UINT32 Gpadl; UINT32 CreationStatus; @@ -345,26 +345,26 @@ typedef struct _VMBUS_CHANNEL_GPADL_CREATED typedef struct _VMBUS_CHANNEL_GPADL_TEARDOWN { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; UINT32 Gpadl; } VMBUS_CHANNEL_GPADL_TEARDOWN, *PVMBUS_CHANNEL_GPADL_TEARDOWN; typedef struct _VMBUS_CHANNEL_GPADL_TORNDOWN { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 Gpadl; } VMBUS_CHANNEL_GPADL_TORNDOWN, *PVMBUS_CHANNEL_GPADL_TORNDOWN; typedef struct _VMBUS_CHANNEL_RELID_RELEASED { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChildRelId; } VMBUS_CHANNEL_RELID_RELEASED, *PVMBUS_CHANNEL_RELID_RELEASED; typedef struct _VMBUS_CHANNEL_INITIATE_CONTACT { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 VMBusVersionRequested; UINT32 TargetMessageVp; union @@ -388,7 +388,7 @@ typedef struct _VMBUS_CHANNEL_INITIATE_CONTACT typedef struct _VMBUS_CHANNEL_VERSION_RESPONSE { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; BOOLEAN VersionSupported; UINT8 ConnectionState; UINT8 Pad[2]; @@ -432,7 +432,7 @@ typedef VMBUS_CHANNEL_MESSAGE_HEADER VMBUS_CHANNEL_UNLOAD_COMPLETE, *PVMBUS_CHAN typedef struct _VMBUS_CHANNEL_OPEN_RESERVED_CHANNEL { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChannelId; UINT32 TargetVp; UINT32 TargetSint; @@ -442,7 +442,7 @@ typedef struct _VMBUS_CHANNEL_OPEN_RESERVED_CHANNEL typedef struct _VMBUS_CHANNEL_CLOSE_RESERVED_CHANNEL { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChannelId; UINT32 TargetVp; UINT32 TargetSint; @@ -450,13 +450,13 @@ typedef struct _VMBUS_CHANNEL_CLOSE_RESERVED_CHANNEL typedef struct _VMBUS_CHANNEL_CLOSE_RESERVED_RESPONSE { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT32 ChannelId; } VMBUS_CHANNEL_CLOSE_RESERVED_RESPONSE, *PVMBUS_CHANNEL_CLOSE_RESERVED_RESPONSE; typedef struct _VMBUS_CHANNEL_TL_CONNECT_REQUEST { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; GUID EndpointId; GUID ServiceId; @@ -472,7 +472,7 @@ typedef struct _VMBUS_CHANNEL_TL_CONNECT_REQUEST typedef struct _VMBUS_CHANNEL_TL_CONNECT_RESULT { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; GUID EndpointId; GUID ServiceId; NTSTATUS Status; @@ -480,14 +480,14 @@ typedef struct _VMBUS_CHANNEL_TL_CONNECT_RESULT typedef struct _VMBUS_CHANNEL_MODIFY_CONNECTION { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; UINT64 ParentToChildMonitorPageGpa; UINT64 ChildToParentMonitorPageGpa; } VMBUS_CHANNEL_MODIFY_CONNECTION, *PVMBUS_CHANNEL_MODIFY_CONNECTION; typedef struct _VMBUS_CHANNEL_MODIFY_CONNECTION_RESPONSE { - VMBUS_CHANNEL_MESSAGE_HEADER; + VMBUS_CHANNEL_MESSAGE_HEADER Header; // // This accepts the same values as in VMBUS_CHANNEL_VERSION_RESPONSE. From d352ea293c0430ea21fb16bec9f1e7a7ae51bb6d Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Tue, 24 Feb 2026 21:05:05 +0000 Subject: [PATCH 12/22] Merged PR 14855019: Cast ReadNoFence INT32 to UINT32 instead of confusingly to UINT64. ReadNoFence returns INT32. In RingBuffer we are comparing that to a UINT32. The code casts the result to UINT64. This is confusing. Does it sign extend or not? i.e. There is both a change in size and signedness. In which order? The change in size is not required. Cast to UINT32 instead. Related work items: #57987809, #60275790 --- MsvmPkg/EmclDxe/RingBuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MsvmPkg/EmclDxe/RingBuffer.c b/MsvmPkg/EmclDxe/RingBuffer.c index 8af9121..5646d02 100644 --- a/MsvmPkg/EmclDxe/RingBuffer.c +++ b/MsvmPkg/EmclDxe/RingBuffer.c @@ -545,7 +545,7 @@ PkCompleteRemoval( // Mark that an interrupt is expected if the ring is now empty. // - if ((UINT64)ReadNoFence((UINT32*)&control->In) == NewOut) + if ((UINT32)ReadNoFence((UINT32*)&control->In) == NewOut) { PkpExpectInterrupt(PkLibContext, TRUE); } From 032530cba3576151d148fb7e070f4b2d2aa6e7fa Mon Sep 17 00:00:00 2001 From: Ravikiran Patil Date: Tue, 24 Feb 2026 23:07:27 +0000 Subject: [PATCH 13/22] Merged PR 14855961: Remove TPM Null sealing in AziHsm Driver Entry and delay TPM PH lock to ReadyToBoot This PR accomplishes the following: - Driver Entry no longer generates Platform hierarchy secret and we avoid TPM null sealing. (This removes the perf issue of TPM operation in driver Entry) - Tcg2PlatformDxe is overriden to MsvmTcg2PlatformDxe, which allows our platform to delay the TPM platform hierarchy sealing to ReadyToBoot. This has security implications for third party drivers or option ROMs in the future though, but is necessary to unblock AziHsm GA - Removes AziHsmEnabled and its PCD Now, VMs that do not use manticore will never face a increased boot regression; DriverEntry for AziHsm is ~0 ms. The work is now done in DriverBindingStart, which only runs if AziHsm device is present. To test, we built an MSVM.fd with serial and consumed it with OpenHCL. We then used OpenHCL to boot a VM with manticore enabled on a manticore-equipped host. We verified that the AziHsm DriverBinding logic succeeds from the informational logs, confirming that the behavior is the same. Here are logs confirming so: [azihsm_tpm_seal_change_log.txt](https://microsoft.visualstudio.com/8d47e068-03c8-4cdc-aa9b-fc6929290322/_apis/git/repositories/1ad2e189-11bd-479f-8f25-a739cc641dfa/pullRequests/14855961/attachments/azihsm_tpm_seal_change_log.txt) This text document (convert it to .md) shows the timing for DriverEntry and DriverBindingStart with the fix [DriverEntryAndBindingTimingWithFix.txt](https://microsoft.visualstudio.com/8d47e068-03c8-4cdc-aa9b-fc6929290322/_apis/git/repositories/1ad2e189-11bd-479f-8f25-a739cc641dfa/pullRequests/14855961/attachments/DriverEntryAndBindingTimingWithFix.txt) Compare this to without the fix [DriverEntryAndBindingTimingWithoutFix.txt](https://microsoft.visualstudio.com/8d47e068-03c8-4cdc-aa9b-fc6929290322/_apis/git/repositories/1ad2e189-11bd-479f-8f25-a739cc641dfa/pullRequests/14855961/attachments/DriverEntryAndBindingTimingWithoutFix.txt) ---- #### AI description (iteration 1) #### PR Classification This pull request deprecates the TPM null sealing logic in the AziHsm driver and cleans up associated sensitive data handling. #### PR Summary The changes remove TPM null sealing operations and event-based sensitive data cleanup from the AziHsm driver while streamlining key derivation to use the TPM platform secret directly, and introduce a new module for TPM platform hierarchy configuration. - **`AziHsmDxe.c`**: Removed TPM null sealing logic, along with ReadyToBoot/UnableToBoot event callbacks and the sensitive data cleanup routines. - **AziHsm key derivation workflow**: Updated in `AziHsmPerformBks3SealingWorkflow` to bypass unsealing via the TPM null hierarchy. - **`MsvmTcg2PlatformDxe.c` & `MsvmTcg2PlatformDxe.inf`**: Added a new platform-specific module to configure and lock the TPM Platform Hierarchy at ReadyToBoot. - **Configuration files**: Updated in files like `BiosInterface.h`, DSC, FDF, DEC, and PlatformPei to remove references to AziHsmEnabled and align with the new TPM platform hierarchy setup. Related work... --- MsvmPkg/AziHsmDxe/AziHsmDxe.c | 255 +++--------------- MsvmPkg/AziHsmDxe/AziHsmDxe.inf | 1 - MsvmPkg/Include/BiosInterface.h | 3 +- MsvmPkg/MsvmPkg.dec | 1 - MsvmPkg/MsvmPkgAARCH64.dsc | 3 +- MsvmPkg/MsvmPkgAARCH64.fdf | 2 +- MsvmPkg/MsvmPkgX64.dsc | 3 +- MsvmPkg/MsvmPkgX64.fdf | 2 +- .../MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.c | 100 +++++++ .../MsvmTcg2PlatformDxe.inf | 48 ++++ MsvmPkg/PlatformPei/Config.c | 2 - MsvmPkg/PlatformPei/PlatformPei.inf | 1 - 12 files changed, 183 insertions(+), 238 deletions(-) create mode 100644 MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.c create mode 100644 MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.inf diff --git a/MsvmPkg/AziHsmDxe/AziHsmDxe.c b/MsvmPkg/AziHsmDxe/AziHsmDxe.c index 2281297..88bb293 100644 --- a/MsvmPkg/AziHsmDxe/AziHsmDxe.c +++ b/MsvmPkg/AziHsmDxe/AziHsmDxe.c @@ -15,22 +15,9 @@ #include "AziHsmAdmin.h" #include -#include - #include #include #include -#include -#include - -STATIC EFI_EVENT mAziHsmReadyToBootEvent = NULL; -STATIC EFI_EVENT mAziHsmUnableToBootEvent = NULL; - -// -// Global Platform Sealed Key - shared across all HSM devices -// -STATIC BOOLEAN mAziHsmSealedPlatormSecretDerived = FALSE; -STATIC AZIHSM_BUFFER mAziHsmSealedPlatformSecret = { 0 }; // Forward declarations for internal helper functions @@ -56,15 +43,6 @@ AziHsmPerformBks3SealingWorkflow ( IN UINTN HsmSerialDataLength ); -// -// Function to cleanup sensitive data -// -VOID -EFIAPI -AziHsmCleanupSensitiveData ( - VOID - ); - // // Driver Binding Instance // @@ -240,15 +218,10 @@ AziHsmDriverBindingStart ( BOOLEAN IsHsmIdValid = FALSE; AZIHSM_DDI_API_REV ApiRevisionMin; AZIHSM_DDI_API_REV ApiRevisionMax; - AZIHSM_DERIVED_KEY DerivedKey; - AZIHSM_BUFFER UnsealedKey; - ZeroMem (&UnsealedKey, sizeof (UnsealedKey)); - ZeroMem (&DerivedKey, sizeof (DerivedKey)); ZeroMem ((VOID *)&HsmIdenData, sizeof (HsmIdenData)); DEBUG ((DEBUG_INFO, "AziHsm: DriverBindingStart called for Controller: %p\n", Controller)); - Status = gBS->OpenProtocol ( Controller, &gEfiDevicePathProtocolGuid, @@ -419,24 +392,24 @@ AziHsmPerformBks3SealingWorkflow ( AZIHSM_BUFFER SealedBKS3Buffer; AZIHSM_BUFFER SealedAesSecret; AZIHSM_BUFFER TpmPlatformSecret; + AZIHSM_DERIVED_KEY TpmDerivedSecret; UINT8 *InputData = NULL; UINT8 *EncryptedData = NULL; - UINTN PadValue = 0; UINT8 Iv[AZIHSM_AES_IV_SIZE]; UINT8 Aes256Key[AZIHSM_AES256_KEY_SIZE]; UINTN PaddedInputSize = 0; - UINT16 EncryptedDataSize = 0; BOOLEAN IsHSMSealSuccess = FALSE; UINT8 WrappedBKS3[AZIHSM_BUFFER_MAX_SIZE]; UINT16 WrappedBKS3KeySize = (UINT16)AZIHSM_BUFFER_MAX_SIZE; AZIHSM_DERIVED_KEY BKS3Key; - AZIHSM_BUFFER KeyIvBuffer; - AZIHSM_KEY_IV_RECORD KeyIvRecord; - UINT32 ExpectedSealedDataSize; UINT8 HsmGuid[AZIHSM_HSM_GUID_MAX_SIZE]; UINT16 HsmGuidSize = AZIHSM_HSM_GUID_MAX_SIZE; AZIHSM_TCG_CONTEXT TcgContext; - + UINTN PadValue = 0; + UINT16 EncryptedDataSize = 0; + AZIHSM_BUFFER KeyIvBuffer; + AZIHSM_KEY_IV_RECORD KeyIvRecord; + UINT32 ExpectedSealedDataSize; if (State == NULL || HsmSerialData == NULL || HsmSerialDataLength == 0) { DEBUG ((DEBUG_ERROR, "AziHsm: AziHsmPerformBks3SealingWorkflow() Invalid parameter\n")); @@ -448,24 +421,30 @@ AziHsmPerformBks3SealingWorkflow ( ZeroMem (WrappedBKS3, AZIHSM_BUFFER_MAX_SIZE); ZeroMem (&BKS3Key, sizeof (BKS3Key)); ZeroMem (&TpmPlatformSecret, sizeof(TpmPlatformSecret)); + ZeroMem (&TpmDerivedSecret, sizeof(TpmDerivedSecret)); ZeroMem (HsmGuid, sizeof (HsmGuid)); ZeroMem (&TcgContext, sizeof (TcgContext)); DEBUG ((DEBUG_INFO, "AziHsm: Starting BKS3 key derivation workflow\n")); - if (!mAziHsmSealedPlatormSecretDerived) { - DEBUG ((DEBUG_ERROR, "AziHsm: Sealed Platform hierarchy secret not available.\n")); - Status = EFI_NOT_READY; + Status = AziHsmGetTpmPlatformSecret (&TpmDerivedSecret); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "AziHsm: BKS3 key derivation workflow failed: %r\n", Status)); goto Exit; } - // Unseal the sealed blob using null hierarchy (ensures we can only unseal in current boot session) - Status = AziHsmUnsealUsingTpmNullHierarchy (&mAziHsmSealedPlatformSecret, &TpmPlatformSecret); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "AziHsm: Failed to unseal platform key sealed blob using null hierarchy: %r\n", Status)); + // + // Copy derived key into AZIHSM_BUFFER for use by AziHsmDeriveBKS3fromId + // + if (TpmDerivedSecret.KeySize > sizeof (TpmPlatformSecret.Data)) { + DEBUG ((DEBUG_ERROR, "AziHsm: Derived key size exceeds buffer capacity\n")); + Status = EFI_BUFFER_TOO_SMALL; goto Exit; } + CopyMem (TpmPlatformSecret.Data, TpmDerivedSecret.KeyData, TpmDerivedSecret.KeySize); + TpmPlatformSecret.Size = (UINT16)TpmDerivedSecret.KeySize; + Status = AziHsmDeriveBKS3fromId (&TpmPlatformSecret, (UINT8 *)(HsmSerialData), HsmSerialDataLength, &BKS3Key); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "AziHsm: Failed to derive BKS3 key from unsealed blob: %r\n", Status)); @@ -494,6 +473,7 @@ AziHsmPerformBks3SealingWorkflow ( goto Exit; } + // Use TPM to get random AES key and IV if (EFI_ERROR (AziHsmTpmGetRandom (sizeof (Aes256Key), Aes256Key))) { DEBUG ((DEBUG_ERROR, "AziHsm: AziHsmPerformBks3SealingWorkflow - TPM GetRandom failed for key\n")); @@ -611,6 +591,7 @@ AziHsmPerformBks3SealingWorkflow ( goto Cleanup; } + DEBUG ((DEBUG_INFO, "AziHsm: SetSealBKS3 Blob size : %d\n", SealedBKS3Buffer.Size)); Status = AziHsmSetSealedBks3 (State, ApiRevisionMax, SealedBKS3Buffer.Data, SealedBKS3Buffer.Size, &IsHSMSealSuccess); @@ -660,6 +641,7 @@ AziHsmPerformBks3SealingWorkflow ( ZeroMem (HsmGuid, sizeof (HsmGuid)); ZeroMem (&TcgContext, sizeof (TcgContext)); ZeroMem (&TpmPlatformSecret, sizeof(TpmPlatformSecret)); + ZeroMem (&TpmDerivedSecret, sizeof(TpmDerivedSecret)); return Status; } @@ -751,6 +733,12 @@ AziHsmAes256CbcEncrypt ( DEBUG ((DEBUG_ERROR, "AziHsm: AziHsmAes256CbcEncrypt - AesCbcEncrypt failed\n")); Status = EFI_DEVICE_ERROR; goto Exit; + } + + // Ensure output data size does not exceed MAX_UINT16 + if(InputDataSize > MAX_UINT16) { + DEBUG ((DEBUG_ERROR, "AziHsm: Encrypt: Input data size %u exceeds maximum output size %u\n", InputDataSize, MAX_UINT16)); + Status = EFI_BUFFER_TOO_SMALL; goto Exit; } @@ -854,13 +842,6 @@ AziHsmDriverBindingStop ( } Exit: - // - // Clear sensitive data as backup cleanup trigger - // This ensures cleanup happens if driver is stopped for any reason - // - DEBUG ((DEBUG_WARN, "AziHsm: DriverBindingStop - triggering sensitive data cleanup\n")); - AziHsmCleanupSensitiveData (); - DEBUG ((DEBUG_INFO, "AziHsm: DriverBindingStop completed. Status: %r\n", Status)); return Status; } @@ -1079,54 +1060,7 @@ AziHsmDriverUnload ( return Status; } -/** - Ready to Boot event notification handler. - - @param[in] Event The event that triggered this notification - @param[in] Context Context pointer (can be NULL) -**/ -VOID -EFIAPI -AziHsmReadyToBootCallback ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - DEBUG ((DEBUG_INFO, "AziHsm: Ready to Boot event triggered - clearing sensitive data\n")); - - // - // Clear sensitive data when ready to boot - // - AziHsmCleanupSensitiveData (); - - // - // Close the event after handling - // - gBS->CloseEvent (Event); -} -/** - Unable to Boot event notification handler. - This is called when the system is unable to find bootable devices/options. - - @param[in] Event The event that triggered this notification - @param[in] Context Context pointer (can be NULL) -**/ -VOID -EFIAPI -AziHsmUnableToBootCallback ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - DEBUG ((DEBUG_ERROR, "AziHsm: Unable to Boot event triggered - clearing sensitive data\n")); - - // Clear sensitive data when unable to boot - AziHsmCleanupSensitiveData(); - - // Close the event after handling - gBS->CloseEvent (Event); -} /** The entry point for HSM driver, used to install HSM driver on the ImageHandle. @@ -1144,58 +1078,6 @@ AziHsmDriverEntry ( ) { EFI_STATUS Status; - AZIHSM_DERIVED_KEY TpmDerivedSecret; - AZIHSM_BUFFER TpmDerivedSecretBlob; - AZIHSM_BUFFER SealedSecretBlob; - - // - // Check if AziHsm is enabled via PCD - // - if (!PcdGetBool (PcdAziHsmEnabled)) { - DEBUG ((DEBUG_INFO, "AziHsm: Driver disabled via PcdAziHsmEnabled\n")); - return EFI_SUCCESS; - } - - ZeroMem (&TpmDerivedSecret, sizeof (TpmDerivedSecret)); - ZeroMem (&TpmDerivedSecretBlob, sizeof (TpmDerivedSecretBlob)); - ZeroMem (&SealedSecretBlob, sizeof (SealedSecretBlob)); - - // - // Derive BKS3 key from TPM using the workflow - // - Status = AziHsmGetTpmPlatformSecret (&TpmDerivedSecret); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "AziHsm: BKS3 key derivation workflow failed: %r\n", Status)); - goto Exit; - } - - // - // Seal the derived key to the null hierarchy for secure storage - // - if (TpmDerivedSecret.KeySize > sizeof (TpmDerivedSecretBlob.Data)) { - DEBUG ((DEBUG_ERROR, "AziHsm: Derived key size exceeds maximum buffer size of the TpmDerivedKeyBlob\n")); - Status = EFI_BAD_BUFFER_SIZE; - goto Exit; - } - - CopyMem (TpmDerivedSecretBlob.Data, TpmDerivedSecret.KeyData, TpmDerivedSecret.KeySize); - TpmDerivedSecretBlob.Size = (UINT16)TpmDerivedSecret.KeySize; - - // Seal the derived key to the TPM null hierarchy(to ensure it is associated with current boot) and - // does not persist across reboots - Status = AziHsmSealToTpmNullHierarchy (&TpmDerivedSecretBlob, &SealedSecretBlob); - - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "AziHsm: Sealing to null hierarchy failed: %r\n", Status)); - goto Exit; - } - - // - // Store the sealed key globally for reuse across all HSM devices - // - CopyMem (&(mAziHsmSealedPlatformSecret.Data), &(SealedSecretBlob.Data), SealedSecretBlob.Size); - mAziHsmSealedPlatformSecret.Size = SealedSecretBlob.Size; - mAziHsmSealedPlatormSecretDerived = TRUE; Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, @@ -1207,7 +1089,7 @@ AziHsmDriverEntry ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "AziHsm: Install driver binding failed. Status: %r\n", Status)); - goto Cleanup; + goto Exit; } // Install EFI Driver Supported EFI Version Protocol required for @@ -1220,89 +1102,12 @@ AziHsmDriverEntry ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "AziHsm: Install Driver Supported EFI Version failed. Status: %r\n", Status)); - goto Cleanup; - } - - // - // Register for Ready to Boot event to clear sensitive data before OS launch - // This is the standard event that fires just before UEFI transfers control to OS - // - Status = EfiCreateEventReadyToBootEx ( - TPL_CALLBACK, - AziHsmReadyToBootCallback, - NULL, - &mAziHsmReadyToBootEvent - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "AziHsm: Failed to create Ready to Boot event: %r\n", Status)); - goto Cleanup; - } - - DEBUG ((DEBUG_INFO, "AziHsm: Ready to Boot event registered successfully\n")); - - // - // Register to unable to boot event to cleanup sensitive data - // This event is signaled when the system cannot find bootable devices/options - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - AziHsmUnableToBootCallback, - NULL, - &gMsvmUnableToBootEventGuid, - &mAziHsmUnableToBootEvent - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "AziHsm: Failed to create Unable to Boot event: %r\n", Status)); - goto Cleanup; + goto Exit; } - DEBUG ((DEBUG_INFO, "AziHsm: Unable to Boot event registered successfully\n")); - DEBUG ((DEBUG_INFO, "AziHsm: Driver loaded successfully\n")); - goto Exit; -Cleanup: - ZeroMem(&mAziHsmSealedPlatformSecret, sizeof(mAziHsmSealedPlatformSecret)); - mAziHsmSealedPlatormSecretDerived = FALSE; Exit: - ZeroMem (&TpmDerivedSecret, sizeof (TpmDerivedSecret)); - ZeroMem (&TpmDerivedSecretBlob, sizeof (TpmDerivedSecretBlob)); - ZeroMem (&SealedSecretBlob, sizeof (SealedSecretBlob)); - return Status; } -// -// Flag to prevent multiple cleanup calls -// -STATIC BOOLEAN mSensitiveDataCleared = FALSE; - -/** - Cleanup sensitive data from HSM and memory. - Called from multiple triggers to ensure cleanup happens regardless of boot outcome. -**/ -VOID -EFIAPI -AziHsmCleanupSensitiveData ( - VOID - ) -{ - if (mSensitiveDataCleared) { - DEBUG ((DEBUG_INFO, "AziHsm: Sensitive data already cleared, skipping\n")); - return; - } - - DEBUG ((DEBUG_INFO, "AziHsm: *** Starting sensitive data cleanup ***\n")); - - // - // Clear sensitive data from HSM before OS takes control - // - ZeroMem (&mAziHsmSealedPlatformSecret, sizeof (AZIHSM_BUFFER)); - mAziHsmSealedPlatormSecretDerived = FALSE; - DEBUG ((DEBUG_INFO, "AziHsm: Global Platform Hierarchy secret cleared\n")); - - mSensitiveDataCleared = TRUE; - DEBUG ((DEBUG_INFO, "AziHsm: *** Sensitive data cleanup completed ***\n")); -} - diff --git a/MsvmPkg/AziHsmDxe/AziHsmDxe.inf b/MsvmPkg/AziHsmDxe/AziHsmDxe.inf index f2c4666..33542c7 100644 --- a/MsvmPkg/AziHsmDxe/AziHsmDxe.inf +++ b/MsvmPkg/AziHsmDxe/AziHsmDxe.inf @@ -84,7 +84,6 @@ gMsvmUnableToBootEventGuid [Pcd] - gMsvmPkgTokenSpaceGuid.PcdAziHsmEnabled gMsvmPkgTokenSpaceGuid.PcdIsolationSharedGpaBoundary gMsvmPkgTokenSpaceGuid.PcdIsolationSharedGpaCanonicalizationBitmask diff --git a/MsvmPkg/Include/BiosInterface.h b/MsvmPkg/Include/BiosInterface.h index 01efb49..6253bea 100644 --- a/MsvmPkg/Include/BiosInterface.h +++ b/MsvmPkg/Include/BiosInterface.h @@ -789,8 +789,7 @@ typedef struct _UEFI_CONFIG_FLAGS UINT64 CxlMemoryEnabled : 1; UINT64 MtrrsInitializedAtLoad : 1; UINT64 HvSintEnabled : 1; - UINT64 AziHsmEnabled : 1; - UINT64 Reserved:33; + UINT64 Reserved:34; } Flags; } UEFI_CONFIG_FLAGS; diff --git a/MsvmPkg/MsvmPkg.dec b/MsvmPkg/MsvmPkg.dec index 237f2ae..b99bd37 100644 --- a/MsvmPkg/MsvmPkg.dec +++ b/MsvmPkg/MsvmPkg.dec @@ -303,7 +303,6 @@ gMsvmPkgTokenSpaceGuid.PcdMtrrsInitializedAtLoad|FALSE|BOOLEAN|0x6067 gMsvmPkgTokenSpaceGuid.PcdNvmeNamespaceFilter|FALSE|BOOLEAN|0x6068 gMsvmPkgTokenSpaceGuid.PcdHvSintEnabled|FALSE|BOOLEAN|0x6069 - gMsvmPkgTokenSpaceGuid.PcdAziHsmEnabled|FALSE|BOOLEAN|0x6072 # UEFI_CONFIG_PROCESSOR_INFORMATION gMsvmPkgTokenSpaceGuid.PcdProcessorCount|0x0|UINT32|0x6032 diff --git a/MsvmPkg/MsvmPkgAARCH64.dsc b/MsvmPkg/MsvmPkgAARCH64.dsc index 0140c79..f6a41c7 100644 --- a/MsvmPkg/MsvmPkgAARCH64.dsc +++ b/MsvmPkg/MsvmPkgAARCH64.dsc @@ -675,7 +675,6 @@ gMsvmPkgTokenSpaceGuid.PcdHostEmulatorsWhenHardwareIsolated|FALSE gMsvmPkgTokenSpaceGuid.PcdTpmLocalityRegsEnabled|FALSE gMsvmPkgTokenSpaceGuid.PcdHvSintEnabled|FALSE - gMsvmPkgTokenSpaceGuid.PcdAziHsmEnabled|FALSE # UEFI_CONFIG_PROCESSOR_INFORMATION gMsvmPkgTokenSpaceGuid.PcdProcessorCount|0x0 @@ -894,7 +893,7 @@ NULL|MsvmPkg/Library/Tcg2PreInitLib/Tcg2PreInitLibPei.inf } - SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf { + MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.inf { Tpm2DeviceLib|MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.inf TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf diff --git a/MsvmPkg/MsvmPkgAARCH64.fdf b/MsvmPkg/MsvmPkgAARCH64.fdf index 47d4f65..ca1c10d 100644 --- a/MsvmPkg/MsvmPkgAARCH64.fdf +++ b/MsvmPkg/MsvmPkgAARCH64.fdf @@ -249,7 +249,7 @@ INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf INF SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf INF SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf INF SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf -INF SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf +INF MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.inf # UI Theme Protocol. INF MsGraphicsPkg/MsUiTheme/Dxe/MsUiThemeProtocol.inf diff --git a/MsvmPkg/MsvmPkgX64.dsc b/MsvmPkg/MsvmPkgX64.dsc index 26cc229..4204790 100644 --- a/MsvmPkg/MsvmPkgX64.dsc +++ b/MsvmPkg/MsvmPkgX64.dsc @@ -673,7 +673,6 @@ gMsvmPkgTokenSpaceGuid.PcdWatchdogEnabled|FALSE gMsvmPkgTokenSpaceGuid.PcdHostEmulatorsWhenHardwareIsolated|FALSE gMsvmPkgTokenSpaceGuid.PcdTpmLocalityRegsEnabled|FALSE - gMsvmPkgTokenSpaceGuid.PcdAziHsmEnabled|FALSE # UEFI_CONFIG_PROCESSOR_INFORMATION gMsvmPkgTokenSpaceGuid.PcdProcessorCount|0x0 @@ -919,7 +918,7 @@ NULL|MsvmPkg/Library/ExcludeMainFvFromMeasurementLib/ExcludeMainFvFromMeasurementLib.inf } - SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf { + MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.inf { Tpm2DeviceLib|MsvmPkg/Library/Tpm2DeviceLib/Tpm2DeviceLib.inf TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf diff --git a/MsvmPkg/MsvmPkgX64.fdf b/MsvmPkg/MsvmPkgX64.fdf index 0817fc0..75481d7 100644 --- a/MsvmPkg/MsvmPkgX64.fdf +++ b/MsvmPkg/MsvmPkgX64.fdf @@ -291,7 +291,7 @@ INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf INF SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf INF SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf INF SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf -INF SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf +INF MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.inf # UI Theme Protocol. INF MsGraphicsPkg/MsUiTheme/Dxe/MsUiThemeProtocol.inf diff --git a/MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.c b/MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.c new file mode 100644 index 0000000..00e70b3 --- /dev/null +++ b/MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.c @@ -0,0 +1,100 @@ +/** @file + Platform specific TPM2 component for configuring the Platform Hierarchy. + + Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +// MU_CHANGE - START refactor Tcg2PlatformDxe to lock TPM at EndOfDxe or ReadyToBoot depending on boot mode. + +#include + +#include +// #include // MS_HYP_CHANGE +#include +#include +#include +// #include // MS_HYP_CHANGE + +/** + This callback function will run at EndOfDxe or ReadyToBoot based on boot mode. + + Configuration of the TPM's Platform Hierarchy Authorization Value (platformAuth) + and Platform Hierarchy Authorization Policy (platformPolicy) can be defined through this function. + + @param Event Pointer to this event + @param Context Event handler private data + **/ +VOID +EFIAPI +TpmReadyToLockEventCallBack ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + DEBUG ((DEBUG_INFO, "[%a] Disabling TPM Platform Hierarchy\n", __func__)); + ConfigureTpmPlatformHierarchy (); + + gBS->CloseEvent (Event); +} + +/** + The driver's entry point. Will register a function for callback during ReadyToBoot event to + configure the TPM's platform authorization. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval other Some error occurs when executing this entry point. +**/ +EFI_STATUS +EFIAPI +Tcg2PlatformDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + // MS_HYP_CHANGE BEGIN + // EFI_BOOT_MODE BootMode; + // MS_HYP_CHANGE END + EFI_EVENT Event; + + // MS_HYP_CHANGE BEGIN + // BootMode = GetBootModeHob (); + + // In flash update boot path, leave TPM Platform Hierarchy enabled until ReadyToBoot (which should never actually + // occur, since capsule reset will occur first). + // if (BootMode == BOOT_ON_FLASH_UPDATE) { + + // + // Lock the TPM platform hierarchy at ReadyToBoot rather than EndOfDxe. + // AziHsmDxe needs access to the TPM platform hierarchy during + // DriverBindingStart, which executes after EndOfDxe. Moving the lock to + // ReadyToBoot gives AziHsmDxe the window it needs. This cannot be done + // from AziHsmDxe's DriverEntry because DriverEntry runs unconditionally + // and cannot check for the presence of an AziHsm device, which would + // cause TPM operations to execute unnecessarily on non-AziHsm VMs. + // + Status = EfiCreateEventReadyToBootEx (TPL_CALLBACK, TpmReadyToLockEventCallBack, NULL, &Event); + // } else { + // // In all other boot paths, disable TPM Platform Hierarchy at EndOfDxe. + // Status = gBS->CreateEventEx ( + // EVT_NOTIFY_SIGNAL, + // TPL_CALLBACK, + // TpmReadyToLockEventCallBack, + // NULL, + // &gEfiEndOfDxeEventGroupGuid, + // &Event + // ); + // } + // MS_HYP_CHANGE END + + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +// MU_CHANGE - END refactor Tcg2PlatformDxe to lock TPM at EndOfDxe or ReadyToBoot depending on boot mode. diff --git a/MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.inf b/MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.inf new file mode 100644 index 0000000..d274914 --- /dev/null +++ b/MsvmPkg/MsvmTcg2PlatformDxe/MsvmTcg2PlatformDxe.inf @@ -0,0 +1,48 @@ +## @file +# Platform specific TPM2 component for configuring the Platform Hierarchy. +# +# This is a HyperV platform override of the MU Tiano Tcg2PlatformDxe. +# Unlike the upstream version, this always disables the TPM Platform Hierarchy +# at ReadyToBoot regardless of boot mode. +# +# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) Microsoft Corporation.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +#Override : 00000002 | SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf | 0c8473803cbb74953e267512e7eb4674 | 2026-02-23T18-25-36 | 475361f7a3ece77dc955e3cb052c088352414ea7 + +[Defines] + INF_VERSION = 0x00010017 + BASE_NAME = MsvmTcg2PlatformDxe + FILE_GUID = EA810C19-EF34-4E04-BA68-7CBC0A8E20B2 + VERSION_STRING = 1.0 + MODULE_TYPE = DXE_DRIVER + ENTRY_POINT = Tcg2PlatformDxeEntryPoint +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF AARCH64 +# + +[LibraryClasses] + BaseLib + UefiBootServicesTableLib + UefiDriverEntryPoint + DebugLib + UefiLib + TpmPlatformHierarchyLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + SecurityPkg/SecurityPkg.dec + +[Sources] + MsvmTcg2PlatformDxe.c + +[Depex] + gEfiTcg2ProtocolGuid + diff --git a/MsvmPkg/PlatformPei/Config.c b/MsvmPkg/PlatformPei/Config.c index 75da9e1..326f4dc 100644 --- a/MsvmPkg/PlatformPei/Config.c +++ b/MsvmPkg/PlatformPei/Config.c @@ -732,7 +732,6 @@ DebugDumpUefiConfigStruct( DEBUG((DEBUG_VERBOSE, "\tTpmLocalityRegsEnabled: %u\n", flags->Flags.TpmLocalityRegsEnabled)); DEBUG((DEBUG_VERBOSE, "\tMtrrsInitializedAtLoad: %u\n", flags->Flags.MtrrsInitializedAtLoad)); DEBUG((DEBUG_VERBOSE, "\tHvSintEnabled: %u\n", flags->Flags.HvSintEnabled)); - DEBUG((DEBUG_VERBOSE, "\tAziHsmEnabled: %u\n", flags->Flags.AziHsmEnabled)); break; case UefiConfigProcessorInformation: @@ -900,7 +899,6 @@ ConfigSetUefiConfigFlags( PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdTpmLocalityRegsEnabled, (UINT8) ConfigFlags->Flags.TpmLocalityRegsEnabled)); PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdMtrrsInitializedAtLoad, (UINT8) ConfigFlags->Flags.MtrrsInitializedAtLoad)); PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdHvSintEnabled, (UINT8) ConfigFlags->Flags.HvSintEnabled)); - PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdAziHsmEnabled, (UINT8) ConfigFlags->Flags.AziHsmEnabled)); // // If memory protections are enabled, configure the value into the HOB. diff --git a/MsvmPkg/PlatformPei/PlatformPei.inf b/MsvmPkg/PlatformPei/PlatformPei.inf index 1fd34dc..6987260 100644 --- a/MsvmPkg/PlatformPei/PlatformPei.inf +++ b/MsvmPkg/PlatformPei/PlatformPei.inf @@ -194,7 +194,6 @@ gMsvmPkgTokenSpaceGuid.PcdMtrrsInitializedAtLoad gMsvmPkgTokenSpaceGuid.PcdNvmeNamespaceFilter gMsvmPkgTokenSpaceGuid.PcdHvSintEnabled - gMsvmPkgTokenSpaceGuid.PcdAziHsmEnabled [Pcd.AArch64] gMsvmPkgTokenSpaceGuid.PcdSystemMemoryBaseAddress From 32b7f50a92206a3af0639a92cd54aada506daad3 Mon Sep 17 00:00:00 2001 From: Mike Ebersol Date: Wed, 25 Feb 2026 00:49:00 +0000 Subject: [PATCH 14/22] Merged PR 14863276: Revert "Merged PR 14617102: Add opt-in ACPI device for Linux L1VH SINT discov... Revert "Merged PR 14617102: Add opt-in ACPI device for Linux L1VH SINT discovery on ARM64" This reverts commit 374c9111ccc6cdf8352b44e1142b430eac8a880e. Related work items: #60730240 --- MsvmPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 1 - MsvmPkg/AcpiPlatformDxe/Dsdt.c | 3 -- MsvmPkg/AcpiTables/AcpiTables.inf | 1 - MsvmPkg/AcpiTables/Dsdt.asl | 31 +-------------------- MsvmPkg/Include/BiosInterface.h | 3 +- MsvmPkg/MsvmPkg.dec | 4 --- MsvmPkg/MsvmPkgAARCH64.dsc | 7 +---- MsvmPkg/PlatformPei/Config.c | 2 -- MsvmPkg/PlatformPei/PlatformPei.inf | 1 - 9 files changed, 3 insertions(+), 50 deletions(-) diff --git a/MsvmPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/MsvmPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf index c293425..759daa1 100644 --- a/MsvmPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/MsvmPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -95,7 +95,6 @@ gMsvmPkgTokenSpaceGuid.PcdTpmEnabled ## CONSUMES gMsvmPkgTokenSpaceGuid.PcdVirtualBatteryEnabled ## CONSUMES gMsvmPkgTokenSpaceGuid.PcdWatchdogEnabled ## CONSUMES - gMsvmPkgTokenSpaceGuid.PcdHvSintEnabled ## CONSUMES [Pcd.X64] gMsvmPkgTokenSpaceGuid.PcdAcpiMadtMpMailBoxAddress ## PRODUCES diff --git a/MsvmPkg/AcpiPlatformDxe/Dsdt.c b/MsvmPkg/AcpiPlatformDxe/Dsdt.c index c830d14..f0ba257 100644 --- a/MsvmPkg/AcpiPlatformDxe/Dsdt.c +++ b/MsvmPkg/AcpiPlatformDxe/Dsdt.c @@ -32,7 +32,6 @@ typedef struct _DSDT_AML_DATA UINT8 SgxMemoryEnabled; UINT8 ProcIdleEnabled; UINT8 CxlMemoryEnabled; - UINT8 HvSintEnabled; UINT16 NvdimmCount; } DSDT_AML_DATA; @@ -139,7 +138,6 @@ Return Value: data->ProcIdleEnabled = PcdGetBool(PcdProcIdleEnabled); data->CxlMemoryEnabled = PcdGetBool(PcdCxlMemoryEnabled); data->NvdimmCount = PcdGet16(PcdNvdimmCount); - data->HvSintEnabled = PcdGetBool(PcdHvSintEnabled); DEBUG((DEBUG_VERBOSE, "--- %a: Mmio1Start 0x%lx\n", __FUNCTION__, data->Mmio1Start)); DEBUG((DEBUG_VERBOSE, "--- %a: Mmio1Length 0x%lx\n", __FUNCTION__, data->Mmio1Start)); @@ -154,7 +152,6 @@ Return Value: DEBUG((DEBUG_VERBOSE, "--- %a: ProcIdleEnabled 0x%x\n", __FUNCTION__, data->ProcIdleEnabled)); DEBUG((DEBUG_VERBOSE, "--- %a: CxlMemoryEnabled 0x%x\n", __FUNCTION__, data->CxlMemoryEnabled)); DEBUG((DEBUG_VERBOSE, "--- %a: NvdimmCount 0x%x\n", __FUNCTION__, data->NvdimmCount)); - DEBUG((DEBUG_VERBOSE, "--- %a: HvSintEnabled 0x%x\n", __FUNCTION__, data->HvSintEnabled)); // // Allocate space for the NVDIMM IO Buffer if VPMEM is enabled. diff --git a/MsvmPkg/AcpiTables/AcpiTables.inf b/MsvmPkg/AcpiTables/AcpiTables.inf index d267d3b..a0e0791 100644 --- a/MsvmPkg/AcpiTables/AcpiTables.inf +++ b/MsvmPkg/AcpiTables/AcpiTables.inf @@ -51,7 +51,6 @@ gMsvmPkgTokenSpaceGuid.PcdNonSecureEL1TimerGSIV ## CONSUMES gMsvmPkgTokenSpaceGuid.PcdVirtualEL1TimerGSIV ## CONSUMES gMsvmPkgTokenSpaceGuid.PcdNonSecureEL2TimerGSIV ## CONSUMES - gMsvmPkgTokenSpaceGuid.PcdInterceptSintVector ## CONSUMES [Pcd.X64] gMsvmPkgTokenSpaceGuid.PcdRtcRegisterBase ## CONSUMES diff --git a/MsvmPkg/AcpiTables/Dsdt.asl b/MsvmPkg/AcpiTables/Dsdt.asl index 6b386bb..abd5c3a 100644 --- a/MsvmPkg/AcpiTables/Dsdt.asl +++ b/MsvmPkg/AcpiTables/Dsdt.asl @@ -62,7 +62,6 @@ DefinitionBlock ( SGXE,8, // SGX Memory enabled/disabled PADE,8, // Processor Aggregator Device enabled/disabled CCFG,8, // CXL memory support enabled/disabled - SINT,8, // HV SINT PPI device enabled NCNT,16, // NVDIMM count } @@ -112,7 +111,7 @@ DefinitionBlock ( // Function 1 : Strict S4 enforcement toggle function If (LEqual(ToInteger(Arg2), 1)) - { + { Return(0x0001) } } @@ -377,34 +376,6 @@ DefinitionBlock ( ) } -#if defined(_DSDT_ARM_) - // Intercept SINT ========================================================= - // Exposes a PPI for Linux L1VH to use for hypervisor intercept SINTs. - // Only enabled when the loader sets the HvSintEnabled flag. - - If(LGreater(SINT, 0)) - { - Device(\_SB.VMOD.SINT) - { - Name(_HID, "MSFT1003") - Name(_UID, 0) - Name(_DDN, "Hyper-V SINTs") - Name(_CRS, ResourceTemplate() - { - Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) - {FixedPcdGet8(PcdInterceptSintVector)} - }) - // _STA: Return status bitmap - // Bit 0: Present, Bit 1: Enabled, Bit 3: Functioning - // Bit 2 NOT set: Do not show in UI (prevents "unknown device" in Device Manager) - Method(_STA, 0, NotSerialized) - { - Return (0x0B) - } - } - } -#endif - // TPM ==================================================================== If(LGreater(TCFG, 0)) diff --git a/MsvmPkg/Include/BiosInterface.h b/MsvmPkg/Include/BiosInterface.h index 6253bea..66a24ce 100644 --- a/MsvmPkg/Include/BiosInterface.h +++ b/MsvmPkg/Include/BiosInterface.h @@ -788,8 +788,7 @@ typedef struct _UEFI_CONFIG_FLAGS UINT64 Dhcp6DuidTypeLlt : 1; UINT64 CxlMemoryEnabled : 1; UINT64 MtrrsInitializedAtLoad : 1; - UINT64 HvSintEnabled : 1; - UINT64 Reserved:34; + UINT64 Reserved:35; } Flags; } UEFI_CONFIG_FLAGS; diff --git a/MsvmPkg/MsvmPkg.dec b/MsvmPkg/MsvmPkg.dec index b99bd37..7ab89f5 100644 --- a/MsvmPkg/MsvmPkg.dec +++ b/MsvmPkg/MsvmPkg.dec @@ -87,9 +87,6 @@ gMsvmPkgTokenSpaceGuid.PcdVmbusSintIndex|0x2|UINT8|0x3001 gMsvmPkgTokenSpaceGuid.PcdVmbusVector|0x5|UINT8|0x3002 - # Intercept SINT PPI for Linux L1VH - gMsvmPkgTokenSpaceGuid.PcdInterceptSintVector|0x0|UINT8|0x3003 - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile|{ 0x25, 0x4e, 0x37, 0x7e, 0x01, 0x8e, 0xee, 0x4f, 0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6, 0xcd }|VOID*|0x30000016 # maximum number of event channels. @@ -302,7 +299,6 @@ gMsvmPkgTokenSpaceGuid.PcdTpmLocalityRegsEnabled|FALSE|BOOLEAN|0x6065 gMsvmPkgTokenSpaceGuid.PcdMtrrsInitializedAtLoad|FALSE|BOOLEAN|0x6067 gMsvmPkgTokenSpaceGuid.PcdNvmeNamespaceFilter|FALSE|BOOLEAN|0x6068 - gMsvmPkgTokenSpaceGuid.PcdHvSintEnabled|FALSE|BOOLEAN|0x6069 # UEFI_CONFIG_PROCESSOR_INFORMATION gMsvmPkgTokenSpaceGuid.PcdProcessorCount|0x0|UINT32|0x6032 diff --git a/MsvmPkg/MsvmPkgAARCH64.dsc b/MsvmPkg/MsvmPkgAARCH64.dsc index f6a41c7..3708467 100644 --- a/MsvmPkg/MsvmPkgAARCH64.dsc +++ b/MsvmPkg/MsvmPkgAARCH64.dsc @@ -362,10 +362,6 @@ # use the next available, 18. gMsvmPkgTokenSpaceGuid.PcdVmbusVector|18 - # Intercept SINT PPI for Linux L1VH. - # PPIs 19-21 are GIC timers, so use 22. - gMsvmPkgTokenSpaceGuid.PcdInterceptSintVector|22 - # BIOS Device gMsvmPkgTokenSpaceGuid.PcdBiosBaseAddress|0xEFFED000 @@ -425,7 +421,7 @@ # The runtime state of this PCD can be modified in the debugger by # modifying EfiBdDebugPrintGlobalMask and EfiBdDebugPrintComponentMask. # - # We now expect the host bios device to parse the in-memory advanced logger + # We now expect the host bios device to parse the in-memory advanced logger # buffer to our tracing facilities # # NOTE: Additional debug levels may cause the in-memory advanced logger @@ -674,7 +670,6 @@ gMsvmPkgTokenSpaceGuid.PcdWatchdogEnabled|FALSE gMsvmPkgTokenSpaceGuid.PcdHostEmulatorsWhenHardwareIsolated|FALSE gMsvmPkgTokenSpaceGuid.PcdTpmLocalityRegsEnabled|FALSE - gMsvmPkgTokenSpaceGuid.PcdHvSintEnabled|FALSE # UEFI_CONFIG_PROCESSOR_INFORMATION gMsvmPkgTokenSpaceGuid.PcdProcessorCount|0x0 diff --git a/MsvmPkg/PlatformPei/Config.c b/MsvmPkg/PlatformPei/Config.c index 326f4dc..dc05b90 100644 --- a/MsvmPkg/PlatformPei/Config.c +++ b/MsvmPkg/PlatformPei/Config.c @@ -731,7 +731,6 @@ DebugDumpUefiConfigStruct( DEBUG((DEBUG_VERBOSE, "\tWatchdogEnabled: %u\n", flags->Flags.WatchdogEnabled)); DEBUG((DEBUG_VERBOSE, "\tTpmLocalityRegsEnabled: %u\n", flags->Flags.TpmLocalityRegsEnabled)); DEBUG((DEBUG_VERBOSE, "\tMtrrsInitializedAtLoad: %u\n", flags->Flags.MtrrsInitializedAtLoad)); - DEBUG((DEBUG_VERBOSE, "\tHvSintEnabled: %u\n", flags->Flags.HvSintEnabled)); break; case UefiConfigProcessorInformation: @@ -898,7 +897,6 @@ ConfigSetUefiConfigFlags( PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdWatchdogEnabled, (UINT8) ConfigFlags->Flags.WatchdogEnabled)); PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdTpmLocalityRegsEnabled, (UINT8) ConfigFlags->Flags.TpmLocalityRegsEnabled)); PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdMtrrsInitializedAtLoad, (UINT8) ConfigFlags->Flags.MtrrsInitializedAtLoad)); - PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdHvSintEnabled, (UINT8) ConfigFlags->Flags.HvSintEnabled)); // // If memory protections are enabled, configure the value into the HOB. diff --git a/MsvmPkg/PlatformPei/PlatformPei.inf b/MsvmPkg/PlatformPei/PlatformPei.inf index 6987260..f732c85 100644 --- a/MsvmPkg/PlatformPei/PlatformPei.inf +++ b/MsvmPkg/PlatformPei/PlatformPei.inf @@ -193,7 +193,6 @@ gMsvmPkgTokenSpaceGuid.PcdTpmLocalityRegsEnabled gMsvmPkgTokenSpaceGuid.PcdMtrrsInitializedAtLoad gMsvmPkgTokenSpaceGuid.PcdNvmeNamespaceFilter - gMsvmPkgTokenSpaceGuid.PcdHvSintEnabled [Pcd.AArch64] gMsvmPkgTokenSpaceGuid.PcdSystemMemoryBaseAddress From 2850f19349ddd365ee56c1c8bd438ca339d95410 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 25 Feb 2026 05:08:04 +0000 Subject: [PATCH 15/22] Merged PR 14858540: Clang: Remove __assume. It was a bad idea with Visual C++ and should be avoided even if not switching compilers. It leads to silent bad code. HvHypercallLib.c implicit declaration of function '__assume' is invalid in C99. Related work items: #57987809, #60275790 --- MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c b/MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c index b189601..541f5df 100644 --- a/MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c +++ b/MsvmPkg/Library/HvHypercallLib/HvHypercallLib.c @@ -708,7 +708,6 @@ Return Value: default: ASSERT(FALSE); - __assume(0); } return msrIndex; From fa3b3039c5417e8603ecb6fea219035dba345391 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 25 Feb 2026 05:30:42 +0000 Subject: [PATCH 16/22] Merged PR 14857494: Clang: Fix case and/or path of includes. Clang: Fix case of includes (uppercase, lowercase), to match file system. BiosDeviceLibCore.c non-portable path to file ''; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path] Snp.h: Fix case of include NetvscDxe.h. Fix case of include nvspprotocol.h. Correct case of includ VmbusPacketFormat.h Fix case of include BaseLib.h. Fix include path of of cpu.h. Bd.h: error: 'cpu.h' file not found Fix include ntstatus.h. Actually include the intended smaller one usually, larger one sometimes. This should be further cleaned up, to avoid the case insensitive name collision, VmbusNtStatus and KdNtStatus, or just combine them, now that KdNtStatus is reasonably small. If you get the wrong one, unsurprising: bdapi.c use of undeclared identifier 'STATUS_SUCCESS' bdapi.c use of undeclared identifier 'STATUS_INVALID_PARAMETER' ---- Code cleanup to fix include case mismatches for clang compliance. This pull request corrects header file include cases and updates architecture-specific conditional includes to match the filesystem, ensuring builds are clang compliant. It also supports linked work items addressing nested virtualization and miscellaneous clang fixes. - In `MsvmPkg/Library/BdLib/Bd.h`, the single include of "cpu.h" is replaced with conditional includes for architecture-specific headers and commented standard library includes are replaced with an include for "ntstatus.h". - In `MsvmPkg/NetvscDxe` (across both header and source files), include statements are updated to fix the case for `PrintLib` and `nvspprotocol.h`. - In `MsvmPkg/StorvscDxe/StorchannelDxe.c`, the include is corrected from "Industrystandard/Scsi.h" to "IndustryStandard/Scsi.h". - In modules like `EmclDxe/Init.c`, `BiosDeviceLibCore.c`, and `VariableDxe.c`, includes have been updated from "Baselib.h" to "BaseLib.h". - In `SynthKeyDxe/SynthKeyChannel.h` and `VideoDxe/VideoDxe.h`, header naming is fixed from "VmBusPacketFormat.h" to "VmbusPacketFormat.h". Related work items: #41399366, #54710354, #60275790 --- MsvmPkg/EmclDxe/Init.c | 2 +- MsvmPkg/Library/BiosDeviceLib/BiosDeviceLibCore.c | 2 +- MsvmPkg/NetvscDxe/NetvscDxe.c | 2 +- MsvmPkg/NetvscDxe/NetvscDxe.h | 5 ++--- MsvmPkg/NetvscDxe/Snp.h | 2 +- MsvmPkg/StorvscDxe/StorchannelDxe.c | 4 +--- MsvmPkg/SynthKeyDxe/SynthKeyChannel.h | 2 +- MsvmPkg/VariableDxe/VariableDxe.c | 2 +- MsvmPkg/VideoDxe/VideoDxe.h | 2 +- 9 files changed, 10 insertions(+), 13 deletions(-) diff --git a/MsvmPkg/EmclDxe/Init.c b/MsvmPkg/EmclDxe/Init.c index ca07789..5311d81 100644 --- a/MsvmPkg/EmclDxe/Init.c +++ b/MsvmPkg/EmclDxe/Init.c @@ -7,7 +7,7 @@ **/ -#include "transportp.h" +#include "Transportp.h" #define RING_BUFFER_POOL_TAG 'gnrV' diff --git a/MsvmPkg/Library/BiosDeviceLib/BiosDeviceLibCore.c b/MsvmPkg/Library/BiosDeviceLib/BiosDeviceLibCore.c index 257bb8e..c8abad4 100644 --- a/MsvmPkg/Library/BiosDeviceLib/BiosDeviceLibCore.c +++ b/MsvmPkg/Library/BiosDeviceLib/BiosDeviceLibCore.c @@ -7,7 +7,7 @@ --*/ #include -#include +#include #include #include diff --git a/MsvmPkg/NetvscDxe/NetvscDxe.c b/MsvmPkg/NetvscDxe/NetvscDxe.c index b6c61f0..dcf75a9 100644 --- a/MsvmPkg/NetvscDxe/NetvscDxe.c +++ b/MsvmPkg/NetvscDxe/NetvscDxe.c @@ -14,7 +14,7 @@ #include #include "NetvscDxe.h" -#include "NvspProtocol.h" +#include "nvspprotocol.h" #include "rndis.h" // diff --git a/MsvmPkg/NetvscDxe/NetvscDxe.h b/MsvmPkg/NetvscDxe/NetvscDxe.h index ec13aae..7b283e4 100644 --- a/MsvmPkg/NetvscDxe/NetvscDxe.h +++ b/MsvmPkg/NetvscDxe/NetvscDxe.h @@ -23,9 +23,8 @@ #include #include #include -#include - -#include +#include +#include #define MAXIMUM_ETHERNET_PACKET_SIZE 1514 diff --git a/MsvmPkg/NetvscDxe/Snp.h b/MsvmPkg/NetvscDxe/Snp.h index 6c3a826..ed25053 100644 --- a/MsvmPkg/NetvscDxe/Snp.h +++ b/MsvmPkg/NetvscDxe/Snp.h @@ -12,7 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include -#include +#include #include #include diff --git a/MsvmPkg/StorvscDxe/StorchannelDxe.c b/MsvmPkg/StorvscDxe/StorchannelDxe.c index 102ddea..56cd3a9 100644 --- a/MsvmPkg/StorvscDxe/StorchannelDxe.c +++ b/MsvmPkg/StorvscDxe/StorchannelDxe.c @@ -6,10 +6,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ - #include "StorvscDxe.h" - -#include +#include #include #include "StorportDxe.h" diff --git a/MsvmPkg/SynthKeyDxe/SynthKeyChannel.h b/MsvmPkg/SynthKeyDxe/SynthKeyChannel.h index 82f9b47..1999710 100644 --- a/MsvmPkg/SynthKeyDxe/SynthKeyChannel.h +++ b/MsvmPkg/SynthKeyDxe/SynthKeyChannel.h @@ -10,7 +10,7 @@ #pragma once #include -#include +#include EFI_STATUS SynthKeyChannelOpen( diff --git a/MsvmPkg/VariableDxe/VariableDxe.c b/MsvmPkg/VariableDxe/VariableDxe.c index 9c27c52..8384694 100644 --- a/MsvmPkg/VariableDxe/VariableDxe.c +++ b/MsvmPkg/VariableDxe/VariableDxe.c @@ -11,7 +11,7 @@ **/ #include -#include +#include #include #include #include diff --git a/MsvmPkg/VideoDxe/VideoDxe.h b/MsvmPkg/VideoDxe/VideoDxe.h index 1be04ad..c9bf3d9 100644 --- a/MsvmPkg/VideoDxe/VideoDxe.h +++ b/MsvmPkg/VideoDxe/VideoDxe.h @@ -43,7 +43,7 @@ typedef struct _RECT { #define BYTE UINT8 #include -#include +#include #define VIDEODXE_VERSION 1 #define VIDEODXE_CONTEXT_SIGNATURE SIGNATURE_32('V','D','X','E') From e8abf33220bb28ce1088793e4dd5629620168998 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 25 Feb 2026 07:12:27 +0000 Subject: [PATCH 17/22] Merged PR 14858692: Clang: Emcl: Name members. ``` Emcl.h:191:5: error: declaration does not declare anything [-Werror,-Wmissing-declarations] EFI_EMCL_PROTOCOL; ^~~~~~~~~~~~~~~~~ ``` Name it Base, use it. Use it instead of casting also. C++ would help here. :) Related work items: #54710354, #60275790 --- MsvmPkg/EmclDxe/Emcl.c | 22 +++++++++++----------- MsvmPkg/Include/Protocol/Emcl.h | 5 +---- MsvmPkg/StorvscDxe/StorchannelDxe.c | 19 +++++++++---------- MsvmPkg/VpcivscDxe/VpcivscDxe.c | 10 +++++----- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/MsvmPkg/EmclDxe/Emcl.c b/MsvmPkg/EmclDxe/Emcl.c index 6fc768b..240d247 100644 --- a/MsvmPkg/EmclDxe/Emcl.c +++ b/MsvmPkg/EmclDxe/Emcl.c @@ -2162,17 +2162,17 @@ Return Value: { ZeroMem(Context, sizeof(*Context)); Context->Signature = EMCL_CONTEXT_SIGNATURE; - Context->EmclProtocol.StartChannel = EmclStartChannel; - Context->EmclProtocol.StopChannel = EmclStopChannel; - Context->EmclProtocol.SendPacket = EmclSendPacket; - Context->EmclProtocol.CompletePacket = EmclCompletePacket; - Context->EmclProtocol.SetReceiveCallback = EmclSetReceiveCallback; - Context->EmclProtocol.CreateGpadl = EmclCreateGpadl; - Context->EmclProtocol.DestroyGpadl = EmclDestroyGpadl; - Context->EmclProtocol.GetGpadlHandle = EmclGetGpadlHandle; - Context->EmclProtocol.GetGpadlBuffer = EmclGetGpadlBuffer; - Context->EmclProtocol.CreateGpaRange = EmclCreateGpaRange; - Context->EmclProtocol.DestroyGpaRange = EmclDestroyGpaRange; + Context->EmclProtocol.Base.StartChannel = EmclStartChannel; + Context->EmclProtocol.Base.StopChannel = EmclStopChannel; + Context->EmclProtocol.Base.SendPacket = EmclSendPacket; + Context->EmclProtocol.Base.CompletePacket = EmclCompletePacket; + Context->EmclProtocol.Base.SetReceiveCallback = EmclSetReceiveCallback; + Context->EmclProtocol.Base.CreateGpadl = EmclCreateGpadl; + Context->EmclProtocol.Base.DestroyGpadl = EmclDestroyGpadl; + Context->EmclProtocol.Base.GetGpadlHandle = EmclGetGpadlHandle; + Context->EmclProtocol.Base.GetGpadlBuffer = EmclGetGpadlBuffer; + Context->EmclProtocol.Base.CreateGpaRange = EmclCreateGpaRange; + Context->EmclProtocol.Base.DestroyGpaRange = EmclDestroyGpaRange; Context->EmclProtocol.SendPacketEx = EmclSendPacketEx; InitializeListHead(&Context->CompletionEntries); InitializeListHead(&Context->OutgoingQueue); diff --git a/MsvmPkg/Include/Protocol/Emcl.h b/MsvmPkg/Include/Protocol/Emcl.h index 1e6d92d..3bca282 100644 --- a/MsvmPkg/Include/Protocol/Emcl.h +++ b/MsvmPkg/Include/Protocol/Emcl.h @@ -186,12 +186,9 @@ EFI_STATUS IN OPTIONAL VOID *CompletionContext ); -#pragma warning(disable : 4201) struct _EFI_EMCL_V2_PROTOCOL { - EFI_EMCL_PROTOCOL; - + EFI_EMCL_PROTOCOL Base; EFI_EMCL_SEND_PACKET_EX SendPacketEx; }; -#pragma warning(default : 4201) extern EFI_GUID gEfiEmclV2ProtocolGuid; diff --git a/MsvmPkg/StorvscDxe/StorchannelDxe.c b/MsvmPkg/StorvscDxe/StorchannelDxe.c index 56cd3a9..0dcb377 100644 --- a/MsvmPkg/StorvscDxe/StorchannelDxe.c +++ b/MsvmPkg/StorvscDxe/StorchannelDxe.c @@ -115,15 +115,15 @@ Return Value: goto Cleanup; } - status = Emcl->SetReceiveCallback( - (EFI_EMCL_PROTOCOL*)Emcl, + status = Emcl->Base.SetReceiveCallback( + &Emcl->Base, StorChannelReceivePacketCallback, context, TPL_STORVSC_CALLBACK ); - status = Emcl->StartChannel( - (EFI_EMCL_PROTOCOL*)Emcl, + status = Emcl->Base.StartChannel( + &Emcl->Base, RING_INCOMING_PAGE_COUNT, RING_OUTGOING_PAGE_COUNT); @@ -163,7 +163,6 @@ Return Value: return status; } - VOID StorChannelClose ( IN PSTORVSC_CHANNEL_CONTEXT ChannelContext @@ -186,7 +185,7 @@ Return Value: { if (ChannelContext->Emcl != NULL) { - ChannelContext->Emcl->StopChannel((EFI_EMCL_PROTOCOL*)ChannelContext->Emcl); + ChannelContext->Emcl->Base.StopChannel(&ChannelContext->Emcl->Base); } FreePool(ChannelContext); } @@ -563,7 +562,7 @@ Return Value: } status = ChannelContext->Emcl->SendPacketEx( - (EFI_EMCL_PROTOCOL*)ChannelContext->Emcl, + &ChannelContext->Emcl->Base, &packet, packetSize, buffers, @@ -722,8 +721,8 @@ Return Value: // // Nothing to do here. Just complete the packet. // - context->Emcl->CompletePacket( - (EFI_EMCL_PROTOCOL*)context->Emcl, + context->Emcl->Base.CompletePacket( + &context->Emcl->Base, PacketContext, Buffer, BufferLength @@ -787,7 +786,7 @@ Return Value: packetSize = ChannelContext->MaxPacketSize; status = EmclSendPacketSync( - (EFI_EMCL_PROTOCOL*)ChannelContext->Emcl, + &ChannelContext->Emcl->Base, Packet, packetSize, NULL, diff --git a/MsvmPkg/VpcivscDxe/VpcivscDxe.c b/MsvmPkg/VpcivscDxe/VpcivscDxe.c index e28d361..c83ec87 100644 --- a/MsvmPkg/VpcivscDxe/VpcivscDxe.c +++ b/MsvmPkg/VpcivscDxe/VpcivscDxe.c @@ -278,7 +278,7 @@ VpciChannelReceivePacketCallback( // Complete the packet. DEBUG((DEBUG_VPCI_INFO, "Completing VPCI recv packet.\n")); - context->Emcl->CompletePacket((EFI_EMCL_PROTOCOL*) context->Emcl, + context->Emcl->Base.CompletePacket(&context->Emcl->Base, PacketContext, Buffer, BufferLength); @@ -373,7 +373,7 @@ VpciChannelSendPacketSync( goto Cleanup; } - status = Context->Emcl->SendPacket((EFI_EMCL_PROTOCOL*)Context->Emcl, + status = Context->Emcl->Base.SendPacket(&Context->Emcl->Base, Packet, PacketLength, NULL, @@ -432,7 +432,7 @@ VpciChannelOpen( { EFI_STATUS status = EFI_DEVICE_ERROR; - status = Context->Emcl->SetReceiveCallback((EFI_EMCL_PROTOCOL*)Context->Emcl, + status = Context->Emcl->Base.SetReceiveCallback(&Context->Emcl->Base, VpciChannelReceivePacketCallback, Context, TPL_VPCIVSC_CALLBACK @@ -445,7 +445,7 @@ VpciChannelOpen( return status; } - status = Context->Emcl->StartChannel((EFI_EMCL_PROTOCOL*)Context->Emcl, + status = Context->Emcl->Base.StartChannel(&Context->Emcl->Base, RING_BUFFER_INCOMING_PAGE_COUNT, RING_BUFFER_OUTGOING_PAGE_COUNT); @@ -464,7 +464,7 @@ VpciChannelClose( IN PVPCIVSC_CONTEXT Context ) { - Context->Emcl->StopChannel((EFI_EMCL_PROTOCOL*)Context->Emcl); + Context->Emcl->Base.StopChannel(&Context->Emcl->Base); } /// \brief Negotiate the protocol with the VSP. See corresponding windows From 3c9f6f204dba235b7e2a151d8e3861ed66ce3f47 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 25 Feb 2026 07:38:12 +0000 Subject: [PATCH 18/22] Merged PR 14855092: Clang: PlatformPei/Config.c braces for switch/case scopes. Add braces so there are scopes around local variables. And/or, to avoid goto (switch) around initialization, since C99 allows locals not at scope start. Braces should suffice in place of blank lines, and sometimes there is blank before break, sometimes not. Converge on not. Related work items: #57987809 --- MsvmPkg/PlatformPei/Config.c | 226 ++++++++++++++++++++++------------- 1 file changed, 140 insertions(+), 86 deletions(-) diff --git a/MsvmPkg/PlatformPei/Config.c b/MsvmPkg/PlatformPei/Config.c index dc05b90..19fec6a 100644 --- a/MsvmPkg/PlatformPei/Config.c +++ b/MsvmPkg/PlatformPei/Config.c @@ -557,109 +557,127 @@ DebugDumpUefiConfigStruct( switch(Header->Type) { case UefiConfigStructureCount: + { UEFI_CONFIG_STRUCTURE_COUNT *count = (UEFI_CONFIG_STRUCTURE_COUNT*) Header; DEBUG((DEBUG_VERBOSE, "\tTotalStructureCount: %u\n", count->TotalStructureCount)); break; - + } case UefiConfigBiosInformation: + { UEFI_CONFIG_BIOS_INFORMATION *biosInfo = (UEFI_CONFIG_BIOS_INFORMATION*) Header; DEBUG((DEBUG_VERBOSE, "\tBiosSizePages: 0x%x\n\tLegacyMemoryMap:%u\n", biosInfo->BiosSizePages, biosInfo->Flags.LegacyMemoryMap)); break; - + } case UefiConfigMadt: + { UEFI_CONFIG_MADT * madt = (UEFI_CONFIG_MADT*)Header; DebugDumpMadt(madt->Madt); break; - + } case UefiConfigSrat: + { UEFI_CONFIG_SRAT *srat = (UEFI_CONFIG_SRAT*) Header; DebugDumpSrat(srat->Srat); break; - + } case UefiConfigSlit: + { UEFI_CONFIG_SLIT *slit = (UEFI_CONFIG_SLIT*)Header; DebugDumpSlit(slit->Slit); break; - + } case UefiConfigPptt: DEBUG((DEBUG_VERBOSE, "\tPPTT table found.\n")); break; - case UefiConfigHmat: + { UEFI_CONFIG_HMAT *hmat = (UEFI_CONFIG_HMAT*)Header; DebugDumpHmat(hmat->Hmat); break; - + } case UefiConfigMemoryMap: + { UEFI_CONFIG_MEMORY_MAP *memMap = (UEFI_CONFIG_MEMORY_MAP*) Header; DebugDumpMemoryMap(memMap->MemoryMap, Header->Length - sizeof(UEFI_CONFIG_HEADER), PcdGetBool(PcdLegacyMemoryMap)); break; - + } case UefiConfigEntropy: DEBUG((DEBUG_VERBOSE, "\tEntropy table found.\n")); break; - case UefiConfigBiosGuid: + { UEFI_CONFIG_BIOS_GUID *biosGuid = (UEFI_CONFIG_BIOS_GUID*) Header; DEBUG((DEBUG_VERBOSE, "\tBiosGuid: %g\n", (EFI_GUID*) biosGuid->BiosGuid)); break; - + } case UefiConfigSmbiosSystemManufacturer: + { UEFI_CONFIG_SMBIOS_SYSTEM_MANUFACTURER *systemManufacturer = (UEFI_CONFIG_SMBIOS_SYSTEM_MANUFACTURER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios System Manufacturer: %a\n", systemManufacturer->SystemManufacturer)); break; - + } case UefiConfigSmbiosSystemProductName: + { UEFI_CONFIG_SMBIOS_SYSTEM_PRODUCT_NAME *systemProductName = (UEFI_CONFIG_SMBIOS_SYSTEM_PRODUCT_NAME*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios System Product Name: %a\n", systemProductName->SystemProductName)); break; - + } case UefiConfigSmbiosSystemVersion: + { UEFI_CONFIG_SMBIOS_SYSTEM_VERSION *systemVersion = (UEFI_CONFIG_SMBIOS_SYSTEM_VERSION*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios System Version: %a\n", systemVersion->SystemVersion)); break; - + } case UefiConfigSmbiosSystemSerialNumber: + { UEFI_CONFIG_SMBIOS_SYSTEM_SERIAL_NUMBER *systemSerialNumber = (UEFI_CONFIG_SMBIOS_SYSTEM_SERIAL_NUMBER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios System Serial Number: %a\n", systemSerialNumber->SystemSerialNumber)); break; - + } case UefiConfigSmbiosSystemSKUNumber: + { UEFI_CONFIG_SMBIOS_SYSTEM_SKU_NUMBER *systemSKUNumber = (UEFI_CONFIG_SMBIOS_SYSTEM_SKU_NUMBER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios System SKU Number: %a\n", systemSKUNumber->SystemSKUNumber)); break; - + } case UefiConfigSmbiosSystemFamily: + { UEFI_CONFIG_SMBIOS_SYSTEM_FAMILY *systemFamily = (UEFI_CONFIG_SMBIOS_SYSTEM_FAMILY*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios System Family: %a\n", systemFamily->SystemFamily)); break; - + } case UefiConfigSmbiosBaseSerialNumber: + { UEFI_CONFIG_SMBIOS_BASE_SERIAL_NUMBER *baseSerialNumber = (UEFI_CONFIG_SMBIOS_BASE_SERIAL_NUMBER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Base Serial Number: %a\n", baseSerialNumber->BaseSerialNumber)); break; - + } case UefiConfigSmbiosChassisSerialNumber: + { UEFI_CONFIG_SMBIOS_CHASSIS_SERIAL_NUMBER *chassisSerialNumber = (UEFI_CONFIG_SMBIOS_CHASSIS_SERIAL_NUMBER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Chassis Serial Number: %a\n", chassisSerialNumber->ChassisSerialNumber)); break; - + } case UefiConfigSmbiosChassisAssetTag: + { UEFI_CONFIG_SMBIOS_CHASSIS_ASSET_TAG *chassisAssetTag = (UEFI_CONFIG_SMBIOS_CHASSIS_ASSET_TAG*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Chassis Asset Tag: %a\n", chassisAssetTag->ChassisAssetTag)); break; - + } case UefiConfigSmbiosBiosLockString: + { UEFI_CONFIG_SMBIOS_BIOS_LOCK_STRING *biosLockString = (UEFI_CONFIG_SMBIOS_BIOS_LOCK_STRING*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Bios Lock String: %a\n", biosLockString->BiosLockString)); break; - + } case UefiConfigSmbiosMemoryDeviceSerialNumber: + { UEFI_CONFIG_SMBIOS_MEMORY_DEVICE_SERIAL_NUMBER *memoryDeviceSerialNumber = (UEFI_CONFIG_SMBIOS_MEMORY_DEVICE_SERIAL_NUMBER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Memory Device Serial Number: %a\n", memoryDeviceSerialNumber->MemoryDeviceSerialNumber)); break; - + } case UefiConfigSmbios31ProcessorInformation: + { UEFI_CONFIG_SMBIOS_3_1_PROCESSOR_INFORMATION *procInfo = (UEFI_CONFIG_SMBIOS_3_1_PROCESSOR_INFORMATION*) Header; DEBUG((DEBUG_VERBOSE, "\tProcessorType: %u\n", procInfo->ProcessorType)); DEBUG((DEBUG_VERBOSE, "\tProcessorID: 0x%x\n", procInfo->ProcessorID)); @@ -672,38 +690,45 @@ DebugDumpUefiConfigStruct( DEBUG((DEBUG_VERBOSE, "\tProcessorCharacteristics: 0x%x\n", procInfo->ProcessorCharacteristics)); DEBUG((DEBUG_VERBOSE, "\tProcessorFamily2: %u\n", procInfo->ProcessorFamily2)); break; - + } case UefiConfigSmbiosSocketDesignation: + { UEFI_CONFIG_SMBIOS_SOCKET_DESIGNATION *socketDesignation = (UEFI_CONFIG_SMBIOS_SOCKET_DESIGNATION*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Socket Designation: %a\n", socketDesignation->SocketDesignation)); break; - + } case UefiConfigSmbiosProcessorManufacturer: + { UEFI_CONFIG_SMBIOS_PROCESSOR_MANUFACTURER *processorManufacturer = (UEFI_CONFIG_SMBIOS_PROCESSOR_MANUFACTURER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Processor Manufacturer: %a\n", processorManufacturer->ProcessorManufacturer)); break; - + } case UefiConfigSmbiosProcessorVersion: + { UEFI_CONFIG_SMBIOS_PROCESSOR_VERSION *processorVersion = (UEFI_CONFIG_SMBIOS_PROCESSOR_VERSION*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Processor Version: %a\n", processorVersion->ProcessorVersion)); break; - + } case UefiConfigSmbiosProcessorSerialNumber: + { UEFI_CONFIG_SMBIOS_PROCESSOR_SERIAL_NUMBER *processorSerialNumber = (UEFI_CONFIG_SMBIOS_PROCESSOR_SERIAL_NUMBER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Processor Serial Number: %a\n", processorSerialNumber->ProcessorSerialNumber)); break; - + } case UefiConfigSmbiosProcessorAssetTag: + { UEFI_CONFIG_SMBIOS_PROCESSOR_ASSET_TAG *processorAssetTag = (UEFI_CONFIG_SMBIOS_PROCESSOR_ASSET_TAG*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Processor Asset Tag: %a\n", processorAssetTag->ProcessorAssetTag)); break; - + } case UefiConfigSmbiosProcessorPartNumber: + { UEFI_CONFIG_SMBIOS_PROCESSOR_PART_NUMBER *processorPartNumber = (UEFI_CONFIG_SMBIOS_PROCESSOR_PART_NUMBER*) Header; DEBUG((DEBUG_VERBOSE, "\tSmbios Processor Part Number: %a\n", processorPartNumber->ProcessorPartNumber)); break; - + } case UefiConfigFlags: + { UEFI_CONFIG_FLAGS *flags = (UEFI_CONFIG_FLAGS*) Header; DEBUG((DEBUG_VERBOSE, "\tSerialControllersEnabled: %u\n", flags->Flags.SerialControllersEnabled)); DEBUG((DEBUG_VERBOSE, "\tPauseAfterBootFailure: %u\n", flags->Flags.PauseAfterBootFailure)); @@ -732,22 +757,25 @@ DebugDumpUefiConfigStruct( DEBUG((DEBUG_VERBOSE, "\tTpmLocalityRegsEnabled: %u\n", flags->Flags.TpmLocalityRegsEnabled)); DEBUG((DEBUG_VERBOSE, "\tMtrrsInitializedAtLoad: %u\n", flags->Flags.MtrrsInitializedAtLoad)); break; - + } case UefiConfigProcessorInformation: + { UEFI_CONFIG_PROCESSOR_INFORMATION *processorInfo = (UEFI_CONFIG_PROCESSOR_INFORMATION*) Header; DEBUG((DEBUG_VERBOSE, "\tProcessor Count: %u\n\tProcessorsPerVirtualSocket: %u\n", processorInfo->ProcessorCount, processorInfo->ProcessorsPerVirtualSocket)); break; - + } case UefiConfigMmioRanges: + { UEFI_CONFIG_MMIO_RANGES *mmioRanges = (UEFI_CONFIG_MMIO_RANGES*) Header; DEBUG((DEBUG_VERBOSE, "\tMmio Ranges:\n")); DEBUG((DEBUG_VERBOSE, "\tStart:0x%17lx Size:0x%x\n", mmioRanges->Ranges[0].MmioPageNumberStart, mmioRanges->Ranges[0].MmioSizeInPages)); DEBUG((DEBUG_VERBOSE, "\tStart:0x%17lx Size:0x%x\n", mmioRanges->Ranges[1].MmioPageNumberStart, mmioRanges->Ranges[1].MmioSizeInPages)); break; - + } case UefiConfigAcpiTable: + { UEFI_CONFIG_ACPI_TABLE *acpi = (UEFI_CONFIG_ACPI_TABLE*) Header; UINT64 acpiTableSize = acpi->Header.Length - sizeof(UEFI_CONFIG_HEADER); EFI_ACPI_DESCRIPTION_HEADER* acpiHeader = (EFI_ACPI_DESCRIPTION_HEADER*) acpi->AcpiTableData; @@ -755,17 +783,19 @@ DebugDumpUefiConfigStruct( DEBUG((DEBUG_VERBOSE, "\tAcpi Header Size:0x%x\n", acpiHeader->Length)); DEBUG((DEBUG_VERBOSE, "\tAcpi Header Signature:0x%x\n", acpiHeader->Signature)); break; - + } case UefiConfigNvdimmCount: + { UEFI_CONFIG_NVDIMM_COUNT *cfg = (UEFI_CONFIG_NVDIMM_COUNT*) Header; DEBUG((DEBUG_VERBOSE, "\tNVDIMM Count:0x%lx\n", cfg->Count)); break; - + } case UefiConfigVpciInstanceFilter: + { UEFI_CONFIG_VPCI_INSTANCE_FILTER *filter = (UEFI_CONFIG_VPCI_INSTANCE_FILTER*) Header; DEBUG((DEBUG_VERBOSE, "\tVpci instance filter:%g\n", (EFI_GUID*) filter->InstanceGuid)); break; - + } case UefiConfigMcfg: DEBUG((DEBUG_VERBOSE, "\tMCFG table found.\n")); break; @@ -1216,12 +1246,14 @@ Return Value: switch(header->Type) { case UefiConfigBiosInformation: + { UEFI_CONFIG_BIOS_INFORMATION *biosInfo = (UEFI_CONFIG_BIOS_INFORMATION*) header; PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdLegacyMemoryMap, (UINT8)biosInfo->Flags.LegacyMemoryMap)); requiredStructures.UefiConfigBiosInformation = 1; break; - + } case UefiConfigMadt: + { UEFI_CONFIG_MADT * madtStructure = (UEFI_CONFIG_MADT*)header; EFI_ACPI_DESCRIPTION_HEADER *madtHdr = (EFI_ACPI_DESCRIPTION_HEADER*)madtStructure->Madt; @@ -1239,8 +1271,9 @@ Return Value: requiredStructures.UefiConfigMadt = 1; #endif break; - + } case UefiConfigSrat: + { UEFI_CONFIG_SRAT *sratStructure = (UEFI_CONFIG_SRAT*) header; EFI_ACPI_DESCRIPTION_HEADER *sratHdr = (EFI_ACPI_DESCRIPTION_HEADER*) sratStructure->Srat; @@ -1261,8 +1294,9 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSratSize, sratHdr->Length)); requiredStructures.UefiConfigSrat = 1; break; - + } case UefiConfigSlit: + { UEFI_CONFIG_SLIT *slitStructure = (UEFI_CONFIG_SLIT*) header; EFI_ACPI_DESCRIPTION_HEADER *slitHdr = (EFI_ACPI_DESCRIPTION_HEADER*) slitStructure->Slit; @@ -1277,8 +1311,9 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSlitPtr, (UINT64)slitStructure->Slit)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSlitSize, slitHdr->Length)); break; - + } case UefiConfigPptt: + { UEFI_CONFIG_PPTT *ppttStructure = (UEFI_CONFIG_PPTT*) header; EFI_ACPI_DESCRIPTION_HEADER *ppttHdr = (EFI_ACPI_DESCRIPTION_HEADER*) ppttStructure->Pptt; @@ -1293,8 +1328,9 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdPpttPtr, (UINT64)ppttStructure->Pptt)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdPpttSize, ppttHdr->Length)); break; - + } case UefiConfigHmat: + { UEFI_CONFIG_HMAT *hmatStructure = (UEFI_CONFIG_HMAT*) header; EFI_ACPI_DESCRIPTION_HEADER *hmatHdr = (EFI_ACPI_DESCRIPTION_HEADER*) hmatStructure->Hmat; @@ -1309,115 +1345,119 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdHmatPtr, (UINT64)hmatStructure->Hmat)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdHmatSize, hmatHdr->Length)); break; - + } case UefiConfigMemoryMap: + { UEFI_CONFIG_MEMORY_MAP *memoryMapStructure = (UEFI_CONFIG_MEMORY_MAP*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdMemoryMapPtr, (UINT64) memoryMapStructure->MemoryMap)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdMemoryMapSize, header->Length - sizeof(UEFI_CONFIG_HEADER))); requiredStructures.UefiConfigMemoryMap = 1; break; - + } case UefiConfigEntropy: + { UEFI_CONFIG_ENTROPY *entropy = (UEFI_CONFIG_ENTROPY*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdEntropyPtr, (UINT64) entropy->Entropy)); requiredStructures.UefiConfigEntropy = 1; break; - + } case UefiConfigBiosGuid: + { UEFI_CONFIG_BIOS_GUID *biosGuid = (UEFI_CONFIG_BIOS_GUID*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdBiosGuidPtr, (UINT64) biosGuid->BiosGuid)); requiredStructures.UefiConfigBiosGuid = 1; break; - + } case UefiConfigSmbiosSystemManufacturer: + { UEFI_CONFIG_SMBIOS_SYSTEM_MANUFACTURER *systemManufacturer = (UEFI_CONFIG_SMBIOS_SYSTEM_MANUFACTURER*) header; GetSmbiosStructureStringLength(header->Length, systemManufacturer->SystemManufacturer, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosSystemManufacturerStr, (UINT64)systemManufacturer->SystemManufacturer)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosSystemManufacturerSize, stringLength)); - break; - + } case UefiConfigSmbiosSystemProductName: + { UEFI_CONFIG_SMBIOS_SYSTEM_PRODUCT_NAME *systemProductName = (UEFI_CONFIG_SMBIOS_SYSTEM_PRODUCT_NAME*) header; GetSmbiosStructureStringLength(header->Length, systemProductName->SystemProductName, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosSystemProductNameStr, (UINT64)systemProductName->SystemProductName)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosSystemProductNameSize, stringLength)); - break; - + } case UefiConfigSmbiosSystemVersion: + { UEFI_CONFIG_SMBIOS_SYSTEM_VERSION *systemVersion = (UEFI_CONFIG_SMBIOS_SYSTEM_VERSION*) header; GetSmbiosStructureStringLength(header->Length, systemVersion->SystemVersion, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosSystemVersionStr, (UINT64)systemVersion->SystemVersion)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosSystemVersionSize, stringLength)); - break; - + } case UefiConfigSmbiosSystemSerialNumber: + { UEFI_CONFIG_SMBIOS_SYSTEM_SERIAL_NUMBER *systemSerialNumber = (UEFI_CONFIG_SMBIOS_SYSTEM_SERIAL_NUMBER*) header; GetSmbiosStructureStringLength(header->Length, systemSerialNumber->SystemSerialNumber, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosSystemSerialNumberStr, (UINT64)systemSerialNumber->SystemSerialNumber)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosSystemSerialNumberSize, stringLength)); - break; - + } case UefiConfigSmbiosSystemSKUNumber: + { UEFI_CONFIG_SMBIOS_SYSTEM_SKU_NUMBER *systemSKUNumber = (UEFI_CONFIG_SMBIOS_SYSTEM_SKU_NUMBER*) header; GetSmbiosStructureStringLength(header->Length, systemSKUNumber->SystemSKUNumber, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosSystemSKUNumberStr, (UINT64)systemSKUNumber->SystemSKUNumber)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosSystemSKUNumberSize, stringLength)); - break; - + } case UefiConfigSmbiosSystemFamily: + { UEFI_CONFIG_SMBIOS_SYSTEM_FAMILY *systemFamily = (UEFI_CONFIG_SMBIOS_SYSTEM_FAMILY*) header; GetSmbiosStructureStringLength(header->Length, systemFamily->SystemFamily, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosSystemFamilyStr, (UINT64)systemFamily->SystemFamily)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosSystemFamilySize, stringLength)); - break; - + } case UefiConfigSmbiosBaseSerialNumber: + { UEFI_CONFIG_SMBIOS_BASE_SERIAL_NUMBER *baseSerialNumber = (UEFI_CONFIG_SMBIOS_BASE_SERIAL_NUMBER*) header; GetSmbiosStructureStringLength(header->Length, baseSerialNumber->BaseSerialNumber, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosBaseSerialNumberStr, (UINT64)baseSerialNumber->BaseSerialNumber)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosBaseSerialNumberSize, stringLength)); - break; - + } case UefiConfigSmbiosChassisSerialNumber: + { UEFI_CONFIG_SMBIOS_CHASSIS_SERIAL_NUMBER *chassisSerialNumber = (UEFI_CONFIG_SMBIOS_CHASSIS_SERIAL_NUMBER*) header; GetSmbiosStructureStringLength(header->Length, chassisSerialNumber->ChassisSerialNumber, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosChassisSerialNumberStr, (UINT64)chassisSerialNumber->ChassisSerialNumber)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosChassisSerialNumberSize, stringLength)); - break; - + } case UefiConfigSmbiosChassisAssetTag: + { UEFI_CONFIG_SMBIOS_CHASSIS_ASSET_TAG *chassisAssetTag = (UEFI_CONFIG_SMBIOS_CHASSIS_ASSET_TAG*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosChassisAssetTagStr, (UINT64) chassisAssetTag->ChassisAssetTag)); GetSmbiosStructureStringLength(header->Length, chassisAssetTag->ChassisAssetTag, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosChassisAssetTagSize, stringLength)); - break; - + } case UefiConfigSmbiosBiosLockString: + { UEFI_CONFIG_SMBIOS_BIOS_LOCK_STRING *biosLockString = (UEFI_CONFIG_SMBIOS_BIOS_LOCK_STRING*) header; GetSmbiosStructureStringLength(header->Length, biosLockString->BiosLockString, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosBiosLockStringStr, (UINT64)biosLockString->BiosLockString)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosBiosLockStringSize, stringLength)); - break; - + } case UefiConfigSmbiosMemoryDeviceSerialNumber: + { UEFI_CONFIG_SMBIOS_MEMORY_DEVICE_SERIAL_NUMBER *memoryDeviceSerialNumber = (UEFI_CONFIG_SMBIOS_MEMORY_DEVICE_SERIAL_NUMBER*) header; GetSmbiosStructureStringLength(header->Length, memoryDeviceSerialNumber->MemoryDeviceSerialNumber, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosMemoryDeviceSerialNumberStr, (UINT64)memoryDeviceSerialNumber->MemoryDeviceSerialNumber)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosMemoryDeviceSerialNumberSize, stringLength)); - break; - + } case UefiConfigSmbios31ProcessorInformation: + { UEFI_CONFIG_SMBIOS_3_1_PROCESSOR_INFORMATION *procInfo = (UEFI_CONFIG_SMBIOS_3_1_PROCESSOR_INFORMATION*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet8S(PcdSmbiosProcessorType, procInfo->ProcessorType)); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosProcessorID, procInfo->ProcessorID)); @@ -1430,68 +1470,71 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet16S(PcdSmbiosProcessorCharacteristics, procInfo->ProcessorCharacteristics)); PEI_FAIL_FAST_IF_FAILED(PcdSet16S(PcdSmbiosProcessorFamily2, procInfo->ProcessorFamily2)); break; - + } case UefiConfigSmbiosSocketDesignation: + { UEFI_CONFIG_SMBIOS_SOCKET_DESIGNATION *socketDesignation = (UEFI_CONFIG_SMBIOS_SOCKET_DESIGNATION*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosProcessorSocketDesignationStr, (UINT64) socketDesignation->SocketDesignation)); GetSmbiosStructureStringLength(header->Length, socketDesignation->SocketDesignation, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosProcessorSocketDesignationSize, stringLength)); - break; - + } case UefiConfigSmbiosProcessorManufacturer: + { UEFI_CONFIG_SMBIOS_PROCESSOR_MANUFACTURER *processorManufacturer = (UEFI_CONFIG_SMBIOS_PROCESSOR_MANUFACTURER*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosProcessorManufacturerStr, (UINT64) processorManufacturer->ProcessorManufacturer)); GetSmbiosStructureStringLength(header->Length, processorManufacturer->ProcessorManufacturer, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosProcessorManufacturerSize, stringLength)); - break; - + } case UefiConfigSmbiosProcessorVersion: + { UEFI_CONFIG_SMBIOS_PROCESSOR_VERSION *processorVersion = (UEFI_CONFIG_SMBIOS_PROCESSOR_VERSION*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosProcessorVersionStr, (UINT64) processorVersion->ProcessorVersion)); GetSmbiosStructureStringLength(header->Length, processorVersion->ProcessorVersion, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosProcessorVersionSize, stringLength)); - break; - + } case UefiConfigSmbiosProcessorSerialNumber: + { UEFI_CONFIG_SMBIOS_PROCESSOR_SERIAL_NUMBER *processorSerialNumber = (UEFI_CONFIG_SMBIOS_PROCESSOR_SERIAL_NUMBER*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosProcessorSerialNumberStr, (UINT64) processorSerialNumber->ProcessorSerialNumber)); GetSmbiosStructureStringLength(header->Length, processorSerialNumber->ProcessorSerialNumber, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosProcessorSerialNumberSize, stringLength)); - break; - + } case UefiConfigSmbiosProcessorAssetTag: + { UEFI_CONFIG_SMBIOS_PROCESSOR_ASSET_TAG *processorAssetTag = (UEFI_CONFIG_SMBIOS_PROCESSOR_ASSET_TAG*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosProcessorAssetTagStr, (UINT64) processorAssetTag->ProcessorAssetTag)); GetSmbiosStructureStringLength(header->Length, processorAssetTag->ProcessorAssetTag, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosProcessorAssetTagSize, stringLength)); - break; - + } case UefiConfigSmbiosProcessorPartNumber: + { UEFI_CONFIG_SMBIOS_PROCESSOR_PART_NUMBER *processorPartNumber = (UEFI_CONFIG_SMBIOS_PROCESSOR_PART_NUMBER*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSmbiosProcessorAssetTagStr, (UINT64) processorPartNumber->ProcessorPartNumber)); GetSmbiosStructureStringLength(header->Length, processorPartNumber->ProcessorPartNumber, &stringLength); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSmbiosProcessorAssetTagSize, stringLength)); - break; - + } case UefiConfigFlags: + { UEFI_CONFIG_FLAGS *flags = (UEFI_CONFIG_FLAGS*) header; ConfigSetUefiConfigFlags(flags); requiredStructures.UefiConfigFlags = 1; break; - + } case UefiConfigProcessorInformation: + { UEFI_CONFIG_PROCESSOR_INFORMATION *processorInfo = (UEFI_CONFIG_PROCESSOR_INFORMATION*) header; ConfigSetProcessorInfo(processorInfo); requiredStructures.UefiConfigProcessorInformation = 1; break; - + } case UefiConfigMmioRanges: + { UINT64 lowGap, highGap; UEFI_CONFIG_MMIO_RANGES *mmioRanges = (UEFI_CONFIG_MMIO_RANGES*) header; @@ -1524,8 +1567,9 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdHighMmioGapSizeInPages, mmioRanges->Ranges[highGap].MmioSizeInPages)); requiredStructures.UefiConfigMmioRanges = 1; break; - + } case UefiConfigAcpiTable: + { UEFI_CONFIG_ACPI_TABLE *acpiTable = (UEFI_CONFIG_ACPI_TABLE*) header; EFI_ACPI_DESCRIPTION_HEADER *acpiHeader = (EFI_ACPI_DESCRIPTION_HEADER*) acpiTable->AcpiTableData; @@ -1542,20 +1586,23 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdAcpiTablePtr, (UINT64) acpiTable->AcpiTableData)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdAcpiTableSize, acpiHeader->Length)); break; - + } case UefiConfigNvdimmCount: + { UEFI_CONFIG_NVDIMM_COUNT *cfg = (UEFI_CONFIG_NVDIMM_COUNT*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet16S(PcdNvdimmCount, cfg->Count)); break; - + } case UefiConfigVpciInstanceFilter: + { UEFI_CONFIG_VPCI_INSTANCE_FILTER *filter = (UEFI_CONFIG_VPCI_INSTANCE_FILTER*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdVpciInstanceFilterGuidPtr, (UINT64) filter->InstanceGuid)); PEI_FAIL_FAST_IF_FAILED(PcdSetBoolS(PcdNvmeNamespaceFilter, TRUE)); break; - + } #if defined(MDE_CPU_X64) case UefiConfigAspt: + { UEFI_CONFIG_AMD_ASPT *asptStructure = (UEFI_CONFIG_AMD_ASPT*) header; EFI_ACPI_DESCRIPTION_HEADER *asptHdr = (EFI_ACPI_DESCRIPTION_HEADER*) asptStructure->Aspt; @@ -1570,16 +1617,20 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdAsptPtr, (UINT64)asptStructure->Aspt)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdAsptSize, asptHdr->Length)); break; + } #endif #if defined(MDE_CPU_AARCH64) case UefiConfigGic: + { UEFI_CONFIG_GIC *gicConfig = (UEFI_CONFIG_GIC*) header; PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdGicDistributorBase, gicConfig->GicDistributorBase)); PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdGicRedistributorsBase, gicConfig->GicRedistributorsBase)); break; + } #endif case UefiConfigMcfg: + { UEFI_CONFIG_MCFG *mcfgStructure = (UEFI_CONFIG_MCFG*) header; EFI_ACPI_DESCRIPTION_HEADER *mcfgHdr = (EFI_ACPI_DESCRIPTION_HEADER*) mcfgStructure->Mcfg; @@ -1594,8 +1645,9 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdMcfgPtr, (UINT64)mcfgStructure->Mcfg)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdMcfgSize, mcfgHdr->Length)); break; - + } case UefiConfigSsdt: + { UEFI_CONFIG_SSDT *ssdtStructure = (UEFI_CONFIG_SSDT*) header; EFI_ACPI_DESCRIPTION_HEADER *ssdtHdr = (EFI_ACPI_DESCRIPTION_HEADER*) ssdtStructure->Ssdt; @@ -1610,8 +1662,9 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdSsdtPtr, (UINT64)ssdtStructure->Ssdt)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdSsdtSize, ssdtHdr->Length)); break; - + } case UefiConfigIort: + { UEFI_CONFIG_IORT *iortStructure = (UEFI_CONFIG_IORT*) header; EFI_ACPI_DESCRIPTION_HEADER *iortHdr = (EFI_ACPI_DESCRIPTION_HEADER*) iortStructure->Iort; @@ -1626,6 +1679,7 @@ Return Value: PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdIortPtr, (UINT64)iortStructure->Iort)); PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdIortSize, iortHdr->Length)); break; + } } calculatedConfigSize += header->Length; From ec776af02492b6cb7c1dd7eacb49c5c254892ea9 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 25 Feb 2026 09:53:21 +0000 Subject: [PATCH 19/22] Merged PR 14856370: Clang: cast to void** ``` DeviceBootManagerLib.c:493:25: error: incompatible pointer types passing 'EFI_DEVICE_PATH_PROTOCOL **' to parameter of type 'void **' [-Werror,-Wincompatible-pointer-types] DevicePath ^~~~~~~~~~ ``` etc. Related work items: #57987809 --- MsvmPkg/EventLogDxe/EventLogger.c | 2 +- MsvmPkg/Library/BootEventLogLib/BootEventLogLib.c | 6 ++---- MsvmPkg/Library/DeviceBootManagerLib/DeviceBootManagerLib.c | 6 ++---- MsvmPkg/Library/EmclLib/EmclLib.c | 3 +-- MsvmPkg/Library/EventLogLib/EventLogLib.c | 3 +-- MsvmPkg/NetvscDxe/NetvscDxe.c | 6 +++--- MsvmPkg/NetvscDxe/Snp.c | 6 +++--- MsvmPkg/VmbfsDxe/Vmbfs.c | 4 ++-- MsvmPkg/VmbfsDxe/VmbfsDxe.c | 4 ++-- MsvmPkg/VmbfsDxe/VmbfsFile.c | 2 +- MsvmPkg/VpcivscDxe/VpcivscDxe.c | 4 ++-- 11 files changed, 20 insertions(+), 26 deletions(-) diff --git a/MsvmPkg/EventLogDxe/EventLogger.c b/MsvmPkg/EventLogDxe/EventLogger.c index a452f0d..ee99132 100644 --- a/MsvmPkg/EventLogDxe/EventLogger.c +++ b/MsvmPkg/EventLogDxe/EventLogger.c @@ -637,7 +637,7 @@ Return Value: allocSize = sizeof(EVENT_CHANNEL) + Attributes->BufferSize; - status = EfiHandleTableAllocateObject(mEventChannels, allocSize, &channel, &handle); + status = EfiHandleTableAllocateObject(mEventChannels, allocSize, (void**)&channel, &handle); if (EFI_ERROR(status)) { diff --git a/MsvmPkg/Library/BootEventLogLib/BootEventLogLib.c b/MsvmPkg/Library/BootEventLogLib/BootEventLogLib.c index b322d0b..a03ff55 100644 --- a/MsvmPkg/Library/BootEventLogLib/BootEventLogLib.c +++ b/MsvmPkg/Library/BootEventLogLib/BootEventLogLib.c @@ -197,8 +197,7 @@ Return Value: goto Exit; } - status = EventLogPendingGet(mBootEvent, &eventDesc, &bootEvent); - + status = EventLogPendingGet(mBootEvent, &eventDesc, (void**)&bootEvent); if (EFI_ERROR(status)) { goto Exit; @@ -262,8 +261,7 @@ Return Value: goto Exit; } - status = EventLogPendingGet(mBootEvent, &eventDesc, &bootEvent); - + status = EventLogPendingGet(mBootEvent, &eventDesc, (void**)&bootEvent); if (EFI_ERROR(status)) { goto Exit; diff --git a/MsvmPkg/Library/DeviceBootManagerLib/DeviceBootManagerLib.c b/MsvmPkg/Library/DeviceBootManagerLib/DeviceBootManagerLib.c index 0ff7d27..fe08561 100644 --- a/MsvmPkg/Library/DeviceBootManagerLib/DeviceBootManagerLib.c +++ b/MsvmPkg/Library/DeviceBootManagerLib/DeviceBootManagerLib.c @@ -476,8 +476,7 @@ DeviceBootManagerBeforeConsole ( Status = gBS->HandleProtocol ( ConsoleIn, &gEfiDevicePathProtocolGuid, - &(gPlatformConsoles[0].DevicePath) // device path for ConIn - ); + (void**)&(gPlatformConsoles[0].DevicePath)); // device path for ConIn if (EFI_ERROR (Status)) { DEBUG((DEBUG_ERROR, "Device Path on handle of Hyper-V keyboard device not found. Status = %r\n", Status)); } @@ -490,8 +489,7 @@ DeviceBootManagerBeforeConsole ( Status = gBS->HandleProtocol ( ConsoleOut, &gEfiDevicePathProtocolGuid, - DevicePath // device path for ConOut - ); + (void**)DevicePath); // device path for ConOut if (EFI_ERROR (Status)) { ConsoleOut = NULL; DEBUG((DEBUG_ERROR, "Device Path on handle of Hyper-V video device not found. Status = %r\n", Status)); diff --git a/MsvmPkg/Library/EmclLib/EmclLib.c b/MsvmPkg/Library/EmclLib/EmclLib.c index d08e690..2d4af83 100644 --- a/MsvmPkg/Library/EmclLib/EmclLib.c +++ b/MsvmPkg/Library/EmclLib/EmclLib.c @@ -82,8 +82,7 @@ Return Value: status = gBS->HandleProtocol(handle, &gEfiDriverBindingProtocolGuid, - &driverBinding); - + (void**)&driverBinding); ASSERT_EFI_ERROR(status); status = driverBinding->Start(driverBinding, diff --git a/MsvmPkg/Library/EventLogLib/EventLogLib.c b/MsvmPkg/Library/EventLogLib/EventLogLib.c index e958f2b..a88a5e0 100644 --- a/MsvmPkg/Library/EventLogLib/EventLogLib.c +++ b/MsvmPkg/Library/EventLogLib/EventLogLib.c @@ -40,8 +40,7 @@ Return Value: (gBS != NULL) && (gBS->LocateProtocol != NULL)) { - status = gBS->LocateProtocol(&gEfiEventLogProtocolGuid, NULL, &mEventLogProtocol); - + status = gBS->LocateProtocol (&gEfiEventLogProtocolGuid, NULL, (void**)&mEventLogProtocol); if (EFI_ERROR (status)) { mEventLogProtocol = NULL; diff --git a/MsvmPkg/NetvscDxe/NetvscDxe.c b/MsvmPkg/NetvscDxe/NetvscDxe.c index dcf75a9..0ca007d 100644 --- a/MsvmPkg/NetvscDxe/NetvscDxe.c +++ b/MsvmPkg/NetvscDxe/NetvscDxe.c @@ -472,7 +472,7 @@ Return Value: // The buffer is used temporarily for multiple sync transactions. // Hence, dequeueing the buffer from the FreeTxBufferQueue isn't required. // - TxQueueDequeue(&AdapterInfo->FreeTxBuffersQueue, &pRndisMessage); + TxQueueDequeue(&AdapterInfo->FreeTxBuffersQueue, (void**)&pRndisMessage); TxQueueEnqueue(&AdapterInfo->FreeTxBuffersQueue, pRndisMessage); rndisBufferIndex = (UINT32)((((UINT64) pRndisMessage) - ((UINT64) AdapterInfo->TxBuffer))/AdapterInfo->TxSectionSize); } @@ -786,7 +786,7 @@ Routine Description: // The buffer is used temporarily for a sync transaction. // Hence, dequeueing the buffer from the FreeTxBufferQueue isn't required. // - TxQueueDequeue(&AdapterInfo->FreeTxBuffersQueue, &pRndisMessage); + TxQueueDequeue(&AdapterInfo->FreeTxBuffersQueue, (void**)&pRndisMessage); TxQueueEnqueue(&AdapterInfo->FreeTxBuffersQueue, pRndisMessage); rndisBufferIndex = (UINT32)((((UINT64) pRndisMessage) - ((UINT64) AdapterInfo->TxBuffer))/AdapterInfo->TxSectionSize); } @@ -964,7 +964,7 @@ Routine Description: goto Cleanup; } - TxQueueDequeue(&AdapterInfo->FreeTxBuffersQueue, ¤tTxBuffer); + TxQueueDequeue(&AdapterInfo->FreeTxBuffersQueue, (void**)¤tTxBuffer); txPacketContext = AllocatePool(sizeof(TX_PACKET_CONTEXT)); diff --git a/MsvmPkg/NetvscDxe/Snp.c b/MsvmPkg/NetvscDxe/Snp.c index 9c59dc1..c8d81bd 100644 --- a/MsvmPkg/NetvscDxe/Snp.c +++ b/MsvmPkg/NetvscDxe/Snp.c @@ -121,7 +121,7 @@ Routine Description: status = gBS->AllocatePool( EfiBootServicesData, totalPathLen, - &devicePtr); + (void**)&devicePtr); if (status != EFI_SUCCESS) { @@ -312,7 +312,7 @@ Return Value: gBS->OpenProtocol( DeviceHandle, &gEfiSimpleNetworkProtocolGuid, - &SnpProtocol, + (void**)&SnpProtocol, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL); @@ -530,7 +530,7 @@ Return Value: status = gBS->AllocatePool( EfiBootServicesData, sizeof (NETVSC_ADAPTER_CONTEXT), - &adapterContext); + (void**)&adapterContext); if (EFI_ERROR(status)) { diff --git a/MsvmPkg/VmbfsDxe/Vmbfs.c b/MsvmPkg/VmbfsDxe/Vmbfs.c index a6dfec2..756bcc6 100644 --- a/MsvmPkg/VmbfsDxe/Vmbfs.c +++ b/MsvmPkg/VmbfsDxe/Vmbfs.c @@ -148,14 +148,14 @@ Return Value: status = gBS->AllocatePool(EfiBootServicesData, VMBFS_MAXIMUM_MESSAGE_SIZE, - &fileSystemInformation->PacketBuffer); + (void**)&fileSystemInformation->PacketBuffer); if (EFI_ERROR(status)) { goto Cleanup; } - status = gBS->AllocatePool(EfiBootServicesData, sizeof(*allocatedFileProtocol), &allocatedFileProtocol); + status = gBS->AllocatePool(EfiBootServicesData, sizeof(*allocatedFileProtocol), (void**)&allocatedFileProtocol); if (EFI_ERROR(status)) { diff --git a/MsvmPkg/VmbfsDxe/VmbfsDxe.c b/MsvmPkg/VmbfsDxe/VmbfsDxe.c index 50af40c..f30a68b 100644 --- a/MsvmPkg/VmbfsDxe/VmbfsDxe.c +++ b/MsvmPkg/VmbfsDxe/VmbfsDxe.c @@ -186,7 +186,7 @@ Return Value: status = gBS->AllocatePool(EfiBootServicesData, sizeof(*simpleFileSystemProtocol), - &simpleFileSystemProtocol); + (void**)&simpleFileSystemProtocol); if (EFI_ERROR(status)) { @@ -199,7 +199,7 @@ Return Value: status = gBS->OpenProtocol( ControllerHandle, &gEfiDevicePathProtocolGuid, - &devicePath, + (void**)&devicePath, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); diff --git a/MsvmPkg/VmbfsDxe/VmbfsFile.c b/MsvmPkg/VmbfsDxe/VmbfsFile.c index d71a921..f7d194e 100644 --- a/MsvmPkg/VmbfsDxe/VmbfsFile.c +++ b/MsvmPkg/VmbfsDxe/VmbfsFile.c @@ -303,7 +303,7 @@ Return Value: status = gBS->AllocatePool(EfiBootServicesData, sizeof(*allocatedFileProtocol) + filePathLengthInBytes, - &allocatedFileProtocol); + (void**)&allocatedFileProtocol); if (EFI_ERROR(status)) { status = EFI_OUT_OF_RESOURCES; diff --git a/MsvmPkg/VpcivscDxe/VpcivscDxe.c b/MsvmPkg/VpcivscDxe/VpcivscDxe.c index c83ec87..c4aabd5 100644 --- a/MsvmPkg/VpcivscDxe/VpcivscDxe.c +++ b/MsvmPkg/VpcivscDxe/VpcivscDxe.c @@ -379,7 +379,7 @@ VpciChannelSendPacketSync( NULL, 0, VpciChannelSendCompletionCallback, - &completionContext); + (void**)&completionContext); if (EFI_ERROR(status)) { @@ -1116,7 +1116,7 @@ VpcivscDriverBindingSupported ( status = gBS->OpenProtocol( ControllerHandle, &gEfiVmbusProtocolGuid, - &vmbus, + (void**)&vmbus, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL); From d290ef19bdbded939a9f95db3e5e1a47858df278 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 25 Feb 2026 18:26:23 +0000 Subject: [PATCH 20/22] Merged PR 14873703: Clang: Get UINT32_MAX and UINT64_MAX from stdint.h. stdint.h is appropriate for UINT64_C. Really it is appropriate for UINT8, 16, 32, 64 (uint8_t, uint16_t, uint32_t, uint64_t), if C99 can be depended on instead of C89. (Even with C89, it is likely provided by gcc/clang.) And it provides UINT32_MAX, UINT64_MAX. Which clashes with ours. We could undef, or just use them. i.e. Extremely mild cleanup via reuse of std. While UEFI avoids std in general, I think for a very very small number of things, it is OK. (ie. stdint.h, stddef.h, limits.h, stdarg.h) Related work items: #57987809 --- MsvmPkg/EmclDxe/Emcl.c | 8 +------- MsvmPkg/EmclDxe/RingBuffer.c | 5 +---- MsvmPkg/VpcivscDxe/VpcivscDxe.c | 6 +----- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/MsvmPkg/EmclDxe/Emcl.c b/MsvmPkg/EmclDxe/Emcl.c index 240d247..426c88b 100644 --- a/MsvmPkg/EmclDxe/Emcl.c +++ b/MsvmPkg/EmclDxe/Emcl.c @@ -5,10 +5,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ - #include #include - #include #include #include @@ -16,14 +14,12 @@ #include #include #include - #include #include #include - #include - #include +#include #define EMCL_DRIVER_VERSION 0x10 @@ -33,8 +29,6 @@ #define VARIABLE_STRUCT_SIZE(_Type_,_Field_,_Size_) \ ((OFFSET_OF(_Type_,_Field_)) + sizeof(*(((_Type_ *)0)->_Field_)) * (_Size_)) -#define UINT64_MAX 0xffffffffffffffff - typedef struct _EMCL_BOUNCE_BLOCK { LIST_ENTRY BlockListEntry; diff --git a/MsvmPkg/EmclDxe/RingBuffer.c b/MsvmPkg/EmclDxe/RingBuffer.c index 5646d02..62f6b56 100644 --- a/MsvmPkg/EmclDxe/RingBuffer.c +++ b/MsvmPkg/EmclDxe/RingBuffer.c @@ -5,14 +5,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ - #include - #include "transportp.h" +#include #define MAXIMUM_EXPECTED_INTERRUPT_COUNT 64 -#define UINT32_MAX 0xffffffff - VOID PkpExpectInterrupt( diff --git a/MsvmPkg/VpcivscDxe/VpcivscDxe.c b/MsvmPkg/VpcivscDxe/VpcivscDxe.c index c4aabd5..fb50e08 100644 --- a/MsvmPkg/VpcivscDxe/VpcivscDxe.c +++ b/MsvmPkg/VpcivscDxe/VpcivscDxe.c @@ -4,9 +4,7 @@ Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent --*/ - #include "VpcivscDxe.h" - #include #include #include @@ -17,8 +15,8 @@ #include #include #include - #include +#include #define AZIHSM_VENDOR_ID 0x1414 #define AZIHSM_DEVICE_ID 0xC003 @@ -112,8 +110,6 @@ UINT64 mCanonicalizationMask; #define RING_BUFFER_INCOMING_PAGE_COUNT 16 #define RING_BUFFER_OUTGOING_PAGE_COUNT 16 -#define UINT32_MAX 0xffffffff - /// \brief Debug print a VPCI device. /// /// \param[in] Device The device to print From 21bb21c1e304b227c85a7d034c7699535a84874c Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 25 Feb 2026 19:27:12 +0000 Subject: [PATCH 21/22] Merged PR 14873872: Clang: include stddef.h for size_t. Related work items: #57987809, #60275790 --- MsvmPkg/SmbiosPlatformDxe/SmbiosPlatform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MsvmPkg/SmbiosPlatformDxe/SmbiosPlatform.c b/MsvmPkg/SmbiosPlatformDxe/SmbiosPlatform.c index 06fdd33..c9e4cfa 100644 --- a/MsvmPkg/SmbiosPlatformDxe/SmbiosPlatform.c +++ b/MsvmPkg/SmbiosPlatformDxe/SmbiosPlatform.c @@ -7,9 +7,7 @@ Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent --*/ - #include - #include #include #include @@ -20,6 +18,7 @@ #include #include #include +#include #define MAJOR_RELEASE_VERSION 4 #define MINOR_RELEASE_VERSION 1 From fedecfae6e106e0998792d7c896a36b326f131c6 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Thu, 26 Feb 2026 22:43:49 +0000 Subject: [PATCH 22/22] Merged PR 14877228: clang: Remove extra pound signs. ``` PlatformThemeLib.c:31 error: pasting formed 'mMsUiFontPackageHdr_Selawik_Regular_8pt_Fixed)', an invalid preprocessing token FONT_DECL (FixedFont, Selawik_Regular_8pt_Fixed) ^ ``` --- .../Library/PlatformThemeLib/PlatformThemeLib.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MsvmPkg/Library/PlatformThemeLib/PlatformThemeLib.c b/MsvmPkg/Library/PlatformThemeLib/PlatformThemeLib.c index b2acea8..753d90e 100644 --- a/MsvmPkg/Library/PlatformThemeLib/PlatformThemeLib.c +++ b/MsvmPkg/Library/PlatformThemeLib/PlatformThemeLib.c @@ -12,14 +12,14 @@ #define FILLED_AT_RUNTIME 0 -#define FONT_DECL(TABLE, NAME ) \ - \ - static MS_UI_FONT_DESCRIPTION TABLE = { \ - MS_UI_CUSTOM_FONT_ ## NAME ## _CELL_HEIGHT, \ - MS_UI_CUSTOM_FONT_ ## NAME ## _CELL_WIDTH, \ - MS_UI_CUSTOM_FONT_ ## NAME ## _MAX_ADVANCE, \ - sizeof (mMsUiFontPackageHdr_ ## NAME ## ), \ - sizeof (mMsUiFontPackageGlyphs_ ## NAME ## ), \ +#define FONT_DECL(TABLE, NAME ) \ + \ + static MS_UI_FONT_DESCRIPTION TABLE = { \ + MS_UI_CUSTOM_FONT_ ## NAME ## _CELL_HEIGHT, \ + MS_UI_CUSTOM_FONT_ ## NAME ## _CELL_WIDTH, \ + MS_UI_CUSTOM_FONT_ ## NAME ## _MAX_ADVANCE, \ + sizeof (mMsUiFontPackageHdr_ ## NAME), \ + sizeof (mMsUiFontPackageGlyphs_ ## NAME), \ FILLED_AT_RUNTIME, \ FILLED_AT_RUNTIME \ };