- Fix a typo in HalpAllocPhysicalMemory, that caused the function to remove MADs that still had pages rather than removing those who are empty. Fixes an assertion on VMWare.
Kudos go to Kamil for tracking it down.
- Fix another bug in HalpAllocPhysicalMemory, where the size of the newly allocated MAD was set to the alignment value instead of the original MAD, this lead to conflicting MADs and possible reuse of hal memory by the kernel. This seems to fix a bugcheck 0x19 with halacpi.

svn path=/trunk/; revision=53861
This commit is contained in:
Timo Kreuzer 2011-09-26 15:01:11 +00:00
parent 2eb01ed674
commit a7a2617223

View file

@ -99,7 +99,7 @@ HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
if (Alignment)
{
/* Check if we had leftovers */
if ((MdBlock->PageCount - Alignment) != PageCount)
if (MdBlock->PageCount > (PageCount + Alignment))
{
/* Get the next descriptor */
FreeBlock = &HalpAllocationDescriptorArray[UsedDescriptors];
@ -113,8 +113,10 @@ HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
InsertHeadList(&MdBlock->ListEntry, &FreeBlock->ListEntry);
}
/* Use this descriptor */
NewBlock->PageCount = Alignment;
/* Trim the original block to the alignment only */
MdBlock->PageCount = Alignment;
/* Insert the descriptor after the original one */
InsertHeadList(&MdBlock->ListEntry, &NewBlock->ListEntry);
}
else
@ -123,11 +125,11 @@ HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
MdBlock->BasePage += (ULONG)PageCount;
MdBlock->PageCount -= (ULONG)PageCount;
/* Insert the descriptor */
/* Insert the descriptor before the original one */
InsertTailList(&MdBlock->ListEntry, &NewBlock->ListEntry);
/* Remove the entry if the whole block was allocated */
if (!MdBlock->PageCount == 0) RemoveEntryList(&MdBlock->ListEntry);
if (MdBlock->PageCount == 0) RemoveEntryList(&MdBlock->ListEntry);
}
/* Return the address */