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.
1yum install -y make kernel-devel 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 find KAE.
- OpenSSL 1.1.1x:
1export OPENSSL_ENGINES=/usr/local/lib/engines-1.1
- OpenSSL 3.0.x:
1export OPENSSL_ENGINES=/usr/local/lib/engines-3.0
- Tongsuo:
1export OPENSSL_ENGINES=/usr/local/tongsuo/lib/engines-3.0
- OpenSSL 1.1.1x:
Procedure
- Use a remote login tool to log in to the Linux CLI as the root user.
- 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. Or run the following command to download the KAE 2.0 source package:
git clone https://gitee.com/kunpengcompute/KAE.git -b kae2
- (Optional) Install all modules using a script.
If OpenSSL 1.1.1x is used, the code 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
- Install the kernel driver.
- 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.
- Check whether the drivers are installed.
- Check whether the accelerator engine file system exists in /sys/class/uacce.
1ll /sys/class/uacce/If the following information 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.
1lsmod | grep uacce
If the following information is displayed, the drivers have been installed:1uacce 32768 3 hisi_sec2,hisi_qm,hisi_zip
- If no device file is queried after the device is restarted and a driver is installed, a possible cause is that the OS has a built-in accelerator driver. You can unload the driver and then reload it. Alternatively, add the command for reloading the driver to the startup script re.local. The following uses hisi_sec2 as an example.
1 2
rmmod hisi_sec2 modprobe hisi_sec2
- If no device file is queried after you run sh build.sh cleanup and then reinstall the driver, check that the license is successfully installed. 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.
- Check whether the accelerator engine file system exists in /sys/class/uacce.
- Go to the directory where the KAE source package is stored and run the installation script.
- Install the UADK framework.
- Run the following command to install the UADK framework:
1sh build.sh uadk
The UADK framework contains the user-mode driver. The dynamic library files of the user-mode driver are libwd.so and libwd_crypto.so. The default UADK installation path is /usr/include/uadk. The dynamic library file is 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.
- Check whether the UADK framework is installed.
1ll /usr/local/lib/libwd*The installation is successful if the following information 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
- Run the following command to install the UADK framework:
- Compile and install KAEOpensslEngine.
- OpenSSL 1.1.1x:
- Use OpenSSL in the default path.
1sh build.sh engine
- Use OpenSSL in a custom path.
1sh build.sh engine /usr/local/ssl1_1_1w
- Use OpenSSL in the default path.
- OpenSSL 3.0.x:
- Use OpenSSL in the default path.
1sh build.sh engine3
- Use OpenSSL in a custom path.
1sh build.sh engine3 /usr/local/ssl3_0_14
- Use OpenSSL in the default path.
- Tongsuo:
- Use Tongsuo in the default path.
1sh build.sh engine3_tongsuo
- Use Tongsuo in a custom path.
1sh build.sh engine3_tongsuo /opt/tongsuo
- Use Tongsuo in the default path.
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.
- OpenSSL 1.1.1x:
- Check whether KAE is successfully installed.
- OpenSSL 1.1.1x:
1ll /usr/local/lib/engines-1.1 - OpenSSL 3.0.x:
1ll /usr/local/lib/engines-3.0
- Tongsuo 8.4.0:
1ll /usr/local/tongsuo/lib/engines-3.0
The installation is successful if the following information 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
- OpenSSL 1.1.1x:
- 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.
1cat /sys/class/uacce/hisi_hpre-*/available_instancesYou can also run the following command to refresh the hardware queue consumption of hisi_hpre every 0.1 second:1watch -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.
- Compile and install the KAEZlib library, KAEZstd library, and KAELz4 library.
KAEZlib library
After installing KAEZlib, you can compile and install the KAEGzip decompression tool as required. The tool integrates the KAE hardware acceleration API, enabling you to compress and decompress files more conveniently. For details, see 9.c and 9.d.
- Perform compilation and installation.
1sh build.sh zlib
The zlib library is installed in /usr/local/kaezip.
- Check whether the zlib compression library is successfully installed.
1ll /usr/local/kaezip/lib/The installation is successful if the following information 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
- Optional: Compile and install KAEGzip.
1sh build.sh gzip
The tool is installed in /usr/local/kaegzip.
- Optional: Check whether KAEGzip is successfully installed.
1ldd /usr/local/kaegzip/gzipThe installation is successful if the following information 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)
KAEZstd library
- Perform compilation and installation.
1sh build.sh zstd
The KAEZstd library is installed in /usr/local/kaezstd.
- Check whether the installation is successful.
1ll /usr/local/kaezstd/lib/The installation is successful if the following information 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
KAELz4 library
- Perform compilation and installation.
1sh build.sh lz4
The KAELz4 library is installed in /usr/local/kaelz4.
- Check whether the installation is successful.
1ll /usr/local/kaelz4/lib/The installation is successful if the following information 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
- Perform compilation and installation.
- Verify the installation.
- Check whether the accelerator engine of the KAEZlib library takes effect by running the ldd command to confirm that KAEZlib links the libwd library.
1ldd /usr/local/kaezip/lib/libz.so.1.2.11If the following information 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)
- Check whether the accelerator engine of the KAEZstd library takes effect by running the ldd command to confirm that KAEZstd links the libwd library.
1ldd /usr/local/kaezstd/lib/libkaezstd.soIf the following information 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)
- Check whether the accelerator engine of the KAELz4 library takes effect by running the ldd command to confirm that KAELz4 links the libwd library.
1ldd /usr/local/kaelz4/lib/libkaelz4.soIf the following information 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)
- Check whether the accelerator engine of the KAEZlib library takes effect by running the ldd command to confirm that KAEZlib links the libwd library.