Skip to contentSkip to conversation

software reset

DISCUSSION Andi Kleen 6 participants 10 messages Apr 29, 2003 – Apr 30, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 200304291037.13598.jbriggs@briggsmedia.com.suse.lists.linux.kernel

Andi Kleen

author
#1 lore raw
Quoted 7 lines · joe briggs

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)); 
} 
#2 lore raw
Quoted 4 lines · Andi Kleen

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

#3 lore raw
Quoted 9 lines · Jamie Lokier
Quoted 4 lines · Andi Kleen

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

#4 lore raw
Quoted 8 lines · Eric W. Biederman

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

#5 lore raw
Quoted 7 lines · Gabriel Paubert
Quoted 6 lines · Eric W. Biederman

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.

Quoted 5 lines
Quoted 2 lines

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

#6 lore raw
Quoted 12 lines · Eric W. Biederman
Quoted 10 lines · Gabriel Paubert
Quoted 8 lines · Eric W. Biederman

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.

Quoted 7 lines
Quoted 2 lines

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

#7 lore raw
In reply to Eric W. Biederman
Quoted 7 lines · Eric W. Biederman
Quoted 7 lines · Eric W. Biederman
Quoted 6 lines

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.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

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

#8 lore raw
In reply to Andi Kleen

Hi,

	Just a doubt...

	#define MODULE 1
	#define __KERNEL__ 1

	What are those for? What do they do?
Quoted 36 lines · Andi Kleen
Quoted 7 lines · joe briggs

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)); 
} 
Quoted 7 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
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 [email protected]
+ 55 21 9432-9266

author
#9 lore raw
Quoted 4 lines · Rafael Santos
	#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

#10 lore raw
In reply to Andi Kleen
Followup to:  <[email protected]>
By author:    Andi Kleen <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 11 lines
Quoted 7 lines · joe briggs

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.

Quoted 5 lines

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

Signature · 3 lines
<[email protected]> at work, <[email protected]> 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