Module Name:    src
Committed By:   bouyer
Date:           Fri Apr 10 14:42:00 UTC 2020

Modified Files:
        src/sys/arch/amd64/amd64 [bouyer-xenpvh]: spl.S vector.S
        src/sys/arch/amd64/conf [bouyer-xenpvh]: XEN3_PVHVM
        src/sys/arch/i386/conf [bouyer-xenpvh]: XEN3PAE_PVHVM
        src/sys/arch/i386/i386 [bouyer-xenpvh]: spl.S vector.S
        src/sys/arch/x86/include [bouyer-xenpvh]: intr.h

Log Message:
spllower(): Also check Xen pending events
hypervisor_pvhvm_callback(): exit via Xdoreti, so that pending interrupts
are checked.
disable __HAVE_FAST_SOFTINTS only for XENPV, it now works for PVHVM.
We still have to disable PREEMPTION, until we support MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.43.4.2 -r1.43.4.3 src/sys/arch/amd64/amd64/spl.S
cvs rdiff -u -r1.73 -r1.73.6.1 src/sys/arch/amd64/amd64/vector.S
cvs rdiff -u -r1.3.2.1 -r1.3.2.2 src/sys/arch/amd64/conf/XEN3_PVHVM
cvs rdiff -u -r1.3.2.1 -r1.3.2.2 src/sys/arch/i386/conf/XEN3PAE_PVHVM
cvs rdiff -u -r1.50 -r1.50.4.1 src/sys/arch/i386/i386/spl.S
cvs rdiff -u -r1.85 -r1.85.6.1 src/sys/arch/i386/i386/vector.S
cvs rdiff -u -r1.61 -r1.61.6.1 src/sys/arch/x86/include/intr.h

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/spl.S
diff -u src/sys/arch/amd64/amd64/spl.S:1.43.4.2 src/sys/arch/amd64/amd64/spl.S:1.43.4.3
--- src/sys/arch/amd64/amd64/spl.S:1.43.4.2	Thu Apr  9 21:01:33 2020
+++ src/sys/arch/amd64/amd64/spl.S	Fri Apr 10 14:41:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.43.4.2 2020/04/09 21:01:33 bouyer Exp $	*/
+/*	$NetBSD: spl.S,v 1.43.4.3 2020/04/10 14:41:59 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -91,7 +91,7 @@ ENTRY(splraise)
 	ret
 END(splraise)
 
-#ifndef XEN
+#ifndef XENPV
 /*
  * Xsoftintr()
  *
@@ -242,6 +242,11 @@ ENTRY(spllower)
 	cli
 	testl	CPUVAR(IPENDING),%edx
 	jnz	2f
+#if defined(XEN)
+	movl	CPUVAR(XUNMASK)(,%rdi,4),%edx
+	testl	CPUVAR(XPENDING),%edx
+	jnz	2f
+#endif
 	movl	%edi,CPUVAR(ILEVEL)
 	popf
 1:

Index: src/sys/arch/amd64/amd64/vector.S
diff -u src/sys/arch/amd64/amd64/vector.S:1.73 src/sys/arch/amd64/amd64/vector.S:1.73.6.1
--- src/sys/arch/amd64/amd64/vector.S:1.73	Mon Dec 30 23:32:29 2019
+++ src/sys/arch/amd64/amd64/vector.S	Fri Apr 10 14:41:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.73 2019/12/30 23:32:29 thorpej Exp $	*/
+/*	$NetBSD: vector.S,v 1.73.6.1 2020/04/10 14:41:59 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -815,7 +815,6 @@ ENTRY(hypervisor_callback)
 	movq	(%rsp),%rcx
 	movq	8(%rsp),%r11
 	addq	$16,%rsp
-IDTVEC(hypervisor_pvhvm_callback)
 	pushq	$0		/* Dummy error code */
 	pushq	$T_ASTFLT
 	INTRENTRY
@@ -827,8 +826,21 @@ IDTVEC(hypervisor_pvhvm_callback)
 	jnz	doreti_checkast
 1:
 	INTRFASTEXIT
-IDTVEC_END(hypervisor_pvhvm_callback)
 END(hypervisor_callback)
+
+IDTVEC(hypervisor_pvhvm_callback)
+	pushq	$0		/* Dummy error code */
+	pushq	$T_ASTFLT
+	INTRENTRY
+	movl    CPUVAR(ILEVEL),%edi
+	pushq   %rdi /* for Xdoreti */
+	/* sti?? */
+	movq	%rsp,%rdi
+	subq	$8,%rdi;	/* don't forget if_ppl */
+	call	do_hypervisor_callback
+	incl	CPUVAR(IDEPTH)
+	jmp 	_C_LABEL(Xdoreti)
+IDTVEC_END(hypervisor_pvhvm_callback)
 #endif /* XEN */
 
 #ifdef XENPV

