Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
From: Michael D Labriola
Date: Thu Jan 19 2012 - 12:47:11 EST
Michael D Labriola/EB/GDYN wrote on 01/19/2012 10:48:53 AM:
> Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote on 01/19/2012 10:45:04 AM:
>
> > > checking if reboot_type's value is anything other than BOOT_ACPI
(which
> > > is the default), but that does assume BOOT_ACPI is the default. What
if
> > > that's ever changed? Seems likely to me that whoever changes the
default
> > > in the future could very easily re-break this at that point.
> > >
> > > Thoughts?
> >
> > Fair point - how about a BOOT_DEFAULT define value if it hasn't been
set
> > and we can just make it do the same as ACPI in the switch ?
>
> Sounds good to me. I'll whip that up and resubmit.
Well, how about this. Using a #define won't do as far as I can tell.
But I can reduce the size of the diff considerably like this.
Random question... why do we have a reboot_init function that does DMI
checking with reboot_dmi_table (callbacks are mostly set_bios_reboot, but
there is a single set_kbd_reboot) and also a pci_reboot_init which does
the DMI check again using a separate pci_reboot_dmi_table (all callbacks
are to set_pci_reboot)?
Wouldn't it make more sense to do a single DMI scan using one big table?
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 37a458b..0fc5b31 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -39,6 +39,14 @@ static int reboot_mode;
enum reboot_type reboot_type = BOOT_ACPI;
int reboot_force;
+/* This variable is used privately to keep track of whether or not
+ * reboot_type is still set to its default value (i.e., reboot= hasn't
+ * been set on the command line). This is needed so that we can
+ * suppress DMI scanning for reboot quirks. Without it, it's
+ * impossible to override a faulty reboot quirk without recompiling.
+ */
+static int reboot_default = 1;
+
#if defined(CONFIG_X86_32) && defined(CONFIG_SMP)
static int reboot_cpu = -1;
#endif
@@ -67,6 +75,12 @@ bool port_cf9_safe = false;
static int __init reboot_setup(char *str)
{
for (;;) {
+ /* Having anything passed on the command line via
+ * reboot= will cause us to disable DMI checking
+ * below.
+ */
+ reboot_default = 0;
+
switch (*str) {
case 'w':
reboot_mode = 0x1234;
@@ -316,7 +330,12 @@ static struct dmi_system_id __initdata
reboot_dmi_table[] = {
static int __init reboot_init(void)
{
- dmi_check_system(reboot_dmi_table);
+ /* Only do the DMI check if reboot_type hasn't been overridden
+ * on the command line
+ */
+ if (reboot_default) {
+ dmi_check_system(reboot_dmi_table);
+ }
return 0;
}
core_initcall(reboot_init);
@@ -465,7 +484,12 @@ static struct dmi_system_id __initdata
pci_reboot_dmi_table[] = {
static int __init pci_reboot_init(void)
{
- dmi_check_system(pci_reboot_dmi_table);
+ /* Only do the DMI check if reboot_type hasn't been overridden
+ * on the command line
+ */
+ if (reboot_default) {
+ dmi_check_system(pci_reboot_dmi_table);
+ }
return 0;
}
core_initcall(pci_reboot_init);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/