linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86, reboot: skip DMI checks if reboot set by user
@ 2012-01-17 15:16 Michael D Labriola
  2012-01-17 19:58 ` Alan Cox
  0 siblings, 1 reply; 11+ messages in thread
From: Michael D Labriola @ 2012-01-17 15:16 UTC (permalink / raw)
  To: Ingo Molnar, Matthew Garrett
  Cc: Michael D Labriola, H. Peter Anvin, Kushal Koolwal, linux-kernel,
	michael.d.labriola, support, Thomas Gleixner, x86

This commit causes DMI checks for vendor specific reboot
quirks to be skipped if the user passed in a reboot= arg
on the command line.

Signed-off-by: Michael D Labriola <mlabriol@gdeb.com>
---
 arch/x86/kernel/reboot.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 37a458b..4240d58 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -38,6 +38,7 @@ static const struct desc_ptr no_idt = {};
 static int reboot_mode;
 enum reboot_type reboot_type = BOOT_ACPI;
 int reboot_force;
+int reboot_user;
 
 #if defined(CONFIG_X86_32) && defined(CONFIG_SMP)
 static int reboot_cpu = -1;
@@ -70,10 +71,12 @@ static int __init reboot_setup(char *str)
                switch (*str) {
                case 'w':
                        reboot_mode = 0x1234;
+                       reboot_user = 1;
                        break;
 
                case 'c':
                        reboot_mode = 0;
+                       reboot_user = 1;
                        break;
 
 #ifdef CONFIG_X86_32
@@ -87,6 +90,7 @@ static int __init reboot_setup(char *str)
                                /* we will leave sorting out the final 
value
                                   when we are ready to reboot, since we 
might not
                                   have detected BSP APIC ID or 
smp_num_cpu */
+                       reboot_user = 1;
                        break;
 #endif /* CONFIG_SMP */
 
@@ -98,10 +102,12 @@ static int __init reboot_setup(char *str)
                case 'e':
                case 'p':
                        reboot_type = *str;
+                       reboot_user = 1;
                        break;
 
                case 'f':
                        reboot_force = 1;
+                       reboot_user = 1;
                        break;
                }
 
@@ -316,7 +322,10 @@ static struct dmi_system_id __initdata 
reboot_dmi_table[] = {
 
 static int __init reboot_init(void)
 {
-       dmi_check_system(reboot_dmi_table);
+       /* Skip the DMI check if user set reboot= on the command line */
+       if (!reboot_user) {
+               dmi_check_system(reboot_dmi_table);
+       }
        return 0;
 }
 core_initcall(reboot_init);
@@ -465,7 +474,10 @@ static struct dmi_system_id __initdata 
pci_reboot_dmi_table[] = {
 
 static int __init pci_reboot_init(void)
 {
-       dmi_check_system(pci_reboot_dmi_table);
+       /* Skip the DMI check if user set reboot= on the command line */
+       if (!reboot_user) {
+               dmi_check_system(pci_reboot_dmi_table);
+       }
        return 0;
 }
 core_initcall(pci_reboot_init);
-- 
1.6.0.3




 

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-17 15:16 [PATCH] x86, reboot: skip DMI checks if reboot set by user Michael D Labriola
@ 2012-01-17 19:58 ` Alan Cox
  2012-01-19 15:32   ` Michael D Labriola
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Cox @ 2012-01-17 19:58 UTC (permalink / raw)
  To: Michael D Labriola
  Cc: Ingo Molnar, Matthew Garrett, H. Peter Anvin, Kushal Koolwal,
	linux-kernel, michael.d.labriola, support, Thomas Gleixner, x86

On Tue, 17 Jan 2012 10:16:03 -0500
Michael D Labriola <mlabriol@gdeb.com> wrote:

> This commit causes DMI checks for vendor specific reboot
> quirks to be skipped if the user passed in a reboot= arg
> on the command line.
> 
> Signed-off-by: Michael D Labriola <mlabriol@gdeb.com>
> ---
>  arch/x86/kernel/reboot.c |   16 ++++++++++++++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
> index 37a458b..4240d58 100644
> --- a/arch/x86/kernel/reboot.c
> +++ b/arch/x86/kernel/reboot.c
> @@ -38,6 +38,7 @@ static const struct desc_ptr no_idt = {};
>  static int reboot_mode;
>  enum reboot_type reboot_type = BOOT_ACPI;
>  int reboot_force;
> +int reboot_user;

static ...

>                 case 'f':
>                         reboot_force = 1;
> +                       reboot_user = 1;

Cleaner would be to add a 

BOOT_ACPI_FORCE perhaps so you can tell ACPI v ACPI specified by user

>                         break;
>                 }
>  
> @@ -316,7 +322,10 @@ static struct dmi_system_id __initdata 
> reboot_dmi_table[] = {
>  
>  static int __init reboot_init(void)
>  {
> -       dmi_check_system(reboot_dmi_table);
> +       /* Skip the DMI check if user set reboot= on the command line */
> +       if (!reboot_user) {

then do

	if (reboot_type == BOOT_ACPI)
> +               dmi_check_system(reboot_dmi_table);
> +       }

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-17 19:58 ` Alan Cox
@ 2012-01-19 15:32   ` Michael D Labriola
  2012-01-19 15:45     ` Alan Cox
  0 siblings, 1 reply; 11+ messages in thread