Index: src/sys/arch/amd64/conf/XEN3_PVHVM
diff -u src/sys/arch/amd64/conf/XEN3_PVHVM:1.3.2.1 src/sys/arch/amd64/conf/XEN3_PVHVM:1.3.2.2
--- src/sys/arch/amd64/conf/XEN3_PVHVM:1.3.2.1	Wed Apr  8 17:56:08 2020
+++ src/sys/arch/amd64/conf/XEN3_PVHVM	Fri Apr 10 14:42:00 2020
@@ -1,10 +1,11 @@
-# $NetBSD: XEN3_PVHVM,v 1.3.2.1 2020/04/08 17:56:08 bouyer Exp $
+# $NetBSD: XEN3_PVHVM,v 1.3.2.2 2020/04/10 14:42:00 bouyer Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
 options		XENPVHVM
 
 #options 	MULTIPROCESSOR	# Not yet.
+options 	NO_PREEMPTION
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -12,7 +13,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_PVHVM-$Revision: 1.3.2.1 $"
+#ident		"XEN3_PVHVM-$Revision: 1.3.2.2 $"
 
 maxusers	32		# estimated number of users
 options 	MAXPHYS=32768	#xbd doesn't handle 64k transfers

Index: src/sys/arch/i386/conf/XEN3PAE_PVHVM
diff -u src/sys/arch/i386/conf/XEN3PAE_PVHVM:1.3.2.1 src/sys/arch/i386/conf/XEN3PAE_PVHVM:1.3.2.2
--- src/sys/arch/i386/conf/XEN3PAE_PVHVM:1.3.2.1	Wed Apr  8 17:56:08 2020
+++ src/sys/arch/i386/conf/XEN3PAE_PVHVM	Fri Apr 10 14:42:00 2020
@@ -1,10 +1,11 @@
-# $NetBSD: XEN3PAE_PVHVM,v 1.3.2.1 2020/04/08 17:56:08 bouyer Exp $
+# $NetBSD: XEN3PAE_PVHVM,v 1.3.2.2 2020/04/10 14:42:00 bouyer Exp $
 
 include 	"arch/xen/conf/std.xen"
 
 options		XENPVHVM		# PVHVM domU support
 
 #options 	MULTIPROCESSOR	# Not yet.
+options 	NO_PREEMPTION
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -115,7 +116,7 @@ hypervisor*	at mainbus?		# Xen hyperviso
 #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
 #balloon*	at xenbus?		# Xen balloon device
 

Index: src/sys/arch/i386/i386/spl.S
diff -u src/sys/arch/i386/i386/spl.S:1.50 src/sys/arch/i386/i386/spl.S:1.50.4.1
--- src/sys/arch/i386/i386/spl.S:1.50	Wed Jan  8 17:38:41 2020
+++ src/sys/arch/i386/i386/spl.S	Fri Apr 10 14:42:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.50 2020/01/08 17:38:41 ad Exp $	*/
+/*	$NetBSD: spl.S,v 1.50.4.1 2020/04/10 14:42:00 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.50 2020/01/08 17:38:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.50.4.1 2020/04/10 14:42:00 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_spldebug.h"
@@ -94,6 +94,11 @@ ENTRY(spllower)
 	cli
 	testl	CPUVAR(IPENDING),%edx
 	jnz	2f
+#if defined(XEN)
+	movl	CPUVAR(XUNMASK)(,%ecx,4),%edx
+	testl	CPUVAR(XPENDING),%edx
+	jnz	2f
+#endif
 	movl	%ecx,CPUVAR(ILEVEL)
 	popf
 1:
@@ -353,7 +358,7 @@ END(doreti_checkast)
 #endif
 IDTVEC_END(doreti)
 
-#ifndef XEN
+#ifndef XENPV
 /*
  * Xsoftintr()
  *
@@ -455,4 +460,4 @@ IDTVEC(resume_preempt)
 	cli
 	jmp	*%esi
 IDTVEC_END(resume_preempt)
-#endif /* !XEN */
+#endif /* !XENPV */

