linux-stable/arch/x86/xen
Lai Jiangshan e19a078339 x86/xen: Add xenpv_restore_regs_and_return_to_usermode()
[ Upstream commit 5c8f6a2e31 ]

In the native case, PER_CPU_VAR(cpu_tss_rw + TSS_sp0) is the
trampoline stack. But XEN pv doesn't use trampoline stack, so
PER_CPU_VAR(cpu_tss_rw + TSS_sp0) is also the kernel stack.

In that case, source and destination stacks are identical, which means
that reusing swapgs_restore_regs_and_return_to_usermode() in XEN pv
would cause %rsp to move up to the top of the kernel stack and leave the
IRET frame below %rsp.

This is dangerous as it can be corrupted if #NMI / #MC hit as either of
these events occurring in the middle of the stack pushing would clobber
data on the (original) stack.

And, with  XEN pv, swapgs_restore_regs_and_return_to_usermode() pushing
the IRET frame on to the original address is useless and error-prone
when there is any future attempt to modify the code.

 [ bp: Massage commit message. ]

Fixes: 7f2590a110 ("x86/entry/64: Use a per-CPU trampoline stack for IDT entries")
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lkml.kernel.org/r/20211126101209.8613-4-jiangshanlai@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-12-08 09:04:54 +01:00
..
apic.c x86/apic: Cleanup destination mode 2020-10-28 20:26:25 +01:00
debugfs.c x86: xen: no need to check return value of debugfs_create functions 2019-06-03 15:49:07 +02:00
debugfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
efi.c efi: x86/xen: switch to efi_get_secureboot_mode helper 2020-11-17 15:09:32 +01:00
enlighten.c xen/x86: adjust data placement 2021-10-05 08:36:19 +02:00
enlighten_hvm.c x86/xen: Don't register Xen IPIs when they aren't going to be used 2021-01-13 16:12:07 +01:00
enlighten_pv.c xen/x86: hook up xen_banner() also for PVH 2021-10-05 08:36:14 +02:00
enlighten_pvh.c xen/x86: adjust data placement 2021-10-05 08:36:19 +02:00
grant-table.c x86/xen: open code alloc_vm_area in arch_gnttab_valloc 2020-10-18 09:27:10 -07:00
irq.c x86/pv: Rework arch_local_irq_restore() to not use popf 2021-02-10 12:36:45 +01:00
Kconfig xen/x86: allow PVH Dom0 without XEN_PV=y 2021-10-05 08:35:56 +02:00
Makefile xen/x86: allow PVH Dom0 without XEN_PV=y 2021-10-05 08:35:56 +02:00
mmu.c x86/xen: Add SPDX identifier in arch/x86/xen files 2018-09-03 16:50:33 +02:00
mmu.h mm: update ptep_modify_prot_start/commit to take vm_area_struct as arg 2019-03-05 21:07:18 -08:00
mmu_hvm.c x86/paravirt: Use a single ops structure 2018-09-03 16:50:35 +02:00
mmu_pv.c xen/privcmd: drop "pages" parameter from xen_remap_pfn() 2021-10-05 08:20:27 +02:00
multicalls.c treewide: Switch printk users from %pf and %pF to %ps and %pS, respectively 2019-04-09 14:19:06 +02:00
multicalls.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
p2m.c xen: fix setting of max_pfn in shared_info 2021-08-30 11:55:36 +02:00
pci-swiotlb-xen.c xen/pci-swiotlb: reduce visibility of symbols 2021-09-20 17:01:19 +02:00
platform-pci-unplug.c x86: xen: platform-pci-unplug: use pr_err() and pr_warn() instead of raw printk() 2021-08-30 12:09:54 +02:00
pmu.c Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-10-23 16:16:40 +01:00
pmu.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
setup.c Revert "xen: fix p2m size in dom0 for disabled memory hotplug case" 2021-03-24 18:33:36 -05:00
smp.c xen/events: only register debug interrupt for 2-level events 2020-10-23 05:41:25 -05:00
smp.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
smp_hvm.c x86/xen: fix 'nopvspin' build error 2021-01-18 07:22:20 +01:00
smp_pv.c xen/x86: drop redundant zeroing from cpu_initialize_context() 2021-09-20 16:55:54 +02:00
spinlock.c x86/xen: don't unbind uninitialized lock_kicker_irq 2020-11-09 07:43:45 -06:00
suspend.c x86/xen: Zero MSR_IA32_SPEC_CTRL before suspend 2018-02-28 16:03:19 +01:00
suspend_hvm.c xen: Move xen_setup_callback_vector() definition to include/xen/hvm.h 2020-06-11 15:15:19 +02:00
suspend_pv.c locking/seqlock, headers: Untangle the spaghetti monster 2020-08-06 16:13:13 +02:00
time.c x86/paravirt: Switch time pvops functions to use static_call() 2021-03-11 16:17:52 +01:00
trace.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vga.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xen-asm.S x86/xen: Add xenpv_restore_regs_and_return_to_usermode() 2021-12-08 09:04:54 +01:00
xen-head.S x86/xen: Support objtool vmlinux.o validation in xen-head.S 2021-01-26 11:33:02 -06:00
xen-ops.h xen/x86: hook up xen_banner() also for PVH 2021-10-05 08:36:14 +02:00