Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MsvmPkg/MsvmPkgAARCH64.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@

[PcdsFixedAtBuild.common]
# Advanced Logger Config
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPreMemPages|1 # Size is 4KB
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPreMemPages|8 # Size is 32KB
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPages|1024 # Size is 4MB
!if $(DEBUGLIB_SERIAL) == 1
!ifdef DEBUG_NOISY
Expand Down
2 changes: 1 addition & 1 deletion MsvmPkg/MsvmPkgX64.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
# Original value: 0xFA000000
#
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerBase|0x0
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPreMemPages|1 # Size is 4KB
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPreMemPages|8 # Size is 32KB
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPages|1024 # Size is 4MB
!if $(DEBUGLIB_SERIAL) == 1
!ifdef DEBUG_NOISY
Expand Down
2 changes: 1 addition & 1 deletion MsvmPkg/PlatformPei/AArch64/Mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ ConfigureMmu(
return EFI_INVALID_PARAMETER;
}

DEBUG((DEBUG_VERBOSE, "ConfigureMmu(0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
DEBUG((DEBUG_INFO, "ConfigureMmu(0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
MaxAddress, lowMmioSize, highMmioBaseAddress, highMmioSize));

//
Expand Down
41 changes: 41 additions & 0 deletions MsvmPkg/PlatformPei/Config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,47 @@ Return Value:
PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdLowMmioGapSizeInPages, mmioRanges->Ranges[lowGap].MmioSizeInPages));
PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdHighMmioGapBasePageNumber, mmioRanges->Ranges[highGap].MmioPageNumberStart));
PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdHighMmioGapSizeInPages, mmioRanges->Ranges[highGap].MmioSizeInPages));

// Log resolved MMIO PCDs in bytes; SafeUint64Mult guards the page-to-byte conversion.
{
UINT64 lowBaseBytes;
UINT64 lowSizeBytes;
UINT64 highBaseBytes;
UINT64 highSizeBytes;

if (RETURN_ERROR(SafeUint64Mult(mmioRanges->Ranges[lowGap].MmioPageNumberStart, (UINT64)SIZE_4KB, &lowBaseBytes)) ||
RETURN_ERROR(SafeUint64Mult(mmioRanges->Ranges[lowGap].MmioSizeInPages, (UINT64)SIZE_4KB, &lowSizeBytes)))
{
DEBUG((DEBUG_WARN,
"ConfigMmio: LowGap (pages) base=0x%lx size=0x%lx (byte conversion overflow)\n",
mmioRanges->Ranges[lowGap].MmioPageNumberStart,
mmioRanges->Ranges[lowGap].MmioSizeInPages));
}
else
{
DEBUG((DEBUG_INFO,
"ConfigMmio: LowGap base=0x%lx size=0x%lx\n",
lowBaseBytes,
lowSizeBytes));
}

if (RETURN_ERROR(SafeUint64Mult(mmioRanges->Ranges[highGap].MmioPageNumberStart, (UINT64)SIZE_4KB, &highBaseBytes)) ||
RETURN_ERROR(SafeUint64Mult(mmioRanges->Ranges[highGap].MmioSizeInPages, (UINT64)SIZE_4KB, &highSizeBytes)))
{
DEBUG((DEBUG_WARN,
"ConfigMmio: HighGap (pages) base=0x%lx size=0x%lx (byte conversion overflow)\n",
mmioRanges->Ranges[highGap].MmioPageNumberStart,
mmioRanges->Ranges[highGap].MmioSizeInPages));
}
else
{
DEBUG((DEBUG_INFO,
"ConfigMmio: HighGap base=0x%lx size=0x%lx\n",
highBaseBytes,
highSizeBytes));
}
}

requiredStructures.UefiConfigMmioRanges = 1;
break;
}
Expand Down
7 changes: 3 additions & 4 deletions MsvmPkg/VmbfsDxe/Vmbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ Return Value:
goto Cleanup;
}

ZeroMem(fileSystemInformation->PacketBuffer, VMBFS_MAXIMUM_MESSAGE_SIZE);

status = gBS->AllocatePool(EfiBootServicesData, sizeof(*allocatedFileProtocol), (void**)&allocatedFileProtocol);

