From 9ff9bd81c4259db3e027999dd5c05341ffaa9b4e Mon Sep 17 00:00:00 2001 From: Serge Gautherie Date: Sat, 3 Feb 2018 00:19:18 +0100 Subject: [PATCH] [NTOSKRNL] Round memory size up, "debug log" part Assumed to better match actual physical RAM size. CORE-12321 --- ntoskrnl/ex/init.c | 5 +++-- ntoskrnl/kd/kdio.c | 9 ++++++--- ntoskrnl/kd64/kdinit.c | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c index 826cc3b3565..1e9a9c07f89 100644 --- a/ntoskrnl/ex/init.c +++ b/ntoskrnl/ex/init.c @@ -1580,8 +1580,9 @@ Phase1InitializationDiscard(IN PVOID Context) WINDOWS_NT_INFO_STRING, &MsgEntry); - /* Get total RAM size */ - Size = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; + /* Get total RAM size, in MiB */ + /* Round size up. Assumed to better match actual physical RAM size */ + Size = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024); /* Create the string */ StringBuffer = InitBuffer->VersionBuffer; diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index 53c99c43d47..38a1d3fc9a2 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -93,7 +93,8 @@ KdpGetMemorySizeInMBs(IN PLOADER_PARAMETER_BLOCK LoaderBlock) } } - return NumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; + /* Round size up. Assumed to better match actual physical RAM size */ + return ALIGN_UP_BY(NumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024); } /* See also: kd64\kdinit.c */ @@ -255,7 +256,8 @@ KdpInitDebugLog(PKD_DISPATCH_TABLE DispatchTable, KeInitializeSpinLock(&KdpDebugLogSpinLock); /* Display separator + ReactOS version at start of the debug log */ - MemSizeMBs = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; + /* Round size up. Assumed to better match actual physical RAM size */ + MemSizeMBs = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024); KdpPrintBanner(MemSizeMBs); } else if (BootPhase == 2) @@ -554,7 +556,8 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, KeInitializeSpinLock(&KdpDmesgLogSpinLock); /* Display separator + ReactOS version at start of the debug log */ - MemSizeMBs = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; + /* Round size up. Assumed to better match actual physical RAM size */ + MemSizeMBs = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024); KdpPrintBanner(MemSizeMBs); } else if (BootPhase == 2) diff --git a/ntoskrnl/kd64/kdinit.c b/ntoskrnl/kd64/kdinit.c index 64a7c7b5194..b6a8beb9ce9 100644 --- a/ntoskrnl/kd64/kdinit.c +++ b/ntoskrnl/kd64/kdinit.c @@ -62,7 +62,8 @@ KdpGetMemorySizeInMBs(IN PLOADER_PARAMETER_BLOCK LoaderBlock) } } - return NumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; + /* Round size up. Assumed to better match actual physical RAM size */ + return ALIGN_UP_BY(NumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024); } /* See also: kd\kdio.c */