* grub-core/kern/xen/init.c: Do not map more pages than we can address.

This commit is contained in:
Vladimir Serbinenko 2013-11-22 13:04:29 +01:00
parent 189090cee9
commit e1c22419ac
2 changed files with 15 additions and 0 deletions

View file

@ -1,3 +1,7 @@
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/xen/init.c: Do not map more pages than we can address.
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com> 2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/efi/mm.c: Limit allocations to 2GiB when not compiling * grub-core/kern/efi/mm.c: Limit allocations to 2GiB when not compiling

View file

@ -341,6 +341,14 @@ page2offset (grub_uint64_t page)
return page << 12; return page << 12;
} }
#if defined (__x86_64__) && defined (__code_model_large__)
#define MAX_TOTAL_PAGES (1LL << (64 - 12))
#elif defined (__x86_64__)
#define MAX_TOTAL_PAGES (1LL << (31 - 12))
#else
#define MAX_TOTAL_PAGES (1LL << (32 - 12))
#endif
static void static void
map_all_pages (void) map_all_pages (void)
{ {
@ -355,6 +363,9 @@ map_all_pages (void)
grub_size_t n_unusable_pages = 0; grub_size_t n_unusable_pages = 0;
struct mmu_update m2p_updates[2 * MAX_N_UNUSABLE_PAGES]; struct mmu_update m2p_updates[2 * MAX_N_UNUSABLE_PAGES];
if (total_pages > MAX_TOTAL_PAGES - 4)
total_pages = MAX_TOTAL_PAGES - 4;
grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver));
gnttab_setver.version = 2; gnttab_setver.version = 2;