diff --git a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3Protocols.c b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3Protocols.c index 4bd19be66e..9731dedb67 100644 --- a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3Protocols.c +++ b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3Protocols.c @@ -35,9 +35,9 @@ Ring3BlockIoRead ( SysCallBlockIoRead, This, MediaId, - Lba, BufferSize, - Buffer + Buffer, + Lba ); } @@ -55,9 +55,9 @@ Ring3BlockIoWrite ( SysCallBlockIoWrite, This, MediaId, - Lba, BufferSize, - Buffer + Buffer, + Lba ); } @@ -87,9 +87,9 @@ Ring3DiskIoRead ( SysCallDiskIoRead, This, MediaId, - Offset, BufferSize, - Buffer + Buffer, + Offset ); } @@ -107,9 +107,9 @@ Ring3DiskIoWrite ( SysCallDiskIoWrite, This, MediaId, - Offset, BufferSize, - Buffer + Buffer, + Offset ); } diff --git a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c index e42fa8752b..54f0b2abd1 100644 --- a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c +++ b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c @@ -150,8 +150,8 @@ Ring3FreePages ( Status = SysCall ( SysCallFreePages, - Memory, - NumberOfPages + NumberOfPages, + Memory ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Ring3: Failed to free %d pages.\n", NumberOfPages)); @@ -594,7 +594,7 @@ Ring3LocateHandleBuffer ( Buffer ); - if ((NumberHandles != NULL) && (Buffer != NULL) && (*Buffer != NULL)) { + if ((NumberHandles != NULL) && (*NumberHandles != 0) && (Buffer != NULL) && (*Buffer != NULL)) { PoolSize = *NumberHandles * sizeof (EFI_HANDLE *); Status = CoreAllocatePool (EfiRing3MemoryType, PoolSize, &Pool); diff --git a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c index ea5940f924..f6d004c012 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c +++ b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c @@ -565,17 +565,17 @@ CallBootService ( case SysCallFreePages: // - // Argument 1: EFI_PHYSICAL_ADDRESS Memory - // Argument 2: UINTN NumberOfPages + // Argument 1: UINTN NumberOfPages + // Argument 2: EFI_PHYSICAL_ADDRESS Memory // - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)CoreRbp->Argument1, &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)CoreRbp->Argument2, &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(CoreRbp->Argument1 + CoreRbp->Argument2 * EFI_PAGE_SIZE - 1), &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(CoreRbp->Argument2 + CoreRbp->Argument1 * EFI_PAGE_SIZE - 1), &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); return gBS->FreePages ( - (EFI_PHYSICAL_ADDRESS)CoreRbp->Argument1, - CoreRbp->Argument2 + *(EFI_PHYSICAL_ADDRESS *)&CoreRbp->Argument2, + CoreRbp->Argument1 ); case SysCallRaiseTpl: @@ -811,9 +811,9 @@ CallBootService ( // // Argument 1: EFI_BLOCK_IO_PROTOCOL *This // Argument 2: UINT32 MediaId - // Argument 3: EFI_LBA Lba - // Argument 4: UINTN BufferSize - // Argument 5: VOID *Buffer + // Argument 3: UINTN BufferSize + // Argument 4: VOID *Buffer + // Argument 5: EFI_LBA Lba // BlockIo = FindInterface (FALSE, (VOID *)CoreRbp->Argument1); @@ -825,10 +825,10 @@ CallBootService ( ASSERT ((Attributes & EFI_MEMORY_USER) != 0); DisableSMAP (); - Argument4 = UserRsp->Arguments[4]; + Attributes = *(UINT64 *)&UserRsp->Arguments[5]; EnableSMAP (); - Argument5 = (UINTN)AllocatePool (Argument4); + Argument5 = (UINTN)AllocatePool (CoreRbp->Argument3); if ((VOID *)Argument5 == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -836,17 +836,17 @@ CallBootService ( Status = BlockIo->ReadBlocks ( BlockIo, (UINT32)CoreRbp->Argument2, - (EFI_LBA)CoreRbp->Argument3, - Argument4, + (EFI_LBA)Attributes, + CoreRbp->Argument3, (VOID *)Argument5 ); DisableSMAP (); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)UserRsp->Arguments[5], &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)UserRsp->Arguments[4], &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp->Arguments[5] + Argument4 - 1), &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp->Arguments[4] + CoreRbp->Argument3 - 1), &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - CopyMem ((VOID *)UserRsp->Arguments[5], (VOID *)Argument5, Argument4); + CopyMem ((VOID *)UserRsp->Arguments[4], (VOID *)Argument5, CoreRbp->Argument3); EnableSMAP (); FreePool ((VOID *)Argument5); @@ -857,9 +857,9 @@ CallBootService ( // // Argument 1: EFI_BLOCK_IO_PROTOCOL *This // Argument 2: UINT32 MediaId - // Argument 3: EFI_LBA Lba - // Argument 4: UINTN BufferSize - // Argument 5: VOID *Buffer + // Argument 3: UINTN BufferSize + // Argument 4: VOID *Buffer + // Argument 5: EFI_LBA Lba // BlockIo = FindInterface (FALSE, (VOID *)CoreRbp->Argument1); @@ -870,29 +870,27 @@ CallBootService ( gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp + 7 * sizeof (UINTN) - 1), &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - DisableSMAP (); - Argument4 = UserRsp->Arguments[4]; - EnableSMAP (); - - Argument5 = (UINTN)AllocatePool (Argument4); + Argument5 = (UINTN)AllocatePool (CoreRbp->Argument3); if ((VOID *)Argument5 == NULL) { return EFI_OUT_OF_RESOURCES; } DisableSMAP (); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)UserRsp->Arguments[5], &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)UserRsp->Arguments[4], &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp->Arguments[5] + Argument4 - 1), &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp->Arguments[4] + CoreRbp->Argument3 - 1), &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - CopyMem ((VOID *)Argument5,(VOID *)UserRsp->Arguments[5], Argument4); + CopyMem ((VOID *)Argument5,(VOID *)UserRsp->Arguments[4], CoreRbp->Argument3); + + Attributes = *(UINT64 *)&UserRsp->Arguments[5]; EnableSMAP (); Status = BlockIo->WriteBlocks ( BlockIo, (UINT32)CoreRbp->Argument2, - (EFI_LBA)CoreRbp->Argument3, - Argument4, + (EFI_LBA)Attributes, + CoreRbp->Argument3, (VOID *)Argument5 ); @@ -916,9 +914,9 @@ CallBootService ( // // Argument 1: EFI_DISK_IO_PROTOCOL *This // Argument 2: UINT32 MediaId - // Argument 3: UINT64 Offset - // Argument 4: UINTN BufferSize - // Argument 5: VOID *Buffer + // Argument 3: UINTN BufferSize + // Argument 4: VOID *Buffer + // Argument 5: UINT64 Offset // DiskIo = FindInterface (FALSE, (VOID *)CoreRbp->Argument1); @@ -930,10 +928,10 @@ CallBootService ( ASSERT ((Attributes & EFI_MEMORY_USER) != 0); DisableSMAP (); - Argument4 = UserRsp->Arguments[4]; + Attributes = *(UINT64 *)&UserRsp->Arguments[5]; EnableSMAP (); - Argument5 = (UINTN)AllocatePool (Argument4); + Argument5 = (UINTN)AllocatePool (CoreRbp->Argument3); if ((VOID *)Argument5 == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -941,17 +939,17 @@ CallBootService ( Status = DiskIo->ReadDisk ( DiskIo, (UINT32)CoreRbp->Argument2, - (UINT64)CoreRbp->Argument3, - Argument4, + Attributes, + CoreRbp->Argument3, (VOID *)Argument5 ); DisableSMAP (); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)UserRsp->Arguments[5], &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)UserRsp->Arguments[4], &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp->Arguments[5] + Argument4 - 1), &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp->Arguments[4] + CoreRbp->Argument3 - 1), &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - CopyMem ((VOID *)UserRsp->Arguments[5], (VOID *)Argument5, Argument4); + CopyMem ((VOID *)UserRsp->Arguments[4], (VOID *)Argument5, CoreRbp->Argument3); EnableSMAP (); FreePool ((VOID *)Argument5); @@ -962,9 +960,9 @@ CallBootService ( // // Argument 1: EFI_DISK_IO_PROTOCOL *This // Argument 2: UINT32 MediaId - // Argument 3: UINT64 Offset - // Argument 4: UINTN BufferSize - // Argument 5: VOID *Buffer + // Argument 3: UINTN BufferSize + // Argument 4: VOID *Buffer + // Argument 5: UINT64 Offset // DiskIo = FindInterface (FALSE, (VOID *)CoreRbp->Argument1); @@ -975,29 +973,27 @@ CallBootService ( gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp + 7 * sizeof (UINTN) - 1), &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - DisableSMAP (); - Argument4 = UserRsp->Arguments[4]; - EnableSMAP (); - - Argument5 = (UINTN)AllocatePool (Argument4); + Argument5 = (UINTN)AllocatePool (CoreRbp->Argument3); if ((VOID *)Argument5 == NULL) { return EFI_OUT_OF_RESOURCES; } DisableSMAP (); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)UserRsp->Arguments[5], &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)UserRsp->Arguments[4], &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp->Arguments[5] + Argument4 - 1), &Attributes); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp->Arguments[4] + CoreRbp->Argument3 - 1), &Attributes); ASSERT ((Attributes & EFI_MEMORY_USER) != 0); - CopyMem ((VOID *)Argument5, (VOID *)UserRsp->Arguments[5], Argument4); + CopyMem ((VOID *)Argument5, (VOID *)UserRsp->Arguments[4], CoreRbp->Argument3); + + Attributes = *(UINT64 *)&UserRsp->Arguments[5]; EnableSMAP (); Status = DiskIo->WriteDisk ( DiskIo, (UINT32)CoreRbp->Argument2, - (UINT64)CoreRbp->Argument3, - Argument4, + Attributes, + CoreRbp->Argument3, (VOID *)Argument5 );