linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: software reset
       [not found] <200304291037.13598.jbriggs@briggsmedia.com.suse.lists.linux.kernel>
@ 2003-04-29 15:19 ` Andi Kleen
  2003-04-30  7:50   ` Jamie Lokier
                     ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Andi Kleen @ 2003-04-29 15:19 UTC (permalink / raw)
  To: joe briggs; +Cc: linux-kernel

joe briggs <jbriggs@briggsmedia.com> writes:

> Can anyone tell me how to absolutely force a reset on a i386?  Specifically, 
> is there a system call that will call the assembly instruction to assert the 
> RESET bus line? I try to use the "reboot(LINUX_REBOOT_CMD_RESTART,0,0,NULL)" 
> call, but it will not always work.  Occassionally, I experience a "missed 
> interrupt" on a Promise IDE controller, and while I can telnet into the 
> system, I can't reset it.  Any help greatly appreciated!  Since these systems 
> are 1000's of miles away, the need to remotely reset it paramont.

The most reliable way is to force a triple fault; load zero into
the IDT register and then trigger an exception. The linux kernel 
does that in fact for reboot and so far I haven't seen any machine failing
to reset yet.

-Andi

If you don't trust reboot you can use something like (untested!).
Compile with -c and load with insmod. I'm pretty sure it will reset
your box.

#define MODULE 1
#define __KERNEL__ 1
#include <linux/module.h>

int init_module(void)
{ 
        static struct { 
                short limit;
                unsigned ptr;
        } desc = { 64000, 0 }; 

        asm volatile("lidt %0" : "m" (desc)); 
        asm volatile("movl %0,%%esp ; int $3" : "g" (0)); 
} 


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

* Re: software reset
  2003-04-29 15:19 ` software reset Andi Kleen
@ 2003-04-30  7:50   ` Jamie Lokier
  2003-04-30 11:04     ` Eric W. Biederman
  2003-04-30 23:00   ` Rafael Santos
  2003-04-30 23:20   ` H. Peter Anvin
  2 siblings, 1 reply; 13+ messages in thread
From: Jamie Lokier @ 2003-04-30  7:50 UTC (permalink / raw)
  To: Andi Kleen; +Cc: joe briggs, linux-kernel

Andi Kleen wrote:
> The most reliable way is to force a triple fault; load zero into
> the IDT register and then trigger an exception. The linux kernel 
> does that in fact for reboot and so far I haven't seen any machine failing
> to reset yet.

There are some 486s which don't boot on triple fault, nor on asking
the keyboard controller to pulse the reset line.  Hence the 3rd option,
"reboot=bios".

-- Jamie

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

* Re: software reset
  2003-04-30  7:50   ` Jamie Lokier
@ 2003-04-30 11:04     ` Eric W. Biederman
  2003-04-30 16:15       ` Gabriel Paubert
  0 siblings, 1 reply; 13+ messages in thread
From: Eric W. Biederman @ 2003-04-30 11:04 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Andi Kleen, joe briggs, linux-kernel

Jamie Lokier <jamie@shareable.org> writes:

> Andi Kleen wrote:
> > The most reliable way is to force a triple fault; load zero into
> > the IDT register and then trigger an exception. The linux kernel 
> > does that in fact for reboot and so far I haven't seen any machine failing
> > to reset yet.
> 
> There are some 486s which don't boot on triple fault, nor on asking
> the keyboard controller to pulse the reset line.  Hence the 3rd option,
> "reboot=bios".

And as an interesting data point all a triple fault does on a modern
system is to put the cpu in a weird stopped state.  Some hardware
usually the southbridge then detects this and if properly configured
will trigger the reset line.

I believe this may actually go back into history as far as the 486 but
I have not done the researched to see how far back this behavior goes.

Eric

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

* Re: software reset
  2003-04-30 11:04     ` Eric W. Biederman
@ 2003-04-30 16:15       ` Gabriel Paubert
  2003-04-30 17:02         ` Eric W. Biederman
  0 siblings, 1 reply; 13+ messages in thread
From: Gabriel Paubert @ 2003-04-30 16:15 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Jamie Lokier, Andi Kleen, joe briggs, linux-kernel

On Wed, Apr 30, 2003 at 05:04:59AM -0600, Eric W. Biederman wrote:
> 
> And as an interesting data point all a triple fault does on a modern
> system is to put the cpu in a weird stopped state.  Some hardware
> usually the southbridge then detects this and if properly configured
> will trigger the reset line.
> 
> I believe this may actually go back into history as far as the 486 but
> I have not done the researched to see how far back this behavior goes.

Try 286. It was the fastest (actually only) way to make a 286 switch back
from protected to real mode.

	Gabriel

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

* Re: software reset
  2003-04-30 16:15       ` Gabriel Paubert
