Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Xen MP panics in cpu_switchto()



On Mon, Jan 13, 2020 at 05:43:51PM +0100, Manuel Bouyer wrote:
> On Mon, Jan 13, 2020 at 04:59:50PM +0100, Manuel Bouyer wrote:
> > It also sets rsp and rbp. I think rbp is not set by anything else, at last
> > in the Xen case.
> > The different rbp value would explain why in one case we hit a KASSERT()
> > in lwp_startup later.
> > But I don't know what pcb_rbp contains; I couldn't find where the pcb for
> > idlelwp is initialized.
> 
> I tried the attached patch, which should set rsp/rbp as cpu_switchto()
> does. It doens't cause the lwp_startup() KASSERT as calling cpu_switchto()
> does; it also doesn't change the scheduler behavior.

With the patch this time

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
Index: sys/arch/xen/x86/cpu.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/x86/cpu.c,v
retrieving revision 1.131
diff -u -p -u -r1.131 cpu.c
--- sys/arch/xen/x86/cpu.c	23 Nov 2019 19:40:38 -0000	1.131
+++ sys/arch/xen/x86/cpu.c	13 Jan 2020 16:40:50 -0000
@@ -739,7 +739,16 @@ cpu_hatch(void *v)
 
 	aprint_debug_dev(ci->ci_dev, "running\n");
 
-	cpu_switchto(NULL, ci->ci_data.cpu_idlelwp, true);
+#ifdef __x86_64__
+	asm("movq %0, %%rsp" : : "r" (pcb->pcb_rsp));
+	asm("movq %0, %%rbp" : : "r" (pcb->pcb_rbp));
+#else
+	asm("movl %0, %%esp" : : "r" (pcb->pcb_esp));
+	asm("movl %0, %%ebp" : : "r" (pcb->pcb_ebp));
+#endif
+	KASSERT(ci->ci_curlwp == ci->ci_data.cpu_idlelwp);
+
+	//cpu_switchto(NULL, ci->ci_data.cpu_idlelwp, true);
 
 	idle_loop(NULL);
 	KASSERT(false);


Home | Main Index | Thread Index | Old Index