* [PATCH 0/2] x86/sgx: Revert two recent master changes
@ 2019-10-08 4:12 Sean Christopherson
2019-10-08 4:12 ` [PATCH 1/2] x86/sgx: Revert using BIT() to define ENCLS_FAULT_FLAG Sean Christopherson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sean Christopherson @ 2019-10-08 4:12 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx
Revert two changes that break the build and cause panic during boot.
Not true reverts since the chanes have already been squashed.
Sean Christopherson (2):
x86/sgx: Revert using BIT() to define ENCLS_FAULT_FLAG
x86/sgx: Revert moving sgx_init() call to sgx_detect()
arch/x86/include/asm/sgx.h | 7 -------
arch/x86/kernel/cpu/intel.c | 5 -----
arch/x86/kernel/cpu/sgx/encls.h | 2 +-
arch/x86/kernel/cpu/sgx/main.c | 16 +++++++++-------
arch/x86/kernel/cpu/sgx/reclaim.c | 2 +-
arch/x86/kernel/cpu/sgx/sgx.h | 2 +-
6 files changed, 12 insertions(+), 22 deletions(-)
delete mode 100644 arch/x86/include/asm/sgx.h
--
2.22.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] x86/sgx: Revert using BIT() to define ENCLS_FAULT_FLAG
2019-10-08 4:12 [PATCH 0/2] x86/sgx: Revert two recent master changes Sean Christopherson
@ 2019-10-08 4:12 ` Sean Christopherson
2019-10-08 4:12 ` [PATCH 2/2] x86/sgx: Revert moving sgx_init() call to sgx_detect() Sean Christopherson
2019-10-08 23:28 ` [PATCH 0/2] x86/sgx: Revert two recent master changes Jarkko Sakkinen
2 siblings, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2019-10-08 4:12 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx
ENCLS_FAULT_FLAG is run through __stringify() in the ENCLS asm helpers,
the build fails miserably if its defined via BIT().
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
arch/x86/kernel/cpu/sgx/encls.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/sgx/encls.h b/arch/x86/kernel/cpu/sgx/encls.h
index f286ba85773e..1676571c8a59 100644
--- a/arch/x86/kernel/cpu/sgx/encls.h
+++ b/arch/x86/kernel/cpu/sgx/encls.h
@@ -60,7 +60,7 @@ enum sgx_encls_leaf {
* between positive (faults and SGX error codes) and negative (system
* error codes) values.
*/
-#define ENCLS_FAULT_FLAG BIT(30)
+#define ENCLS_FAULT_FLAG 0x40000000
/* Retrieve the encoded trapnr from the specified return code. */
#define ENCLS_TRAPNR(r) ((r) & ~ENCLS_FAULT_FLAG)
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] x86/sgx: Revert moving sgx_init() call to sgx_detect()
2019-10-08 4:12 [PATCH 0/2] x86/sgx: Revert two recent master changes Sean Christopherson
2019-10-08 4:12 ` [PATCH 1/2] x86/sgx: Revert using BIT() to define ENCLS_FAULT_FLAG Sean Christopherson
@ 2019-10-08 4:12 ` Sean Christopherson
2019-10-08 23:28 ` [PATCH 0/2] x86/sgx: Revert two recent master changes Jarkko Sakkinen
2 siblings, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2019-10-08 4:12 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx
Calling sgx_init() from sgx_detect() causes panic during early boot
because sgx_init() is intended to be run only on the boot CPU, whereas
init_intel() and thus sgx_detect() is run on every CPU, including
hotplugged CPUs.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
arch/x86/include/asm/sgx.h | 7 -------
arch/x86/kernel/cpu/intel.c | 5 -----
arch/x86/kernel/cpu/sgx/main.c | 16 +++++++++-------
arch/x86/kernel/cpu/sgx/reclaim.c | 2 +-
arch/x86/kernel/cpu/sgx/sgx.h | 2 +-
5 files changed, 11 insertions(+), 21 deletions(-)
delete mode 100644 arch/x86/include/asm/sgx.h
diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h
deleted file mode 100644
index a450b1550768..000000000000
--- a/arch/x86/include/asm/sgx.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
-#ifndef _X86_ASM_SGX_H
-#define _X86_ASM_SGX_H
-
-void sgx_init(void);
-
-#endif /* _X86_ASM_SGX_H */
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 5b6786710295..89a71367716c 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -31,10 +31,6 @@
#include <asm/apic.h>
#endif
-#ifdef CONFIG_INTEL_SGX
-#include <asm/sgx.h>
-#endif
-
/*
* Just in case our CPU detection goes bad, or you have a weird system,
* allow a way to override the automatic disabling of MPX.
@@ -653,7 +649,6 @@ static void __maybe_unused detect_sgx(struct cpuinfo_x86 *c)
goto err_msrs_rdonly;
}
- sgx_init();
return;
err_unsupported:
diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index 5638270c6edf..426f8b21f04c 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -158,7 +158,7 @@ void sgx_free_page(struct sgx_epc_page *page)
WARN(ret > 0, "sgx: EREMOVE returned %d (0x%x)", ret, ret);
}
-static void sgx_free_epc_section(struct sgx_epc_section *section)
+static void __init sgx_free_epc_section(struct sgx_epc_section *section)
{
struct sgx_epc_page *page;
@@ -179,8 +179,9 @@ static void sgx_free_epc_section(struct sgx_epc_section *section)
memunmap(section->va);
}
-static bool sgx_alloc_epc_section(u64 addr, u64 size, unsigned long index,
- struct sgx_epc_section *section)
+static bool __init sgx_alloc_epc_section(u64 addr, u64 size,
+ unsigned long index,
+ struct sgx_epc_section *section)
{
unsigned long nr_pages = size >> PAGE_SHIFT;
struct sgx_epc_page *page;
@@ -212,7 +213,7 @@ static bool sgx_alloc_epc_section(u64 addr, u64 size, unsigned long index,
return false;
}
-static void sgx_page_cache_teardown(void)
+static void __init sgx_page_cache_teardown(void)
{
int i;
@@ -225,13 +226,13 @@ static void sgx_page_cache_teardown(void)
* bits 12-31 of the metric and @high bits 0-19 define the bits 32-51 of the
* metric.
*/
-static inline u64 sgx_calc_section_metric(u64 low, u64 high)
+static inline u64 __init sgx_calc_section_metric(u64 low, u64 high)
{
return (low & GENMASK_ULL(31, 12)) +
((high & GENMASK_ULL(19, 0)) << 32);
}
-static bool sgx_page_cache_init(void)
+static bool __init sgx_page_cache_init(void)
{
u32 eax, ebx, ecx, edx, type;
u64 pa, size;
@@ -278,7 +279,7 @@ static bool sgx_page_cache_init(void)
return true;
}
-void sgx_init(void)
+static void __init sgx_init(void)
{
int ret;
@@ -303,3 +304,4 @@ void sgx_init(void)
err_page_cache:
sgx_page_cache_teardown();
}
+arch_initcall(sgx_init);
diff --git a/arch/x86/kernel/cpu/sgx/reclaim.c b/arch/x86/kernel/cpu/sgx/reclaim.c
index cc3c12972e8c..391fbc3e7e98 100644
--- a/arch/x86/kernel/cpu/sgx/reclaim.c
+++ b/arch/x86/kernel/cpu/sgx/reclaim.c
@@ -97,7 +97,7 @@ static int ksgxswapd(void *p)
return 0;
}
-bool sgx_page_reclaimer_init(void)
+bool __init sgx_page_reclaimer_init(void)
{
struct task_struct *tsk;
diff --git a/arch/x86/kernel/cpu/sgx/sgx.h b/arch/x86/kernel/cpu/sgx/sgx.h
index c1bc78921af1..882ef8ba4aa9 100644
--- a/arch/x86/kernel/cpu/sgx/sgx.h
+++ b/arch/x86/kernel/cpu/sgx/sgx.h
@@ -76,7 +76,7 @@ extern struct wait_queue_head(ksgxswapd_waitq);
extern struct list_head sgx_active_page_list;
extern spinlock_t sgx_active_page_list_lock;
-bool sgx_page_reclaimer_init(void);
+bool __init sgx_page_reclaimer_init(void);
void sgx_mark_page_reclaimable(struct sgx_epc_page *page);
void sgx_reclaim_pages(void);
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] x86/sgx: Revert two recent master changes
2019-10-08 4:12 [PATCH 0/2] x86/sgx: Revert two recent master changes Sean Christopherson
2019-10-08 4:12 ` [PATCH 1/2] x86/sgx: Revert using BIT() to define ENCLS_FAULT_FLAG Sean Christopherson
2019-10-08 4:12 ` [PATCH 2/2] x86/sgx: Revert moving sgx_init() call to sgx_detect() Sean Christopherson
@ 2019-10-08 23:28 ` Jarkko Sakkinen
2 siblings, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2019-10-08 23:28 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linux-sgx
On Mon, Oct 07, 2019 at 09:12:24PM -0700, Sean Christopherson wrote:
> Revert two changes that break the build and cause panic during boot.
> Not true reverts since the chanes have already been squashed.
>
> Sean Christopherson (2):
> x86/sgx: Revert using BIT() to define ENCLS_FAULT_FLAG
> x86/sgx: Revert moving sgx_init() call to sgx_detect()
Thanks!
/Jarkko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-08 23:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-08 4:12 [PATCH 0/2] x86/sgx: Revert two recent master changes Sean Christopherson
2019-10-08 4:12 ` [PATCH 1/2] x86/sgx: Revert using BIT() to define ENCLS_FAULT_FLAG Sean Christopherson
2019-10-08 4:12 ` [PATCH 2/2] x86/sgx: Revert moving sgx_init() call to sgx_detect() Sean Christopherson
2019-10-08 23:28 ` [PATCH 0/2] x86/sgx: Revert two recent master changes Jarkko Sakkinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.