@ 2003-04-30 17:02         ` Eric W. Biederman
  2003-04-30 17:19           ` Gabriel Paubert
  2003-04-30 19:31           ` Jamie Lokier
  0 siblings, 2 replies; 13+ messages in thread
From: Eric W. Biederman @ 2003-04-30 17:02 UTC (permalink / raw)
  To: Gabriel Paubert; +Cc: Jamie Lokier, Andi Kleen, joe briggs, linux-kernel

Gabriel Paubert <paubert@iram.es> writes:

> On Wed, Apr 30, 2003 at 05:04:59AM -0600, Eric W. Biederman wrote:
> > 
> > And as an interesting data point all a triple fault does on a modern
> > system is to put the cpu in a weird stopped state.  Some hardware
> > usually the southbridge then detects this and if properly configured
> > will trigger the reset line.
> > 
> > I believe this may actually go back into history as far as the 486 but
> > I have not done the researched to see how far back this behavior goes.
> 
> Try 286. It was the fastest (actually only) way to make a 286 switch back
> from protected to real mode.

A triple fault would put a 286 into coma mode?  And the hardware had to
reset the chip?

Just trying to be clear on what you are saying.

Eric

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

* Re: software reset
  2003-04-30 17:02         ` Eric W. Biederman
@ 2003-04-30 17:19           ` Gabriel Paubert
  2003-04-30 19:31           ` Jamie Lokier
  1 sibling, 0 replies; 13+ messages in thread
From: Gabriel Paubert @ 2003-04-30 17:19 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Jamie Lokier, Andi Kleen, joe briggs, linux-kernel

On Wed, Apr 30, 2003 at 11:02:41AM -0600, Eric W. Biederman wrote:
> Gabriel Paubert <paubert@iram.es> writes:
> 
> > On Wed, Apr 30, 2003 at 05:04:59AM -0600, Eric W. Biederman wrote:
> > > 
> > > And as an interesting data point all a triple fault does on a modern
> > > system is to put the cpu in a weird stopped state.  Some hardware
> > > usually the southbridge then detects this and if properly configured
> > > will trigger the reset line.
> > > 
> > > I believe this may actually go back into history as far as the 486 but
> > > I have not done the researched to see how far back this behavior goes.
> > 
> > Try 286. It was the fastest (actually only) way to make a 286 switch back
> > from protected to real mode.
> 
> A triple fault would put a 286 into coma mode?  And the hardware had to
> reset the chip?
> 
> Just trying to be clear on what you are saying.

Yes, that's at least what I remember. 

	Gabriel

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

* Re: software reset
  2003-04-30 17:02         ` Eric W. Biederman
  2003-04-30 17:19           ` Gabriel Paubert
@ 2003-04-30 19:31           ` Jamie Lokier
  1 sibling, 0 replies; 13+ messages in thread
From: Jamie Lokier @ 2003-04-30 19:31 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Gabriel Paubert, Andi Kleen, joe briggs, linux-kernel

Eric W. Biederman wrote:
> > On Wed, Apr 30, 2003 at 05:04:59AM -0600, Eric W. Biederman wrote:
> > > 
> > > And as an interesting data point all a triple fault does on a modern
> > > system is to put the cpu in a weird stopped state.  Some hardware
> > > usually the southbridge then detects this and if properly configured
> > > will trigger the reset line.
> > > 
> > > I believe this may actually go back into history as far as the 486 but
> > > I have not done the researched to see how far back this behavior goes.
> > 
> > Try 286. It was the fastest (actually only) way to make a 286 switch back
> > from protected to real mode.
> 
> A triple fault would put a 286 into coma mode?  And the hardware had to
> reset the chip?

And then, after the reset, a flag would tell the BIOS to jump directly
to application's real mode code instead of booting as usual.

-- Jamie

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

* Re: software reset
  2003-04-29 15:19 ` software reset Andi Kleen
  2003-04-30  7:50   ` Jamie Lokier
@ 2003-04-30 23:00   ` Rafael Santos
  2003-04-30 23:14     ` Andi Kleen
  2003-04-30 23:20   ` H. Peter Anvin
  2 siblings, 1 reply; 13+ messages in thread
