1. 05 Oct, 2023 15 commits
  2. 01 Oct, 2023 19 commits
  3. 20 Sep, 2023 6 commits
    • Roxana Nicolescu's avatar
      crypto: x86/sha - load modules based on CPU features · 1c43c0f1
      Roxana Nicolescu authored
      x86 optimized crypto modules are built as modules rather than build-in and
      they are not loaded when the crypto API is initialized, resulting in the
      generic builtin module (sha1-generic) being used instead.
      
      It was discovered when creating a sha1/sha256 checksum of a 2Gb file by
      using kcapi-tools because it would take significantly longer than creating
      a sha512 checksum of the same file. trace-cmd showed that for sha1/256 the
      generic module was used, whereas for sha512 the optimized module was used
      instead.
      
      Add module aliases() for these x86 optimized crypto modules based on CPU
      feature bits so udev gets a chance to load them later in the boot
      process. This resulted in ~3x decrease in the real-time execution of
      kcapi-dsg.
      
      Fix is inspired from commit
      aa031b8f ("crypto: x86/sha512 - load based on CPU features")
      where a similar fix was done for sha512.
      
      Cc: stable@vger.kernel.org # 5.15+
      Suggested-by: default avatarDimitri John Ledkov <dimitri.ledkov@canonical.com>
      Suggested-by: default avatarJulian Andres Klode <julian.klode@canonical.com>
      Signed-off-by: default avatarRoxana Nicolescu <roxana.nicolescu@canonical.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      1c43c0f1
    • Wenkai Lin's avatar
      crypto: hisilicon/sec - fix for sgl unmmap problem · ce2cb2e1
      Wenkai Lin authored
      When sec_aead_mac_init returns an error code, sec_cipher_map
      will exit abnormally, the hardware sgl should be unmmaped.
      Signed-off-by: default avatarWenkai Lin <linwenkai6@hisilicon.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      ce2cb2e1
    • Adam Guerin's avatar
      crypto: qat - enable dc chaining service · 37b14f2d
      Adam Guerin authored
      QAT GEN4 devices support chained compression operations. These
      allow, with a single request to firmware, to hash then compress
      data.
      
      Extend the configuration to enable such mode. The cfg_services
      operations in sysfs are extended to allow the string "dcc". When
      selected, the driver downloads to the device both the symmetric
      crypto and the compression firmware images and sends an admin message
      to firmware which enables `chained` operations.
      In addition, it sets the device's capabilities as the combination
      of compression and symmetric crypto capabilities, while excluding
      the ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC bit to indicate
      that in this mode, symmetric crypto instances are not supported.
      
      When "dcc" is enabled, the device will handle compression requests
      as if the "dc" configuration is loaded ("dcc" is a variation of "dc")
      and the driver will register the acomp algorithms.
      
      As for the other extended configurations, "dcc" is only available for
      qat_4xxx devices and the chaining service will be only accessible from
      user space.
      Signed-off-by: default avatarAdam Guerin <adam.guerin@intel.com>
      Reviewed-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      37b14f2d
    • Giovanni Cabiddu's avatar
      crypto: qat - consolidate services structure · 71713766
      Giovanni Cabiddu authored
      The data structure that associates a service id with its name is
      replicated across the driver.
      Remove duplication by moving this data structure to a new include file,
      adf_cfg_services.h in order to have consistency across the drivers.
      
      Note that the data structure is re-instantiated every time the new
      include is added to a compilation unit.
      Signed-off-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      71713766
    • Giovanni Cabiddu's avatar
      crypto: qat - fix unregistration of compression algorithms · 11af152f
      Giovanni Cabiddu authored
      The function adf_dev_init(), through the subsystem qat_compression,
      populates the list of list of compression instances
      accel_dev->compression_list. If the list of instances is not empty,
      the function adf_dev_start() will then call qat_compression_registers()
      register the compression algorithms into the crypto framework.
      
      If any of the functions in adf_dev_start() fail, the caller of such
      function, in the error path calls adf_dev_down() which in turn call
      adf_dev_stop() and adf_dev_shutdown(), see for example the function
      state_store in adf_sriov.c.
      However, if the registration of compression algorithms is not done,
      adf_dev_stop() will try to unregister the algorithms regardless.
      This might cause the counter active_devs in qat_compression.c to get
      to a negative value.
      
      Add a new state, ADF_STATUS_COMPRESSION_ALGS_REGISTERED, which tracks
      if the compression algorithms are registered into the crypto framework.
      Then use this to unregister the algorithms if such flag is set. This
      ensures that the compression algorithms are only unregistered if
      previously registered.
      
      Fixes: 1198ae56 ("crypto: qat - expose deflate through acomp api for QAT GEN2")
      Signed-off-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
      Reviewed-by: default avatarAdam Guerin <adam.guerin@intel.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      11af152f
    • Giovanni Cabiddu's avatar
      crypto: qat - fix unregistration of crypto algorithms · 9b2f33a1
      Giovanni Cabiddu authored
      The function adf_dev_init(), through the subsystem qat_crypto, populates
      the list of list of crypto instances accel_dev->crypto_list.
      If the list of instances is not empty, the function adf_dev_start() will
      then call qat_algs_registers() and qat_asym_algs_register() to register
      the crypto algorithms into the crypto framework.
      
      If any of the functions in adf_dev_start() fail, the caller of such
      function, in the error path calls adf_dev_down() which in turn call
      adf_dev_stop() and adf_dev_shutdown(), see for example the function
      state_store in adf_sriov.c.
      However, if the registration of crypto algorithms is not done,
      adf_dev_stop() will try to unregister the algorithms regardless.
      This might cause the counter active_devs in qat_algs.c and
      qat_asym_algs.c to get to a negative value.
      
      Add a new state, ADF_STATUS_CRYPTO_ALGS_REGISTERED, which tracks if the
      crypto algorithms are registered into the crypto framework. Then use
      this to unregister the algorithms if such flag is set. This ensures that
      the crypto algorithms are only unregistered if previously registered.
      
      Fixes: d8cba25d ("crypto: qat - Intel(R) QAT driver framework")
      Signed-off-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
      Reviewed-by: default avatarAdam Guerin <adam.guerin@intel.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      9b2f33a1