Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VqQte-0005gm-Iz for mharc-grub-devel@gnu.org; Tue, 10 Dec 2013 12:14:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqQtX-0005eX-D5 for grub-devel@gnu.org; Tue, 10 Dec 2013 12:14:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqQtS-0005DM-Hk for grub-devel@gnu.org; Tue, 10 Dec 2013 12:14:51 -0500 Received: from mail-qe0-f53.google.com ([209.85.128.53]:45475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqQtS-0005DH-D7 for grub-devel@gnu.org; Tue, 10 Dec 2013 12:14:46 -0500 Received: by mail-qe0-f53.google.com with SMTP id nc12so4382573qeb.12 for ; Tue, 10 Dec 2013 09:14:46 -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=Jnn3+id9puc4fqFP85S/CecwkDSDOJEh8Iho8bbgfwY=; b=YCPirPo4xHXBoA9aq8ehT0V3p5mQ0O8Eljo9lxDlzvbDXUFPNbqaevxeFA2XRJSmXr lY9l5ccFNzIjpnUaiMHDcIjkKdEJhZBZfZsPixJ3WAnBUqeUqp09BLHBfFg4YEQMFh2O 2opDfamEcKl4irhJapVRZwYBaPqi9+2aD8N5MOpCWQNS7GHl+o5xlsJUzT0/ITtwTKcz IjhgBT1phim8FqQkhHHCM0uOWB3Tkf8xtp6lDGhcBaNfcnNp7c7XAxZFIgYlxMxif0HC k/DoN/p9m/IVFFea3n8cCJTiHevPrisUI/VIl/JHnRm+xkZk4VXbhb9BvSVXyWls52SJ jINQ== X-Gm-Message-State: ALoCoQnbTZk9+0eyHRwo2rnajn3sv61mAffOwcTRd4WZPQFDvfvNwYexVsAkWuJPFZyqUzNkQJW3 X-Received: by 10.224.103.129 with SMTP id k1mr9435282qao.77.1386695685974; Tue, 10 Dec 2013 09:14:45 -0800 (PST) Received: from rocoto.smurfnet.nu ([2001:4b98:dc0:41:216:3eff:fea7:75f3]) by mx.google.com with ESMTPSA id w5sm48149589qat.10.2013.12.10.09.14.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 10 Dec 2013 09:14:45 -0800 (PST) Date: Tue, 10 Dec 2013 18:15:01 +0100 From: Leif Lindholm To: The development of GNU GRUB Subject: Re: kern/efi/mm.c - MAX_USABLE_ADDRESS Message-ID: <20131210171501.GI22356@rocoto.smurfnet.nu> References: <20131209173036.GK24997@rocoto.smurfnet.nu> <52A61537.7030407@gmail.com> <20131209211720.GA22356@rocoto.smurfnet.nu> <20131210145940.GF22356@rocoto.smurfnet.nu> <52A73A9C.8090901@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tsOsTdHNUZQcU9Ye" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52A73A9C.8090901@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.53 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: Tue, 10 Dec 2013 17:14:56 -0000 --tsOsTdHNUZQcU9Ye Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Dec 10, 2013 at 05:00:28PM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > > How about the attached? > > > You need to prefix define with GRUB_EFI_ as soon as it's a global define > and not limited to one file. Otherwise patch looks good. Can you send > corrected version? Attached. > > Compile tested for arm/arm64/i386/x86_64, runtime tested on arm64. Same again. / Leif --tsOsTdHNUZQcU9Ye Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-efi-mm-make-MAX_USABLE_ADDRESS-platform-specific.patch" From 09d798628d88542b2af361d5898b179efa2194b3 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 10 Dec 2013 12:24:57 +0000 Subject: [PATCH] efi: mm: make MAX_USABLE_ADDRESS platform-specific --- ChangeLog | 5 +++++ grub-core/kern/efi/mm.c | 20 ++++++++------------ include/grub/arm/efi/memory.h | 5 +++++ include/grub/arm64/efi/memory.h | 5 +++++ include/grub/i386/efi/memory.h | 5 +++++ include/grub/ia64/efi/memory.h | 5 +++++ include/grub/x86_64/efi/memory.h | 9 +++++++++ 7 files changed, 42 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index b706eb5..62fdb03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2013-12-10 Leif Lindholm + * make MAX_USABLE_ADDRESS platform-specific + * grub-core/kern/efi/mm.c: add Vladimir's new BYTES_TO_PAGES_DOWN macro. + +2013-12-10 Leif Lindholm + * grub-core/lib/fdt.c: change memcpy => grub_memcpy 2013-12-09 Jon McCune diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 6e9dace..be37afd 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -21,6 +21,7 @@ #include #include #include +#include #if defined (__i386__) || defined (__x86_64__) #include @@ -30,14 +31,9 @@ ((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__) -#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 @@ -64,7 +60,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, #if 1 /* Limit the memory access to less than 4GB for 32-bit platforms. */ - if (address > MAX_USABLE_ADDRESS) + if (address > GRUB_EFI_MAX_USABLE_ADDRESS) return 0; #endif @@ -72,7 +68,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, if (address == 0) { type = GRUB_EFI_ALLOCATE_MAX_ADDRESS; - address = MAX_USABLE_ADDRESS; + address = GRUB_EFI_MAX_USABLE_ADDRESS; } else type = GRUB_EFI_ALLOCATE_ADDRESS; @@ -92,7 +88,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, { /* Uggh, the address 0 was allocated... This is too annoying, so reallocate another one. */ - address = MAX_USABLE_ADDRESS; + address = GRUB_EFI_MAX_USABLE_ADDRESS; status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address); grub_efi_free_pages (0, pages); if (status != GRUB_EFI_SUCCESS) @@ -325,7 +321,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, { if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY #if 1 - && desc->physical_start <= MAX_USABLE_ADDRESS + && desc->physical_start <= GRUB_EFI_MAX_USABLE_ADDRESS #endif && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000 && desc->num_pages != 0) @@ -343,9 +339,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 (GRUB_EFI_MAX_USABLE_ADDRESS)) filtered_desc->num_pages - = (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL) + = (BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS) - BYTES_TO_PAGES (filtered_desc->physical_start)); #endif diff --git a/include/grub/arm/efi/memory.h b/include/grub/arm/efi/memory.h index c9a61bb..2c64918 100644 --- a/include/grub/arm/efi/memory.h +++ b/include/grub/arm/efi/memory.h @@ -1 +1,6 @@ +#ifndef GRUB_MEMORY_CPU_HEADER #include + +#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff + +#endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/arm64/efi/memory.h b/include/grub/arm64/efi/memory.h index c9a61bb..c6cb324 100644 --- a/include/grub/arm64/efi/memory.h +++ b/include/grub/arm64/efi/memory.h @@ -1 +1,6 @@ +#ifndef GRUB_MEMORY_CPU_HEADER #include + +#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL + +#endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/i386/efi/memory.h b/include/grub/i386/efi/memory.h index c9a61bb..2c64918 100644 --- a/include/grub/i386/efi/memory.h +++ b/include/grub/i386/efi/memory.h @@ -1 +1,6 @@ +#ifndef GRUB_MEMORY_CPU_HEADER #include + +#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff + +#endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/ia64/efi/memory.h b/include/grub/ia64/efi/memory.h index c9a61bb..2c64918 100644 --- a/include/grub/ia64/efi/memory.h +++ b/include/grub/ia64/efi/memory.h @@ -1 +1,6 @@ +#ifndef GRUB_MEMORY_CPU_HEADER #include + +#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff + +#endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/x86_64/efi/memory.h b/include/grub/x86_64/efi/memory.h index c9a61bb..46e9145 100644 --- a/include/grub/x86_64/efi/memory.h +++ b/include/grub/x86_64/efi/memory.h @@ -1 +1,10 @@ +#ifndef GRUB_MEMORY_CPU_HEADER #include + +#if defined (__code_model_large__) +#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff +#else +#define GRUB_EFI_MAX_USABLE_ADDRESS 0x7fffffff +#endif + +#endif /* ! GRUB_MEMORY_CPU_HEADER */ -- 1.7.10.4 --tsOsTdHNUZQcU9Ye--