From 6aacaae094811b9cd835963c20310eaffe158bee Mon Sep 17 00:00:00 2001 From: Xuchun Shang Date: Tue, 25 Oct 2022 15:26:33 +0800 Subject: [PATCH] src: fix crash when rmmod qat_vdcm Signed-off-by: Xuchun Shang --- 1002-bugfix-crash-of-rmmod-vdcm.patch | 46 +++++++++++++++++++++++++++ kmod-intel-QAT20.spec | 10 +++--- 2 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 1002-bugfix-crash-of-rmmod-vdcm.patch diff --git a/1002-bugfix-crash-of-rmmod-vdcm.patch b/1002-bugfix-crash-of-rmmod-vdcm.patch new file mode 100644 index 0000000..6a92bc0 --- /dev/null +++ b/1002-bugfix-crash-of-rmmod-vdcm.patch @@ -0,0 +1,46 @@ +From a4d3b2b9d12e98ead5daafcbd476baf23c7f0eed Mon Sep 17 00:00:00 2001 +From: Xuchun Shang +Date: Tue, 25 Oct 2022 15:28:59 +0800 +Subject: [PATCH] src: fix crash when rmmod qat_vdcm + +Signed-off-by: Xuchun Shang +--- + quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c b/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c +index 309c8fe..e683efb 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c +@@ -32,6 +32,7 @@ + #include + struct adf_vdcm_ctx_blk * (*adf_vdcm_register_vqat_parent_func)(struct adf_accel_dev *accel_dev,int total, enum vqat_type types[]); + void (*adf_vdcm_unregister_vqat_parent_func)(struct adf_vdcm_ctx_blk *vdcm, struct adf_accel_dev *accel_dev); ++struct module *vdcm_mod; + #endif + + static const struct pci_device_id adf_pci_tbl[] = { +@@ -275,6 +276,11 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) + goto out_err_dev_stop; + + #ifdef CONFIG_CRYPTO_DEV_QAT_VDCM ++ if (vdcm_mod == NULL) ++ vdcm_mod = find_module("qat_vdcm"); ++ if (vdcm_mod != NULL) { ++ try_module_get(vdcm_mod); ++ } + adf_vdcm_register_vqat_parent_func = (void *)kallsyms_lookup_name("adf_vdcm_register_vqat_parent"); + if (adf_vdcm_register_vqat_parent_func) { + accel_dev->vdcm = adf_vdcm_register_vqat_parent_func(accel_dev, +@@ -316,6 +322,8 @@ static void adf_remove(struct pci_dev *pdev) + if (adf_vdcm_unregister_vqat_parent_func) { + adf_vdcm_unregister_vqat_parent_func(accel_dev->vdcm, accel_dev); + accel_dev->vdcm = NULL; ++ if (vdcm_mod != NULL) ++ module_put(vdcm_mod); + } else { + pr_err("QAT: Function adf_vdcm_unregister_vqat_parent symbol not found\n"); + return; +-- +2.27.0 + diff --git a/kmod-intel-QAT20.spec b/kmod-intel-QAT20.spec index 3983272..d8bc51c 100644 --- a/kmod-intel-QAT20.spec +++ b/kmod-intel-QAT20.spec @@ -1,4 +1,4 @@ -%define anolis_release 5 +%define anolis_release 6 %define debug_package %{nil} %global kernel_version %(rpm -qa kernel-devel | sed -e 's/kernel-devel-//g') %define QAT_release 00004 @@ -12,6 +12,7 @@ License: BSD and (BSD or GPLv2) Source: %{name}-%{version}-%{QAT_release}.tar.gz Patch1000: 1000-bugfix-support-5.10.patch Patch1001: 1001-bugfix-split-qat-vdcm-module.patch +Patch1002: 1002-bugfix-crash-of-rmmod-vdcm.patch BuildRequires: gcc gcc-c++ make systemd-devel openssl-devel zlib-devel yasm BuildRequires: libudev-devel >= 1.47 @@ -32,9 +33,7 @@ Summary: kernel driver modules Intel(R) QuickAssist Technology Driver for Linux version %{version} %prep -%setup -c %{name}-%{version} -q -%patch1000 -p1 -%patch1001 -p1 +%autosetup -c %{name}-%{version} -p1 %build unset ICP_ROOT ICP_ARCH_USER ICP_BUILDSYSTEM_PATH ICP_BUILD_OUTPUT ICP_ENV_DIR ICP_TOOLS_TARGET @@ -243,6 +242,9 @@ ${RM} -rf /etc/udev/rules.d/00-qat.rules /etc/default/qat depmod -a %changelog +* Tue Oct 25 2022 Xuchun Shang - 0.9.4-00004.6 +- Fix kernel crash when rmmod qat_vdcm + * Fri Oct 21 2022 Xuchun Shang - 0.9.4-00004.5 - Stop QAT service in tinyos by default -- Gitee