linux-stable/arch
Lai Jiangshan 00fcd8552c x86/sev: Annotate stack change in the #VC handler
[ Upstream commit c42b145181 ]

In idtentry_vc(), vc_switch_off_ist() determines a safe stack to
switch to, off of the IST stack. Annotate the new stack switch with
ENCODE_FRAME_POINTER in case UNWINDER_FRAME_POINTER is used.

A stack walk before looks like this:

  CPU: 0 PID: 0 Comm: swapper Not tainted 5.18.0-rc7+ #2
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
  Call Trace:
   <TASK>
   dump_stack_lvl
   dump_stack
   kernel_exc_vmm_communication
   asm_exc_vmm_communication
   ? native_read_msr
   ? __x2apic_disable.part.0
   ? x2apic_setup
   ? cpu_init
   ? trap_init
   ? start_kernel
   ? x86_64_start_reservations
   ? x86_64_start_kernel
   ? secondary_startup_64_no_verify
   </TASK>

and with the fix, the stack dump is exact:

  CPU: 0 PID: 0 Comm: swapper Not tainted 5.18.0-rc7+ #3
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
  Call Trace:
   <TASK>
   dump_stack_lvl
   dump_stack
   kernel_exc_vmm_communication
   asm_exc_vmm_communication
  RIP: 0010:native_read_msr
  Code: ...
  < snipped regs >
   ? __x2apic_disable.part.0
   x2apic_setup
   cpu_init
   trap_init
   start_kernel
   x86_64_start_reservations
   x86_64_start_kernel
   secondary_startup_64_no_verify
   </TASK>

  [ bp: Test in a SEV-ES guest and rewrite the commit message to
    explain what exactly this does. ]

Fixes: a13644f3a5 ("x86/entry/64: Add entry code for #VC handler")
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220316041612.71357-1-jiangshanlai@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-09 10:23:00 +02:00
..
alpha alpha: fix alloc_zeroed_user_highpage_movable() 2022-06-09 10:22:43 +02:00
arc ARC: entry: fix syscall_trace_exit argument 2022-04-27 14:39:00 +02:00
arm signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:22:48 +02:00
arm64 arm64: stackleak: fix current_top_of_stack() 2022-06-09 10:22:55 +02:00
csky uaccess: fix type mismatch warnings from access_ok() 2022-04-08 14:24:01 +02:00
h8300
hexagon uaccess: fix integer overflow on access_ok() 2022-03-28 09:58:45 +02:00
ia64 ia64: define get_cycles macro for arch-override 2022-05-30 09:29:12 +02:00
m68k m68k: math-emu: Fix dependencies of math emulation support 2022-06-09 10:22:59 +02:00
microblaze uaccess: fix nios2 and microblaze get_user_8() 2022-04-08 14:23:18 +02:00
mips mips: use fallback for random_get_entropy() instead of just c0 random 2022-05-30 09:29:13 +02:00
nds32 nds32: fix access_ok() checks in get/put_user 2022-03-28 09:58:46 +02:00
nios2 nios2: use fallback for random_get_entropy() instead of zero 2022-05-30 09:29:14 +02:00
openrisc openrisc: start CPU timer early in boot 2022-06-09 10:22:38 +02:00
parisc parisc/stifb: Implement fb_is_primary_device() 2022-06-09 10:22:26 +02:00
powerpc powerpc/iommu: Add missing of_node_put in iommu_init_early_dart 2022-06-09 10:22:43 +02:00
riscv riscv: Move alternative length validation into subsection 2022-06-09 10:22:27 +02:00
s390 s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES 2022-06-09 10:22:36 +02:00
sh Documentation, arch: Remove leftovers from CIFS_WEAK_PW_HASH 2022-01-27 11:05:21 +01:00
sparc signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:22:48 +02:00
um ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP 2022-06-09 10:22:29 +02:00
x86 x86/sev: Annotate stack change in the #VC handler 2022-06-09 10:23:00 +02:00
xtensa ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP 2022-06-09 10:22:29 +02:00
.gitignore
Kconfig stack: Constrain and fix stack offset randomization with Clang builds 2022-04-08 14:23:06 +02:00