Skip to content

Commit 2e92493

Browse files
committed
x86/xen: avoid warning in Xen pv guest with CONFIG_AMD_MEM_ENCRYPT enabled
When booting a kernel which has been built with CONFIG_AMD_MEM_ENCRYPT enabled as a Xen pv guest a warning is issued for each processor: [ 5.964347] ------------[ cut here ]------------ [ 5.968314] WARNING: CPU: 0 PID: 1 at /home/gross/linux/head/arch/x86/xen/enlighten_pv.c:660 get_trap_addr+0x59/0x90 [ 5.972321] Modules linked in: [ 5.976313] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 5.11.0-rc5-default #75 [ 5.980313] Hardware name: Dell Inc. OptiPlex 9020/0PC5F7, BIOS A05 12/05/2013 [ 5.984313] RIP: e030:get_trap_addr+0x59/0x90 [ 5.988313] Code: 42 10 83 f0 01 85 f6 74 04 84 c0 75 1d b8 01 00 00 00 c3 48 3d 00 80 83 82 72 08 48 3d 20 81 83 82 72 0c b8 01 00 00 00 eb db <0f> 0b 31 c0 c3 48 2d 00 80 83 82 48 ba 72 1c c7 71 1c c7 71 1c 48 [ 5.992313] RSP: e02b:ffffc90040033d38 EFLAGS: 00010202 [ 5.996313] RAX: 0000000000000001 RBX: ffffffff82a141d0 RCX: ffffffff8222ec38 [ 6.000312] RDX: ffffffff8222ec38 RSI: 0000000000000005 RDI: ffffc90040033d40 [ 6.004313] RBP: ffff8881003984a0 R08: 0000000000000007 R09: ffff888100398000 [ 6.008312] R10: 0000000000000007 R11: ffffc90040246000 R12: ffff8884082182a8 [ 6.012313] R13: 0000000000000100 R14: 000000000000001d R15: ffff8881003982d0 [ 6.016316] FS: 0000000000000000(0000) GS:ffff888408200000(0000) knlGS:0000000000000000 [ 6.020313] CS: e030 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6.024313] CR2: ffffc900020ef000 CR3: 000000000220a000 CR4: 0000000000050660 [ 6.028314] Call Trace: [ 6.032313] cvt_gate_to_trap.part.7+0x3f/0x90 [ 6.036313] ? asm_exc_double_fault+0x30/0x30 [ 6.040313] xen_convert_trap_info+0x87/0xd0 [ 6.044313] xen_pv_cpu_up+0x17a/0x450 [ 6.048313] bringup_cpu+0x2b/0xc0 [ 6.052313] ? cpus_read_trylock+0x50/0x50 [ 6.056313] cpuhp_invoke_callback+0x80/0x4c0 [ 6.060313] _cpu_up+0xa7/0x140 [ 6.064313] cpu_up+0x98/0xd0 [ 6.068313] bringup_nonboot_cpus+0x4f/0x60 [ 6.072313] smp_init+0x26/0x79 [ 6.076313] kernel_init_freeable+0x103/0x258 [ 6.080313] ? rest_init+0xd0/0xd0 [ 6.084313] kernel_init+0xa/0x110 [ 6.088313] ret_from_fork+0x1f/0x30 [ 6.092313] ---[ end trace be9ecf17dceeb4f3 ]--- Reason is that there is no Xen pv trap entry for X86_TRAP_VC. Fix that by adding a generic trap handler for unknown traps and wire all unknown bare metal handlers to this generic handler, which will just crash the system in case such a trap will ever happen. Fixes: 0786138 ("x86/sev-es: Add a Runtime #VC Exception Handler") Cc: <[email protected]> # v5.10 Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Andrew Cooper <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 5f46400 commit 2e92493

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

arch/x86/include/asm/idtentry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ DECLARE_IDTENTRY_VC(X86_TRAP_VC, exc_vmm_communication);
616616

617617
#ifdef CONFIG_XEN_PV
618618
DECLARE_IDTENTRY_XENCB(X86_TRAP_OTHER, exc_xen_hypervisor_callback);
619+
DECLARE_IDTENTRY_RAW(X86_TRAP_OTHER, exc_xen_unknown_trap);
619620
#endif
620621

621622
/* Device interrupts common/spurious */

arch/x86/xen/enlighten_pv.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,13 @@ DEFINE_IDTENTRY_RAW(xenpv_exc_debug)
583583
exc_debug(regs);
584584
}
585585

586+
DEFINE_IDTENTRY_RAW(exc_xen_unknown_trap)
587+
{
588+
/* This should never happen and there is no way to handle it. */
589+
pr_err("Unknown trap in Xen PV mode.");
590+
BUG();
591+
}
592+
586593
struct trap_array_entry {
587594
void (*orig)(void);
588595
void (*xen)(void);
@@ -631,6 +638,7 @@ static bool __ref get_trap_addr(void **addr, unsigned int ist)
631638
{
632639
unsigned int nr;
633640
bool ist_okay = false;
641+
bool found = false;
634642

635643
/*
636644
* Replace trap handler addresses by Xen specific ones.
@@ -645,6 +653,7 @@ static bool __ref get_trap_addr(void **addr, unsigned int ist)
645653
if (*addr == entry->orig) {
646654
*addr = entry->xen;
647655
ist_okay = entry->ist_okay;
656+
found = true;
648657
break;
649658
}
650659
}
@@ -655,9 +664,13 @@ static bool __ref get_trap_addr(void **addr, unsigned int ist)
655664
nr = (*addr - (void *)early_idt_handler_array[0]) /
656665
EARLY_IDT_HANDLER_SIZE;
657666
*addr = (void *)xen_early_idt_handler_array[nr];
667+
found = true;
658668
}
659669

660-
if (WARN_ON(ist != 0 && !ist_okay))
670+
if (!found)
671+
*addr = (void *)xen_asm_exc_xen_unknown_trap;
672+
673+
if (WARN_ON(found && ist != 0 && !ist_okay))
661674
return false;
662675

663676
return true;

arch/x86/xen/xen-asm.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ xen_pv_trap asm_exc_simd_coprocessor_error
178178
#ifdef CONFIG_IA32_EMULATION
179179
xen_pv_trap entry_INT80_compat
180180
#endif
181+
xen_pv_trap asm_exc_xen_unknown_trap
181182
xen_pv_trap asm_exc_xen_hypervisor_callback
182183

183184
__INIT

0 commit comments

Comments
 (0)