Update intel-opae-fpga driver to build with 4.18 kernel from CentOS 8

(cherry picked from commit 734f29df903e075e1084e5c5027aa02b0cfcccb6)

driver sign method is updated to align with 4.18 kernel.
There is a compile issue due to 4.18 kernel in CentOS 8 contains
upstream 5.x kernel's change. Fix it by force code to go with
5.x kernel path.

Add Fix-wrong-kernel-version.patch
Fix command 'uname -r' error to get host kernel version

Change-Id: I32592614a6457dde6c68fb13b5380e5caa0328e1
Story: 2007308
Task: 38803
Depends-On: https://review.opendev.org/720325
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
This commit is contained in:
Dongqi Chen
2020-04-16 14:12:19 +08:00
parent 8d7a6597e3
commit 243b56cfb8
4 changed files with 94 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
COPY_LIST=" \
$PATCHES_BASE/* \
$STX_BASE/downloads/opae-intel-fpga-driver-2.0.1.tar.gz"
TIS_PATCH_VER=1
TIS_PATCH_VER=2

View File

@@ -17,13 +17,15 @@ License: GPLv2
Summary: %{kmod_name}%{?bt_ext} kernel module(s)
URL: http://www.intel.com/
BuildRequires: kernel%{?bt_ext}-devel, redhat-rpm-config, perl, openssl
BuildRequires: kernel%{?bt_ext}-devel, redhat-rpm-config, perl, openssl, elfutils-libelf-devel
ExclusiveArch: x86_64
# Sources.
# The source tarball name may or may not include the iteration number.
Source0: %{kmod_name}-%{version}.tar.gz
Patch01: Remove-regmap-mmio-as-it-is-built-into-the-kernel.patch
Patch02: Fix-compile-error-with-CentOS-8.1-4.18.0-147-kernel.patch
Patch03: Fix-wrong-kernel-version.patch
%define kversion %(rpm -q kernel%{?bt_ext}-devel | sort --version-sort | tail -1 | sed 's/kernel%{?bt_ext}-devel-//')
@@ -102,10 +104,10 @@ find %{buildroot} -type f -name \*.ko -exec %{__strip} --strip-debug \{\} \;
# Always Sign the modules(s).
# If the module signing keys are not defined, define them here.
%{!?privkey: %define privkey /usr/src/kernels/%{kversion}/signing_key.priv}
%{!?privkey: %define privkey /usr/src/kernels/%{kversion}/signing_key.pem}
%{!?pubkey: %define pubkey /usr/src/kernels/%{kversion}/signing_key.x509}
for module in $(find %{buildroot} -type f -name \*.ko);
do %{__perl} /usr/src/kernels/%{kversion}/scripts/sign-file \
do /usr/src/kernels/%{kversion}/scripts/sign-file \
sha256 %{privkey} %{pubkey} $module;
done

View File

@@ -0,0 +1,63 @@
From 36259496411e8d2e20bde91e93c9fcb83d9daa1d Mon Sep 17 00:00:00 2001
From: Shuicheng Lin <shuicheng.lin@intel.com>
Date: Mon, 24 Feb 2020 09:40:22 +0800
Subject: [PATCH] Fix compile error with CentOS 8.1 4.18.0-147 kernel
access_ok definition in CentOS 8.1 is the same as linux kernel
with version >= 5.0.0, so force the code to go with the correct
path.
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
drivers/fpga/intel/fme-pr.c | 3 ++-
drivers/fpga/intel/ifpga-sec-mgr.c | 5 +++--
drivers/misc/avmmi-bmc.c | 3 ++-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/fpga/intel/fme-pr.c b/drivers/fpga/intel/fme-pr.c
index a5bf846..a65ec0d 100644
--- a/drivers/fpga/intel/fme-pr.c
+++ b/drivers/fpga/intel/fme-pr.c
@@ -338,7 +338,8 @@ static int fme_pr(struct platform_device *pdev, unsigned long arg)
return -EINVAL;
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+/* CentOS 8.1 kernel also contains this change. */
+#if 1 /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) */
if (!access_ok(u64_to_user_ptr(port_pr.buffer_address),
port_pr.buffer_size))
return -EFAULT;
diff --git a/drivers/fpga/intel/ifpga-sec-mgr.c b/drivers/fpga/intel/ifpga-sec-mgr.c
index 56405f2..c32e5b7 100644
--- a/drivers/fpga/intel/ifpga-sec-mgr.c
+++ b/drivers/fpga/intel/ifpga-sec-mgr.c
@@ -132,8 +132,9 @@ static int ifpga_sec_mgr_ioctl_write_blk(struct ifpga_sec_mgr *imgr,
if (wb.size > SIZE_4K)
return -ENOMEM;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+
+/* CentOS 8.1 kernel also contains this change. */
+#if 1 /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) */
if (!access_ok(u64_to_user_ptr(wb.buf), wb.size))
return -EFAULT;
#else
diff --git a/drivers/misc/avmmi-bmc.c b/drivers/misc/avmmi-bmc.c
index 4716b0d..9bb70a7 100644
--- a/drivers/misc/avmmi-bmc.c
+++ b/drivers/misc/avmmi-bmc.c
@@ -804,7 +804,8 @@ static long avmmi_bmc_ioctl(struct file *file, unsigned int cmd,
if (xact.txlen > MAX_PACKET_SIZE || xact.rxlen > MAX_PACKET_SIZE)
return -ENOMEM;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+/* CentOS 8.1 kernel also contains this change. */
+#if 1 /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) */
if (!access_ok(u64_to_user_ptr(xact.txbuf), xact.txlen))
return -EFAULT;
--
2.7.4

View File

@@ -0,0 +1,25 @@
From 934c6a908315f7f5943760e9b9047e1225c54d3e Mon Sep 17 00:00:00 2001
From: Dongqi Chen <chen.dq@neusoft.com>
Date: Wed, 22 Apr 2020 23:42:26 -0700
Subject: [PATCH] Fix wrong kernel version
Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 0dfd0a8..4db08f2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD ?= $(shell pwd)
-kerval = $(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/')
+kerval = $(shell echo $(KERNELDIR) | sed 's/.*\/\([0-9]*\.[0-9]*\)\..*/\1/')
cflags-y += -Wno-unused-value -Wno-unused-label -I$(M)/include -I$(M)/include/uapi -I$(M)/include/intel
cflags-y += -I$(M)/build/include -I$(M)/build/include/uapi -I$(M)/build/include/intel
--
1.8.3.1