Commit-ID:  88168dcb255f44892bcf9f6fac6aeb424471ffaa
Gitweb:     http://git.kernel.org/tip/88168dcb255f44892bcf9f6fac6aeb424471ffaa
Author:     Yinghai Lu <ying...@kernel.org>
AuthorDate: Thu, 13 Jun 2013 21:02:56 +0800
Committer:  H. Peter Anvin <h...@linux.intel.com>
CommitDate: Fri, 14 Jun 2013 14:04:50 -0700

x86, ACPI: Find acpi tables in initrd early from head_32.S/head64.c

head64.c can use the #PF handler automatic page tables to access initrd before
init mem mapping and initrd relocating.

head_32.S can use 32-bit flat mode to access initrd before init mem
mapping initrd relocating.

This patch introduces x86_acpi_override_find(), which is called from
head_32.S/head64.c, to replace acpi_initrd_override_find(). So that we
can makes 32bit and 64 bit more consistent.

-v2: use inline function in header file instead according to tj.
     also still need to keep #idef head_32.S to avoid compiling error.
-v3: need to move down reserve_initrd() after acpi_initrd_override_copy(),
     to make sure we are using right address.

Signed-off-by: Yinghai Lu <ying...@kernel.org>
Link: 
http://lkml.kernel.org/r/1371128589-8953-10-git-send-email-tangc...@cn.fujitsu.com
Cc: Pekka Enberg <penb...@kernel.org>
Cc: Jacob Shin <jacob.s...@amd.com>
Cc: Rafael J. Wysocki <r...@sisk.pl>
Cc: linux-a...@vger.kernel.org
Tested-by: Thomas Renninger <tr...@suse.de>
Reviewed-by: Tang Chen <tangc...@cn.fujitsu.com>
Tested-by: Tang Chen <tangc...@cn.fujitsu.com>
Signed-off-by: H. Peter Anvin <h...@linux.intel.com>
---
 arch/x86/include/asm/setup.h |  6 ++++++
 arch/x86/kernel/head64.c     |  2 ++
 arch/x86/kernel/head_32.S    |  4 ++++
 arch/x86/kernel/setup.c      | 34 ++++++++++++++++++++++++++++++----
 4 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index 4f71d48..6f885b7 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -42,6 +42,12 @@ extern void visws_early_detect(void);
 static inline void visws_early_detect(void) { }
 #endif
 
+#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+void x86_acpi_override_find(void);
+#else
+static inline void x86_acpi_override_find(void) { }
+#endif
+
 extern unsigned long saved_video_mode;
 
 extern void reserve_standard_io_resources(void);
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 55b6761..229b281 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -175,6 +175,8 @@ void __init x86_64_start_kernel(char * real_mode_data)
        if (console_loglevel == 10)
                early_printk("Kernel alive\n");
 
+       x86_acpi_override_find();
+
        clear_page(init_level4_pgt);
        /* set init_level4_pgt kernel high mapping*/
        init_level4_pgt[511] = early_level4_pgt[511];
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 73afd11..ca08f0e 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -149,6 +149,10 @@ ENTRY(startup_32)
        call load_ucode_bsp
 #endif
 
+#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+       call x86_acpi_override_find
+#endif
+
 /*
  * Initialize page tables.  This creates a PDE and a set of page
  * tables, which are located immediately beyond __brk_base.  The variable
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 142e042..d11b1b7 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -421,6 +421,34 @@ static void __init reserve_initrd(void)
 }
 #endif /* CONFIG_BLK_DEV_INITRD */
 
+#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+void __init x86_acpi_override_find(void)
+{
+       unsigned long ramdisk_image, ramdisk_size;
+       unsigned char *p = NULL;
+
+#ifdef CONFIG_X86_32
+       struct boot_params *boot_params_p;
+
+       /*
+        * 32bit is from head_32.S, and it is 32bit flat mode.
+        * So need to use phys address to access global variables.
+        */
+       boot_params_p = (struct boot_params *)__pa_nodebug(&boot_params);
+       ramdisk_image = get_ramdisk_image(boot_params_p);
+       ramdisk_size  = get_ramdisk_size(boot_params_p);
+       p = (unsigned char *)ramdisk_image;
+       acpi_initrd_override_find(p, ramdisk_size, true);
+#else
+       ramdisk_image = get_ramdisk_image(&boot_params);
+       ramdisk_size  = get_ramdisk_size(&boot_params);
+       if (ramdisk_image)
+               p = __va(ramdisk_image);
+       acpi_initrd_override_find(p, ramdisk_size, false);
+#endif
+}
+#endif
+
 static void __init parse_setup_data(void)
 {
        struct setup_data *data;
@@ -1117,12 +1145,10 @@ void __init setup_arch(char **cmdline_p)
        /* Allocate bigger log buffer */
        setup_log_buf(1);
 
-       reserve_initrd();
-
-       acpi_initrd_override_find((void *)initrd_start,
-                                       initrd_end - initrd_start, false);
        acpi_initrd_override_copy();
 
+       reserve_initrd();
+
        reserve_crashkernel();
 
        vsmp_init();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to