Module Name: src
Committed By: bouyer
Date: Thu Apr 16 17:50:52 UTC 2020
Modified Files:
src/sys/arch/amd64/amd64 [bouyer-xenpvh]: vector.S
src/sys/arch/amd64/conf [bouyer-xenpvh]: GENERIC_XENHVM
src/sys/arch/i386/i386 [bouyer-xenpvh]: vector.S
src/sys/arch/xen/x86 [bouyer-xenpvh]: hypervisor_machdep.c
Log Message:
amd64: Xhypervisor_pvhvm_callback has to be in text.user for SVS.
Thanks to maxv@ for helping me with this.
Enable SVS again.
While there, increase ci_idepth before calling do_hypervisor_callback,
and don't touch ci_idepth while looping over pending events.
To generate a diff of this commit:
cvs rdiff -u -r1.73.6.4 -r1.73.6.5 src/sys/arch/amd64/amd64/vector.S
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/arch/amd64/conf/GENERIC_XENHVM
cvs rdiff -u -r1.85.6.5 -r1.85.6.6 src/sys/arch/i386/i386/vector.S
cvs rdiff -u -r1.36.8.2 -r1.36.8.3 src/sys/arch/xen/x86/hypervisor_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/amd64/vector.S
diff -u src/sys/arch/amd64/amd64/vector.S:1.73.6.4 src/sys/arch/amd64/amd64/vector.S:1.73.6.5
--- src/sys/arch/amd64/amd64/vector.S:1.73.6.4 Thu Apr 16 08:46:34 2020
+++ src/sys/arch/amd64/amd64/vector.S Thu Apr 16 17:50:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vector.S,v 1.73.6.4 2020/04/16 08:46:34 bouyer Exp $ */
+/* $NetBSD: vector.S,v 1.73.6.5 2020/04/16 17:50:51 bouyer Exp $ */
/*
* Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -761,17 +761,20 @@ ENTRY(hypervisor_callback)
movq (%rsp),%rcx
movq 8(%rsp),%r11
addq $16,%rsp
+ jmp _C_LABEL(Xhypervisor_pvhvm_callback)
+ TEXT_USER_BEGIN
IDTVEC(hypervisor_pvhvm_callback)
pushq $0 /* Dummy error code */
pushq $T_ASTFLT
INTRENTRY
movl CPUVAR(ILEVEL),%edi
pushq %rdi /* for Xdoreti */
+ incl CPUVAR(IDEPTH)
movq %rsp,%rdi
call do_hypervisor_callback
- incl CPUVAR(IDEPTH)
jmp _C_LABEL(Xdoreti)
IDTVEC_END(hypervisor_pvhvm_callback)
+ TEXT_USER_END
END(hypervisor_callback)
#endif /* XEN */
Index: src/sys/arch/amd64/conf/GENERIC_XENHVM
diff -u src/sys/arch/amd64/conf/GENERIC_XENHVM:1.1.2.3 src/sys/arch/amd64/conf/GENERIC_XENHVM:1.1.2.4
--- src/sys/arch/amd64/conf/GENERIC_XENHVM:1.1.2.3 Thu Apr 16 10:42:26 2020
+++ src/sys/arch/amd64/conf/GENERIC_XENHVM Thu Apr 16 17:50:51 2020
@@ -1,14 +1,13 @@
-# $NetBSD: GENERIC_XENHVM,v 1.1.2.3 2020/04/16 10:42:26 bouyer Exp $
+# $NetBSD: GENERIC_XENHVM,v 1.1.2.4 2020/04/16 17:50:51 bouyer Exp $
include "arch/amd64/conf/GENERIC"
options XENPVHVM
options XEN
-no options SVS # Separate Virtual Space
options MAXPHYS=32768 #xbd doesn't handle 64k transfers
hypervisor* at mainbus? # Xen hypervisor
#vcpu* at hypervisor? # Xen virtual CPUs
xenbus* at hypervisor? # Xen virtual bus
xencons* at hypervisor? # Xen virtual console
-xennet* at xenbus? # Xen virtual network interface
+xennet* at xenbus? # Xen virtual network interface
xbd* at xenbus? # Xen virtual block device
Index: src/sys/arch/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.85.6.5 src/sys/arch/i386/i386/vector.S:1.85.6.6
--- src/sys/arch/i386/i386/vector.S:1.85.6.5 Thu Apr 16 08:46:34 2020
+++ src/sys/arch/i386/i386/vector.S Thu Apr 16 17:50:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vector.S,v 1.85.6.5 2020/04/16 08:46:34 bouyer Exp $ */
+/* $NetBSD: vector.S,v 1.85.6.6 2020/04/16 17:50:52 bouyer Exp $ */
/*
* Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.85.6.5 2020/04/16 08:46:34 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.85.6.6 2020/04/16 17:50:52 bouyer Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -1013,11 +1013,12 @@ IDTVEC(hypervisor_pvhvm_callback)
pushl $T_ASTFLT
INTRENTRY
pushl CPUVAR(ILEVEL)
- push %esp
- call do_hypervisor_callback
- add $4,%esp
IDEPTH_INCR
- CLI(%eax)
+ /* IDEPTH_INCR puts %esp on stack; we use it as argument to
+ * do_hypervisor_callback. But don't restore the stack after,
+ * Xdoreti needs it too.
+ */
+ call do_hypervisor_callback
jmp _C_LABEL(Xdoreti)
IDTVEC_END(hypervisor_pvhvm_callback)
END(hypervisor_callback)
Index: src/sys/arch/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.36.8.2 src/sys/arch/xen/x86/hypervisor_machdep.c:1.36.8.3
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.36.8.2 Thu Apr 16 08:46:35 2020
+++ src/sys/arch/xen/x86/hypervisor_machdep.c Thu Apr 16 17:50:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor_machdep.c,v 1.36.8.2 2020/04/16 08:46:35 bouyer Exp $ */
+/* $NetBSD: hypervisor_machdep.c,v 1.36.8.3 2020/04/16 17:50:52 bouyer Exp $ */
/*
*
@@ -54,11 +54,12 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.36.8.2 2020/04/16 08:46:35 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.36.8.3 2020/04/16 17:50:52 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kmem.h>
+#include <sys/cpu.h>
#include <uvm/uvm_extern.h>
@@ -215,7 +216,9 @@ evt_do_hypervisor_callback(unsigned int
{
KASSERT(args != NULL);
+#ifdef DOM0OPS
struct cpu_info *ci = curcpu();
+#endif
struct intrframe *regs = args;
#ifdef PORT_DEBUG
@@ -223,9 +226,8 @@ evt_do_hypervisor_callback(unsigned int
printf("do_hypervisor_callback event %d\n", port);
#endif
if (evtsource[port]) {
- ci->ci_idepth++;
+ KASSERT(cpu_intr_p());
evtchn_do_event(port, regs);
- ci->ci_idepth--;
}
#ifdef DOM0OPS
else {
@@ -233,9 +235,8 @@ evt_do_hypervisor_callback(unsigned int
/* fast path */
int oipl = ci->ci_ilevel;
ci->ci_ilevel = IPL_HIGH;
- ci->ci_idepth++;
+ KASSERT(cpu_intr_p());
xenevt_event(port);
- ci->ci_idepth--;
ci->ci_ilevel = oipl;
} else {
/* set pending event */