[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1313060386-4858-10-git-send-email-matt@console-pimps.org>
Date: Thu, 11 Aug 2011 11:59:46 +0100
From: Matt Fleming <matt@...sole-pimps.org>
To: linux-kernel@...r.kernel.org
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...e.hu>,
"H. Peter Anvin" <hpa@...or.com>, Matthew Garrett <mjg@...hat.com>
Subject: [PATCH 9/9] x86, efi: Make efi_call_phys_prelog() CONFIG_RELOCATABLE-aware
From: Matt Fleming <matt.fleming@...ux.intel.com>
efi_call_phys_prelog() assumes that the kernel was loaded at a
physical address within the first 8MB of ram, usually
0x1000000. However, this isn't the case with a CONFIG_RELOCATABLE=y
kernel which could have been loaded anywhere in the physical address
space.
Replace the hardcoded pgd_index(0) and pgd_index(PAGE_OFFSET) with the
runtime addresses of the kernel in the physical and virtual space,
respectively.
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: Matthew Garrett <mjg@...hat.com>
Signed-off-by: Matt Fleming <matt.fleming@...ux.intel.com>
---
arch/x86/platform/efi/efi_32.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
index 5cab48e..1156e9a 100644
--- a/arch/x86/platform/efi/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
@@ -44,8 +44,12 @@ void efi_call_phys_prelog(void)
{
unsigned long cr4;
unsigned long temp;
+ unsigned long phys_addr, virt_addr;
struct desc_ptr gdt_descr;
+ virt_addr = (unsigned long)_text;
+ phys_addr = virt_addr - PAGE_OFFSET;
+
local_irq_save(efi_rt_eflags);
/*
@@ -57,18 +61,18 @@ void efi_call_phys_prelog(void)
if (cr4 & X86_CR4_PAE) {
efi_bak_pg_dir_pointer[0].pgd =
- swapper_pg_dir[pgd_index(0)].pgd;
- swapper_pg_dir[0].pgd =
- swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd;
+ swapper_pg_dir[pgd_index(phys_addr)].pgd;
+ swapper_pg_dir[pgd_index(phys_addr)].pgd =
+ swapper_pg_dir[pgd_index(virt_addr)].pgd;
} else {
efi_bak_pg_dir_pointer[0].pgd =
- swapper_pg_dir[pgd_index(0)].pgd;
+ swapper_pg_dir[pgd_index(phys_addr)].pgd;
efi_bak_pg_dir_pointer[1].pgd =
- swapper_pg_dir[pgd_index(0x400000)].pgd;
- swapper_pg_dir[pgd_index(0)].pgd =
- swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd;
- temp = PAGE_OFFSET + 0x400000;
- swapper_pg_dir[pgd_index(0x400000)].pgd =
+ swapper_pg_dir[pgd_index(phys_addr + 0x400000)].pgd;
+ swapper_pg_dir[pgd_index(phys_addr)].pgd =
+ swapper_pg_dir[pgd_index(virt_addr)].pgd;
+ temp = virt_addr + 0x400000;
+ swapper_pg_dir[pgd_index(phys_addr + 0x400000)].pgd =
swapper_pg_dir[pgd_index(temp)].pgd;
}
--
1.7.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists