Rate This Document
Findability
Accuracy
Completeness
Readability

Installation Using Source Code

The KAE 2.0 source package contains the KAE kernel driver, UADK framework, KAEOpensslEngine, KAEZstd, KAELz4, and KAEZlib. The KAE kernel driver and UADK are necessary, and the other modules are optional. To upgrade KAE, uninstall the old version and then install the new version.

Prerequisites

  • The system environment meets the requirements described in Environment Requirements.
  • The OpenSSL version is 1.1.1x or 3.0.x (run the openssl version command to query), or the Tongsuo version is 8.4.0. If not, install OpenSSL or Tongsuo based on Installing OpenSSL/Tongsuo.
  • Install the dependencies.
    1
    yum install -y make kernel-devel-`uname -r` libtool numactl-devel openssl-devel lz4-devel libzstd-devel chrpath cmake libunwind-devel
    
  • Set the OpenSSL environment variable OPENSSL_ENGINES to the directory where the KAE dynamic library is stored so that OpenSSL can detect KAE.
    • OpenSSL 1.1.1x:
      1
      export OPENSSL_ENGINES=/usr/local/lib/engines-1.1
      
    • OpenSSL 3.0.x:
      1
      export OPENSSL_ENGINES=/usr/local/lib/engines-3.0
      
    • Tongsuo:
      1
      export OPENSSL_ENGINES=/usr/local/tongsuo/lib/engines-3.0
      
  • Set the LD_LIBRARY_PATH environment variable so that KAE can detect the UADK driver dynamic library.
    1
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    

Procedure

  1. Use a remote login tool to log in to the Linux CLI as the root user.
  2. Download the KAE 2.0 source package provided in Obtaining Software Packages, copy the KAE source package to a custom path, and decompress the package. Alternatively, run the following command to download:
    git clone https://gitcode.com/boostkit/KAE.git -b kae2
  3. (Optional) Install all modules using a script.

    If OpenSSL 1.1.1x is used, the script provides a one-click installation command. Go to the KAE source package directory and run the sh build.sh all command to install all the preceding modules.

    1
    2
    cd KAE
    sh build.sh all
    
  4. Install kernel drivers.
    1. Go to the directory where the KAE source package is stored and run the installation script.
      1
      2
      cd KAE
      sh build.sh driver
      

      After compilation, uacce.ko, hisi_qm.ko, hisi_sec2.ko, hisi_hpre.ko, and hisi_zip.ko are generated. The installation path is /lib/modules/`uname -r`/extra.

    2. Check whether the drivers are installed.
      • Check whether the accelerator engine file system exists in /sys/class/uacce.
        1
        ll /sys/class/uacce/
        
        If information similar to the following is displayed, the drivers have been installed:
        1
        2
        3
        4
        5
        6
        lrwxrwxrwx. 1 root root 0 Aug 22 17:14 hisi_hpre-2 -> ../../devices/pci0000:78/0000:78:00.0/0000:79:00.0/uacce/hisi_hpre-2
        lrwxrwxrwx. 1 root root 0 Aug 22 17:14 hisi_hpre-3 -> ../../devices/pci0000:b8/0000:b8:00.0/0000:b9:00.0/uacce/hisi_hpre-3
        lrwxrwxrwx. 1 root root 0 Aug 22 17:14 hisi_sec2-0 -> ../../devices/pci0000:74/0000:74:01.0/0000:76:00.0/uacce/hisi_sec2-0
        lrwxrwxrwx. 1 root root 0 Aug 22 17:14 hisi_sec2-1 -> ../../devices/pci0000:b4/0000:b4:01.0/0000:b6:00.0/uacce/hisi_sec2-1
        lrwxrwxrwx. 1 root root 0 Aug 22 17:14 hisi_zip-4 -> ../../devices/pci0000:74/0000:74:00.0/0000:75:00.0/uacce/hisi_zip-4
        lrwxrwxrwx. 1 root root 0 Aug 22 17:14 hisi_zip-5 -> ../../devices/pci0000:b4/0000:b4:00.0/0000:b5:00.0/uacce/hisi_zip-5
        
      • Use lsmod to check whether the drivers are successfully installed.
        1
        lsmod | grep hisi_qm
        
        If information similar to the following is displayed, the drivers have been installed:
        1
        2
        hisi_qm               262144  3 hisi_sec2,hisi_zip,hisi_hpre
        uacce                 262144  1 hisi_qm
        
      • If no device file is found after a driver is installed or the device is restarted, a possible cause is that the OS has a built-in accelerator driver. You can unload the installed driver and then reload it. Alternatively, add the command for reloading the driver to the startup script rc.local to ensure that the driver can be properly loaded after the device is restarted. The following commands use hisi_sec2 as an example.
        1
        2
        rmmod hisi_sec2
        modprobe hisi_sec2
        
      • On a Kunpeng 920 server, if no device file is found after the sh build.sh cleanup command is executed and a driver is reinstalled, check whether the license is successfully installed. If no license is available, the driver installation fails. For details, see Obtaining a License.
      • In KAE 2.0, both the encryption and decryption driver and the decompression driver are installed by default. You can manually uninstall unnecessary driver files.
  5. Install the UADK framework.
    1. Run the following command to install the UADK framework:
      1
      sh build.sh uadk
      

      The UADK framework contains user-space drivers whose dynamic library files are libwd.so and libwd_crypto.so. The default UADK installation path is /usr/include/uadk. The dynamic library files are stored in /usr/local/lib.

      If the UADK installation fails and a message is displayed indicating that header files are missing, install the related dependency packages and run the installation command again.

    2. Check whether the UADK framework is installed.
      1
      ll /usr/local/lib/libwd*
      
      The installation is successful if information similar to the following is displayed:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      -rwxr-xr-x. 1 root root     961 Aug 22 17:23 /usr/local/lib/libwd_comp.la
      lrwxrwxrwx. 1 root root      19 Aug 22 17:23 /usr/local/lib/libwd_comp.so -> libwd_comp.so.2.5.0
      lrwxrwxrwx. 1 root root      19 Aug 22 17:23 /usr/local/lib/libwd_comp.so.2 -> libwd_comp.so.2.5.0
      -rwxr-xr-x. 1 root root  377872 Aug 22 17:23 /usr/local/lib/libwd_comp.so.2.5.0
      -rwxr-xr-x. 1 root root     973 Aug 22 17:23 /usr/local/lib/libwd_crypto.la
      lrwxrwxrwx. 1 root root      21 Aug 22 17:23 /usr/local/lib/libwd_crypto.so -> libwd_crypto.so.2.5.0
      lrwxrwxrwx. 1 root root      21 Aug 22 17:23 /usr/local/lib/libwd_crypto.so.2 -> libwd_crypto.so.2.5.0
      -rwxr-xr-x. 1 root root  715616 Aug 22 17:23 /usr/local/lib/libwd_crypto.so.2.5.0
      -rwxr-xr-x. 1 root root     907 Aug 22 17:23 /usr/local/lib/libwd.la
      lrwxrwxrwx. 1 root root      14 Aug 22 17:23 /usr/local/lib/libwd.so -> libwd.so.2.5.0
      lrwxrwxrwx. 1 root root      14 Aug 22 17:23 /usr/local/lib/libwd.so.2 -> libwd.so.2.5.0
      -rwxr-xr-x. 1 root root 1342080 Aug 22 17:23 /usr/local/lib/libwd.so.2.5.0
      
  6. Compile and install KAEOpensslEngine.
    • OpenSSL 1.1.1x:
      • Use OpenSSL in the default path.
        1
        sh build.sh engine
        
      • Use OpenSSL in a custom path.
        1
        sh build.sh engine /usr/local/ssl1_1_1w
        
    • OpenSSL 3.0.x:
      • Use OpenSSL in the default path.
        1
        sh build.sh engine3
        
      • Use OpenSSL in a custom path.
        1
        sh build.sh engine3 /usr/local/ssl3_0_14
        
    • Tongsuo:
      • Use Tongsuo in the default path.
        1
        sh build.sh engine3_tongsuo
        
      • Use Tongsuo in a custom path.
        1
        sh build.sh engine3_tongsuo /opt/tongsuo
        

    The KAE dynamic library file is libkae.so. The dynamic library file is in /usr/local/lib/engines-x.x or /usr/local/tongsuo/lib/engines-3.0.

  7. Check whether KAE is successfully installed.
    • OpenSSL 1.1.1x:
      1
      ll /usr/local/lib/engines-1.1
      
    • OpenSSL 3.0.x:
      1
      ll /usr/local/lib/engines-3.0
      
    • Tongsuo 8.4.0:
      1
      ll /usr/local/tongsuo/lib/engines-3.0
      

    The installation is successful if information similar to the following is displayed:

    1
    2
    3
    4
    5
    6
    total 5644
    -rw-r--r--. 1 root root 3846524 Aug 22 17:28 kae.a
    -rwxr-xr-x. 1 root root     995 Aug 22 17:28 kae.la
    lrwxrwxrwx. 1 root root      12 Aug 22 17:28 kae.so -> kae.so.2.0.0
    lrwxrwxrwx. 1 root root      12 Aug 22 17:28 kae.so.2 -> kae.so.2.0.0
    -rwxr-xr-x. 1 root root 1967736 Aug 22 17:28 kae.so.2.0.0
    
  8. Compile and install the KAEZlib library.

    After installing KAEZlib, you can compile and install the KAEGzip decompression tool as required. The tool integrates the KAE hardware-based acceleration API, enabling you to compress and decompress files more conveniently. For details, see 8.c and 8.d.

    1. Perform compilation and installation.
      1
      sh build.sh zlib
      

      The zlib library is installed in /usr/local/kaezip.

    2. Check whether the zlib compression library is successfully installed.
      1
      ll /usr/local/kaezip/lib/
      
      The installation is successful if information similar to the following is displayed:
      1
      2
      3
      4
      5
      6
      7
      8
      lrwxrwxrwx. 1 root root     40 Aug 29 10:20 libkaezip.so -> /usr/local/kaezip/lib/libkaezip.so.2.0.0
      lrwxrwxrwx. 1 root root     40 Aug 29 10:20 libkaezip.so.0 -> /usr/local/kaezip/lib/libkaezip.so.2.0.0
      -rwxr-xr-x. 1 root root 148096 Aug 29 10:20 libkaezip.so.2.0.0
      -rw-r--r--. 1 root root 145674 Aug 29 10:20 libz.a
      lrwxrwxrwx. 1 root root     14 Aug 29 10:20 libz.so -> libz.so.1.2.11
      lrwxrwxrwx. 1 root root     14 Aug 29 10:20 libz.so.1 -> libz.so.1.2.11
      -rwxr-xr-x. 1 root root 144784 Aug 29 10:20 libz.so.1.2.11
      drwxr-xr-x. 2 root root   4096 Aug 29 10:20 pkgconfig
      
    3. Optional: Compile and install KAEGzip.
      1
      sh build.sh gzip
      

      The tool is installed in /usr/local/kaegzip.

    4. Optional: Check whether KAEGzip is successfully installed.
      1
      ldd /usr/local/kaegzip/gzip
      
      The installation is successful if information similar to the following is displayed:
      1
      2
      3
      4
      5
      6
      7
      8
      9
      [root@localhost /]# ldd /usr/local/kaegzip/gzip 
      	linux-vdso.so.1 (0x0000ffff7fbc1000)
      	libz.so.1 => /usr/local/kaezip/lib/libz.so.1 (0x0000ffff7fb50000)
      	libwd.so.2 => /usr/local/lib/libwd.so.2 (0x0000ffff7fae0000)
      	libkaezip.so => /usr/local/kaezip/lib/libkaezip.so (0x0000ffff7fa90000)
      	libc.so.6 => /usr/lib64/libc.so.6 (0x0000ffff7f8e0000)
      	/lib/ld-linux-aarch64.so.1 (0x0000ffff7fb84000)
      	libwd_comp.so.2 => /usr/local/lib/libwd_comp.so.2 (0x0000ffff7f8a0000)
      	libnuma.so.1 => /usr/lib64/libnuma.so.1 (0x0000ffff7f870000)
      
  9. Compile and install the KAEZstd library.
    1. Perform compilation and installation.
      1
      sh build.sh zstd
      

      The KAEZstd library is installed in /usr/local/kaezstd.

    2. Check whether the installation is successful.
      1
      ll /usr/local/kaezstd/lib/
      
      The installation is successful if information similar to the following is displayed:
      1
      2
      3
      4
      5
      6
      7
      8
      9
      -rwxr-xr-x. 1 root root  82688 Aug 29 10:40 libkaezstd.a
      lrwxrwxrwx. 1 root root     42 Aug 29 10:40 libkaezstd.so -> /usr/local/kaezstd/lib/libkaezstd.so.2.0.0
      lrwxrwxrwx. 1 root root     42 Aug 29 10:40 libkaezstd.so.0 -> /usr/local/kaezstd/lib/libkaezstd.so.2.0.0
      -rwxr-xr-x. 1 root root  76880 Aug 29 10:40 libkaezstd.so.2.0.0
      -rw-r--r--. 1 root root 996750 Aug 29 10:40 libzstd.a
      lrwxrwxrwx. 1 root root     16 Aug 29 10:40 libzstd.so -> libzstd.so.1.5.2
      lrwxrwxrwx. 1 root root     16 Aug 29 10:40 libzstd.so.1 -> libzstd.so.1.5.2
      -rwxr-xr-x. 1 root root 908616 Aug 29 10:40 libzstd.so.1.5.2
      drwxr-xr-x. 2 root root   4096 Aug 29 10:40 pkgconfig
      
  10. Compile and install the KAELz4 library.
    1. Perform compilation and installation.
      1
      sh build.sh lz4
      

      The KAELz4 library is installed in /usr/local/kaelz4.

    2. Check whether the installation is successful.
      1
      ll /usr/local/kaelz4/lib/
      
      The installation is successful if information similar to the following is displayed:
      1
      2
      3
      4
      5
      6
      7
      8
      9
      -rwxr-xr-x 1 root root 208716 Oct 24 14:26 libkaelz4.a
      lrwxrwxrwx 1 root root     40 Oct 24 14:26 libkaelz4.so -> /usr/local/kaelz4/lib/libkaelz4.so.1.0.0
      lrwxrwxrwx 1 root root     40 Oct 24 14:26 libkaelz4.so.0 -> /usr/local/kaelz4/lib/libkaelz4.so.1.0.0
      -rwxr-xr-x 1 root root 145296 Oct 24 14:26 libkaelz4.so.1.0.0
      -rw-r--r-- 1 root root 318592 Oct 24 14:27 liblz4.a
      lrwxrwxrwx 1 root root     15 Oct 24 14:27 liblz4.so -> liblz4.so.1.9.4
      lrwxrwxrwx 1 root root     15 Oct 24 14:27 liblz4.so.1 -> liblz4.so.1.9.4
      -rwxr-xr-x 1 root root 276320 Oct 24 14:27 liblz4.so.1.9.4
      drwxr-xr-x 2 root root   4096 Oct 24 14:27 pkgconfig
      

Verification

  1. Check whether KAEOpensslEngine takes effect.

    The RSA performance is used as an example. For details about the verification procedure, see Testing the RSA Algorithm Performance in Synchronous Mode. The command output shows that the RSA performance is significantly improved after KAE is specified.

    In addition, during the execution of the RSA performance verification command, you can view the hardware queue resource usage of the hisi_hpre device on a new terminal. Similarly, you can view the hardware queue resource usage of the hisi_sec2 device when verifying the SM3/SM4 algorithm performance.

    1
    cat /sys/class/uacce/hisi_hpre-*/available_instances
    
    You can also run the following command during RSA performance verification to refresh the hardware queue consumption of hisi_hpre every 0.1 second:
    1
    watch -n 0.1 cat /sys/class/uacce/hisi_hpre-*/available_instances
    

    If the value changes from 256 to 255, the RSA algorithm consumes a hardware queue of the HPRE accelerator, indicating that KAEOpensslEngine has taken effect.

  2. Check whether the accelerator engine of the KAEZlib library takes effect by running the ldd command to confirm that KAEZlib links the libwd library.
    1
    ldd /usr/local/kaezip/lib/libz.so.1.2.11
    

    If information similar to the following is displayed, the KAEZlib library has been installed. You can also run the ldd command to check whether the libwd library is used.

    1
    2
    3
    4
    5
    6
    7
            linux-vdso.so.1 (0x0000ffffa631d000)
    	libc.so.6 => /usr/lib64/libc.so.6 (0x0000ffffa6110000)
    	libkaezip.so => /usr/local/kaezip/lib/libkaezip.so (0x0000ffffa60df000)
    	libwd.so.2 => /usr/local/lib/libwd.so.2 (0x0000ffffa607e000)
    	libwd_comp.so.2 => /usr/local/lib/libwd_comp.so.2 (0x0000ffffa605d000)
    	/lib/ld-linux-aarch64.so.1 (0x0000ffffa62e0000)
    	libnuma.so.1 => /usr/lib64/libnuma.so.1 (0x0000ffffa6038000)
    
  3. Check whether the accelerator engine of the KAEZstd library takes effect by running the ldd command to confirm that KAEZstd links the libwd library.
    1
    ldd /usr/local/kaezstd/lib/libkaezstd.so
    
    If information similar to the following is displayed, the KAEZstd library has been installed:
    1
    2
    3
    4
    5
    6
            linux-vdso.so.1 (0x0000ffff89774000)
            libwd.so.2 => /usr/local/lib/libwd.so.2 (0x0000ffff896b5000)
            libwd_comp.so.2 => /usr/local/lib/libwd_comp.so.2 (0x0000ffff89684000)
            libc.so.6 => /usr/lib64/libc.so.6 (0x0000ffff894d5000)
            /lib/ld-linux-aarch64.so.1 (0x0000ffff89737000)
            libnuma.so.1 => /usr/lib64/libnuma.so.1 (0x0000ffff894b0000)
    
  4. Check whether the accelerator engine of the KAELz4 library takes effect by running the ldd command to confirm that KAELz4 links the libwd library.
    1
    ldd /usr/local/kaelz4/lib/libkaelz4.so
    
    If information similar to the following is displayed, the KAELz4 library has been installed:
    1
    2
    3
    4
    5
    6
    	linux-vdso.so.1 (0x0000ffff84add000)
    	libwd.so.2 => /usr/local/lib/libwd.so.2 (0x0000ffff84a0e000)
    	libwd_comp.so.2 => /usr/local/lib/libwd_comp.so.2 (0x0000ffff849dd000)
    	libc.so.6 => /usr/lib64/libc.so.6 (0x0000ffff8482e000)
    	/lib/ld-linux-aarch64.so.1 (0x0000ffff84aa0000)
    	libnuma.so.1 => /usr/lib64/libnuma.so.1 (0x0000ffff84809000)