FreeBSD Bugzilla – Attachment 256331 Details for
Bug 280037
KTLS with Intel QAT may trigger kernel panics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
draft patch that addresses comment no.11 and 14
patch-qat.patch (text/plain), 2.94 KB, created by
ss3bsd
on 2025-01-01 23:51:37 UTC
(
hide
)
Description:
draft patch that addresses comment no.11 and 14
Filename:
MIME Type:
Creator:
ss3bsd
Created:
2025-01-01 23:51:37 UTC
Size:
2.94 KB
patch
obsolete
>diff --git sys/dev/qat/qat/qat_ocf.c sys/dev/qat/qat/qat_ocf.c >index 8958c7b82e49..52e3388bab6b 100644 >--- sys/dev/qat/qat/qat_ocf.c >+++ sys/dev/qat/qat/qat_ocf.c >@@ -850,6 +850,7 @@ qat_ocf_process(device_t dev, struct cryptop *crp, int hint) > status = qat_ocf_cookie_alloc(qat_instance, &qat_cookie); > if (CPA_STATUS_SUCCESS != status) { > rc = EAGAIN; >+ device_printf(dev, "EAGAIN qat_ocf_cookie_alloc\n"); > goto fail; > } > >@@ -905,6 +906,7 @@ qat_ocf_process(device_t dev, struct cryptop *crp, int hint) > if (CPA_STATUS_RESOURCE == status) { > mtx_unlock(&qat_instance->cyInstMtx); > rc = EAGAIN; >+ device_printf(dev, "EAGAIN qat_ocf_handle_session_update\n"); > goto fail; > } else if (CPA_STATUS_SUCCESS != status) { > mtx_unlock(&qat_instance->cyInstMtx); >@@ -918,6 +920,7 @@ qat_ocf_process(device_t dev, struct cryptop *crp, int hint) > if (CPA_STATUS_SUCCESS != status) { > if (CPA_STATUS_RETRY == status) { > rc = EAGAIN; >+ device_printf(dev, "EAGAIN cpaCySymDpEnqueueOp\n"); > goto fail; > } > device_printf(dev, >diff --git sys/kern/uipc_ktls.c sys/kern/uipc_ktls.c >index 294a196db60d..ed30d9711244 100644 >--- sys/kern/uipc_ktls.c >+++ sys/kern/uipc_ktls.c >@@ -1856,6 +1856,22 @@ ktls_destroy(struct ktls_session *tls) > MPASS(tls->refcount == 0); > > inp = tls->inp; >+ >+ if ( !tls->sync_dispatch && atomic_swap_int(&tls->destroying, 1) == 0 ){ >+ /* >+ * prevent a deadlocking race condition observed with QAT driver >+ * where qat_ocf_remove_session() which is called by ktls_ocf_free() >+ * fails to wait in-flight callback execution and leaks memory >+ * resources in the driver. >+ */ >+ counter_u64_add(ktls_destroy_task, 1); >+ TASK_INIT(&tls->destroy_task, 0, >+ ktls_destroy_help, tls); >+ (void)taskqueue_enqueue(taskqueue_thread, >+ &tls->destroy_task); >+ return; >+ } >+ > if (tls->tx) { > wlocked = INP_WLOCKED(inp); > if (!wlocked && !INP_TRY_WLOCK(inp)) { >diff --git sys/opencrypto/ktls_ocf.c sys/opencrypto/ktls_ocf.c >index f61fb7f73b5d..1bc6bf98d377 100644 >--- sys/opencrypto/ktls_ocf.c >+++ sys/opencrypto/ktls_ocf.c >@@ -243,6 +243,15 @@ ktls_ocf_dispatch_async_cb(struct cryptop *crp) > crp->crp_etype = 0; > crp->crp_flags &= ~CRYPTO_F_DONE; > counter_u64_add(ocf_retries, 1); >+ >+ /* delay a little time as workaround to prevent rapid recursive >+ * calls that result in kernel panic by resource starvation. >+ * The panic would still occur if the crypto function returns EAGAIN forever, >+ */ >+ >+ printf("ktls_ocf_dispatch_async_cb EAGAIN DELAY\n"); >+ DELAY(100); >+ > error = crypto_dispatch(crp); > if (error != 0) { > crypto_destroyreq(crp); >diff --git sys/sys/ktls.h sys/sys/ktls.h >index 693864394ffe..97c3745dd0f9 100644 >--- sys/sys/ktls.h >+++ sys/sys/ktls.h >@@ -202,6 +202,9 @@ struct ktls_session { > > /* Used to destroy any kTLS session */ > struct task destroy_task; >+ >+ /* will be destroyed by the destroy_task */ >+ int destroying; > } __aligned(CACHE_LINE_SIZE); > > extern unsigned int ktls_ifnet_max_rexmit_pct;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 280037
:
251744
|
251776
|
251786
| 256331 |
256343