From 458f7a2e40f35316863a17599e1813e1d9d77bbd Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 11 Mar 2009 17:47:38 -0700 Subject: runkernel: when computing initrd address, skip fractional pages Make sure no part of the initrd extends into memory that is in a fractional page at the end of memory. The kernel may not be able to map such a fractional page, and therefore will be unable to access that memory. --- core/runkernel.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/runkernel.inc b/core/runkernel.inc index 143920d0..f42abf08 100644 --- a/core/runkernel.inc +++ b/core/runkernel.inc @@ -1,6 +1,6 @@ ;; ----------------------------------------------------------------------- ;; -;; Copyright 1994-2008 H. Peter Anvin - All Rights Reserved +;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -536,10 +536,16 @@ parse_load_initrd: je .get_chunk ; Compute the initrd target location + ; Note: we round to a page boundary twice here. The first + ; time it is to make sure we don't use any fractional page + ; which may be valid RAM but which will be ignored by the + ; kernel (and therefore is inaccessible.) The second time + ; it is to make sure we start out on page boundary. mov edx,[cs:InitRDEnd] sub edx,[cs:InitRDStart] mov [su_ramdisklen],edx mov eax,[cs:MyHighMemSize] + and ax,0F000h ; Round to a page boundary sub eax,edx and ax,0F000h ; Round to a page boundary mov [su_ramdiskat],eax -- cgit v1.2.3