tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Crash in crypto_init



Hi,

Sorry, it's my bug.

On 2017/07/19 20:11, Martin Husemann wrote:
> Trying to boot  -current on a uniprocessor arm soc results in:
> 
> gtidmac0: XOR Engine 4 channels, intr 5, 6, 7, 8
> gttwsi0 at mvsoc0 unit 0 offset 0x11000-0x110ff irq 29: Marvell TWSI controller
> iic0 at gttwsi0: I2C bus
> mvcesa0 at mvsoc0 unit 0 offset 0x3d000-0x3dfff irq 22: Marvell Cryptographic Engines and Security Accelerator
> panic: kernel diagnostic assertion "i != IPI_SYNCH_ID" failed: file "../../../../kern/subr_ipi.c", line 138 
> Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x4:        bx      r14
> db> bt
> 0xc0587b44: netbsd:vpanic+0x10
> 0xc0587b5c: netbsd:kern_assert+0x40
> 0xc0587b94: netbsd:ipi_register+0xac
> 0xc0587bd4: netbsd:softint_establish+0x108
> 0xc0587c4c: netbsd:crypto_init0+0x110
> 0xc0587c6c: netbsd:_run_once+0x80
> 0xc0587c9c: netbsd:crypto_get_driverid+0x16c
> 0xc0587cd4: netbsd:mvcesa_attach+0x7c

I think the reason is mvcesa_attach() is called before ipi_sysinit().
Could you try below tentative patch?
====================
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 63e115ae4b3..30a1e2f54ee 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -524,6 +524,9 @@ main(void)
 	/* Enable deferred processing of RNG samples */
 	rnd_init_softint();
 
+	extern void crypto_init_later(void);
+	crypto_init_later();
+
 #ifdef RND_PRINTF
 	/* Enable periodic injection of console output into entropy pool */
 	kprintf_init_callout();
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index 18103269408..401e5442089 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -417,18 +417,30 @@ crypto_init0(void)
 		return crypto_destroy(false);
 	}
 
+#if 0
 	crypto_ret_si = softint_establish(SOFTINT_NET|SOFTINT_MPSAFE|SOFTINT_RCPU,
 	    &cryptoret_softint, NULL);
 	if (crypto_ret_si == NULL) {
 		printf("crypto_init: cannot establish ret queue handler\n");
 		return crypto_destroy(false);
 	}
+#endif
 
 	sysctl_opencrypto_setup(&sysctl_opencrypto_clog);
 
 	return 0;
 }
 
+void crypto_init_later(void);
+void
+crypto_init_later(void)
+{
+
+	crypto_ret_si = softint_establish(SOFTINT_NET|SOFTINT_MPSAFE|SOFTINT_RCPU,
+	    &cryptoret_softint, NULL);
+	KASSERT (crypto_ret_si != NULL);
+}
+
 int
 crypto_init(void)
 {
====================

Yes, it is ugly... Please give me some more time to implement formal patch.


Thanks,

-- 
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.

Device Engineering Section,
IoT Platform Development Department,
Network Division,
Technology Unit

Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>


Home | Main Index | Thread Index | Old Index