From: Michael D Labriola @ 2012-01-19 15:32 UTC (permalink / raw)
  To: Alan Cox
  Cc: H. Peter Anvin, Kushal Koolwal, linux-kernel, michael.d.labriola,
	Ingo Molnar, Matthew Garrett, support, Thomas Gleixner, x86

Alan Cox <alan@lxorguk.ukuu.org.uk> wrote on 01/17/2012 02:58:41 PM:

> On Tue, 17 Jan 2012 10:16:03 -0500
> Michael D Labriola <mlabriol@gdeb.com> wrote:
> 
> > This commit causes DMI checks for vendor specific reboot
> > quirks to be skipped if the user passed in a reboot= arg
> > on the command line.
> > 
> > Signed-off-by: Michael D Labriola <mlabriol@gdeb.com>
> > ---
> >  arch/x86/kernel/reboot.c |   16 ++++++++++++++--
> >  1 files changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
> > index 37a458b..4240d58 100644
> > --- a/arch/x86/kernel/reboot.c
> > +++ b/arch/x86/kernel/reboot.c
> > @@ -38,6 +38,7 @@ static const struct desc_ptr no_idt = {};
> >  static int reboot_mode;
> >  enum reboot_type reboot_type = BOOT_ACPI;
> >  int reboot_force;
> > +int reboot_user;
> 
> static ...

Oops, good point.

