tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Crash in crypto_init
Hi,
On 2017/07/19 20:55, Martin Husemann wrote:
> On Wed, Jul 19, 2017 at 08:40:27PM +0900, Kengo NAKAHARA wrote:
>> I think the reason is mvcesa_attach() is called before ipi_sysinit().
>> Could you try below tentative patch?
>
> Thanks for the quick workaround, it boots now!
I re-implement fix patch. Could you revert previous workaround and try
the following patch?
====================
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index 18103269408..2c896c5f512 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.92 2017/07/18 06:01:36 knakahara Exp $"
#include <sys/errno.h>
#include <sys/module.h>
#include <sys/xcall.h>
+#include <sys/device.h>
#if defined(_KERNEL_OPT)
#include "opt_ocf.h"
@@ -382,6 +383,8 @@ static void crypto_driver_lock(struct cryptocap *);
static void crypto_driver_unlock(struct cryptocap *);
static void crypto_driver_clear(struct cryptocap *);
+static int crypto_init_finalize(device_t);
+
static struct cryptostats cryptostats;
#ifdef CRYPTO_TIMING
static int crypto_timing = 0;
@@ -417,10 +420,13 @@ crypto_init0(void)
return crypto_destroy(false);
}
- 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");
+ /*
+ * Some encryption devicees(such as mvcesa) is attached before
+ * ipi_sysinit(). That causes assertion in ipi_register() as
+ * crypto_ret_si softint uses SOFTINT_RCPU.
+ */
+ if (config_finalize_register(NULL, crypto_init_finalize) != 0) {
+ printf("crypto_init: cannot register crypto_init_finalize\n");
return crypto_destroy(false);
}
@@ -429,6 +435,17 @@ crypto_init0(void)
return 0;
}
+static int
+crypto_init_finalize(device_t self __unused)
+{
+
+ crypto_ret_si = softint_establish(SOFTINT_NET|SOFTINT_MPSAFE|SOFTINT_RCPU,
+ &cryptoret_softint, NULL);
+ KASSERT(crypto_ret_si != NULL);
+
+ return 0;
+}
+
int
crypto_init(void)
{
====================
If no issue occurs, I will commit this patch.
Does anyone have a comment?
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