if (EFI_ERROR(status))
Expand Down Expand Up @@ -219,10 +221,7 @@ Return Value:
if (bytesRead != sizeof(*VersionResponseMessage) ||
VersionResponseMessage->Header.Type != VmbfsMessageTypeVersionResponse)
{

VMBFS_BAD_HOST;
status = EFI_DEVICE_ERROR;
goto Cleanup;
FAIL_FAST_UNEXPECTED_HOST_BEHAVIOR();
}

if (VersionResponseMessage->Status != VmbfsVersionSupported)
Expand Down
1 change: 1 addition & 0 deletions MsvmPkg/VmbfsDxe/VmbfsDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
[LibraryClasses]
BaseLib
BaseMemoryLib
CrashLib
DebugLib
EmclLib
MemoryAllocationLib
Expand Down
3 changes: 1 addition & 2 deletions MsvmPkg/VmbfsDxe/VmbfsEfi.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
#include <Library/UefiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/SynchronizationLib.h>
#include <Library/CrashLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/EmclLib.h>


#define VMBFS_BAD_HOST ASSERT(FALSE)

#define GetPacketBuffer(fileInformation, Type) ((Type*)((fileInformation)->FileSystem->FileSystemInformation.PacketBuffer))
#define GetPacketSize(fileInformation) (((fileInformation)->FileSystem->FileSystemInformation.PacketSize))
#define GetFileSystemInformation(fileInformation) (&((fileInformation)->FileSystem->FileSystemInformation))
Expand Down
24 changes: 6 additions & 18 deletions MsvmPkg/VmbfsDxe/VmbfsFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ Return Value:

if (BufferLength > VMBFS_MAXIMUM_MESSAGE_SIZE)
{
VMBFS_BAD_HOST;
BufferLength = MIN(BufferLength, VMBFS_MAXIMUM_MESSAGE_SIZE);
FAIL_FAST_UNEXPECTED_HOST_BEHAVIOR();
}

CopyMem(fileSystemInformation->PacketBuffer, Buffer, BufferLength);
Expand Down Expand Up @@ -381,10 +380,7 @@ Return Value:
if (bytesRead != sizeof(*getFileInfoResponseMessage) ||
getFileInfoResponseMessage->Header.Type != VmbfsMessageTypeGetFileInfoResponse)
{

VMBFS_BAD_HOST;
status = EFI_DEVICE_ERROR;
goto Cleanup;
FAIL_FAST_UNEXPECTED_HOST_BEHAVIOR();
}

if (getFileInfoResponseMessage->Status == VmbfsFileNotFound)
Expand Down Expand Up @@ -591,9 +587,7 @@ Return Value:
if (bytesReceived < sizeof(*readFileResponseMessage) ||
readFileResponseMessage->Header.Type != VmbfsMessageTypeReadFileResponse)
{
VMBFS_BAD_HOST;
status = EFI_DEVICE_ERROR;
goto Cleanup;
FAIL_FAST_UNEXPECTED_HOST_BEHAVIOR();
}

status = VmbfsErrorToEfiError(readFileResponseMessage->Status);
Expand All @@ -605,9 +599,7 @@ Return Value:
bytesReceived -= sizeof(VMBFS_MESSAGE_READ_FILE_RESPONSE);
if (bytesReceived > bytesRequested)
{
VMBFS_BAD_HOST;
status = EFI_DEVICE_ERROR;
goto Cleanup;
FAIL_FAST_UNEXPECTED_HOST_BEHAVIOR();
}

CopyMem((UINT8*)Buffer,
Expand Down Expand Up @@ -702,9 +694,7 @@ Return Value:
if (bytesReceived < sizeof(*readFileResponseMessage) ||
readFileResponseMessage->Header.Type != VmbfsMessageTypeReadFileRdmaResponse)
{
VMBFS_BAD_HOST;
status = EFI_DEVICE_ERROR;
goto Cleanup;
FAIL_FAST_UNEXPECTED_HOST_BEHAVIOR();
}

status = VmbfsErrorToEfiError(readFileResponseMessage->Status);
Expand All @@ -715,9 +705,7 @@ Return Value:

if (readFileResponseMessage->ByteCount > bytesRequested)
{
VMBFS_BAD_HOST;
status = EFI_DEVICE_ERROR;
goto Cleanup;
FAIL_FAST_UNEXPECTED_HOST_BEHAVIOR();
}

*BytesRead = readFileResponseMessage->ByteCount;
Expand Down
Loading