[Bug 286321] [FBSD 15.0 Current] kernel panic "panic: incoming crp already done" while running kyua tests with qat driver

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 24 Apr 2025 13:20:08 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286321

            Bug ID: 286321
           Summary: [FBSD 15.0 Current] kernel panic "panic: incoming crp
                    already done" while running kyua tests with qat driver
           Product: Base System
           Version: 15.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: vishnu.dasx.ramachandran@intel.com

When running kyua tests on FBSD 15.0-CURRENT with qat accelerator hardware
(registered with OCF to run crypto pay loads), we see kernel panic in
g_eli_crypto_rerun() which in turn calls crypto_dispatch_one().
Panic log "panic: incoming crp already done"

g_eli_crypto_rerun() gets called when the qat acceleration software returns
EAGAIN(file: sys/dev/qat/qat/qat_ocf.c, function: qat_ocf_process()). Since the
request submission to qat driver has failed,  crypto_done(crp) is called and
crp->crp_etype is set to EAGAIN.

On seeing EGAIN, g_eli_crypto_read_done()/ g_eli_crypto_write_done() calls
g_eli_crypto_rerun().
In g_eli_crypto_rerun(), since CRYPTO_F_DONE bit is not cleared from
crp->crp_flags before calling crypto_dispatch_one(), we see kernel panic in

    KASSERT(!(crp->crp_flags & CRYPTO_F_DONE),
        ("incoming crp already done"));

Command executed:
cd /usr/tests/ && kyua -v test_suites.FreeBSD.disks='/dev/md0 /dev/md1' test
sys/geom/class/eli


Please Note: This issue is not seen on STABLE branches and occurs only on FBSD
15.0-CURRENT wherein "include "std.debug" is getting added to GENERIC conf file
by default. This std.debug enables INVARIANTS flag that has the above mentioned
KASSERT check.

To fix this kernel panic, we feel that CRYPTO_F_DONE bit should be cleared from
crp->crp_etype in g_eli_crypto_rerun() before invoking crypto_dispatch().
Please suggest.

-- 
You are receiving this mail because:
You are the assignee for the bug.