grub2/0325-grub-core-kern-elfXX.c-grub_elfXX_load-Handle.patch
2013-05-02 16:54:52 -04:00

99 lines
3.6 KiB
Diff

From 8968eeb2ff92930128a5d9820157de08876ab489 Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Fri, 19 Apr 2013 15:05:11 +0200
Subject: [PATCH 325/364] * grub-core/kern/elfXX.c (grub_elfXX_load):
Handle GRUB_ELF_LOAD_FLAGS_30BITS and GRUB_ELF_LOAD_FLAGS_62BITS.
* grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32),
(grub_linux_load64): Mask out 2 high bits.
---
ChangeLog | 7 +++++++
grub-core/kern/elfXX.c | 16 ++++++++++++++--
grub-core/loader/powerpc/ieee1275/linux.c | 4 ++--
include/grub/elfload.h | 4 ++++
4 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7450036..3799129 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-04-19 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/elfXX.c (grub_elfXX_load): Handle
+ GRUB_ELF_LOAD_FLAGS_30BITS and GRUB_ELF_LOAD_FLAGS_62BITS.
+ * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32),
+ (grub_linux_load64): Mask out 2 high bits.
+
2013-04-19 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub.d/30_os-prober.in: Add onstr to linux entries in one
diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c
index b35e235..2e45449 100644
--- a/grub-core/kern/elfXX.c
+++ b/grub-core/kern/elfXX.c
@@ -101,8 +101,20 @@ grub_elfXX_load (grub_elf_t elf, const char *filename,
continue;
load_addr = (grub_addr_t) phdr->p_paddr;
- if (load_flags & GRUB_ELF_LOAD_FLAGS_28BITS)
- load_addr &= 0xFFFFFFF;
+ switch (load_flags & GRUB_ELF_LOAD_FLAGS_BITS)
+ {
+ case GRUB_ELF_LOAD_FLAGS_ALL_BITS:
+ break;
+ case GRUB_ELF_LOAD_FLAGS_28BITS:
+ load_addr &= 0xFFFFFFF;
+ break;
+ case GRUB_ELF_LOAD_FLAGS_30BITS:
+ load_addr &= 0x3FFFFFFF;
+ break;
+ case GRUB_ELF_LOAD_FLAGS_62BITS:
+ load_addr &= 0x3FFFFFFFFFFFFFFFULL;
+ break;
+ }
load_addr += (grub_addr_t) load_offset;
if (load_addr < load_base)
diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
index cff4fd1..3356d51 100644
--- a/grub-core/loader/powerpc/ieee1275/linux.c
+++ b/grub-core/loader/powerpc/ieee1275/linux.c
@@ -204,7 +204,7 @@ grub_linux_load32 (grub_elf_t elf, const char *filename)
linux_addr = seg_addr;
/* Now load the segments into the area we claimed. */
- return grub_elf32_load (elf, filename, (void *) (seg_addr - base_addr), GRUB_ELF_LOAD_FLAGS_NONE, 0, 0);
+ return grub_elf32_load (elf, filename, (void *) (seg_addr - base_addr), GRUB_ELF_LOAD_FLAGS_30BITS, 0, 0);
}
static grub_err_t
@@ -238,7 +238,7 @@ grub_linux_load64 (grub_elf_t elf, const char *filename)
linux_addr = seg_addr;
/* Now load the segments into the area we claimed. */
- return grub_elf64_load (elf, filename, (void *) (grub_addr_t) (seg_addr - base_addr), GRUB_ELF_LOAD_FLAGS_NONE, 0, 0);
+ return grub_elf64_load (elf, filename, (void *) (grub_addr_t) (seg_addr - base_addr), GRUB_ELF_LOAD_FLAGS_62BITS, 0, 0);
}
static grub_err_t
diff --git a/include/grub/elfload.h b/include/grub/elfload.h
index f854d0b..9a7ae4e 100644
--- a/include/grub/elfload.h
+++ b/include/grub/elfload.h
@@ -53,7 +53,11 @@ enum grub_elf_load_flags
{
GRUB_ELF_LOAD_FLAGS_NONE = 0,
GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC = 1,
+ GRUB_ELF_LOAD_FLAGS_BITS = 6,
+ GRUB_ELF_LOAD_FLAGS_ALL_BITS = 0,
GRUB_ELF_LOAD_FLAGS_28BITS = 2,
+ GRUB_ELF_LOAD_FLAGS_30BITS = 4,
+ GRUB_ELF_LOAD_FLAGS_62BITS = 6,
};
grub_err_t grub_elf32_load (grub_elf_t, const char *filename,
void *load_offset, enum grub_elf_load_flags flags, grub_addr_t *,
--
1.8.1.4