Commit 22217739 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'x86_urgent_for_v5.17_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Borislav Petkov:

 - Fix the ptrace regset xfpregs_set() callback to behave according to
   the ABI

 - Handle poisoned pages properly in the SGX reclaimer code

* tag 'x86_urgent_for_v5.17_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/ptrace: Fix xfpregs_set()'s incorrect xmm clearing
  x86/sgx: Fix missing poison handling in reclaimer
parents 0b0894ff 44cad52c
...@@ -344,10 +344,8 @@ static void sgx_reclaim_pages(void) ...@@ -344,10 +344,8 @@ static void sgx_reclaim_pages(void)
{ {
struct sgx_epc_page *chunk[SGX_NR_TO_SCAN]; struct sgx_epc_page *chunk[SGX_NR_TO_SCAN];
struct sgx_backing backing[SGX_NR_TO_SCAN]; struct sgx_backing backing[SGX_NR_TO_SCAN];
struct sgx_epc_section *section;
struct sgx_encl_page *encl_page; struct sgx_encl_page *encl_page;
struct sgx_epc_page *epc_page; struct sgx_epc_page *epc_page;
struct sgx_numa_node *node;
pgoff_t page_index; pgoff_t page_index;
int cnt = 0; int cnt = 0;
int ret; int ret;
...@@ -418,13 +416,7 @@ static void sgx_reclaim_pages(void) ...@@ -418,13 +416,7 @@ static void sgx_reclaim_pages(void)
kref_put(&encl_page->encl->refcount, sgx_encl_release); kref_put(&encl_page->encl->refcount, sgx_encl_release);
epc_page->flags &= ~SGX_EPC_PAGE_RECLAIMER_TRACKED; epc_page->flags &= ~SGX_EPC_PAGE_RECLAIMER_TRACKED;
section = &sgx_epc_sections[epc_page->section]; sgx_free_epc_page(epc_page);
node = section->node;
spin_lock(&node->lock);
list_add_tail(&epc_page->list, &node->free_page_list);
spin_unlock(&node->lock);
atomic_long_inc(&sgx_nr_free_pages);
} }
} }
......
...@@ -91,11 +91,9 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset, ...@@ -91,11 +91,9 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
const void *kbuf, const void __user *ubuf) const void *kbuf, const void __user *ubuf)
{ {
struct fpu *fpu = &target->thread.fpu; struct fpu *fpu = &target->thread.fpu;
struct user32_fxsr_struct newstate; struct fxregs_state newstate;
int ret; int ret;
BUILD_BUG_ON(sizeof(newstate) != sizeof(struct fxregs_state));
if (!cpu_feature_enabled(X86_FEATURE_FXSR)) if (!cpu_feature_enabled(X86_FEATURE_FXSR))
return -ENODEV; return -ENODEV;
...@@ -116,9 +114,10 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset, ...@@ -116,9 +114,10 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
/* Copy the state */ /* Copy the state */
memcpy(&fpu->fpstate->regs.fxsave, &newstate, sizeof(newstate)); memcpy(&fpu->fpstate->regs.fxsave, &newstate, sizeof(newstate));
/* Clear xmm8..15 */ /* Clear xmm8..15 for 32-bit callers */
BUILD_BUG_ON(sizeof(fpu->__fpstate.regs.fxsave.xmm_space) != 16 * 16); BUILD_BUG_ON(sizeof(fpu->__fpstate.regs.fxsave.xmm_space) != 16 * 16);
memset(&fpu->fpstate->regs.fxsave.xmm_space[8], 0, 8 * 16); if (in_ia32_syscall())
memset(&fpu->fpstate->regs.fxsave.xmm_space[8*4], 0, 8 * 16);
/* Mark FP and SSE as in use when XSAVE is enabled */ /* Mark FP and SSE as in use when XSAVE is enabled */
if (use_xsave()) if (use_xsave())
......
...@@ -1224,7 +1224,7 @@ static struct user_regset x86_64_regsets[] __ro_after_init = { ...@@ -1224,7 +1224,7 @@ static struct user_regset x86_64_regsets[] __ro_after_init = {
}, },
[REGSET_FP] = { [REGSET_FP] = {
.core_note_type = NT_PRFPREG, .core_note_type = NT_PRFPREG,
.n = sizeof(struct user_i387_struct) / sizeof(long), .n = sizeof(struct fxregs_state) / sizeof(long),
.size = sizeof(long), .align = sizeof(long), .size = sizeof(long), .align = sizeof(long),
.active = regset_xregset_fpregs_active, .regset_get = xfpregs_get, .set = xfpregs_set .active = regset_xregset_fpregs_active, .regset_get = xfpregs_get, .set = xfpregs_set
}, },
...@@ -1271,7 +1271,7 @@ static struct user_regset x86_32_regsets[] __ro_after_init = { ...@@ -1271,7 +1271,7 @@ static struct user_regset x86_32_regsets[] __ro_after_init = {
}, },
[REGSET_XFP] = { [REGSET_XFP] = {
.core_note_type = NT_PRXFPREG, .core_note_type = NT_PRXFPREG,
.n = sizeof(struct user32_fxsr_struct) / sizeof(u32), .n = sizeof(struct fxregs_state) / sizeof(u32),
.size = sizeof(u32), .align = sizeof(u32), .size = sizeof(u32), .align = sizeof(u32),
.active = regset_xregset_fpregs_active, .regset_get = xfpregs_get, .set = xfpregs_set .active = regset_xregset_fpregs_active, .regset_get = xfpregs_get, .set = xfpregs_set
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment