Skip to content

Commit c3881eb

Browse files
mirabjgross1
authored andcommitted
x86/xen: Make the secondary CPU idle tasks reliable
The unwinder reports the secondary CPU idle tasks' stack on XEN PV as unreliable, which affects at least live patching. cpu_initialize_context() sets up the context of the CPU through VCPUOP_initialise hypercall. After it is woken up, the idle task starts in cpu_bringup_and_idle() function and its stack starts at the offset right below pt_regs. The unwinder correctly detects the end of stack there but it is confused by NULL return address in the last frame. Introduce a wrapper in assembly, which just calls cpu_bringup_and_idle(). The return address is thus pushed on the stack and the wrapper contains the annotation hint for the unwinder regarding the stack state. Signed-off-by: Miroslav Benes <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 2f62f36 commit c3881eb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

arch/x86/xen/smp_pv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static DEFINE_PER_CPU(struct xen_common_irq, xen_irq_work) = { .irq = -1 };
5353
static DEFINE_PER_CPU(struct xen_common_irq, xen_pmu_irq) = { .irq = -1 };
5454

5555
static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id);
56+
void asm_cpu_bringup_and_idle(void);
5657

5758
static void cpu_bringup(void)
5859
{
@@ -309,7 +310,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
309310
* pointing just below where pt_regs would be if it were a normal
310311
* kernel entry.
311312
*/
312-
ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
313+
ctxt->user_regs.eip = (unsigned long)asm_cpu_bringup_and_idle;
313314
ctxt->flags = VGCF_IN_KERNEL;
314315
ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
315316
ctxt->user_regs.ds = __USER_DS;

arch/x86/xen/xen-head.S

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ SYM_CODE_START(startup_xen)
5858
call xen_start_kernel
5959
SYM_CODE_END(startup_xen)
6060
__FINIT
61+
62+
#ifdef CONFIG_XEN_PV_SMP
63+
.pushsection .text
64+
SYM_CODE_START(asm_cpu_bringup_and_idle)
65+
UNWIND_HINT_EMPTY
66+
67+
call cpu_bringup_and_idle
68+
SYM_CODE_END(asm_cpu_bringup_and_idle)
69+
.popsection
70+
#endif
6171
#endif
6272

6373
.pushsection .text

0 commit comments

Comments
 (0)