From: Rafael Santos @ 2003-04-30 23:00 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1877 bytes --]

Hi,

	Just a doubt...

	#define MODULE 1
	#define __KERNEL__ 1

	What are those for? What do they do?



4/29/03 12:19:51 PM, Andi Kleen <ak@suse.de> wrote:

>joe briggs <jbriggs@briggsmedia.com> writes:
>
>> Can anyone tell me how to absolutely force a reset on a i386?  Specifically, 
>> is there a system call that will call the assembly instruction to assert the 
>> RESET bus line? I try to use the "reboot(LINUX_REBOOT_CMD_RESTART,0,0,NULL)" 
>> call, but it will not always work.  Occassionally, I experience a "missed 
>> interrupt" on a Promise IDE controller, and while I can telnet into the 
>> system, I can't reset it.  Any help greatly appreciated!  Since these systems 
>> are 1000's of miles away, the need to remotely reset it paramont.
>
>The most reliable way is to force a triple fault; load zero into
>the IDT register and then trigger an exception. The linux kernel 
>does that in fact for reboot and so far I haven't seen any machine failing
>to reset yet.
>
>-Andi
>
>If you don't trust reboot you can use something like (untested!).
>Compile with -c and load with insmod. I'm pretty sure it will reset
>your box.
>
>#define MODULE 1
>#define __KERNEL__ 1
>#include <linux/module.h>
>
>int init_module(void)
>{ 
>        static struct { 
>                short limit;
>                unsigned ptr;
>        } desc = { 64000, 0 }; 
>
>        asm volatile("lidt %0" : "m" (desc)); 
>        asm volatile("movl %0,%%esp ; int $3" : "g" (0)); 
>} 
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/
>
>
Rafael Costa dos Santos
ThinkFreak Comércio e Soluções em Hardware e Software
Rio de Janeiro / RJ / Brazil
rafael@thinkfreak.com.br
+ 55 21 9432-9266



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

* Re: software reset
  2003-04-30 23:00   ` Rafael Santos
@ 2003-04-30 23:14     ` Andi Kleen
  0 siblings, 0 replies; 13+ messages in thread
From: Andi Kleen @ 2003-04-30 23:14 UTC (permalink / raw)
  To: Rafael Santos; +Cc: Andi Kleen, linux-kernel

On Wed, Apr 30, 2003 at 08:00:02PM -0300, Rafael Santos wrote:
> 	#define MODULE 1
> 	#define __KERNEL__ 1
> 
> 	What are those for? What do they do?

Required for the kernel include files. __KERNEL__ says it's a kernel
compilation and MODULE says it's a module.

Normally they are declared in the kernel makefiles, but for custom
modules with a makefile I tend to write them as defines for convenience.

In 2.5 you'll also need KBUILD_MODNAME

-Andi

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

* Re: software reset
  2003-04-29 15:19 ` software reset Andi Kleen
  2003-04-30  7:50   ` Jamie Lokier
  2003-04-30 23:00   ` Rafael Santos
@ 2003-04-30 23:20   ` H. Peter Anvin
  2 siblings, 0 replies; 13+ messages in thread
From: H. Peter Anvin @ 2003-04-30 23:20 UTC (permalink / raw)
  To: linux-kernel

Followup to:  <p73vfwx2uw8.fsf@oldwotan.suse.de>
By author:    Andi Kleen <ak@suse.de>
In newsgroup: linux.dev.kernel
>
> joe briggs <jbriggs@briggsmedia.com> writes:
> 
> > Can anyone tell me how to absolutely force a reset on a i386?  Specifically, 
> > is there a system call that will call the assembly instruction to assert the 
> > RESET bus line? I try to use the "reboot(LINUX_REBOOT_CMD_RESTART,0,0,NULL)" 
> > call, but it will not always work.  Occassionally, I experience a "missed 
> > interrupt" on a Promise IDE controller, and while I can telnet into the 
> > system, I can't reset it.  Any help greatly appreciated!  Since these systems 
> > are 1000's of miles away, the need to remotely reset it paramont.
> 
> The most reliable way is to force a triple fault; load zero into
> the IDT register and then trigger an exception. The linux kernel 
> does that in fact for reboot and so far I haven't seen any machine failing
> to reset yet.
> 

Except that isn't actually a reset -- it's an INIT, which isn't quite
the same thing; for one thing, the hardware isn't forcibly reset.

