1. 06 Sep, 2024 11 commits
    • Herbert Xu's avatar
      crypto: algboss - Pass instance creation error up · 795f85fc
      Herbert Xu authored
      Pass any errors we get during instance creation up through the
      larval.
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      795f85fc
    • Herbert Xu's avatar
      crypto: api - Fix generic algorithm self-test races · e7a4142b
      Herbert Xu authored
      On Fri, Aug 30, 2024 at 10:51:54AM -0700, Eric Biggers wrote:
      >
      > Given below in defconfig form, use 'make olddefconfig' to apply.  The failures
      > are nondeterministic and sometimes there are different ones, for example:
      >
      > [    0.358017] alg: skcipher: failed to allocate transform for cbc(twofish-generic): -2
      > [    0.358365] alg: self-tests for cbc(twofish) using cbc(twofish-generic) failed (rc=-2)
      > [    0.358535] alg: skcipher: failed to allocate transform for cbc(camellia-generic): -2
      > [    0.358918] alg: self-tests for cbc(camellia) using cbc(camellia-generic) failed (rc=-2)
      > [    0.371533] alg: skcipher: failed to allocate transform for xts(ecb(aes-generic)): -2
      > [    0.371922] alg: self-tests for xts(aes) using xts(ecb(aes-generic)) failed (rc=-2)
      >
      > Modules are not enabled, maybe that matters (I haven't checked yet).
      
      Yes I think that was the key.  This triggers a massive self-test
      run which executes in parallel and reveals a few race conditions
      in the system.  I think it boils down to the following scenario:
      
      Base algorithm X-generic, X-optimised
      Template Y
      Optimised algorithm Y-X-optimised
      
      Everything gets registered, and then the self-tests are started.
      When Y-X-optimised gets tested, it requests the creation of the
      generic Y(X-generic).  Which then itself undergoes testing.
      
      The race is that after Y(X-generic) gets registered, but just
      before it gets tested, X-optimised finally finishes self-testing
      which then causes all spawns of X-generic to be destroyed.  So
      by the time the self-test for Y(X-generic) comes along, it can
      no longer find the algorithm.  This error then bubbles up all
      the way up to the self-test of Y-X-optimised which then fails.
      
      Note that there is some complexity that I've omitted here because
      when the generic self-test fails to find Y(X-generic) it actually
      triggers the construction of it again which then fails for various
      other reasons (these are not important because the construction
      should *not* be triggered at this point).
      
      So in a way the error is expected, and we should probably remove
      the pr_err for the case where ENOENT is returned for the algorithm
      that we're currently testing.
      
      The solution is two-fold.  First when an algorithm undergoes
      self-testing it should not trigger its construction.  Secondly
      if an instance larval fails to materialise due to it being destroyed
      by a more optimised algorithm coming along, it should obviously
      retry the construction.
      
      Remove the check in __crypto_alg_lookup that stops a larval from
      matching new requests based on differences in the mask.  It is better
      to block new requests even if it is wrong and then simply retry the
      lookup.  If this ends up being the wrong larval it will sort iself
      out during the retry.
      
      Reduce the CRYPTO_ALG_TYPE_MASK bits in type during larval creation
      as otherwise LSKCIPHER algorithms may not match SKCIPHER larvals.
      
      Also block the instance creation during self-testing in the function
      crypto_larval_lookup by checking for CRYPTO_ALG_TESTED in the mask
      field.
      
      Finally change the return value when crypto_alg_lookup fails in
      crypto_larval_wait to EAGAIN to redo the lookup.
      
      Fixes: 37da5d0f ("crypto: api - Do not wait for tests during registration")
      Reported-by: default avatarEric Biggers <ebiggers@kernel.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      e7a4142b
    • Weili Qian's avatar
      crypto: hisilicon/qm - inject error before stopping queue · b04f06fc
      Weili Qian authored
      The master ooo cannot be completely closed when the
      accelerator core reports memory error. Therefore, the driver
      needs to inject the qm error to close the master ooo. Currently,
      the qm error is injected after stopping queue, memory may be
      released immediately after stopping queue, causing the device to
      access the released memory. Therefore, error is injected to close master
      ooo before stopping queue to ensure that the device does not access
      the released memory.
      
      Fixes: 6c6dd580 ("crypto: hisilicon/qm - add controller reset interface")
      Signed-off-by: default avatarWeili Qian <qianweili@huawei.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      b04f06fc
    • Weili Qian's avatar
      crypto: hisilicon/hpre - mask cluster timeout error · 145013f7
      Weili Qian authored
      The timeout threshold of the hpre cluster is 16ms. When the CPU
      and device share virtual address, page fault processing time may
      exceed the threshold.
      
      In the current test, there is a high probability that the
      cluster times out. However, the cluster is waiting for the
      completion of memory access, which is not an error, the device
      does not need to be reset. If an error occurs in the cluster,
      qm also reports the error. Therefore, the cluster timeout
      error of hpre can be masked.
      
      Fixes: d90fab0d ("crypto: hisilicon/qm - get error type from hardware registers")
      Signed-off-by: default avatarWeili Qian <qianweili@huawei.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      145013f7
    • Weili Qian's avatar
      crypto: hisilicon/qm - reset device before enabling it · 5d2d1ee0
      Weili Qian authored
      Before the device is enabled again, the device may still
      store the previously processed data. If an error occurs in
      the previous task, the device may fail to be enabled again.
      Therefore, before enabling device, reset the device to restore
      the initial state.
      Signed-off-by: default avatarWeili Qian <qianweili@huawei.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      5d2d1ee0
    • Chenghai Huang's avatar
      crypto: hisilicon/trng - modifying the order of header files · f5dd7c43
      Chenghai Huang authored
      Header files is included Order-ref: standard library headers,
      OS library headers, and project-specific headers. This patch
      modifies the order of header files according to suggestions.
      
      In addition, use %u to print unsigned int variables to prevent
      overflow.
      Signed-off-by: default avatarChenghai Huang <huangchenghai2@huawei.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      f5dd7c43
    • Chenghai Huang's avatar
      crypto: hisilicon - add a lock for the qp send operation · 5fdb4b34
      Chenghai Huang authored
      Apply for a lock before the qp send operation to ensure no
      resource race in multi-concurrency situations.
      
      This modification has almost no impact on performance.
      Signed-off-by: default avatarChenghai Huang <huangchenghai2@huawei.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      5fdb4b34
    • Yang Shen's avatar
      crypto: hisilicon - fix missed error branch · f386dc64
      Yang Shen authored
      If an error occurs in the process after the SGL is mapped
      successfully, it need to unmap the SGL.
      
      Otherwise, memory problems may occur.
      Signed-off-by: default avatarYang Shen <shenyang39@huawei.com>
      Signed-off-by: default avatarChenghai Huang <huangchenghai2@huawei.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      f386dc64
    • Amit Shah's avatar
      crypto: ccp - do not request interrupt on cmd completion when irqs disabled · 3401f63e
      Amit Shah authored
      While sending a command to the PSP, we always requested an interrupt
      from the PSP after command completion.  This worked for most cases.  For
      the special case of irqs being disabled -- e.g. when running within
      crashdump or kexec contexts, we should not set the SEV_CMDRESP_IOC flag,
      so the PSP knows to not attempt interrupt delivery.
      
      Fixes: 8ef97958 ("crypto: ccp: Add panic notifier for SEV/SNP firmware shutdown on kdump")
      Based-on-patch-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Signed-off-by: default avatarAmit Shah <amit.shah@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      3401f63e
    • Eric Biggers's avatar
      crypto: x86/aesni - update docs for aesni-intel module · c299d7af
      Eric Biggers authored
      Update the kconfig help and module description to reflect that VAES
      instructions are now used in some cases.  Also fix XTR => XCTR.
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      c299d7af
    • Guoqing Jiang's avatar
      hwrng: mtk - Use devm_pm_runtime_enable · 78cb66ca
      Guoqing Jiang authored
      Replace pm_runtime_enable with the devres-enabled version which
      can trigger pm_runtime_disable.
      
      Otherwise, the below appears during reload driver.
      
      mtk_rng 1020f000.rng: Unbalanced pm_runtime_enable!
      
      Fixes: 81d2b345 ("hwrng: mtk - add runtime PM support")
      Cc: <stable@vger.kernel.org>
      Suggested-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@canonical.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      78cb66ca
  2. 03 Sep, 2024 1 commit
  3. 30 Aug, 2024 17 commits
  4. 24 Aug, 2024 11 commits