From 84efd2dcf85de07e5eb12e0224ac86bbb4ae1e13 Mon Sep 17 00:00:00 2001 From: Ziliang Guo Date: Fri, 3 Feb 2012 03:51:58 +0000 Subject: [PATCH] Merge in r55173 as per Amine's request. Also apply Cameron's patch that attempts to hack around the memory manager bug. svn path=/branches/ros-branch-0_3_14/; revision=55388 --- boot/freeldr/freeldr/arch/i386/hardware.c | 13 ++++++++++--- ntoskrnl/include/internal/i386/ke.h | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/boot/freeldr/freeldr/arch/i386/hardware.c b/boot/freeldr/freeldr/arch/i386/hardware.c index 25a77b31a35..58298cf3597 100644 --- a/boot/freeldr/freeldr/arch/i386/hardware.c +++ b/boot/freeldr/freeldr/arch/i386/hardware.c @@ -250,7 +250,8 @@ DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber) TRACE("Estimated buffer size %u\n", NodeSize * NodeCount); /* Set 'Configuration Data' value */ - Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + (NodeSize * NodeCount); + Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + + sizeof(CM_PNP_BIOS_INSTALLATION_CHECK) + (NodeSize * NodeCount); PartialResourceList = MmHeapAlloc(Size); if (PartialResourceList == NULL) { @@ -268,8 +269,8 @@ DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber) PartialResourceList->PartialDescriptors[0].ShareDisposition = CmResourceShareUndetermined; - Ptr = (char *)(((ULONG_PTR)&PartialResourceList->PartialDescriptors[0]) + - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); + /* The buffer starts after PartialResourceList->PartialDescriptors[0] */ + Ptr = (char *)(PartialResourceList + 1); /* Set instalation check data */ memcpy (Ptr, InstData, sizeof(CM_PNP_BIOS_INSTALLATION_CHECK)); @@ -292,6 +293,12 @@ DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber) DeviceNode->Size, DeviceNode->Size); + if (PnpBufferSize + DeviceNode->Size > Size) + { + ERR("Buffer too small!\n"); + break; + } + memcpy (Ptr, DeviceNode, DeviceNode->Size); diff --git a/ntoskrnl/include/internal/i386/ke.h b/ntoskrnl/include/internal/i386/ke.h index bbcab28189d..107e099b1a9 100644 --- a/ntoskrnl/include/internal/i386/ke.h +++ b/ntoskrnl/include/internal/i386/ke.h @@ -243,8 +243,8 @@ FORCEINLINE VOID KeInvalidateTlbEntry(IN PVOID Address) { - /* Invalidate the TLB entry for this address */ - __invlpg(Address); + /* HACK: Flush the entire TLB */ + __writecr3(__readcr3()); } FORCEINLINE