Skip to contentSkip to conversation

Experimental IDE oops dumper v0.1

PATCH In review Rusty Russell 6 participants 13 messages Sep 16, 2002 – Sep 18, 2002 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Experimental IDE oops dumper v0.1

Been on my TODO list for a while, finally got around to polishing it off. Some work still to do before it can be included, but you get the idea.

Rusty.

Quoted 1 line

From oopser-0.1/MOTIVATION:

The aim of this software is to make reporting kernel oopses possible for inexperienced users, in a way which doesn't violate their privacy by sending out information without their knowledge. The days of ever Linux user being able to set up a serial console have long gone.

The hope is that significant feedback will allow statistical analysis of hardware and software combinations, making the Linux Kernel more stable. Since most Linux users are on x86, with IDE disks, this is the first aim of the oops dumper.

*Any* crashes are bad, but users tend to ignore a once-a-month lockup (eg. panic while in X). Hopefully this code will allow some of those bug reports to make it back to us.

I hope that distribution vendors will pick this up, perhaps arming the module after noticing an unclean filesystem at boot (it does, after all, take about 60k to hold the compressed kernel symbols). I also ask that they coordinate with the Oops Team to arrange for a single public anonomyzed database where users and coders can query for problems.

Cheers!
Rusty.
Sep 16 2002.

================
Name: IDE Oops Dumper for x86
Author: Rusty Russell
Status: Tested on 2.5.34 i386 SMP

D: This is an experimental IDE oops dumper for 2.5. To test it you
D: will need the userspace utilities from:
D: http://www.kernel.org/pub/linux/kernel/people/rusty/oopser-0.1.tar.gz

arch/i386/kernel/i386_ksyms.c +1 -0
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.34/arch/i386/kernel/i386_ksyms.c working-2.5.34-oopser/arch/i386/kernel/i386_ksyms.c
@@ -172,3 +172,4 @@ extern int is_sony_vaio_laptop;
 EXPORT_SYMBOL(is_sony_vaio_laptop);
 
 EXPORT_SYMBOL(__PAGE_KERNEL);
+EXPORT_SYMBOL(oops_handler);
arch/i386/kernel/traps.c +10 -0
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.34/arch/i386/kernel/traps.c working-2.5.34-oopser/arch/i386/kernel/traps.c
@@ -90,6 +90,7 @@ asmlinkage void machine_check(void);
 
 static int kstack_depth_to_print = 24;
 
+int (*oops_handler)(const char *str, struct pt_regs *regs, long err);
 
 /*
  * If the address is either in the .text section of the
@@ -279,6 +280,15 @@ spinlock_t die_lock = SPIN_LOCK_UNLOCKED
 
 void die(const char * str, struct pt_regs * regs, long err)
 {
+	if (oops_handler) {
+		int ret;
+		local_irq_disable();
+		ret = oops_handler(str, regs, err);
+		local_irq_enable();
+		/* They had an oops handler, but it failed.  Get word out */
+		if (ret != 0)
+			printk(KERN_EMERG "Oops handler failed: %i\n", ret);
+	}
 	console_verbose();
 	spin_lock_irq(&die_lock);
 	bust_spinlocks(1);
drivers/char/Config.in +2 -0
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.34/drivers/char/Config.in working-2.5.34-oopser/drivers/char/Config.in
@@ -206,4 +206,6 @@ fi
 
 tristate '  RAW driver (/dev/raw/rawN)' CONFIG_RAW_DRIVER
 
+dep_tristate '/dev/oopser support (EXPERIMENTAL)' CONFIG_OOPSER $CONFIG_EXPERIMENTAL
+
 endmenu
drivers/char/Makefile +1 -0
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.34/drivers/char/Makefile working-2.5.34-oopser/drivers/char/Makefile
@@ -99,6 +99,7 @@ obj-$(CONFIG_MWAVE) += mwave/
 obj-$(CONFIG_AGP) += agp/
 obj-$(CONFIG_DRM) += drm/
 obj-$(CONFIG_PCMCIA) += pcmcia/
+obj-$(CONFIG_OOPSER) += oopser/
 
 include $(TOPDIR)/Rules.make
 
drivers/char/oopser/Makefile +28 -0
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.34/drivers/char/oopser/Makefile working-2.5.34-oopser/drivers/char/oopser/Makefile
@@ -0,0 +1,28 @@
+#
+# Makefile for /dev/oopser support.
+#
+list-multi := oopser_dev.o
+
+obj-$(CONFIG_OOPSER) += oopser_dev.o
+
+oopser_dev-objs-y = interface.o dumper.o
+oopser_dev-objs-$(CONFIG_X86) += dumper_x86_ide.o regs_x86.o
+
+include $(TOPDIR)/Rules.make
+
+# Check that external references do not slip into dumper core.
+oopser_dev-leaf := dumper_x86_ide.o regs_x86.o dumper.o
+oopser_dev_ALLOWED := tainted|log_buf|log_end
+
+oopser_dev-check: $(oopser_dev-leaf)
+	@for f in $(oopser_dev-leaf); do				     \
+	    for sym in `nm $$f|fgrep ' U '|sed 's/.* U //'|grep -vwE '$(oopser_dev_ALLOWED)'`; \
+	    do								     \
+		if nm $(oopser_dev-leaf)|grep -q " [TD] $$sym\$$"; then :;   \
+		else echo $$f:1:References symbol $$sym|sed 's/.o:/.c:/'>&2; \
+	        fi;							     \
+	    done;							     \
+	done; true
+
+oopser_dev.o: $(oopser_dev-objs-y) #oopser_dev-check
+	$(LD) $(LD_RFLAG) -r -o $@ $(oopser_dev-objs-y)
drivers/char/oopser/decode-table.c +67 -0

67 lines not on this page · raw message

drivers/char/oopser/dumper.c +208 -0

208 lines not on this page · raw message

drivers/char/oopser/dumper_x86_ide.c +134 -0

134 lines not on this page · raw message

drivers/char/oopser/interface.c +244 -0

244 lines not on this page · raw message

drivers/char/oopser/oopser_priv.h +106 -0

106 lines not on this page · raw message

drivers/char/oopser/regs_x86.c +119 -0

119 lines not on this page · raw message

include/linux/kernel.h +2 -0
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.34/include/linux/kernel.h working-2.5.34-oopser/include/linux/kernel.h
@@ -87,6 +87,8 @@ static inline void console_verbose(void)
 		console_loglevel = 15;
 }
 
+struct pt_regs;
+extern int (*oops_handler)(const char *str, struct pt_regs *regs, long err);
 extern void bust_spinlocks(int yes);
 extern int oops_in_progress;		/* If set, an oops, panic(), BUG() or die() is in progress */
 
include/linux/oopser.h +55 -0

55 lines not on this page · raw message

kernel/ksyms.c +2 -0
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.34/kernel/ksyms.c working-2.5.34-oopser/kernel/ksyms.c
@@ -601,3 +601,5 @@ EXPORT_SYMBOL(pidhash);
 #if defined(CONFIG_SMP) && defined(__GENERIC_PER_CPU)
 EXPORT_SYMBOL(__per_cpu_offset);
 #endif
+
+EXPORT_SYMBOL_GPL(tainted);
kernel/printk.c +5 -2
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.34/kernel/printk.c working-2.5.34-oopser/kernel/printk.c
@@ -78,7 +78,7 @@ struct console *console_drivers;
  */
 static spinlock_t logbuf_lock = SPIN_LOCK_UNLOCKED;
 
-static char log_buf[LOG_BUF_LEN];
+char log_buf[LOG_BUF_LEN];
 #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
 
 /*
@@ -87,7 +87,7 @@ static char log_buf[LOG_BUF_LEN];
  */
 static unsigned long log_start;			/* Index into log_buf: next char to be read by syslog() */
 static unsigned long con_start;			/* Index into log_buf: next char to be sent to consoles */
-static unsigned long log_end;			/* Index into log_buf: most-recently-written-char + 1 */
+unsigned long log_end;				/* Index into log_buf: most-recently-written-char + 1 */
 static unsigned long logged_chars;		/* Number of chars produced since last read+clear operation */
 
 struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
@@ -707,3 +707,6 @@ void tty_write_message(struct tty_struct
 		tty->driver.write(tty, 0, msg, strlen(msg));
 	return;
 }
+
+EXPORT_SYMBOL_GPL(log_buf);
+EXPORT_SYMBOL_GPL(log_end);

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#1 lore raw

drivers/char/oopser/dumper_x86_ide.c line 34

Quoted 9 lines
drivers/char/oopser/dumper_x86_ide.c +9 -0
+	/* Pause (at least 400ns) in case we just issued a command */
+	oopser_usec(1);
+	for (i = 0; i < 1000; i++) {
+		b = inb(HD_STATUS);
+		if (!(b & BUSY_STAT)) {
+			if (b & ERR_STAT) return 0;
+			if (b & flag) return 1;
+		}
+		oopser_usec(1000);

This will stop working on SATA when VDMA goes into newer controllers btw.

drivers/char/oopser/dumper_x86_ide.c line 54

Quoted 3 lines
drivers/char/oopser/dumper_x86_ide.c +3 -0
+	/* Bits 24-27, 0x40=LBA, 0x10=slave */
+	if (!wait_before_command()) return -EIO;
+	outb(0x40 | (master ? 0 : 0x10) | ((lba >> 24) & 0x0F), HD_CURRENT);

Doesn't work for LBA48

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (!wait_before_command()) return -EIO;
+	outb(0x40 | (master ? 0 : 0x10) | ((lba >> 24) & 0x0F), HD_CURRENT);

Ditto

drivers/char/oopser/dumper_x86_ide.c line 124

Quoted 7 lines
drivers/char/oopser/dumper_x86_ide.c +7 -0
+/* Called with interrupts off */
+int oopser_read_ide(char dump[512], unsigned int block)
+{
+	/* Wait for non-busy: if not, reset anyway */
+	wait_before_command();
+	/* Soft reset of drive (set nIEN as well) */
+	outb(0x0e, HD_CMD);

Be careful here - one or two drives get nIEN backwards, you might just want to turn off interrupts and be done with it

drivers/char/oopser/dumper_x86_ide.c line 126

Quoted 2 lines
drivers/char/oopser/dumper_x86_ide.c +2 -0
+	oopser_usec(1); /* 400ns according to spec */
+	outb(0x0a, HD_CMD);

You really need to reset and reprogram/retune the controller as well.

I like the infrastructure but the IDE dumper code is wishful thinking in one or two spots. You don't know f the controller is in DMA modes, tuned for different things to the drives or legacy free. Im not sure what to do for legacy free cases but the other bits like LBA48 and retuning probably can be handled with some small chipset specific hooks

Alan

#2 lore raw

Talking about dumping oopsen, would there be any usefulness in outputting crash data to the PC speaker, using a slow, (~300 bps) modulation that would survive being captured on a cassette using a walkman with a microphone, then decoded using a userspace program from a sampled .au file?

Just thought it might be easily implementable, as it doesn't have any pre-requisits, (other than having a PC speaker, which *almost* everybody has).

John.

#3 lore raw
Quoted 4 lines · On Monday 16 September 2002 08:39 am, [email protected] wrote:

Talking about dumping oopsen, would there be any usefulness in outputting crash data to the PC speaker, using a slow, (~300 bps) modulation that would survive being captured on a cassette using a walkman with a microphone, then decoded using a userspace program from a sampled .au file?

This is easier and less error-prone than copying the oops down by hand?

I remember using 300 bps. On a closed electrical circuit without acoustic couplers, you still got line noise. Acoustic couplers put the speaker and microphone right on top of each other and surrounded them with a muffler to try to minimize ambient noise from the room...

Quoted 3 lines

Just thought it might be easily implementable, as it doesn't have any pre-requisits, (other than having a PC speaker, which *almost* everybody has).

Not everybody has a tape recorder, though.

And the -ac branch already does output in morse code. Try taping that and writing a user mode interpreter for it, if you like...

Quoted 1 line

John.

#4 lore raw
Quoted 6 lines
Quoted 4 lines

Talking about dumping oopsen, would there be any usefulness in outputting crash data to the PC speaker, using a slow, (~300 bps) modulation that would survive being captured on a cassette using a walkman with a microphone, then decoded using a userspace program from a sampled .au file?

This is easier and less error-prone than copying the oops down by hand?

Well, it is easy to make a mistake writing it down...

Quoted 4 lines

I remember using 300 bps. On a closed electrical circuit without acoustic couplers, you still got line noise. Acoustic couplers put the speaker and microphone right on top of each other and surrounded them with a muffler to try to minimize ambient noise from the room...

WHAT? I have captured 1200/75 'prestel' style modem communications on tape, and played them back through a speaker, in to a phone handset, and had them faithfully reproduced on a terminal. Having said that, trying to use a 300 bps accustic coupler with a GSM phone wasn't successful, because you get some kind of inductive interference from the phone.

Quoted 8 lines
Quoted 3 lines

Just thought it might be easily implementable, as it doesn't have any pre-requisits, (other than having a PC speaker, which *almost* everybody has).

Not everybody has a tape recorder, though.

And the -ac branch already does output in morse code. Try taping that and writing a user mode interpreter for it, if you like...

Hmmm, that might be worth doing, because it gives you a way to automatically recover the data, rather than typing it in again, (which is prone to errors).

John.

#5 lore raw
In reply to Rob Landley
Quoted 7 lines · Rob Landley
Quoted 4 lines · On Monday 16 September 2002 08:39 am, [email protected] wrote:

Talking about dumping oopsen, would there be any usefulness in outputting crash data to the PC speaker, using a slow, (~300 bps) modulation that would survive being captured on a cassette using a walkman with a microphone, then decoded using a userspace program from a sampled .au file?

This is easier and less error-prone than copying the oops down by hand?

Works in X. Hand copying doesn't. But serial (or printer) console is probably easier.

Quoted 4 lines

I remember using 300 bps. On a closed electrical circuit without acoustic couplers, you still got line noise. Acoustic couplers put the speaker and microphone right on top of each other and surrounded them with a muffler to try to minimize ambient noise from the room...

Well, this is simplex only, so it's a bit easier. And we could use even slower speed, 75 bps would also work.

Quoted 8 lines
Quoted 3 lines

Just thought it might be easily implementable, as it doesn't have any pre-requisits, (other than having a PC speaker, which *almost* everybody has).

Not everybody has a tape recorder, though.

And the -ac branch already does output in morse code. Try taping that and writing a user mode interpreter for it, if you like...

Signature · 2 lines
Vojtech Pavlik
SuSE Labs
#6 lore raw
In reply to Alan Cox
Quoted 11 lines · Alan Cox

drivers/char/oopser/dumper_x86_ide.c line 34

Quoted 9 lines
drivers/char/oopser/dumper_x86_ide.c +9 -0
+	/* Pause (at least 400ns) in case we just issued a command */
+	oopser_usec(1);
+	for (i = 0; i < 1000; i++) {
+		b = inb(HD_STATUS);
+		if (!(b & BUSY_STAT)) {
+			if (b & ERR_STAT) return 0;
+			if (b & flag) return 1;
+		}
+		oopser_usec(1000);

This will stop working on SATA when VDMA goes into newer controllers btw.

I think VDMA is an extra feature, the old PIO will still remain - it has to, for other register accesses, and the data port is not much different.

Quoted 7 lines

Be careful here - one or two drives get nIEN backwards, you might just want to turn off interrupts and be done with it

drivers/char/oopser/dumper_x86_ide.c line 126

Quoted 2 lines
drivers/char/oopser/dumper_x86_ide.c +2 -0
+	oopser_usec(1); /* 400ns according to spec */
+	outb(0x0a, HD_CMD);

You really need to reset and reprogram/retune the controller as well.

No. The controller is always tuned for both PIO and DMA. This is a must
- not all commands are DMA (eg IDENTIFY) and for for example ATAPI some data is sent over PIO and some over DMA even for a single command. So using PIO when the drive is switched to DMA is perfectly OK.

Quoted 3 lines

I like the infrastructure but the IDE dumper code is wishful thinking in one or two spots. You don't know if the controller is in DMA modes, tuned for different things to the drives or legacy free.

Legacy free? That is wishful thinking. Not going to happen any soon. Unfortunately. As for DMA vs PIO, see above.

Quoted 3 lines

Im not sure what
to do for legacy free cases but the other bits like LBA48 and retuning probably can be handled with some small chipset specific hooks

Retuning not needed, LBA48 might be needed. Not sure about LBA48 in PIO mode, it might work even without chipset support - it's usually the LBA48+DMA combination that confuses the chips.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs
#7 lore raw
Quoted 6 lines
Quoted 2 lines

to do for legacy free cases but the other bits like LBA48 and retuning probably can be handled with some small chipset specific hooks

Retuning not needed, LBA48 might be needed. Not sure about LBA48 in PIO mode, it might work even without chipset support - it's usually the LBA48+DMA combination that confuses the chips.

Well we know if it wont work pretty easily, but we need the dump code LBA48 aware otherwise a dump on the end of the disk may end up dumping on the wrong part if it wraps - again could be detected

#8 lore raw
In reply to Alan Cox

In message <[email protected]> you write:

Quoted 11 lines

drivers/char/oopser/dumper_x86_ide.c line 34

Quoted 9 lines
drivers/char/oopser/dumper_x86_ide.c +9 -0
+	/* Pause (at least 400ns) in case we just issued a command */
+	oopser_usec(1);
+	for (i = 0; i < 1000; i++) {
+		b = inb(HD_STATUS);
+		if (!(b & BUSY_STAT)) {
+			if (b & ERR_STAT) return 0;
+			if (b & flag) return 1;
+		}
+		oopser_usec(1000);

This will stop working on SATA when VDMA goes into newer controllers btw.

My ignorance of ATA is incredibly deep. I read an old IDE spec to get this to work. So thanks for checking it.

There are several ways around this: we can detect in userspace and refuse to arm, we can detect in the kernel and refuse to arm, we can detect in kernel or userspace and set an "use LBA48" flag. For example, my userspace code currently does:

	if (ioctl(devfd, HDIO_GET_IDENTITY, &hdid) < 0) {
		perror("Getting identity of drive");
		exit(1);
	}
	if (!(hdid.capability & (1 << 1))) {
		fprintf(stderr, "Drive does not support LBA\n");
		exit(1);
	}
Quoted 10 lines

drivers/char/oopser/dumper_x86_ide.c line 54

Quoted 3 lines
drivers/char/oopser/dumper_x86_ide.c +3 -0
+	/* Bits 24-27, 0x40=LBA, 0x10=slave */
+	if (!wait_before_command()) return -EIO;
+	outb(0x40 | (master ? 0 : 0x10) | ((lba >> 24) & 0x0F), HD_CURRENT);

Doesn't work for LBA48

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (!wait_before_command()) return -EIO;
+	outb(0x40 | (master ? 0 : 0x10) | ((lba >> 24) & 0x0F), HD_CURRENT);

Ditto

OK, what's the codepath for LBA48 look like? And how do I detect it?

Quoted 10 lines

drivers/char/oopser/dumper_x86_ide.c line 124

Quoted 7 lines
drivers/char/oopser/dumper_x86_ide.c +7 -0
+/* Called with interrupts off */
+int oopser_read_ide(char dump[512], unsigned int block)
+{
+	/* Wait for non-busy: if not, reset anyway */
+	wait_before_command();
+	/* Soft reset of drive (set nIEN as well) */
+	outb(0x0e, HD_CMD);

Be careful here - one or two drives get nIEN backwards, you might just want to turn off interrupts and be done with it

Hmm... I have interrupts disabled so I don't really care: should be OK I think. Or were you thinking of something else?

Quoted 4 lines

drivers/char/oopser/dumper_x86_ide.c line 126

Quoted 2 lines
drivers/char/oopser/dumper_x86_ide.c +2 -0
+	oopser_usec(1); /* 400ns according to spec */
+	outb(0x0a, HD_CMD);

You really need to reset and reprogram/retune the controller as well.

OK... How?

Quoted 5 lines

I like the infrastructure but the IDE dumper code is wishful thinking in one or two spots. You don't know f the controller is in DMA modes, tuned for different things to the drives or legacy free. Im not sure what to do for legacy free cases but the other bits like LBA48 and retuning probably can be handled with some small chipset specific hooks

The code always does a read sector then a write: if the sector doesn't contain the right magic, it stops. But the more robust the better.

Patches appreciated 8)
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#9 lore raw

Rusty,

First of all if you are reading the kernel IDE driver and using it as an reference you are TOAST! The kernel assumes nIEN = 0.

Not Interrupt Enable = 0, means device can call the host controller's mailbox effectively.

Not Interrupt Enable = 1 is what you have to tell all devices attached to the HBA.

I have avoided writing the polling state diagrams to C.
You beat Alan over the head to suffer as the interperter andre->C and I get sometime freed I will do them.

Quoted 21 lines · Rusty Russell

In message <[email protected]> you write:

Quoted 11 lines

drivers/char/oopser/dumper_x86_ide.c line 34

Quoted 9 lines
drivers/char/oopser/dumper_x86_ide.c +9 -0
+	/* Pause (at least 400ns) in case we just issued a command */
+	oopser_usec(1);
+	for (i = 0; i < 1000; i++) {
+		b = inb(HD_STATUS);
+		if (!(b & BUSY_STAT)) {
+			if (b & ERR_STAT) return 0;
+			if (b & flag) return 1;
+		}
+		oopser_usec(1000);

This will stop working on SATA when VDMA goes into newer controllers btw.

My ignorance of ATA is incredibly deep. I read an old IDE spec to get this to work. So thanks for checking it.

There are several ways around this: we can detect in userspace and refuse to arm, we can detect in the kernel and refuse to arm, we can detect in kernel or userspace and set an "use LBA48" flag. For example, my userspace code currently does:

Quoted 4 lines
	if (ioctl(devfd, HDIO_GET_IDENTITY, &hdid) < 0) {
		perror("Getting identity of drive");
		exit(1);
	}

Uses and interrupt and nIEN = 0, BUG() for polling

Quoted 4 lines
	if (!(hdid.capability & (1 << 1))) {
		fprintf(stderr, "Drive does not support LBA\n");
		exit(1);
	}

Wrong answer, you do CHS.

Quoted 7 lines
Quoted 7 lines

drivers/char/oopser/dumper_x86_ide.c line 54

Quoted 4 lines
drivers/char/oopser/dumper_x86_ide.c +3 -0
+	/* Bits 24-27, 0x40=LBA, 0x10=slave */
+	if (!wait_before_command()) return -EIO;
+	outb(0x40 | (master ? 0 : 0x10) | ((lba >> 24) & 0x0F), HD_CURRENT);

Doesn't work for LBA48

Quoted 6 lines
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (!wait_before_command()) return -EIO;
+	outb(0x40 | (master ? 0 : 0x10) | ((lba >> 24) & 0x0F), HD_CURRENT);

Ditto

OK, what's the codepath for LBA48 look like? And how do I detect it?

It is a double pump of the registers.
Soon the used HOB registers shall operate in XOR command integrity.

Quoted 11 lines
Quoted 10 lines

drivers/char/oopser/dumper_x86_ide.c line 124

Quoted 7 lines
drivers/char/oopser/dumper_x86_ide.c +7 -0
+/* Called with interrupts off */
+int oopser_read_ide(char dump[512], unsigned int block)
+{
+	/* Wait for non-busy: if not, reset anyway */
+	wait_before_command();
+	/* Soft reset of drive (set nIEN as well) */
+	outb(0x0e, HD_CMD);

Be careful here - one or two drives get nIEN backwards, you might just want to turn off interrupts and be done with it

Quoted 2 lines

Hmm... I have interrupts disabled so I don't really care: should be OK I think. Or were you thinking of something else?

Kernel interrupts are not Device.

Quoted 6 lines
Quoted 4 lines

drivers/char/oopser/dumper_x86_ide.c line 126

Quoted 2 lines
drivers/char/oopser/dumper_x86_ide.c +2 -0
+	oopser_usec(1); /* 400ns according to spec */
+	outb(0x0a, HD_CMD);

You really need to reset and reprogram/retune the controller as well.

OK... How?

Depends of if you want hard or soft reset and if you care about signature decoding for redetecting presence of attached devices.

Quoted 8 lines
Quoted 5 lines

I like the infrastructure but the IDE dumper code is wishful thinking in one or two spots. You don't know f the controller is in DMA modes, tuned for different things to the drives or legacy free. Im not sure what to do for legacy free cases but the other bits like LBA48 and retuning probably can be handled with some small chipset specific hooks

The code always does a read sector then a write: if the sector doesn't contain the right magic, it stops. But the more robust the better.

You need a read-modify-write caller.
You need to remember setfeatures need to be hammered on flushcache and writecache disabled.
You need to be able to walk your buffer and best only if you do single sector transactions and not multimode.

Quoted 1 line

Patches appreciated 8)

I'll try, but time is tight for me.

Cheers,

Andre Hedrick
LAD Storage Consulting Group

#10 lore raw
Quoted 6 lines
Quoted 4 lines
	if (ioctl(devfd, HDIO_GET_IDENTITY, &hdid) < 0) {
		perror("Getting identity of drive");
		exit(1);
	}

Uses and interrupt and nIEN = 0, BUG() for polling

That data can be captured early, in fact if you trust the data structures a little its potentially still there

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Be careful here - one or two drives get nIEN backwards, you might just want to turn off interrupts and be done with it

Hmm... I have interrupts disabled so I don't really care: should be OK I think. Or were you thinking of something else?

Kernel interrupts are not Device.

Should be fine, except as Andre notes you have to poll, but for the simple commands I don't think thats exactly a killer.

Quoted 2 lines

Depends of if you want hard or soft reset and if you care about signature decoding for redetecting presence of attached devices.

I'd guess not. The disk was there, it needs to be in some kind of working form so resetting it all and pretending to be DOS should do ?

Alan

#11 lore raw
In reply to Andre Hedrick

In message <[email protected]> you
write:

Quoted 6 lines
Quoted 4 lines
	if (!(hdid.capability & (1 << 1))) {
		fprintf(stderr, "Drive does not support LBA\n");
		exit(1);
	}

Wrong answer, you do CHS.

I can't test that, so safe answer is to refuse to arm the oopser. Since LBA is most common, that's my first priority.

Quoted 9 lines
Quoted 2 lines

The code always does a read sector then a write: if the sector doesn't contain the right magic, it stops. But the more robust the better.

You need a read-modify-write caller.
You need to remember setfeatures need to be hammered on flushcache and writecache disabled.
You need to be able to walk your buffer and best only if you do single sector transactions and not multimode.

Quoted 3 lines
Quoted 1 line

Patches appreciated 8)

I'll try, but time is tight for me.

Me too 8(. The oopser is allowed to (a) refuse to arm at arming time, or (b) refuse to dump at dumping time, but it'd be nice if it worked on the widest range of stuff possible (ie. CHS and LBA48 at least). Of course, it can't use any external routines, and must be small too.

The IDE layer does a great job (on my hardware) from recovering after we rudely steal the device from it, but no doubt the oopser could be nicer about it.

Thanks for reading,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#12 lore raw
Quoted 11 lines · Rusty Russell

In message <[email protected]> you
write:

Quoted 6 lines
Quoted 4 lines
	if (!(hdid.capability & (1 << 1))) {
		fprintf(stderr, "Drive does not support LBA\n");
		exit(1);
	}

Wrong answer, you do CHS.

I can't test that, so safe answer is to refuse to arm the oopser. Since LBA is most common, that's my first priority.

You may pull this off on /dev/hda or /dev/hdb, but Linux has set a policy to default to CHS regardless if LBA should be used. What really needs to be fixed is to default to LBA and not CHS. The problem is everybody will scream bloody murder.

This is why 48-bit devices killed CHS, it is too brain dead to survive but for the life of me it continues.

Quoted 5 lines

Me too 8(. The oopser is allowed to (a) refuse to arm at arming time, or (b) refuse to dump at dumping time, but it'd be nice if it worked on the widest range of stuff possible (ie. CHS and LBA48 at least). Of course, it can't use any external routines, and must be small too.

Heads up!

If the device is 48-bit capable, but the swap area to dump to is inside the 28-bit addressable region, you can call it with 28-bit commands.

Quoted 3 lines

The IDE layer does a great job (on my hardware) from recovering after we rudely steal the device from it, but no doubt the oopser could be nicer about it.

OIC, that is nice to know you are not able to tank the driver even when abusing it.

Quoted 5 lines

Thanks for reading,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Andre Hedrick
LAD Storage Consulting Group