Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vq8Ln-0001ic-9R for mharc-grub-devel@gnu.org; Mon, 09 Dec 2013 16:26:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq8Lf-0001ha-Ur for grub-devel@gnu.org; Mon, 09 Dec 2013 16:26:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vq8LZ-00064E-W6 for grub-devel@gnu.org; Mon, 09 Dec 2013 16:26:39 -0500 Received: from mail-qe0-f43.google.com ([209.85.128.43]:57327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq8LZ-00064A-SI for grub-devel@gnu.org; Mon, 09 Dec 2013 16:26:33 -0500 Received: by mail-qe0-f43.google.com with SMTP id 2so3437646qeb.30 for ; Mon, 09 Dec 2013 13:26:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=BxXfPVNMkdc9inREZO584PkRd3HxwpJorWWt3+MMTQI=; b=M0aAabbhZeUj0R/e2QYGdt0hU6+iANjxaruQSM95kBjfErhaKzRKUl6D/EXkDMiBU5 ivpxIGv+ZBOWku/th9QdCaxqshCR07bN3cYUMqQZmBHFCyWZtxHB81pDG/QuqZ380RYY iFBpmPvoC6MsSCXQeSng71t5EVuv/TOHBzYqTGAwraklApMB7jgGFdghq0aEyyw9S4q7 822Qkx21W1l8n2j22AOW8TJaT6jrqvNZQ2vKYtjdvBxtj0osyO9GeiAWHxox/KSJRJiv 1etrjZk/CIv7ZR1HxUqmnkXppJsoz5o/4dRFKRJJ1CrgZaz581uBazpnqsmR3fybdxxR VY3Q== X-Gm-Message-State: ALoCoQnplDZslybhuLXoIgeoLGkfosLAETErpoUe7mjjJr7fmdDj5bTn/wVrfGrTBpOtSYKIPvb2 X-Received: by 10.224.151.209 with SMTP id d17mr19507684qaw.87.1386624393385; Mon, 09 Dec 2013 13:26:33 -0800 (PST) Received: from rocoto.smurfnet.nu ([2001:4b98:dc0:41:216:3eff:fea7:75f3]) by mx.google.com with ESMTPSA id f10sm33763559qej.1.2013.12.09.13.26.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 09 Dec 2013 13:26:32 -0800 (PST) Date: Mon, 9 Dec 2013 22:26:49 +0100 From: Leif Lindholm To: The development of GNU GRUB Subject: Re: kern/efi/mm.c - MAX_USABLE_ADDRESS Message-ID: <20131209212649.GB22356@rocoto.smurfnet.nu> References: <20131209173036.GK24997@rocoto.smurfnet.nu> <52A61537.7030407@gmail.com> <52A61D7D.60109@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52A61D7D.60109@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.43 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Dec 2013 21:26:46 -0000 On Mon, Dec 09, 2013 at 08:43:57PM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > If you want to increase it to 0xffffffffffffffff you'll need patch at > bottom of this mail. All other uses of MAX_USABLE_ADDRESS seem to be > fine. I can limit myself to 48 bits addressing due to current architectural restrictions, so not strictly speaking required, but... > With this patch we would lose the last usable page but it's just > 4K and this page is dangerous for overflows anyway so better to avoid. > I'd suggest using something lower (perhaps 1M lower) to avoid potential > bugs in EFI. ...this certainly looks like a good idea regardless. > diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c > index 6e9dace..2becb7b 100644 > --- a/grub-core/kern/efi/mm.c > +++ b/grub-core/kern/efi/mm.c > @@ -30,6 +30,7 @@ > ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size))) > > #define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12) > +#define BYTES_TO_PAGES_DOWN(bytes) ((bytes) >> 12) > #define PAGES_TO_BYTES(pages) ((pages) << 12) > > #if defined (__code_model_large__) || !defined (__x86_64__) > @@ -343,9 +344,9 @@ filter_memory_map (grub_efi_memory_descriptor_t > *memory_map, > #if 1 > if (BYTES_TO_PAGES (filtered_desc->physical_start) > + filtered_desc->num_pages > - > BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL)) > + > BYTES_TO_PAGES_DOWN (MAX_USABLE_ADDRESS)) > filtered_desc->num_pages > - = (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL) > + = (BYTES_TO_PAGES_DOWN (MAX_USABLE_ADDRESS) > - BYTES_TO_PAGES (filtered_desc->physical_start)); > #endif