On *MOST*, but definitely not ALL, chipsets you can force a "true"
reset by writing 0x06 to I/O port 0x0CF9.

	-hpa
-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64

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

* RE: software reset
@ 2003-05-07  6:55 Perez-Gonzalez, Inaky
  0 siblings, 0 replies; 13+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-05-07  6:55 UTC (permalink / raw)
  To: 'James Stevenson', 'joe briggs'
  Cc: 'linux-kernel@vger.kernel.org'


> From: James Stevenson [mailto:james@stev.org]
>
> 1 way to get a garentee reboot is to use a 2nd computer a parrell port
> and a resistor + relay and get the relay to short the reset pins
> on the MB of the machine you wish to reboot.
> 
> You could set this up to reboot up 2 8 machine usign cheap hardware
> like a 486 or something.

Or you can always resort to a meatware solution ... scalable to
as many machines as you want [supposing you provide displacement
means if the distances grow too high ] :)

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)

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

* Re: software reset
  2003-04-29 14:37 joe briggs
@ 2003-04-30 23:12 ` James Stevenson
  0 siblings, 0 replies; 13+ messages in thread
From: James Stevenson @ 2003-04-30 23:12 UTC (permalink / raw)
  To: joe briggs; +Cc: linux-kernel

Hi

1 way to get a garentee reboot is to use a 2nd computer a parrell port
and a resistor + relay and get the relay to short the reset pins
on the MB of the machine you wish to reboot.

You could set this up to reboot up 2 8 machine usign cheap hardware
like a 486 or something.

On Tue, 2003-04-29 at 15:37, joe briggs wrote:
> Can anyone tell me how to absolutely force a reset on a i386?  Specifically, 
> is there a system call that will call the assembly instruction to assert the 
> RESET bus line? I try to use the "reboot(LINUX_REBOOT_CMD_RESTART,0,0,NULL)" 
> call, but it will not always work.  Occassionally, I experience a "missed 
> interrupt" on a Promise IDE controller, and while I can telnet into the 
> system, I can't reset it.  Any help greatly appreciated!  Since these systems 
> are 1000's of miles away, the need to remotely reset it paramont.
> 
> 
> -- 
> Joe Briggs
> Briggs Media Systems
> 105 Burnsen Ave.
> Manchester NH 01304 USA
> TEL/FAX 603-232-3115 MOBILE 603-493-2386
> www.briggsmedia.com
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/




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

* software reset
@ 2003-04-29 14:37 joe briggs
  2003-04-30 23:12 ` James Stevenson
  0 siblings, 1 reply; 13+ messages in thread
From: joe briggs @ 2003-04-29 14:37 UTC (permalink / raw)
  To: linux-kernel

Can anyone tell me how to absolutely force a reset on a i386?  Specifically, 
is there a system call that will call the assembly instruction to assert the 
RESET bus line? I try to use the "reboot(LINUX_REBOOT_CMD_RESTART,0,0,NULL)" 
call, but it will not always work.  Occassionally, I experience a "missed 
interrupt" on a Promise IDE controller, and while I can telnet into the 
system, I can't reset it.  Any help greatly appreciated!  Since these systems 
are 1000's of miles away, the need to remotely reset it paramont.


-- 
Joe Briggs
Briggs Media Systems
105 Burnsen Ave.
Manchester NH 01304 USA
TEL/FAX 603-232-3115 MOBILE 603-493-2386
www.briggsmedia.com

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

end of thread, other threads:[~2003-05-07  6:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200304291037.13598.jbriggs@briggsmedia.com.suse.lists.linux.kernel>
2003-04-29 15:19 ` software reset Andi Kleen
2003-04-30  7:50   ` Jamie Lokier
2003-04-30 11:04     ` Eric W. Biederman
2003-04-30 16:15       ` Gabriel Paubert
2003-04-30 17:02         ` Eric W. Biederman
2003-04-30 17:19           ` Gabriel Paubert
2003-04-30 19:31           ` Jamie Lokier
2003-04-30 23:00   ` Rafael Santos
2003-04-30 23:14     ` Andi Kleen
2003-04-30 23:20   ` H. Peter Anvin
2003-05-07  6:55 Perez-Gonzalez, Inaky
  -- strict thread matches above, loose matches on Subject: below --
2003-04-29 14:37 joe briggs
2003-04-30 23:12 ` James Stevenson

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).