From: "Éric Piel" <Eric.Piel@tremplin-utc.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Tilman Schmidt <tilman@imap.cc>,
Dave Hansen <haveblue@us.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Thomas Renninger <trenn@suse.de>,
Len Brown <len.brown@intel.com>,
Christoph Hellwig <hch@infradead.org>,
Markus Gaugusch <dsdt@gaugusch.at>,
linux-acpi@vger.kernel.org, Al Viro <viro@ZenIV.linux.org.uk>,
Arjan van de Ven <arjanv@redhat.com>
Subject: Re: [2.6.25-rc5-mm1] BUG: spinlock bad magic early during boot
Date: Sat, 15 Mar 2008 20:42:52 +0100 [thread overview]
Message-ID: <47DC26BC.7060502@tremplin-utc.net> (raw)
In-Reply-To: <alpine.LFD.1.00.0803151212180.3020@woody.linux-foundation.org>
[-- Attachment #1: Type: text/plain, Size: 2514 bytes --]
15/03/08 20:21, Linus Torvalds wrote/a écrit:
>
> On Sat, 15 Mar 2008, Tilman Schmidt wrote:
>> Sorry to say, it doesn't. That is, it does shut up the warning I
>> reported, but there's a new one appearing now instead, three lines
>> later.
>
> I've reverted the whole thing. Or rather, since there were various small
> fixup commits over time, and a simple revert doesn't really work, I ended
> up just removing the option and the code that was conditional on it - that
> way, if we really want to fight this out some time (after 2.6.25 is out)
> or some vendor wants to use a known-broken option anyway, there's a simple
> and fairly clean commit to revert the revert.
>
> It's commit 9a9e0d685553af76cb6ae2af93cca4913e7fcd47, see
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=9a9e0d685553af76cb6ae2af93cca4913e7fcd47
>
> for details if you aren't a git person.
Hi,
It's a pity, I had just nearly finished a new approach. Instead of
relying on populate_rootfs() and the filesystem infrastructure, the new
approach directly finds the file in the initramfs. With
unpack_to_rootfs(), it turned out to be rather straightforward. Attached
is a half-tested version of the patch (it boots and works but I haven't
compiled without the option yet). Just in case you would like to change
your mind ;-)
> But quite frankly I don't think that we even want to re-introduce this in
> that form. If we really want to have a dynamic custom DSDT, I think we
> should do the whole DSDT replacement *much* later by ACPI (like just
> before driver loading or something like that).
>
> If the BIOS-provided DSDT is _so_ broken that we cannot even get core
> stuff like the CPU's going, I think it has more serious issues than any
> custom DSDT will ever fix, but letting ACPI actually switch DSDT's at
> run-time (instead of just replacing it when looking for it very very early
> in the boot sequence) in order to work around some device issues sounds
> reasonably sane.
>
> So how about aiming to make that DSDT-replacement something you can do
> from any kernel module, _after_ the original DSDT has already been parsed?
> And then the whole "load it from initrd" turns into a regular thing that
> we can do pretty early, but that we don't have to do quite _this_ early!
Indeed, this form of DSDT override would be the best. However, I have no
idea what is necessary to implement it. Len, does this approach sound
feasible? Where should I start looking at?
Eric
[-- Attachment #2: 0001-DSDT-in-initramfs-directly-access-the-initramfs.patch --]
[-- Type: text/plain, Size: 7354 bytes --]
>From a0e8247f5f0dd5f332639b5635258a35c3648159 Mon Sep 17 00:00:00 2001
From: Eric Piel <eric@circle.(none)>
Date: Sat, 15 Mar 2008 19:49:05 +0100
Subject: [PATCH 1/1] DSDT in initramfs: directly access the initramfs
The current method for reading the DSDT in the initramfs uses the filesystem. Not only this is bad because such functions should normally not used in the kernel, but in addition it brings the requirement that the filesystem infrastructure is already initialised before initialising ACPI. This is quite unlikely to ever happen. (cf http://marc.info/?t=120536629300001&r=1&w=2)
This patch changes the method of access to initramfs. It uses directly unpack_to_rootfs(). This is build over the "check_only" mode: the initramfs is just read... but if we find a file matching the one we are looking for we copy it to memory.
Signed-off-by: Eric Piel <eric.piel@tremplin-utc.net>
---
drivers/acpi/osl.c | 62 +----------------------------------------
init/initramfs.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++----
init/main.c | 7 ----
3 files changed, 74 insertions(+), 74 deletions(-)
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 065819b..8fa630f 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -93,6 +93,7 @@ static char osi_additional_string[OSI_STRING_LENGTH_MAX];
#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
static int acpi_no_initrd_override;
+extern struct acpi_table_header *acpi_find_dsdt_initrd(void);
#endif
/*
@@ -324,67 +325,6 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
return AE_OK;
}
-#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
-static struct acpi_table_header *acpi_find_dsdt_initrd(void)
-{
- struct file *firmware_file;
- mm_segment_t oldfs;
- unsigned long len, len2;
- struct acpi_table_header *dsdt_buffer, *ret = NULL;
- struct kstat stat;
- char *ramfs_dsdt_name = "/DSDT.aml";
-
- printk(KERN_INFO PREFIX "Checking initramfs for custom DSDT\n");
-
- /*
- * Never do this at home, only the user-space is allowed to open a file.
- * The clean way would be to use the firmware loader.
- * But this code must be run before there is any userspace available.
- * A static/init firmware infrastructure doesn't exist yet...
- */
- if (vfs_stat(ramfs_dsdt_name, &stat) < 0)
- return ret;
-
- len = stat.size;
- /* check especially against empty files */
- if (len <= 4) {
- printk(KERN_ERR PREFIX "Failed: DSDT only %lu bytes.\n", len);
- return ret;
- }
-
- firmware_file = filp_open(ramfs_dsdt_name, O_RDONLY, 0);
- if (IS_ERR(firmware_file)) {
- printk(KERN_ERR PREFIX "Failed to open %s.\n", ramfs_dsdt_name);
- return ret;
- }
-
- dsdt_buffer = kmalloc(len, GFP_ATOMIC);
- if (!dsdt_buffer) {
- printk(KERN_ERR PREFIX "Failed to allocate %lu bytes.\n", len);
- goto err;
- }
-
- oldfs = get_fs();
- set_fs(KERNEL_DS);
- len2 = vfs_read(firmware_file, (char __user *)dsdt_buffer, len,
- &firmware_file->f_pos);
- set_fs(oldfs);
- if (len2 < len) {
- printk(KERN_ERR PREFIX "Failed to read %lu bytes from %s.\n",
- len, ramfs_dsdt_name);
- ACPI_FREE(dsdt_buffer);
- goto err;
- }
-
- printk(KERN_INFO PREFIX "Found %lu byte DSDT in %s.\n",
- len, ramfs_dsdt_name);
- ret = dsdt_buffer;
-err:
- filp_close(firmware_file, NULL);
- return ret;
-}
-#endif
-
acpi_status
acpi_os_table_override(struct acpi_table_header * existing_table,
struct acpi_table_header ** new_table)
diff --git a/init/initramfs.c b/init/initramfs.c
index c0b1e05..224bf48 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -6,8 +6,15 @@
#include <linux/delay.h>
#include <linux/string.h>
#include <linux/syscalls.h>
+#include <acpi/acpi.h>
static __initdata char *message;
+#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
+static __initdata char *file_looked_for;
+static __initdata void *file_mem;
+#else
+#define file_looked_for 0
+#endif
static void __init error(char *x)
{
if (!message)
@@ -123,6 +130,7 @@ static __initdata enum state {
SkipIt,
GotName,
CopyFile,
+ CopyFileMem,
GotSymlink,
Reset
} state, next_state;
@@ -267,6 +275,11 @@ static int __init do_name(void)
free_hash();
return 0;
}
+ if (file_looked_for) {
+ if (S_ISREG(mode) && (strcmp(collected, file_looked_for) == 0))
+ state = CopyFileMem;
+ return 0;
+ }
if (dry_run)
return 0;
clean_path(collected, mode);
@@ -299,6 +312,37 @@ static int __init do_name(void)
return 0;
}
+#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
+static int __init do_copy_mem(void)
+{
+ static void *file_current; /* current position in the file */
+ if (file_mem == NULL) {
+ if (body_len < 4) { /* check especially against empty files */
+ error("file is less than 4 bytes");
+ return 1;
+ }
+ file_mem = kmalloc(body_len, GFP_ATOMIC);
+ if (!file_mem) {
+ error("failed to allocate enough memory");
+ return 1;
+ }
+ file_current = file_mem;
+ }
+ if (count >= body_len) {
+ memcpy(file_current, victim, body_len);
+ eat(body_len);
+ } else {
+ memcpy(file_current, victim, count);
+ body_len -= count;
+ file_current += count;
+ eat(count);
+ }
+ return 1;
+}
+#else
+#define do_copy_mem NULL
+#endif
+
static int __init do_copy(void)
{
if (count >= body_len) {
@@ -333,6 +377,7 @@ static __initdata int (*actions[])(void) = {
[SkipIt] = do_skip,
[GotName] = do_name,
[CopyFile] = do_copy,
+ [CopyFileMem] = do_copy_mem,
[GotSymlink] = do_symlink,
[Reset] = do_reset,
};
@@ -538,7 +583,7 @@ skip:
initrd_end = 0;
}
-int __init populate_rootfs(void)
+static int __init populate_rootfs(void)
{
char *err = unpack_to_rootfs(__initramfs_start,
__initramfs_end - __initramfs_start, 0);
@@ -577,10 +622,32 @@ int __init populate_rootfs(void)
}
return 0;
}
-#ifndef CONFIG_ACPI_CUSTOM_DSDT_INITRD
-/*
- * if this option is enabled, populate_rootfs() is called _earlier_ in the
- * boot sequence. This insures that the ACPI initialisation can find the file.
- */
rootfs_initcall(populate_rootfs);
+
+#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
+struct acpi_table_header *acpi_find_dsdt_initrd(void)
+{
+ char *err, *ramfs_dsdt_name = "DSDT.aml";
+
+ printk(KERN_INFO "ACPI: Checking initramfs for custom DSDT\n");
+ file_mem = NULL;
+ file_looked_for = ramfs_dsdt_name;
+ err = unpack_to_rootfs((char *)initrd_start,
+ initrd_end - initrd_start, 1);
+ file_looked_for = NULL;
+
+ if (err) {
+ /*
+ * Even if reading the DSDT file was successful,
+ * we give up if the initramfs cannot be entirely read.
+ */
+ kfree(file_mem);
+ printk(KERN_ERR "ACPI: Aborded because %s.\n", err);
+ return NULL;
+ }
+ if (file_mem)
+ printk(KERN_INFO "ACPI: Found DSDT in %s.\n", ramfs_dsdt_name);
+
+ return file_mem;
+}
#endif
diff --git a/init/main.c b/init/main.c
index fbb0167..99ce949 100644
--- a/init/main.c
+++ b/init/main.c
@@ -102,12 +102,6 @@ static inline void mark_rodata_ro(void) { }
extern void tc_init(void);
#endif
-#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
-extern int populate_rootfs(void);
-#else
-static inline void populate_rootfs(void) {}
-#endif
-
enum system_states system_state;
EXPORT_SYMBOL(system_state);
@@ -650,7 +644,6 @@ asmlinkage void __init start_kernel(void)
check_bugs();
- populate_rootfs(); /* For DSDT override from initramfs */
acpi_early_init(); /* before LAPIC and SMP init */
/* Do the rest non-__init'ed, we're now alive */
--
1.5.4.3
next prev parent reply other threads:[~2008-03-15 19:43 UTC|newest]
Thread overview: 116+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-11 8:14 2.6.25-rc5-mm1 Andrew Morton
2008-03-11 10:16 ` [Build Faliure] 2.6.25-rc5-mm1 build fails Kamalesh Babulal
2008-03-11 10:56 ` Edward Shishkin
2008-03-11 12:55 ` [Build Failure] 2.6.25-rc5-mm1 Build fails with allmodconfig probe_4drives undefined Kamalesh Babulal
2008-03-11 17:41 ` Andrew Morton
2008-03-11 19:35 ` Bartlomiej Zolnierkiewicz
2008-03-11 18:19 ` Andrew Morton
2008-03-11 19:36 ` Bartlomiej Zolnierkiewicz
2008-03-11 17:09 ` 2.6.25-rc5-mm1 (paravirt/vsmp/no PCI) Randy Dunlap
2008-03-11 18:18 ` Jeremy Fitzhardinge
2008-03-12 0:10 ` Ravikiran G Thirumalai
2008-03-12 1:42 ` Randy Dunlap
2008-03-12 1:51 ` Jeremy Fitzhardinge
2008-03-12 7:14 ` Ingo Molnar
2008-03-11 20:23 ` 2.6.25-rc5-mm1 serge
2008-03-11 20:39 ` 2.6.25-rc5-mm1 Andrew Morton
2008-03-12 19:33 ` 2.6.25-rc5-mm1 Torsten Kaiser
2008-03-12 19:44 ` 2.6.25-rc5-mm1 Andrew Morton
2008-03-12 20:01 ` 2.6.25-rc5-mm1 Torsten Kaiser
2008-03-13 22:05 ` 2.6.25-rc5-mm1 Torsten Kaiser
2008-03-13 22:35 ` 2.6.25-rc5-mm1 Andrew Morton
2008-03-13 23:10 ` 2.6.25-rc5-mm1 Badari Pulavarty
2008-03-21 12:12 ` 2.6.25-rc5-mm1 Ingo Molnar
2008-03-12 1:14 ` 2.6.25-rc5-mm1 Dave Young
2008-03-12 7:21 ` 2.6.25-rc5-mm1: NO_HZ=Y && PREEMPT_RCU=Y fails to build Laurent Riffard
2008-03-12 7:44 ` Andrew Morton
2008-03-12 21:32 ` Laurent Riffard
2008-03-12 23:43 ` Tilman Schmidt
2008-03-12 9:17 ` [BUILD_FAILURE] 2.6.25-rc5-mm1 build fails at startup_ipi_hook() with randconfig Kamalesh Babulal
2008-03-12 12:55 ` [BUG] 2.6.25-rc5-mm1 kernel panic with "Exception: 501 " on powerpc Kamalesh Babulal
2008-03-12 17:46 ` Andrew Morton
2008-03-12 17:51 ` Matthew Wilcox
2008-03-12 22:26 ` Michael Ellerman
2008-03-12 22:33 ` Matthew Wilcox
2008-03-13 13:02 ` Kamalesh Babulal
2008-03-12 20:40 ` Benjamin Herrenschmidt
2008-03-12 18:14 ` Badari Pulavarty
2008-03-12 18:10 ` 2.6.25-rc5-mm1 - x86_64 boot problem ? Badari Pulavarty
2008-03-12 18:15 ` Andrew Morton
2008-03-13 17:09 ` 2.6.25-rc5-mm1 - x86_64 boot problem with git-sched.patch Badari Pulavarty
2008-03-13 17:40 ` Badari Pulavarty
2008-03-13 17:55 ` Guillaume Chazarain
2008-03-13 18:20 ` Badari Pulavarty
2008-03-12 23:54 ` [2.6.25-rc5-mm1] BUG: spinlock bad magic early during boot Tilman Schmidt
2008-03-13 0:04 ` Andrew Morton
2008-03-13 21:48 ` Dave Hansen
2008-03-13 20:46 ` Dave Hansen
2008-03-14 0:35 ` Tilman Schmidt
2008-03-14 18:03 ` Dave Hansen
2008-03-14 20:06 ` Dave Hansen
2008-03-14 20:20 ` Linus Torvalds
2008-03-14 20:51 ` Eric Piel
2008-03-14 21:35 ` Dave Hansen
2008-03-14 22:50 ` Eric Piel
2008-03-14 23:29 ` Dave Hansen
2008-03-15 12:47 ` Tilman Schmidt
2008-03-15 19:21 ` Linus Torvalds
2008-03-15 19:42 ` Éric Piel [this message]
2008-03-15 20:19 ` Linus Torvalds
2008-03-16 0:15 ` Éric Piel
2008-03-17 17:27 ` Len Brown
[not found] ` <1205858252.21619.233.camel@queen.suse.de>
2008-03-18 20:32 ` Len Brown
2008-03-20 14:28 ` Thomas Renninger
2008-03-17 17:59 ` Len Brown
2008-03-21 13:17 ` Pavel Machek
2008-03-23 16:00 ` Dave Hansen
2008-03-24 16:03 ` Pavel Machek
2008-03-24 17:05 ` Eric Piel
2008-03-24 17:19 ` Pavel Machek
2008-03-24 17:23 ` Dave Hansen
2008-03-27 9:23 ` Helge Hafting
2008-03-17 18:05 ` Len Brown
2008-03-16 20:11 ` Dave Hansen
2008-03-17 12:23 ` Peter Zijlstra
2008-03-19 23:50 ` Tilman Schmidt
2008-03-17 17:48 ` Len Brown
2008-03-13 0:15 ` [2.6.25-rc5-mm1] WARNING: at drivers/base/sys.c:173 Tilman Schmidt
2008-03-13 18:34 ` Greg KH
2008-03-13 19:57 ` Dave Jones
2008-03-13 19:56 ` Dave Jones
2008-03-13 20:27 ` Greg KH
2008-03-14 0:01 ` Tilman Schmidt
2008-03-14 0:44 ` Dave Jones
2008-03-14 0:57 ` Zhao Yakui
2008-03-14 9:58 ` Tilman Schmidt
2008-03-15 12:16 ` Tilman Schmidt
2008-03-13 14:03 ` 2.6.25-rc5-mm1 shutdown crash Helge Hafting
2008-03-13 16:12 ` Andrew Morton
2008-03-25 12:23 ` Helge Hafting
2008-03-13 19:48 ` [2.6.25-rc5-mm1] regression: cannot run Postfix sendmail command as non-root Tilman Schmidt
2008-03-13 22:21 ` Daniel Lezcano
2008-03-14 0:08 ` Tilman Schmidt
2008-03-17 10:44 ` Daniel Lezcano
2008-03-17 12:50 ` Benjamin Thery
2008-03-17 13:35 ` Tilman Schmidt
2008-03-17 13:06 ` Tilman Schmidt
2008-03-17 13:17 ` Daniel Lezcano
2008-03-19 17:52 ` Benjamin Thery
2008-03-19 21:16 ` Andrew Morton
2008-03-19 22:14 ` Benjamin Thery
2008-03-19 22:49 ` David Miller
2008-03-20 8:26 ` Benjamin Thery
2008-03-20 10:21 ` Rafael J. Wysocki
2008-03-20 12:52 ` Pavel Emelyanov
2008-03-20 13:48 ` Benjamin Thery
2008-03-20 14:38 ` Rafael J. Wysocki
2008-03-19 23:31 ` Tilman Schmidt
2008-03-13 22:07 ` 2.6.25-rc5-mm1: "consolechars" hangs on boot Laurent Riffard
2008-03-13 22:38 ` Andrew Morton
2008-03-14 5:26 ` Oleg Nesterov
2008-03-14 21:06 ` Laurent Riffard
2008-03-15 12:03 ` Oleg Nesterov
2008-03-16 21:38 ` 2.6.25-rc5-mm1 build failure of pcsp.c Mariusz Kozlowski
2008-03-28 22:52 ` 2.6.25-rc5-mm1 sparc64 boot problems due to generic pci_enable_resources() Mariusz Kozlowski
2008-03-28 23:10 ` David Miller
2008-03-29 0:44 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47DC26BC.7060502@tremplin-utc.net \
--to=eric.piel@tremplin-utc.net \
--cc=akpm@linux-foundation.org \
--cc=arjanv@redhat.com \
--cc=dsdt@gaugusch.at \
--cc=haveblue@us.ibm.com \
--cc=hch@infradead.org \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tilman@imap.cc \
--cc=torvalds@linux-foundation.org \
--cc=trenn@suse.de \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox