Skip to content

Commit ec8c298

Browse files
committed
Merge tag 'x86-urgent-2023-10-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Misc fixes: a kerneldoc build warning fix, add SRSO mitigation for AMD-derived Hygon processors, and fix a SGX kernel crash in the page fault handler that can trigger when ksgxd races to reclaim the SECS special page, by making the SECS page unswappable" * tag 'x86-urgent-2023-10-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/sgx: Resolves SECS reclaim vs. page fault for EAUG race x86/srso: Add SRSO mitigation for Hygon processors x86/kgdb: Fix a kerneldoc warning when build with W=1
2 parents 373ceff + c6c2adc commit ec8c298

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
13031303
VULNBL_AMD(0x15, RETBLEED),
13041304
VULNBL_AMD(0x16, RETBLEED),
13051305
VULNBL_AMD(0x17, RETBLEED | SMT_RSB | SRSO),
1306-
VULNBL_HYGON(0x18, RETBLEED | SMT_RSB),
1306+
VULNBL_HYGON(0x18, RETBLEED | SMT_RSB | SRSO),
13071307
VULNBL_AMD(0x19, SRSO),
13081308
{}
13091309
};

arch/x86/kernel/cpu/sgx/encl.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,21 @@ static struct sgx_epc_page *sgx_encl_eldu(struct sgx_encl_page *encl_page,
235235
return epc_page;
236236
}
237237

238+
/*
239+
* Ensure the SECS page is not swapped out. Must be called with encl->lock
240+
* to protect the enclave states including SECS and ensure the SECS page is
241+
* not swapped out again while being used.
242+
*/
243+
static struct sgx_epc_page *sgx_encl_load_secs(struct sgx_encl *encl)
244+
{
245+
struct sgx_epc_page *epc_page = encl->secs.epc_page;
246+
247+
if (!epc_page)
248+
epc_page = sgx_encl_eldu(&encl->secs, NULL);
249+
250+
return epc_page;
251+
}
252+
238253
static struct sgx_encl_page *__sgx_encl_load_page(struct sgx_encl *encl,
239254
struct sgx_encl_page *entry)
240255
{
@@ -248,11 +263,9 @@ static struct sgx_encl_page *__sgx_encl_load_page(struct sgx_encl *encl,
248263
return entry;
249264
}
250265

251-
if (!(encl->secs.epc_page)) {
252-
epc_page = sgx_encl_eldu(&encl->secs, NULL);
253-
if (IS_ERR(epc_page))
254-
return ERR_CAST(epc_page);
255-
}
266+
epc_page = sgx_encl_load_secs(encl);
267+
if (IS_ERR(epc_page))
268+
return ERR_CAST(epc_page);
256269

257270
epc_page = sgx_encl_eldu(entry, encl->secs.epc_page);
258271
if (IS_ERR(epc_page))
@@ -339,6 +352,13 @@ static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma,
339352

340353
mutex_lock(&encl->lock);
341354

355+
epc_page = sgx_encl_load_secs(encl);
356+
if (IS_ERR(epc_page)) {
357+
if (PTR_ERR(epc_page) == -EBUSY)
358+
vmret = VM_FAULT_NOPAGE;
359+
goto err_out_unlock;
360+
}
361+
342362
epc_page = sgx_alloc_epc_page(encl_page, false);
343363
if (IS_ERR(epc_page)) {
344364
if (PTR_ERR(epc_page) == -EBUSY)

arch/x86/kernel/kgdb.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ void kgdb_arch_exit(void)
695695
}
696696

697697
/**
698-
*
699698
* kgdb_skipexception - Bail out of KGDB when we've been triggered.
700699
* @exception: Exception vector number
701700
* @regs: Current &struct pt_regs.

0 commit comments

Comments
 (0)