Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vq4fD-0005bH-Sh for mharc-grub-devel@gnu.org; Mon, 09 Dec 2013 12:30:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq4f5-0005b2-Vt for grub-devel@gnu.org; Mon, 09 Dec 2013 12:30:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vq4ez-0002Qa-Ve for grub-devel@gnu.org; Mon, 09 Dec 2013 12:30:27 -0500 Received: from mail-qa0-f54.google.com ([209.85.216.54]:60358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq4ez-0002Pg-RZ for grub-devel@gnu.org; Mon, 09 Dec 2013 12:30:21 -0500 Received: by mail-qa0-f54.google.com with SMTP id f11so2823194qae.20 for ; Mon, 09 Dec 2013 09:30:21 -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:mime-version :content-type:content-disposition:user-agent; bh=JxESnSSvPfYnu+UrRRt1H8ehaYwXPkwe8XzAbV2pA5E=; b=bBSZ7B8IZu1SnNl1V/oa0IATKSXFsu/ztEnTipjLRoekEAKfgc10iKTbyQ4FRDqNry vppqgs2cLD5msaYFN91m3uqWZt+55E+wk+F0Fu/TC/hEDOwJ/aff4Ba32R5ayowvlc8i IUrAulzGoj87UOKqdOSkeWKCRblX7wXBhmo/uQzQ2uxUA2WbniqTp2EiiOx2s+KHnGLA SQxj7r+/smJqoX5vkhumcmUjPorzlTPI688nVzI7kE1u6w5UNptlrs1U7MylV/ShNpCm L1CxDTmM2w0tPrXEAmJHMLSr/eKfKrchvpFQgnuVOJew4vBTC/UeijahQpj2jZw90UYi yk3w== X-Gm-Message-State: ALoCoQkr6gElToUPIsItCxzvm8MnHGvQqf9QH2T6ZsVOoX3veJdhmwQuGEaGiA+YDszq3+JLsC4i X-Received: by 10.224.51.7 with SMTP id b7mr36402253qag.74.1386610220925; Mon, 09 Dec 2013 09:30:20 -0800 (PST) Received: from rocoto.smurfnet.nu ([2001:4b98:dc0:41:216:3eff:fea7:75f3]) by mx.google.com with ESMTPSA id o5sm31800916qeg.2.2013.12.09.09.30.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 09 Dec 2013 09:30:20 -0800 (PST) Date: Mon, 9 Dec 2013 18:30:36 +0100 From: Leif Lindholm To: grub-devel@gnu.org Subject: kern/efi/mm.c - MAX_USABLE_ADDRESS Message-ID: <20131209173036.GK24997@rocoto.smurfnet.nu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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.216.54 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 17:30:34 -0000 Hi, The EFI memory management code contains a hard-wired limit restricting physical (and virtual, all 1:1 mapped in UEFI) addresses to 32-bit. While this may be the right thing to do on x86, and hasn't caused me any issues on 32-bit ARM, I have received reports of at least two upcoming 64-bit ARM platforms with no RAM in the lower 4GB of physical address space. A simple fix would be to just stack the ifdefs, but a better one might be to move the define to one of (which is currently a dummy for all platforms, simply including ) or types.h. So, for something compile tested only on arm64: diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 6e9dace..5673d23 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -32,12 +32,6 @@ #define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12) #define PAGES_TO_BYTES(pages) ((pages) << 12) -#if defined (__code_model_large__) || !defined (__x86_64__) -#define MAX_USABLE_ADDRESS 0xffffffff -#else -#define MAX_USABLE_ADDRESS 0x7fffffff -#endif - /* The size of a memory map obtained from the firmware. This must be a multiplier of 4KB. */ #define MEMORY_MAP_SIZE 0x3000 diff --git a/include/grub/arm/types.h b/include/grub/arm/types.h index 4a806d0..612ea57 100644 --- a/include/grub/arm/types.h +++ b/include/grub/arm/types.h @@ -25,6 +25,8 @@ /* The size of long. */ #define GRUB_TARGET_SIZEOF_LONG 4 +#define MAX_USABLE_ADDRESS 0xffffffff + /* currently only support little-endian. */ #undef GRUB_TARGET_WORDS_BIGENDIAN diff --git a/include/grub/arm64/types.h b/include/grub/arm64/types.h index d132c5e..d52967d 100644 --- a/include/grub/arm64/types.h +++ b/include/grub/arm64/types.h @@ -25,6 +25,8 @@ /* The size of long. */ #define GRUB_TARGET_SIZEOF_LONG 8 +#define MAX_USABLE_ADDRESS 0xffffffffffffULL + /* currently only support little-endian. */ #undef GRUB_TARGET_WORDS_BIGENDIAN diff --git a/include/grub/i386/types.h b/include/grub/i386/types.h index c20063f..7fa7917 100644 --- a/include/grub/i386/types.h +++ b/include/grub/i386/types.h @@ -25,6 +25,12 @@ /* The size of long. */ #define GRUB_TARGET_SIZEOF_LONG 4 +#if defined (__code_model_large__) +#define MAX_USABLE_ADDRESS 0xffffffff +#else +#define MAX_USABLE_ADDRESS 0x7fffffff +#endif + /* i386 is little-endian. */ #undef GRUB_TARGET_WORDS_BIGENDIAN diff --git a/include/grub/ia64/types.h b/include/grub/ia64/types.h index 91a546d..8f13cf6 100644 --- a/include/grub/ia64/types.h +++ b/include/grub/ia64/types.h @@ -25,6 +25,8 @@ /* The size of long. */ #define GRUB_TARGET_SIZEOF_LONG 8 +#define MAX_USABLE_ADDRESS 0xffffffff + /* ia64 is little-endian (usually). */ #undef GRUB_TARGET_WORDS_BIGENDIAN diff --git a/include/grub/x86_64/types.h b/include/grub/x86_64/types.h index d53138e..baa31bb 100644 --- a/include/grub/x86_64/types.h +++ b/include/grub/x86_64/types.h @@ -25,6 +25,12 @@ /* The size of long. */ #define GRUB_TARGET_SIZEOF_LONG 8 +#if defined (__code_model_large__) +#define MAX_USABLE_ADDRESS 0xffffffff +#else +#define MAX_USABLE_ADDRESS 0x7fffffff +#endif + /* x86_64 is little-endian. */ #undef GRUB_TARGET_WORDS_BIGENDIAN --- Would a cleaned-up patch of the same be acceptable? / Leif