LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-14-2012, 07:57 AM   #1
tbodine88
LQ Newbie
 
Registered: Dec 2011
Posts: 14

Rep: Reputation: Disabled
testing the seven ways to reboot


I have a new to me machine. I'd like to find out if its capable of rebooting using all seven methods of rebooting. I know I can simply use the reboot=? command in the kernel command line in grub or lilo.
When I peruse the kernel source I see that native_machine_emergency_restart will try my selection, but if that fails it will try something else until it succeeds or loops forever.

I'd like a to write a test utility that would write a line to a log file and then try reboot method x, if it was still running after trying this method it would simply exit with and error code.

I was able to do the keyboard method, PCIreset method, but when I try the triple fault method, instead of rebooting I get a segmentation fault. I think this is because my program isn't running in ring zero.

Since I feel certain I will encounter the same difficulties as I progress further I was wondering If I could get some direction on how to accomplish this task.

here is the code for triple fault
Quote:
#include <unistd.h>
#include <stdio.h>
#include <sys/io.h>

static inline void lidt(int *p, int size) {
volatile unsigned short pd[3];

pd[0] = sizeof(int);
pd[1] = (unsigned short )p;
pd[2] = (unsigned short )p >> 16;

asm volatile("lidt (%0)" : : "r" (pd));
} /* end lidt */

int main ( int argc, char *argv[] ) {
int zero = 0;
/* asm("movl 0x0, %eax
lidt %eax
int 0x1" );
*/
lidt( &zero , sizeof( zero) );
__asm__ ( "int $0x00");
} /* end main */
regards Tom Bodine
 
Old 08-15-2012, 03:43 PM   #2
tbodine88
LQ Newbie
 
Registered: Dec 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
Getting triple fault to happen

Create a module, duh.
Make File
Quote:
obj-m := tripleFault.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
tripleFault.c
Quote:
#include <linux/module.h>
#define KERN_EMERG "<0>" /* system is unusable */
#define KERN_ALERT "<1>" /* action must be taken immediately */
#define KERN_CRIT "<2>" /* critical conditions */
#define KERN_ERR "<3>" /* error conditions */
#define KERN_WARNING "<4>" /* warning conditions */
#define KERN_NOTICE "<5>" /* normal but significant condition */
#define KERN_INFO "<6>" /* informational */
#define KERN_DEBUG "<7>" /* debug-level messages */

static inline void lidt(int *p, int size) {
volatile unsigned short pd[3];
pd[0] = sizeof(int);
pd[1] = (unsigned short )p;
pd[2] = (unsigned short )p >> 16;

asm volatile("lidt (%0)" : : "r" (pd));
} /* end lidt */

int init_module(void) { printk( KERN_ALERT "triple fault module loaded\n"); return 0; } /* end init_module */
void cleanup_module(void) {
int zero = 0;
/* asm("movl 0x0, %eax
lidt %eax
int 0x1" );
*/
printk( KERN_ALERT "Triple fault module, causing triple fault\n");
lidt( &zero , sizeof( zero) );
__asm__ ( "int $0x00");
return ;
} /* end cleanup_module */

Thanks for all the help
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Debian Testing problem with reboot/shutdown Xgamer7 Linux - Desktop 3 06-15-2011 04:34 AM
[SOLVED] Debian testing: RAID 1 with 2 disks starts degraded after each reboot from 3rd disk. kalujny Linux - Newbie 1 06-21-2010 01:24 AM
LXer: 15 Ways Nokia’s N900 Is Better Than Apple’s iPhone (and 5 ways it’s not) LXer Syndicated Linux News 0 11-14-2009 08:20 AM
Replace 'etch' with 'testing' in /etc/apt/sources.list to track 'testing' branch? Akhran Debian 3 04-09-2007 10:45 AM
Setup as getting debian testing files from ftp - will it stay with testing BrianHenderson Debian 2 09-02-2004 06:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration