Re: i386 softraid crypto panic

2011-06-07 Thread Manuel Giraud
Matthew Dempsky matt...@dempsky.org writes:

 That line is from my softraid scsibus diff, which was included in the
 Jun 5 snapshots.  There was a bug where it didn't properly unwind a
 failed BIOCCREATERAID attempt.

Ok, it works now with a more recent snapshot. I thought it could be one
of those FBI patches. Thanks.

-- 
Manuel Giraud



i386 softraid crypto panic

2011-06-06 Thread Manuel GIRAUD
Hi,

I'm experiencing a panic after an upgrade from yesterday's snapshot
(SHA256 (bsd.rd) =
d56181843c4355c64d84f8583e0946289ba0b2055b1ba194ce38cb28f725b29b)

Everything but / is under a softraid cryto discipline so I did a
bioctl -c C -l /dev/wd0d softraid0 before running /upgrade. The
upgrade went ok but upon reboot, the bioctl command end up with the
following panic:

panic: kernel diagnostic assertion sc-sc_dis[sc-sd_target] == sd
failed: file ../../../../dev/softraid.c, line 3372
Stopped at   Debugger+0x4: popl %ebp

(I cannot include the 'trace' and 'ps' because the keyboard is not
working at this point)

dmesg before panic:

OpenBSD 4.9-current (GENERIC.MP) #62: Sun Jun  5 15:17:07 MDT 2011
dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
RTC BIOS diagnostic error 11memory_size
cpu0: Intel(R) Core(TM)2 Duo CPU E8600 @ 3.33GHz (GenuineIntel
686-class) 3.33 GHz
cpu0:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,XSAVE
real mem  = 3487096832 (3325MB)
avail mem = 3419242496 (3260MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 07/31/09, BIOS32 rev. 0 @ 0xffea0,
SMBIOS rev. 2.5 @ 0xf0450 (82 entries)
bios0: vendor Dell Inc. version A05 date 07/31/2009
bios0: Dell Inc. OptiPlex 960
acpi0 at bios0: rev 2
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP SSDT APIC BOOT ASF! MCFG HPET  SLIC SSDT SSDT
SSDT
acpi0: wakeup devices VBTN(S4) PCI0(S5) PCI4(S5) PCI2(S5) PCI3(S5)
PCI1(S5) PCI5(S5) PCI6(S5) MOU_(S3) USB0(S3) USB1(S3) USB2(S3) USB3(S3)
USB4(S3) USB5(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 332MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 Duo CPU E8600 @ 3.33GHz (GenuineIntel
686-class) 3.33 GHz
cpu1:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,XSAVE
ioapic0 at mainbus0: apid 8 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 8
acpimcfg0 at acpi0 addr 0xe000, bus 0-255
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 4 (PCI4)
acpiprt1 at acpi0: bus 2 (PCI2)
acpiprt2 at acpi0: bus 3 (PCI3)
acpiprt3 at acpi0: bus 1 (PCI1)
acpiprt4 at acpi0: bus -1 (PCI5)
acpiprt5 at acpi0: bus -1 (PCI6)
acpiprt6 at acpi0: bus 0 (PCI0)
acpicpu0 at acpi0: C1, PSS
acpicpu1 at acpi0: C1, PSS
acpibtn0 at acpi0: VBTN
bios0: ROM list: 0xc/0x1 0xd/0x2000! 0xd2000/0x2000
cpu0: Enhanced SpeedStep 3326 MHz: speeds: , 3000, 2667, 2333, 2000 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 Intel Q45 Host rev 0x03
ppb0 at pci0 dev 1 function 0 Intel Q45 PCIE rev 0x03: msi
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 ATI Radeon HD 3470 rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
radeondrm0 at vga1: apic 8 int 16
drm0 at radeondrm0
Intel Q45 HECI rev 0x03 at pci0 dev 3 function 0 not configured
pciide0 at pci0 dev 3 function 2 Intel Q45 PT IDER rev 0x03: DMA
(unsupported), channel 0 wired to native-PCI, channel 1 wired to
native-PCI
pciide0: using apic 8 int 18 for native-PCI interrupt
pciide0: channel 0 ignored (not responding; disabled or no drives?)
pciide0: channel 1 ignored (not responding; disabled or no drives?)
Intel Q45 KT rev 0x03 at pci0 dev 3 function 3 not configured
em0 at pci0 dev 25 function 0 Intel ICH10 D BM LM rev 0x02: apic 8 int
21, address 00:24:e8:47:9f:46
uhci0 at pci0 dev 26 function 0 Intel 82801JD USB rev 0x02: apic 8 int 16
uhci1 at pci0 dev 26 function 1 Intel 82801JD USB rev 0x02: apic 8 int 17
uhci2 at pci0 dev 26 function 2 Intel 82801JD USB rev 0x02: apic 8 int 22
ehci0 at pci0 dev 26 function 7 Intel 82801JD USB rev 0x02: apic 8 int 22
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 Intel EHCI root hub rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 Intel 82801JD HD Audio rev 0x02: msi
azalia0: codecs: Analog Devices AD1984A
audio0 at azalia0
ppb1 at pci0 dev 28 function 0 Intel 82801JD PCIE rev 0x02: msi
pci2 at ppb1 bus 2
ppb2 at pci0 dev 28 function 1 Intel 82801JD PCIE rev 0x02: msi
pci3 at ppb2 bus 3
uhci3 at pci0 dev 29 function 0 Intel 82801JD USB rev 0x02: apic 8 int 23
uhci4 at pci0 dev 29 function 1 Intel 82801JD USB rev 0x02: apic 8 int 17
uhci5 at pci0 dev 29 function 2 Intel 82801JD USB rev 0x02: apic 8 int 18
ehci1 at pci0 dev 29 function 7 Intel 82801JD USB rev 0x02: apic 8 int 23
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 Intel EHCI root hub rev 2.00/1.00 addr 1
ppb3 at pci0 dev 30 function 0 Intel 82801BA Hub-to-PCI rev 0xa2
pci4 at ppb3 bus 4
pcib0 at pci0 dev 31 function 0 Intel 82801JDO LPC rev 0x02
pciide1 at pci0 dev 31 function 2 

Re: i386 softraid crypto panic

2011-06-06 Thread Ted Unangst
On Mon, Jun 6, 2011 at 9:40 AM, Manuel GIRAUD
manuel.gir...@univ-nantes.fr wrote:
 I'm experiencing a panic after an upgrade from yesterday's snapshot
 (SHA256 (bsd.rd) =
 d56181843c4355c64d84f8583e0946289ba0b2055b1ba194ce38cb28f725b29b)

 Everything but / is under a softraid cryto discipline so I did a
 bioctl -c C -l /dev/wd0d softraid0 before running /upgrade. The
 upgrade went ok but upon reboot, the bioctl command end up with the
 following panic:

 panic: kernel diagnostic assertion sc-sc_dis[sc-sd_target] == sd
 failed: file ../../../../dev/softraid.c, line 3372
 Stopped at   Debugger+0x4: popl %ebp

There is no such line in the source, so apparently there was a patch,
but it looks like it's been removed now.



Re: i386 softraid crypto panic

2011-06-06 Thread Matthew Dempsky
On Mon, Jun 06, 2011 at 02:47:45PM -0400, Ted Unangst wrote:
 On Mon, Jun 6, 2011 at 9:40 AM, Manuel GIRAUD
 manuel.gir...@univ-nantes.fr wrote:
  I'm experiencing a panic after an upgrade from yesterday's snapshot
  (SHA256 (bsd.rd) =
  d56181843c4355c64d84f8583e0946289ba0b2055b1ba194ce38cb28f725b29b)
 
  Everything but / is under a softraid cryto discipline so I did a
  bioctl -c C -l /dev/wd0d softraid0 before running /upgrade. The
  upgrade went ok but upon reboot, the bioctl command end up with the
  following panic:
 
  panic: kernel diagnostic assertion sc-sc_dis[sc-sd_target] == sd
  failed: file ../../../../dev/softraid.c, line 3372
  Stopped at   Debugger+0x4: popl %ebp
 
 There is no such line in the source, so apparently there was a patch,
 but it looks like it's been removed now.

That line is from my softraid scsibus diff, which was included in the
Jun 5 snapshots.  There was a bug where it didn't properly unwind a
failed BIOCCREATERAID attempt.

The diff below fixes this issue, and I haven't been able to reproduce
any other panics in my testing with RAID 0, RAID 1, and crypto
softraid configurations.


Index: softraid.c
===
RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/softraid.c,v
retrieving revision 1.230
diff -u -p -r1.230 softraid.c
--- softraid.c  3 May 2011 17:08:51 -   1.230
+++ softraid.c  6 Jun 2011 17:25:43 -
@@ -87,7 +87,8 @@ struct cfdriver softraid_cd = {
 
 /* scsi  discipline */
 void   sr_scsi_cmd(struct scsi_xfer *);
-void   sr_minphys(struct buf *bp, struct scsi_link *sl);
+void   sr_minphys(struct buf *, struct scsi_link *);
+intsr_scsi_probe(struct scsi_link *);
 void   sr_copy_internal_data(struct scsi_xfer *,
void *, size_t);
 intsr_scsi_ioctl(struct scsi_link *, u_long,
@@ -167,7 +168,7 @@ extern void (*softraid_disk_attach)(str
 
 /* scsi glue */
 struct scsi_adapter sr_switch = {
-   sr_scsi_cmd, sr_minphys, NULL, NULL, sr_scsi_ioctl
+   sr_scsi_cmd, sr_minphys, sr_scsi_probe, NULL, sr_scsi_ioctl
 };
 
 /* native metadata format */
@@ -1632,6 +1633,7 @@ void
 sr_attach(struct device *parent, struct device *self, void *aux)
 {
struct sr_softc *sc = (void *)self;
+   struct scsibus_attach_args saa;
 
DNPRINTF(SR_D_MISC, \n%s: sr_attach, DEVNAME(sc));
 
@@ -1656,6 +1658,18 @@ sr_attach(struct device *parent, struct 
 
printf(\n);
 
+   sc-sc_link.adapter_softc = sc;
+   sc-sc_link.adapter = sr_switch;
+   sc-sc_link.adapter_target = SR_MAX_LD;
+   sc-sc_link.adapter_buswidth = SR_MAX_LD;
+   sc-sc_link.luns = 1;
+
+   bzero(saa, sizeof(saa));
+   saa.saa_sc_link = sc-sc_link;
+
+   sc-sc_scsibus = (struct scsibus_softc *)config_found(sc-sc_dev,
+   saa, scsiprint);
+
softraid_disk_attach = sr_disk_attach;
 
sr_boot_assembly(sc);
@@ -1910,19 +1924,10 @@ sr_scsi_cmd(struct scsi_xfer *xs)
DNPRINTF(SR_D_CMD, %s: sr_scsi_cmd: scsibus%d xs: %p 
flags: %#x\n, DEVNAME(sc), link-scsibus, xs, xs-flags);
 
-   sd = sc-sc_dis[link-scsibus];
+   sd = sc-sc_dis[link-target];
if (sd == NULL) {
-   s = splhigh();
-   sd = sc-sc_attach_dis;
-   splx(s);
-
-   DNPRINTF(SR_D_CMD, %s: sr_scsi_cmd: attaching %p\n,
-   DEVNAME(sc), sd);
-   if (sd == NULL) {
-   printf(%s: sr_scsi_cmd NULL discipline\n,
-   DEVNAME(sc));
-   goto stuffup;
-   }
+   printf(%s: sr_scsi_cmd NULL discipline\n, DEVNAME(sc));
+   goto stuffup;
}
 
if (sd-sd_deleted) {
@@ -1948,19 +1953,6 @@ sr_scsi_cmd(struct scsi_xfer *xs)
wu-swu_dis = sd;
wu-swu_xs = xs;
 
-   /* the midlayer will query LUNs so report sense to stop scanning */
-   if (link-target != 0 || link-lun != 0) {
-   DNPRINTF(SR_D_CMD, %s: bad target:lun %d:%d\n,
-   DEVNAME(sc), link-target, link-lun);
-   sd-sd_scsi_sense.error_code = SSD_ERRCODE_CURRENT |
-   SSD_ERRCODE_VALID;
-   sd-sd_scsi_sense.flags = SKEY_ILLEGAL_REQUEST;
-   sd-sd_scsi_sense.add_sense_code = 0x25;
-   sd-sd_scsi_sense.add_sense_code_qual = 0x00;
-   sd-sd_scsi_sense.extra_len = 4;
-   goto stuffup;
-   }
-
switch (xs-cmd-opcode) {
case READ_COMMAND:
case READ_BIG:
@@ -2036,6 +2028,28 @@ stuffup:
 complete:
sr_scsi_done(sd, xs);
 }
+
+int
+sr_scsi_probe(struct scsi_link *link)
+{
+   struct sr_softc *sc = link-adapter_softc;
+   struct sr_discipline*sd;
+
+   KASSERT(link-target  SR_MAX_LD  link-lun == 0);
+
+   sd = sc-sc_dis[link-target];