> >                 case 'f':
> >                         reboot_force = 1;
> > +                       reboot_user = 1;
> 
> Cleaner would be to add a 
> 
> BOOT_ACPI_FORCE perhaps so you can tell ACPI v ACPI specified by user
> 
> >                         break;
> >                 }
> > 
> > @@ -316,7 +322,10 @@ static struct dmi_system_id __initdata 
> > reboot_dmi_table[] = {
> > 
> >  static int __init reboot_init(void)
> >  {
> > -       dmi_check_system(reboot_dmi_table);
> > +       /* Skip the DMI check if user set reboot= on the command line 
*/
> > +       if (!reboot_user) {
> 
> then do
> 
>    if (reboot_type == BOOT_ACPI)
> > +               dmi_check_system(reboot_dmi_table);
> > +       }

This seems a little less obvious to the casual observer than the way I
implemented it... but maybe that's just me.  It would indeed disable DMI
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?

I'm going to resubmit this patche anyway, as Ingo pointed out I've got
line-wrap issues.

---
Michael D Labriola
Electric Boat
mlabriol@gdeb.com
401-848-8871 (desk)
401-848-8513 (lab)
401-316-9844 (cell)


 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-19 15:32   ` Michael D Labriola
@ 2012-01-19 15:45     ` Alan Cox
  2012-01-19 15:48       ` Michael D Labriola
       [not found]       ` <OF8642E997.5ED041E1-ON8525798A.0056983A-8525798A.0056E05B@LocalDomain>
  0 siblings, 2 replies; 11+ messages in thread
From: Alan Cox @ 2012-01-19 15:45 UTC (permalink / raw)
  To: Michael D Labriola
  Cc: H. Peter Anvin, Kushal Koolwal, linux-kernel, michael.d.labriola,
	Ingo Molnar, Matthew Garrett, support, Thomas Gleixner, x86

> 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 ?

Alan

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-19 15:45     ` Alan Cox
@ 2012-01-19 15:48       ` Michael D Labriola
       [not found]       ` <OF8642E997.5ED041E1-ON8525798A.0056983A-8525798A.0056E05B@LocalDomain>
  1 sibling, 0 replies; 11+ messages in thread
From: Michael D Labriola @ 2012-01-19 15:48 UTC (permalink / raw)
  To: Alan Cox
  Cc: H. Peter Anvin, Kushal Koolwal, linux-kernel, michael.d.labriola,
	Ingo Molnar, Matthew Garrett, support, Thomas Gleixner, x86

Alan Cox <alan@lxorguk.ukuu.org.uk> 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.

---
Michael D Labriola
Electric Boat
mlabriol@gdeb.com
401-848-8871 (desk)
401-848-8513 (lab)
401-316-9844 (cell)




 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
       [not found]       ` <OF8642E997.5ED041E1-ON8525798A.0056983A-8525798A.0056E05B@LocalDomain>
@ 2012-01-19 17:46         ` Michael D Labriola
  2012-01-19 17:52           ` H. Peter Anvin
  0 siblings, 1 reply; 11+ messages in thread
From: Michael D Labriola @ 2012-01-19 17:46 UTC (permalink / raw)
  To: Michael D Labriola
  Cc: Alan Cox, H. Peter Anvin, Kushal Koolwal, linux-kernel,
	michael.d.labriola, Ingo Molnar, Matthew Garrett, support,
	Thomas Gleixner, x86

Michael D Labriola/EB/GDYN wrote on 01/19/2012 10:48:53 AM:

> Alan Cox <alan@lxorguk.ukuu.org.uk> 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);



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-19 17:46         ` Michael D Labriola
@ 2012-01-19 17:52           ` H. Peter Anvin
  2012-01-19 19:14             ` Michael D Labriola
  0 siblings, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2012-01-19 17:52 UTC (permalink / raw)
  To: Michael D Labriola
  Cc: Alan Cox, Kushal Koolwal, linux-kernel, michael.d.labriola,
	Ingo Molnar, Matthew Garrett, support, Thomas Gleixner, x86

On 01/19/2012 09:46 AM, Michael D Labriola wrote:
>
> 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?
>

Yes, and such a patch would be appreciated.

The reason it is as it is dates back to before the 32-64 bit 
unification, as far as I know.

(BIOS reboot is currently not supported on 64 bits, mainly.)

	-hpa


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-19 17:52           ` H. Peter Anvin
@ 2012-01-19 19:14             ` Michael D Labriola
  2012-01-19 19:17               ` H. Peter Anvin
  2012-01-19 19:41               ` Ingo Molnar
  0 siblings, 2 replies; 11+ messages in thread
From: Michael D Labriola @ 2012-01-19 19:14 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Alan Cox, Kushal Koolwal, linux-kernel, michael.d.labriola,
	Ingo Molnar, Matthew Garrett, support, Thomas Gleixner, x86

"H. Peter Anvin" <hpa@zytor.com> wrote on 01/19/2012 12:52:15 PM:

> On 01/19/2012 09:46 AM, Michael D Labriola wrote:
> >
> > 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?
> >
> 
> Yes, and such a patch would be appreciated.
> 
> The reason it is as it is dates back to before the 32-64 bit 
> unification, as far as I know.
> 
> (BIOS reboot is currently not supported on 64 bits, mainly.)

Well, that does complicate it a bit.  I'll gin something up and see what
you think.  I guess it will involve having an #ifdef CONFIG_X86_32 block
inside a single dmi_table structure for the BIOS quirks.

Actually, set_kbd_reboot is inside the current X86_32 only block, along
with the one DMI callback that uses it.  Is this correct?


---
Michael D Labriola
Electric Boat
mlabriol@gdeb.com
401-848-8871 (desk)
401-848-8513 (lab)
401-316-9844 (cell)


 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-19 19:14             ` Michael D Labriola
@ 2012-01-19 19:17               ` H. Peter Anvin
  2012-01-19 19:34                 ` Michael D Labriola
  2012-01-19 19:41               ` Ingo Molnar
  1 sibling, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2012-01-19 19:17 UTC (permalink / raw)
  To: Michael D Labriola
  Cc: Alan Cox, Kushal Koolwal, linux-kernel, michael.d.labriola,
	Ingo Molnar, Matthew Garrett, support, Thomas Gleixner, x86

On 01/19/2012 11:14 AM, Michael D Labriola wrote:
>>
>> Yes, and such a patch would be appreciated.
>>
>> The reason it is as it is dates back to before the 32-64 bit 
>> unification, as far as I know.
>>
>> (BIOS reboot is currently not supported on 64 bits, mainly.)
> 
> Well, that does complicate it a bit.  I'll gin something up and see what
> you think.  I guess it will involve having an #ifdef CONFIG_X86_32 block
> inside a single dmi_table structure for the BIOS quirks.
> 
> Actually, set_kbd_reboot is inside the current X86_32 only block, along
> with the one DMI callback that uses it.  Is this correct?
> 

Probably not, although I suspect most of the users of that are 32-bit
only systems.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-19 19:17               ` H. Peter Anvin
@ 2012-01-19 19:34                 ` Michael D Labriola
  0 siblings, 0 replies; 11+ messages in thread
From: Michael D Labriola @ 2012-01-19 19:34 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Alan Cox, Kushal Koolwal, linux-kernel, michael.d.labriola,
	Ingo Molnar, Matthew Garrett, support, Thomas Gleixner, x86

H. Peter Anvin" <hpa@zytor.com> wrote on 01/19/2012 02:17:54 PM:

> On 01/19/2012 11:14 AM, Michael D Labriola wrote:
> >>
> >> Yes, and such a patch would be appreciated.
> >>
> >> The reason it is as it is dates back to before the 32-64 bit 
> >> unification, as far as I know.
> >>
> >> (BIOS reboot is currently not supported on 64 bits, mainly.)
> > 
> > Well, that does complicate it a bit.  I'll gin something up and see 
what
> > you think.  I guess it will involve having an #ifdef CONFIG_X86_32 
block
> > inside a single dmi_table structure for the BIOS quirks.
> > 
> > Actually, set_kbd_reboot is inside the current X86_32 only block, 
along
> > with the one DMI callback that uses it.  Is this correct?
> > 
> 
> Probably not, although I suspect most of the users of that are 32-bit
> only systems.

How does this look?  The patch looks kinda nasty because of how much code
is getting moved around...  Basically, all I did was move the reboot_init
method and reboot_dmi_table out of the X86_32 block they were in, put the
quirks that set BIOS reboot inside an X86_32 define block, and then added
all the PCI quirks into the new, single DMI table.  I did also move the
set_kbd_reboot method out of the X86_32 block, since all the
documentation I've run into in the kernel suggests that it's valid for
X86_64 as well.

I even tested it by adding an entry to reboot_dmi_table for my machine
and verified that behavior is the same as before the reorg.

Note that this patch got generated from my test tree, so it'll have
conflicts if applied against v3.2.  I'll rebase it and weed that stuff
out if you think it's a good idea.

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index d840e69..e739737 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -150,6 +150,80 @@ static int __init set_bios_reboot(const struct 
dmi_system_id *d)
        return 0;
 }
 
+extern const unsigned char machine_real_restart_asm[];
+extern const u64 machine_real_restart_gdt[3];
+
+void machine_real_restart(unsigned int type)
+{
+       void *restart_va;
+       unsigned long restart_pa;
+       void (*restart_lowmem)(unsigned int);
+       u64 *lowmem_gdt;
+
+       local_irq_disable();
+
+       /* Write zero to CMOS register number 0x0f, which the BIOS POST
+          routine will recognize as telling it to do a proper reboot. 
(Well
+          that's what this book in front of me says -- it may only apply 
to
+          the Phoenix BIOS though, it's not clear).  At the same time,
+          disable NMIs by setting the top bit in the CMOS address 
register,
+          as we're about to do peculiar things to the CPU.  I'm not sure 
if
+          `outb_p' is needed instead of just `outb'.  Use it to be on the
+          safe side.  (Yes, CMOS_WRITE does outb_p's. -  Paul G.)
+        */
+       spin_lock(&rtc_lock);
+       CMOS_WRITE(0x00, 0x8f);
+       spin_unlock(&rtc_lock);
+
+       /*
+        * Switch back to the initial page table.
+        */
+       load_cr3(initial_page_table);
+
+       /* Write 0x1234 to absolute memory location 0x472.  The BIOS reads
+          this on booting to tell it to "Bypass memory test (also warm
+          boot)".  This seems like a fairly standard thing that gets set 
by
+          REBOOT.COM programs, and the previous reset routine did this
+          too. */
+       *((unsigned short *)0x472) = reboot_mode;
+
+       /* Patch the GDT in the low memory trampoline */
+       lowmem_gdt = TRAMPOLINE_SYM(machine_real_restart_gdt);
+
+       restart_va = TRAMPOLINE_SYM(machine_real_restart_asm);
+       restart_pa = virt_to_phys(restart_va);
+       restart_lowmem = (void (*)(unsigned int))restart_pa;
+
+       /* GDT[0]: GDT self-pointer */
+       lowmem_gdt[0] =
+               (u64)(sizeof(machine_real_restart_gdt) - 1) +
+               ((u64)virt_to_phys(lowmem_gdt) << 16);
+       /* GDT[1]: 64K real mode code segment */
+       lowmem_gdt[1] =
+               GDT_ENTRY(0x009b, restart_pa, 0xffff);
+
+       /* Jump to the identity-mapped low memory code */
+       restart_lowmem(type);
+}
+#ifdef CONFIG_APM_MODULE
+EXPORT_SYMBOL(machine_real_restart);
+#endif
+
+#endif /* CONFIG_X86_32 */
+
+/*
+ * Some Apple MacBook and MacBookPro's needs reboot=p to be able to 
reboot
+ */
+static int __init set_pci_reboot(const struct dmi_system_id *d)
+{
+       if (reboot_type != BOOT_CF9) {
+               reboot_type = BOOT_CF9;
+               printk(KERN_INFO "%s series board detected. "
+                      "Selecting PCI-method for reboots.\n", d->ident);
+       }
+       return 0;
+}
+
 static int __init set_kbd_reboot(const struct dmi_system_id *d)
 {
        if (reboot_type != BOOT_KBD) {
@@ -159,7 +233,11 @@ static int __init set_kbd_reboot(const struct 
dmi_system_id *d)
        return 0;
 }
 
+/* This is a single dmi_table handling all reboot quirks.  Note that
+ * REBOOT_BIOS is only available for 32bit
+ */
 static struct dmi_system_id __initdata reboot_dmi_table[] = {
+#ifdef CONFIG_X86_32
        {       /* Handle problems with rebooting on Dell E520's */
                .callback = set_bios_reboot,
                .ident = "Dell E520",
@@ -309,6 +387,8 @@ static struct dmi_system_id __initdata 
reboot_dmi_table[] = {
                        DMI_MATCH(DMI_BOARD_NAME, "P4S800"),
                },
        },
+#endif /* CONFIG_X86_32 */
+
        { /* Handle reboot issue on Acer Aspire one */
                .callback = set_kbd_reboot,
                .ident = "Acer Aspire One A110",
@@ -317,96 +397,6 @@ static struct dmi_system_id __initdata 
reboot_dmi_table[] = {
                        DMI_MATCH(DMI_PRODUCT_NAME, "AOA110"),
                },
        },
-       { }
-};
-
-static int __init reboot_init(void)
-{
-       /* 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);
-
-extern const unsigned char machine_real_restart_asm[];
-extern const u64 machine_real_restart_gdt[3];
-
-void machine_real_restart(unsigned int type)
-{
-       void *restart_va;
-       unsigned long restart_pa;
-       void (*restart_lowmem)(unsigned int);
-       u64 *lowmem_gdt;
-
-       local_irq_disable();
-
-       /* Write zero to CMOS register number 0x0f, which the BIOS POST
-          routine will recognize as telling it to do a proper reboot. 
(Well
-          that's what this book in front of me says -- it may only apply 
to
-          the Phoenix BIOS though, it's not clear).  At the same time,
-          disable NMIs by setting the top bit in the CMOS address 
register,
-          as we're about to do peculiar things to the CPU.  I'm not sure 
if
-          `outb_p' is needed instead of just `outb'.  Use it to be on the
-          safe side.  (Yes, CMOS_WRITE does outb_p's. -  Paul G.)
-        */
-       spin_lock(&rtc_lock);
-       CMOS_WRITE(0x00, 0x8f);
-       spin_unlock(&rtc_lock);
-
-       /*
-        * Switch back to the initial page table.
-        */
-       load_cr3(initial_page_table);
-
-       /* Write 0x1234 to absolute memory location 0x472.  The BIOS reads
-          this on booting to tell it to "Bypass memory test (also warm
-          boot)".  This seems like a fairly standard thing that gets set 
by
-          REBOOT.COM programs, and the previous reset routine did this
-          too. */
-       *((unsigned short *)0x472) = reboot_mode;
-
-       /* Patch the GDT in the low memory trampoline */
-       lowmem_gdt = TRAMPOLINE_SYM(machine_real_restart_gdt);
-
-       restart_va = TRAMPOLINE_SYM(machine_real_restart_asm);
-       restart_pa = virt_to_phys(restart_va);
-       restart_lowmem = (void (*)(unsigned int))restart_pa;
-
-       /* GDT[0]: GDT self-pointer */
-       lowmem_gdt[0] =
-               (u64)(sizeof(machine_real_restart_gdt) - 1) +
-               ((u64)virt_to_phys(lowmem_gdt) << 16);
-       /* GDT[1]: 64K real mode code segment */
-       lowmem_gdt[1] =
-               GDT_ENTRY(0x009b, restart_pa, 0xffff);
-
-       /* Jump to the identity-mapped low memory code */
-       restart_lowmem(type);
-}
-#ifdef CONFIG_APM_MODULE
-EXPORT_SYMBOL(machine_real_restart);
-#endif
-
-#endif /* CONFIG_X86_32 */
-
-/*
- * Some Apple MacBook and MacBookPro's needs reboot=p to be able to 
reboot
- */
-static int __init set_pci_reboot(const struct dmi_system_id *d)
-{
-       if (reboot_type != BOOT_CF9) {
-               reboot_type = BOOT_CF9;
-               printk(KERN_INFO "%s series board detected. "
-                      "Selecting PCI-method for reboots.\n", d->ident);
-       }
-       return 0;
-}
-
-static struct dmi_system_id __initdata pci_reboot_dmi_table[] = {
        {       /* Handle problems with rebooting on Apple MacBook5 */
                .callback = set_pci_reboot,
                .ident = "Apple MacBook5",
@@ -474,17 +464,17 @@ static struct dmi_system_id __initdata 
pci_reboot_dmi_table[] = {
        { }
 };
 
-static int __init pci_reboot_init(void)
+static int __init reboot_init(void)
 {
        /* 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);
+               dmi_check_system(reboot_dmi_table);
        }
        return 0;
 }
-core_initcall(pci_reboot_init);
+core_initcall(reboot_init);
 
 static inline void kb_wait(void)
 {




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86, reboot: skip DMI checks if reboot set by user
  2012-01-19 19:14             ` Michael D Labriola
  2012-01-19 19:17               ` H. Peter Anvin
@ 2012-01-19 19:41               ` Ingo Molnar
  1 sibling, 0 replies; 11+ messages in thread
From: Ingo Molnar @ 2012-01-19 19:41 UTC (permalink / raw)
  To: Michael D Labriola
  Cc: H. Peter Anvin, Alan Cox, Kushal Koolwal, linux-kernel,
	michael.d.labriola, Matthew Garrett, support, Thomas Gleixner,
	x86


* Michael D Labriola <mlabriol@gdeb.com> wrote:

> > Yes, and such a patch would be appreciated.
> > 
> > The reason it is as it is dates back to before the 32-64 bit 
> > unification, as far as I know.
> > 
> > (BIOS reboot is currently not supported on 64 bits, mainly.)
> 
> Well, that does complicate it a bit.  I'll gin something up 
> and see what you think.  I guess it will involve having an
> #ifdef CONFIG_X86_32 block inside a single dmi_table structure
> for the BIOS quirks.

Btw., i'd suggest to keep the two changes in separate patches, 
so that if any causes problems we can bisect to it separately. 
The more patches you can reasonably split it up into, the 
better.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-01-19 19:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-17 15:16 [PATCH] x86, reboot: skip DMI checks if reboot set by user Michael D Labriola
2012-01-17 19:58 ` Alan Cox
2012-01-19 15:32   ` Michael D Labriola
2012-01-19 15:45     ` Alan Cox
2012-01-19 15:48       ` Michael D Labriola
     [not found]       ` <OF8642E997.5ED041E1-ON8525798A.0056983A-8525798A.0056E05B@LocalDomain>
2012-01-19 17:46         ` Michael D Labriola
2012-01-19 17:52           ` H. Peter Anvin
2012-01-19 19:14             ` Michael D Labriola
2012-01-19 19:17               ` H. Peter Anvin
2012-01-19 19:34                 ` Michael D Labriola
2012-01-19 19:41               ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).