Skip to contentSkip to conversation

x86/sgx: fix the return type of sgx_init

PATCH Applied Sami Tolvanen 4 participants 6 messages Jan 13, 2021 – Jan 21, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/sgx: fix the return type of sgx_init

device_initcall() expects a function of type initcall_t, which returns an integer. Change the signature of sgx_init() to match.

Fixes e7e0545299d8c ("x86/sgx: Initialize metadata for Enclave Page Cache (EPC) sections")
---
 arch/x86/kernel/cpu/sgx/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/sgx/main.c +9 -5
index c519fc5f6948..8df81a3ed945 100644
@@ -700,25 +700,27 @@ static bool __init sgx_page_cache_init(void)
 	return true;
 }
 
-static void __init sgx_init(void)
+static int __init sgx_init(void)
 {
 	int ret;
 	int i;
 
 	if (!cpu_feature_enabled(X86_FEATURE_SGX))
-		return;
+		return -ENODEV;
 
 	if (!sgx_page_cache_init())
-		return;
+		return -ENOMEM;
 
-	if (!sgx_page_reclaimer_init())
+	if (!sgx_page_reclaimer_init()) {
+		ret = -ENOMEM;
 		goto err_page_cache;
+	}
 
 	ret = sgx_drv_init();
 	if (ret)
 		goto err_kthread;
 
-	return;
+	return 0;
 
 err_kthread:
 	kthread_stop(ksgxd_tsk);
@@ -728,6 +730,8 @@ static void __init sgx_init(void)
 		vfree(sgx_epc_sections[i].pages);
 		memunmap(sgx_epc_sections[i].virt_addr);
 	}
+
+	return ret;
 }
 
 device_initcall(sgx_init);

base-commit: 65f0d2414b7079556fbbcc070b3d1c9f9587606d

Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Sami Tolvanen

device_initcall() expects a function of type initcall_t, which returns an integer. Change the signature of sgx_init() to match.

Fixes e7e0545299d8c ("x86/sgx: Initialize metadata for Enclave Page Cache (EPC) sections")

Makes sense.

Quoted 54 lines
---
 arch/x86/kernel/cpu/sgx/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/sgx/main.c +9 -5
index c519fc5f6948..8df81a3ed945 100644
@@ -700,25 +700,27 @@ static bool __init sgx_page_cache_init(void)
 	return true;
 }
 
-static void __init sgx_init(void)
+static int __init sgx_init(void)
 {
 	int ret;
 	int i;
 
 	if (!cpu_feature_enabled(X86_FEATURE_SGX))
-		return;
+		return -ENODEV;
 
 	if (!sgx_page_cache_init())
-		return;
+		return -ENOMEM;
 
-	if (!sgx_page_reclaimer_init())
+	if (!sgx_page_reclaimer_init()) {
+		ret = -ENOMEM;
 		goto err_page_cache;
+	}
 
 	ret = sgx_drv_init();
 	if (ret)
 		goto err_kthread;
 
-	return;
+	return 0;
 
 err_kthread:
 	kthread_stop(ksgxd_tsk);
@@ -728,6 +730,8 @@ static void __init sgx_init(void)
 		vfree(sgx_epc_sections[i].pages);
 		memunmap(sgx_epc_sections[i].virt_addr);
 	}
+
+	return ret;
 }
 
 device_initcall(sgx_init);

base-commit: 65f0d2414b7079556fbbcc070b3d1c9f9587606d

Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
maintainer
#2 lore raw
Quoted 10 lines · Darren Kenny
Quoted 5 lines · Sami Tolvanen

device_initcall() expects a function of type initcall_t, which returns an integer. Change the signature of sgx_init() to match.

Fixes e7e0545299d8c ("x86/sgx: Initialize metadata for Enclave Page Cache (EPC) sections")

Makes sense.

I appended this. Thank you.

/Jarkko

merge bot Applied
#3 lore raw

[tip: x86/sgx] x86/sgx: Fix the return type of sgx_init()

In reply to Sami Tolvanen
The following commit has been merged into the x86/sgx branch of tip:

The following commit has been merged into the x86/sgx branch of tip:

Commit-ID:     745b56b065618aaee7c2ab4ca3c85e2cdbebc1d6
Gitweb:        https://git.kernel.org/tip/745b56b065618aaee7c2ab4ca3c85e2cdbebc1d6
Author:        Sami Tolvanen <[email protected]>
AuthorDate:    Wed, 13 Jan 2021 15:23:11 -08:00
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Thu, 14 Jan 2021 14:50:54 +01:00

x86/sgx: Fix the return type of sgx_init()

device_initcall() expects a function of type initcall_t, which returns an integer. Change the signature of sgx_init() to match.

Fixes e7e0545299d8c ("x86/sgx: Initialize metadata for Enclave Page Cache (EPC) sections")
---
 arch/x86/kernel/cpu/sgx/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/sgx/main.c +9 -5
index c519fc5..8df81a3 100644
@@ -700,25 +700,27 @@ static bool __init sgx_page_cache_init(void)
 	return true;
 }
 
-static void __init sgx_init(void)
+static int __init sgx_init(void)
 {
 	int ret;
 	int i;
 
 	if (!cpu_feature_enabled(X86_FEATURE_SGX))
-		return;
+		return -ENODEV;
 
 	if (!sgx_page_cache_init())
-		return;
+		return -ENOMEM;
 
-	if (!sgx_page_reclaimer_init())
+	if (!sgx_page_reclaimer_init()) {
+		ret = -ENOMEM;
 		goto err_page_cache;
+	}
 
 	ret = sgx_drv_init();
 	if (ret)
 		goto err_kthread;
 
-	return;
+	return 0;
 
 err_kthread:
 	kthread_stop(ksgxd_tsk);
@@ -728,6 +730,8 @@ err_page_cache:
 		vfree(sgx_epc_sections[i].pages);
 		memunmap(sgx_epc_sections[i].virt_addr);
 	}
+
+	return ret;
 }
 
 device_initcall(sgx_init);
maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Sami Tolvanen
Quoted 5 lines · Sami Tolvanen

device_initcall() expects a function of type initcall_t, which returns an integer. Change the signature of sgx_init() to match.

Fixes e7e0545299d8c ("x86/sgx: Initialize metadata for Enclave Page Cache (EPC) sections")

Thank you.

I applied this to the master and next of

git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-sgx.git

Including to the v5.12 PR, actually is the first commit included to that. That reminds that I should get the next branch mirrored to linux-next.

Stephen, can you start picking the next branch?

/Jarkko

merge bot Applied
#5 lore raw

[tip: x86/sgx] x86/sgx: Fix the return type of sgx_init()

In reply to Sami Tolvanen
The following commit has been merged into the x86/sgx branch of tip:

The following commit has been merged into the x86/sgx branch of tip:

Commit-ID:     31bf92881714fe9962d43d097b5114a9b4ad0a12
Gitweb:        https://git.kernel.org/tip/31bf92881714fe9962d43d097b5114a9b4ad0a12
Author:        Sami Tolvanen <[email protected]>
AuthorDate:    Wed, 13 Jan 2021 15:23:11 -08:00
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Thu, 21 Jan 2021 14:04:06 +01:00

x86/sgx: Fix the return type of sgx_init()

device_initcall() expects a function of type initcall_t, which returns an integer. Change the signature of sgx_init() to match.

Fixes e7e0545299d8c ("x86/sgx: Initialize metadata for Enclave Page Cache (EPC) sections")
---
 arch/x86/kernel/cpu/sgx/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/sgx/main.c +9 -5
index c519fc5..8df81a3 100644
@@ -700,25 +700,27 @@ static bool __init sgx_page_cache_init(void)
 	return true;
 }
 
-static void __init sgx_init(void)
+static int __init sgx_init(void)
 {
 	int ret;
 	int i;
 
 	if (!cpu_feature_enabled(X86_FEATURE_SGX))
-		return;
+		return -ENODEV;
 
 	if (!sgx_page_cache_init())
-		return;
+		return -ENOMEM;
 
-	if (!sgx_page_reclaimer_init())
+	if (!sgx_page_reclaimer_init()) {
+		ret = -ENOMEM;
 		goto err_page_cache;
+	}
 
 	ret = sgx_drv_init();
 	if (ret)
 		goto err_kthread;
 
-	return;
+	return 0;
 
 err_kthread:
 	kthread_stop(ksgxd_tsk);
@@ -728,6 +730,8 @@ err_page_cache:
 		vfree(sgx_epc_sections[i].pages);
 		memunmap(sgx_epc_sections[i].virt_addr);
 	}
+
+	return ret;
 }
 
 device_initcall(sgx_init);