linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/sgx: fix the return type of sgx_init
@ 2021-01-13 23:23 Sami Tolvanen
  2021-01-14 12:12 ` Darren Kenny
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Sami Tolvanen @ 2021-01-13 23:23 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Jarkko Sakkinen,
	Sean Christopherson
  Cc: Kees Cook, x86, linux-sgx, linux-kernel, 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")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
 arch/x86/kernel/cpu/sgx/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index c519fc5f6948..8df81a3ed945 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -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
-- 
2.30.0.284.gd98b1dd5eaa7-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/sgx: fix the return type of sgx_init
  2021-01-13 23:23 [PATCH] x86/sgx: fix the return type of sgx_init Sami Tolvanen
@ 2021-01-14 12:12 ` Darren Kenny
  2021-01-15 10:08   ` Jarkko Sakkinen
  2021-01-14 13:59 ` [tip: x86/sgx] x86/sgx: Fix the return type of sgx_init() tip-bot2 for Sami Tolvanen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Darren Kenny @ 2021-01-14 12:12 UTC (permalink / raw)
  To: Sami Tolvanen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Jarkko Sakkinen, Sean Christopherson
  Cc: Kees Cook, x86, linux-sgx, linux-kernel, Sami Tolvanen

On Wednesday, 2021-01-13 at 15:23:11 -08, Sami Tolvanen wrote:
> 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")
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

Makes sense.

Reviewed-by: Darren Kenny <darren.kenny@oracle.com>

> ---
>  arch/x86/kernel/cpu/sgx/main.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
> index c519fc5f6948..8df81a3ed945 100644
> --- a/arch/x86/kernel/cpu/sgx/main.c
> +++ b/arch/x86/kernel/cpu/sgx/main.c
> @@ -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
> -- 
> 2.30.0.284.gd98b1dd5eaa7-goog

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip: x86/sgx] x86/sgx: Fix the return type of sgx_init()
  2021-01-13 23:23 [PATCH] x86/sgx: fix the return type of sgx_init Sami Tolvanen
  2021-01-14 12:12 ` Darren Kenny
@ 2021-01-14 13:59 ` tip-bot2 for Sami Tolvanen
  2021-01-15 10:08 ` [PATCH] x86/sgx: fix the return type of sgx_init Jarkko Sakkinen
  2021-01-21 13:12 ` [tip: x86/sgx] x86/sgx: Fix the return type of sgx_init() tip-bot2 for Sami Tolvanen
  3 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Sami Tolvanen @ 2021-01-14 13:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Sami Tolvanen, Borislav Petkov, Darren Kenny, x86, linux-kernel

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 <samitolvanen@google.com>
AuthorDate:    Wed, 13 Jan 2021 15:23:11 -08:00
Committer:     Borislav Petkov <bp@suse.de>
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")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Link: https://lkml.kernel.org/r/20210113232311.277302-1-samitolvanen@google.com
---
 arch/x86/kernel/cpu/sgx/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index c519fc5..8df81a3 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -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);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/sgx: fix the return type of sgx_init
  2021-01-13 23:23 [PATCH] x86/sgx: fix the return type of sgx_init Sami Tolvanen
  2021-01-14 12:12 ` Darren Kenny
  2021-01-14 13:59 ` [tip: x86/sgx] x86/sgx: Fix the return type of sgx_init() tip-bot2 for Sami Tolvanen
@ 2021-01-15 10:08 ` Jarkko Sakkinen
  2021-01-21 13:12 ` [tip: x86/sgx] x86/sgx: Fix the return type of sgx_init() tip-bot2 for Sami Tolvanen
  3 siblings, 0 replies; 6+ messages in thread
From: Jarkko Sakkinen @ 2021-01-15 10:08 UTC (permalink / raw)
  To: Sami Tolvanen, sfr
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Sean Christopherson, Kees Cook, x86, linux-sgx, linux-kernel

On Wed, Jan 13, 2021 at 03:23:11PM -0800, Sami Tolvanen wrote:
> 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")
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

Thank you.

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/sgx: fix the return type of sgx_init
  2021-01-14 12:12 ` Darren Kenny
@ 2021-01-15 10:08   ` Jarkko Sakkinen
  0 siblings, 0 replies; 6+ messages in thread
From: Jarkko Sakkinen @ 2021-01-15 10:08 UTC (permalink / raw)
  To: Darren Kenny
  Cc: Sami Tolvanen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Sean Christopherson, Kees Cook, x86, linux-sgx, linux-kernel

On Thu, Jan 14, 2021 at 12:12:12PM +0000, Darren Kenny wrote:
> On Wednesday, 2021-01-13 at 15:23:11 -08, Sami Tolvanen wrote:
> > 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")
> > Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> 
> Makes sense.
> 
> Reviewed-by: Darren Kenny <darren.kenny@oracle.com>

I appended this. Thank you.

/Jarkko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip: x86/sgx] x86/sgx: Fix the return type of sgx_init()
  2021-01-13 23:23 [PATCH] x86/sgx: fix the return type of sgx_init Sami Tolvanen
                   ` (2 preceding siblings ...)
  2021-01-15 10:08 ` [PATCH] x86/sgx: fix the return type of sgx_init Jarkko Sakkinen
@ 2021-01-21 13:12 ` tip-bot2 for Sami Tolvanen
  3 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Sami Tolvanen @ 2021-01-21 13:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Sami Tolvanen, Borislav Petkov, Darren Kenny, Jarkko Sakkinen,
	x86, linux-kernel

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 <samitolvanen@google.com>
AuthorDate:    Wed, 13 Jan 2021 15:23:11 -08:00
Committer:     Borislav Petkov <bp@suse.de>
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")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lkml.kernel.org/r/20210113232311.277302-1-samitolvanen@google.com
---
 arch/x86/kernel/cpu/sgx/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index c519fc5..8df81a3 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -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);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-21 13:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 23:23 [PATCH] x86/sgx: fix the return type of sgx_init Sami Tolvanen
2021-01-14 12:12 ` Darren Kenny
2021-01-15 10:08   ` Jarkko Sakkinen
2021-01-14 13:59 ` [tip: x86/sgx] x86/sgx: Fix the return type of sgx_init() tip-bot2 for Sami Tolvanen
2021-01-15 10:08 ` [PATCH] x86/sgx: fix the return type of sgx_init Jarkko Sakkinen
2021-01-21 13:12 ` [tip: x86/sgx] x86/sgx: Fix the return type of sgx_init() tip-bot2 for Sami Tolvanen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).