Index: src/sys/arch/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.85 src/sys/arch/i386/i386/vector.S:1.85.6.1
--- src/sys/arch/i386/i386/vector.S:1.85	Mon Dec 30 23:32:29 2019
+++ src/sys/arch/i386/i386/vector.S	Fri Apr 10 14:42:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.85 2019/12/30 23:32:29 thorpej Exp $	*/
+/*	$NetBSD: vector.S,v 1.85.6.1 2020/04/10 14:42:00 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 2019/12/30 23:32:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.85.6.1 2020/04/10 14:42:00 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -940,6 +940,7 @@ END(x2apic_level_stubs)
 #if defined(XEN)
 #define voidop(num)
 
+#ifdef XENPV
 #define	XENINTRSTUB(name, num, early_ack, late_ack, mask, unmask, level_mask) \
 IDTVEC(recurse_ ## name ## num)						;\
 	INTR_RECURSE_HWFRAME						;\
@@ -970,6 +971,36 @@ IDTVEC(resume_ ## name ## num)						\
 	popl	%ebx							;\
 	jmp	*%esi			/* lower spl and do ASTs */	;\
 
+#else /* XENPV */
+#define	XENINTRSTUB(name, num, early_ack, late_ack, mask, unmask, level_mask) \
+IDTVEC(recurse_ ## name ## num)						;\
+	INTR_RECURSE_HWFRAME						;\
+	subl	$4,%esp							;\
+	pushl	$T_ASTFLT		/* trap # for doing ASTs */	;\
+	INTRENTRY							;\
+IDTVEC(resume_ ## name ## num)						\
+	movl	$IREENT_MAGIC,TF_ERR(%esp)				;\
+	pushl	%ebx							;\
+	movl	CPUVAR(XSOURCES) + (num) * 4,%ebp			;\
+	movl	$num,CPUVAR(ILEVEL)					;\
+	IDEPTH_INCR /* leaves old %esp on stack	*/			;\
+	STI(%eax)							;\
+	movl	IS_HANDLERS(%ebp),%ebx					;\
+6:									\
+	pushl	IH_ARG(%ebx)						;\
+	call	*IH_FUN(%ebx)		/* call it */			;\
+	addl	$4,%esp			/* toss the arg */		;\
+	movl	IH_NEXT(%ebx),%ebx	/* next handler in chain */	;\
+	testl	%ebx,%ebx						;\
+	jnz	6b							;\
+									\
+	CLI(%eax)							;\
+	unmask(num)			/* unmask it in hardware */	;\
+	late_ack(num)							;\
+	jmp	_C_LABEL(Xdoreti)	/* lower spl and do ASTs */	;\
+
+#endif /* XENPV */
+
 /*
  * Just unmasking the event isn't enough, we also need to
  * reassert the event pending bit if needed. For now just call
@@ -1079,7 +1110,6 @@ END(xenev_stubs)
  * activation and restart the handler using the previous one.
  */
 ENTRY(hypervisor_callback)
-IDTVEC(hypervisor_pvhvm_callback)	
 	pushl	$0			/* dummy error code */
 	pushl	$T_ASTFLT
 	INTRENTRY
@@ -1140,9 +1170,20 @@ critical_region_fixup:
 	loop	15b
 16:	movl	%edi,%esp	/* final %edi is top of merged stack */
 	jmp	11b
-IDTVEC_END(hypervisor_pvhvm_callback)
 END(hypervisor_callback)
 
+IDTVEC(hypervisor_pvhvm_callback)	
+	pushl	$0			/* dummy error code */
+	pushl	$T_ASTFLT
+	INTRENTRY
+	push	%esp
+	call	do_hypervisor_callback
+	add	$4,%esp
+	push	CPUVAR(ILEVEL)
+	IDEPTH_INCR
+	cli
+	jmp	_C_LABEL(Xdoreti)
+IDTVEC_END(hypervisor_pvhvm_callback)
 #endif /* XEN */
 #ifdef XENPV	
 /*

Index: src/sys/arch/x86/include/intr.h
diff -u src/sys/arch/x86/include/intr.h:1.61 src/sys/arch/x86/include/intr.h:1.61.6.1
--- src/sys/arch/x86/include/intr.h:1.61	Sun Dec 22 15:09:39 2019
+++ src/sys/arch/x86/include/intr.h	Fri Apr 10 14:42:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.61 2019/12/22 15:09:39 thorpej Exp $	*/
+/*	$NetBSD: intr.h,v 1.61.6.1 2020/04/10 14:42:00 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -32,12 +32,12 @@
 #ifndef _X86_INTR_H_
 #define _X86_INTR_H_
 
-#if !defined(XEN)
+#if !defined(XENPV)
 #define	__HAVE_FAST_SOFTINTS
 #if !defined(NO_PREEMPTION)
 #define	__HAVE_PREEMPTION
 #endif /* !defined(NO_PREEMPTION) */
-#endif /*  !defined(XEN) */
+#endif /*  !defined(XENPV) */
 
 #ifdef _KERNEL
 #include <sys/types.h>

Reply via email to