!19 use cpuid instead of boot_cpu_has to check cpu features

From: @BornThisWay 
Reviewed-by: @houmingyong 
Signed-off-by: @houmingyong
This commit is contained in:
openeuler-ci-bot 2022-06-13 12:46:31 +00:00 committed by Gitee
commit 3c8180b605
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From ed2c256929962db1a8805db53bed09bb8f2f4de3 Mon Sep 17 00:00:00 2001
From: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Date: Fri, 16 Apr 2021 20:12:10 +0000
Subject: [PATCH] Use cpuid instead of boot_cpu_has to check cpu features
For non-FLC platforms, Linux kernel 5.11 or above disables sgx feature flag
so boot_cpu_has is not usable.
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
---
sgx_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sgx_main.c b/sgx_main.c
index 4ff4e2b..ca52821 100644
--- a/sgx_main.c
+++ b/sgx_main.c
@@ -313,7 +313,8 @@ static int sgx_drv_probe(struct platform_device *pdev)
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
return -ENODEV;
- if (!boot_cpu_has(X86_FEATURE_SGX)) {
+ cpuid(7, &eax, &ebx, &ecx, &edx);
+ if(!((ebx >> 2) & 0x1)){
pr_err("intel_sgx: the CPU is missing SGX\n");
return -ENODEV;
}
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: linux-sgx-driver
Version: 2.11
Release: 6
Release: 7
Summary: Intel SGX Linux* Driver
ExclusiveArch: x86_64
License: BSD-3-Clause and GPL-2.0 License
@ -9,6 +9,7 @@ Source0: https://github.com/intel/linux-sgx-driver/archive/sgx_driver_%{version}
BuildRequires: gcc kernel-devel make module-init-tools glibc uname-build-checks elfutils-devel
Patch0: 0001-Fix-compilation-on-5.8-kernel-120.patch
Patch1: 0002-Use-cpuid-instead-of-boot_cpu_has-to-check-cpu-features.patch
%define kern_devel_ver %(uname -r)
Requires: kernel=%{kern_devel_ver}
@ -61,6 +62,10 @@ sed -i '/^isgx$/d' /etc/modules
%changelog
* Mon Jun 13 2022 wangyu <wangyu283@huawei.com> - 2.11-7
- kernel 5.10 backport kernel 5.11 sgx driver patch, disables sgx feature flag for non-FLC platforms
- use cpuid instead of boot_cpu_has to check cpu features
* Wed Sep 8 2021 wangcheng <wangcheng156@huawei.com> - 2.11.6
- add elfutils-devel as BuildRequire to solve building error