lkml.org 
[lkml]   [2011]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 9/9] x86, efi: Make efi_call_phys_prelog() CONFIG_RELOCATABLE-aware
Date
From: Matt Fleming <matt.fleming@linux.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@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@linux.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


\
 
 \ /
  Last update: 2011-08-11 13:03    [from the cache]
©2003-2011 Jasper Spaans