CVS commit: [bouyer-xenpvh] src/sys/arch/i386/i386

2020-04-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Apr 18 14:49:57 UTC 2020

Modified Files:
src/sys/arch/i386/i386 [bouyer-xenpvh]: i386_trap.S locore.S

Log Message:
Call stipending() only on XenPV. Fix spurious fpudna from kernel mode


To generate a diff of this commit:
cvs rdiff -u -r1.20.6.1 -r1.20.6.2 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.179.2.2 -r1.179.2.3 src/sys/arch/i386/i386/locore.S

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/i386/i386/i386_trap.S
diff -u src/sys/arch/i386/i386/i386_trap.S:1.20.6.1 src/sys/arch/i386/i386/i386_trap.S:1.20.6.2
--- src/sys/arch/i386/i386/i386_trap.S:1.20.6.1	Sun Apr 12 17:25:52 2020
+++ src/sys/arch/i386/i386/i386_trap.S	Sat Apr 18 14:49:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386_trap.S,v 1.20.6.1 2020/04/12 17:25:52 bouyer Exp $	*/
+/*	$NetBSD: i386_trap.S,v 1.20.6.2 2020/04/18 14:49:57 bouyer Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
 
 #if 0
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.20.6.1 2020/04/12 17:25:52 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.20.6.2 2020/04/18 14:49:57 bouyer Exp $");
 #endif
 
 /*
@@ -434,7 +434,7 @@ calltrap:
 3:	CHECK_DEFERRED_SWITCH
 	jnz	9f
 
-#ifdef XEN
+#ifdef XENPV
 	STIC(%eax)
 	jz	22f
 	call	_C_LABEL(stipending)
@@ -456,7 +456,7 @@ calltrap:
 11:	movl	%ebx,CPUVAR(ILEVEL)	/* restore cpl */
 	jmp	.Lalltraps_checkusr
 22:
-#endif
+#endif /* XEN */
 
 	HANDLE_DEFERRED_FPU
 

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.179.2.2 src/sys/arch/i386/i386/locore.S:1.179.2.3
--- src/sys/arch/i386/i386/locore.S:1.179.2.2	Sun Apr 12 17:25:52 2020
+++ src/sys/arch/i386/i386/locore.S	Sat Apr 18 14:49:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.179.2.2 2020/04/12 17:25:52 bouyer Exp $	*/
+/*	$NetBSD: locore.S,v 1.179.2.3 2020/04/18 14:49:57 bouyer Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.179.2.2 2020/04/12 17:25:52 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.179.2.3 2020/04/18 14:49:57 bouyer Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1478,7 +1478,7 @@ IDTVEC(syscall)
 	orl	CPUVAR(WANT_PMAPLOAD), %eax
 	jnz	9f
 
-#ifdef XEN
+#ifdef XENPV
 	STIC(%eax)
 	jz	14f
 	call	_C_LABEL(stipending)
@@ -1500,7 +1500,7 @@ IDTVEC(syscall)
 17:	movl	%ebx, CPUVAR(ILEVEL)	/* restore cpl  */
 	jmp	.Lsyscall_checkast
 14:
-#endif /* XEN */
+#endif /* XENPV */
 
 #ifdef DIAGNOSTIC
 	cmpl	$IPL_NONE,CPUVAR(ILEVEL)



CVS commit: [bouyer-xenpvh] src/sys/arch/i386/i386

2020-04-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Apr 18 14:49:57 UTC 2020

Modified Files:
src/sys/arch/i386/i386 [bouyer-xenpvh]: i386_trap.S locore.S

Log Message:
Call stipending() only on XenPV. Fix spurious fpudna from kernel mode


To generate a diff of this commit:
cvs rdiff -u -r1.20.6.1 -r1.20.6.2 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.179.2.2 -r1.179.2.3 src/sys/arch/i386/i386/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [bouyer-xenpvh] src/sys/arch/i386/i386

2020-04-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr 12 16:35:49 UTC 2020

Modified Files:
src/sys/arch/i386/i386 [bouyer-xenpvh]: vector.S

Log Message:
The critical section handling is gone, remove comment about it


To generate a diff of this commit:
cvs rdiff -u -r1.85.6.2 -r1.85.6.3 src/sys/arch/i386/i386/vector.S

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/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.85.6.2 src/sys/arch/i386/i386/vector.S:1.85.6.3
--- src/sys/arch/i386/i386/vector.S:1.85.6.2	Sat Apr 11 12:01:42 2020
+++ src/sys/arch/i386/i386/vector.S	Sun Apr 12 16:35:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.85.6.2 2020/04/11 12:01:42 bouyer Exp $	*/
+/*	$NetBSD: vector.S,v 1.85.6.3 2020/04/12 16:35:49 bouyer Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.85.6.2 2020/04/11 12:01:42 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.85.6.3 2020/04/12 16:35:49 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1062,19 +1062,6 @@ END(xenev_stubs)
 
 #ifdef XEN
 
-/*
- * A note on the "critical region" in our callback handler.
- * We want to avoid stacking callback handlers due to events occurring
- * during handling of the last event. To do this, we keep events disabled
- * until weve done all processing. HOWEVER, we must enable events before
- * popping the stack frame (cant be done atomically) and so it would still
- * be possible to get enough handler activations to overflow the stack.
- * Although unlikely, bugs of that kind are hard to track down, so wed
- * like to avoid the possibility.
- * So, on entry to the handler we detect whether we interrupted an
- * existing activation in its critical region -- if so, we pop the current
- * activation and restart the handler using the previous one.
- */
 ENTRY(hypervisor_callback)
 IDTVEC(hypervisor_pvhvm_callback)	
 	pushl	$0			/* dummy error code */



CVS commit: [bouyer-xenpvh] src/sys/arch/i386/i386

2020-04-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr 12 16:35:49 UTC 2020

Modified Files:
src/sys/arch/i386/i386 [bouyer-xenpvh]: vector.S

Log Message:
The critical section handling is gone, remove comment about it


To generate a diff of this commit:
cvs rdiff -u -r1.85.6.2 -r1.85.6.3 src/sys/arch/i386/i386/vector.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [bouyer-xenpvh] src/sys/arch/i386/i386

2020-04-11 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Apr 11 12:01:42 UTC 2020

Modified Files:
src/sys/arch/i386/i386 [bouyer-xenpvh]: spl.S vector.S

Log Message:
calling stipending() is only needed in the PV case; in PVHVM
hypervisor_callback() will be called again as soon as we enable interrupts.

Use the PVHVM XENINTRSTUB for PV too; asjust Xdoreti as needed.
merge hypervisor_callback with hypervisor_pvhvm_callback. The reetrancy should
not be an issue, as we're already re-enabling events in
do_hupervisor_callback (that it, outside of the critical section).
We now can call Xdoreti in both cases.


To generate a diff of this commit:
cvs rdiff -u -r1.50.4.2 -r1.50.4.3 src/sys/arch/i386/i386/spl.S
cvs rdiff -u -r1.85.6.1 -r1.85.6.2 src/sys/arch/i386/i386/vector.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [bouyer-xenpvh] src/sys/arch/i386/i386

2020-04-11 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Apr 11 12:01:42 UTC 2020

Modified Files:
src/sys/arch/i386/i386 [bouyer-xenpvh]: spl.S vector.S

Log Message:
calling stipending() is only needed in the PV case; in PVHVM
hypervisor_callback() will be called again as soon as we enable interrupts.

Use the PVHVM XENINTRSTUB for PV too; asjust Xdoreti as needed.
merge hypervisor_callback with hypervisor_pvhvm_callback. The reetrancy should
not be an issue, as we're already re-enabling events in
do_hupervisor_callback (that it, outside of the critical section).
We now can call Xdoreti in both cases.


To generate a diff of this commit:
cvs rdiff -u -r1.50.4.2 -r1.50.4.3 src/sys/arch/i386/i386/spl.S
cvs rdiff -u -r1.85.6.1 -r1.85.6.2 src/sys/arch/i386/i386/vector.S

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/i386/i386/spl.S
diff -u src/sys/arch/i386/i386/spl.S:1.50.4.2 src/sys/arch/i386/i386/spl.S:1.50.4.3
--- src/sys/arch/i386/i386/spl.S:1.50.4.2	Sat Apr 11 10:11:31 2020
+++ src/sys/arch/i386/i386/spl.S	Sat Apr 11 12:01:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.50.4.2 2020/04/11 10:11:31 bouyer Exp $	*/
+/*	$NetBSD: spl.S,v 1.50.4.3 2020/04/11 12:01:42 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.50.4.2 2020/04/11 10:11:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.50.4.3 2020/04/11 12:01:42 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_spldebug.h"
@@ -236,7 +236,7 @@ IDTVEC(spllower)
 #endif
 3:
 	movl	%ebx,CPUVAR(ILEVEL)
-#ifdef XEN
+#ifdef XENPV
 	STIC(%eax)
 	jz 4f
 	call	_C_LABEL(stipending)
@@ -260,7 +260,7 @@ IDTVEC(spllower)
 IDTVEC_END(spllower)
 
 /*
- * Handle return from interrupt after device handler finishes.
+ * Xdoreti: Handle return from interrupt after device handler finishes.
  *
  * Important registers:
  *   ebx - cpl to restore
@@ -270,10 +270,8 @@ IDTVEC_END(spllower)
  * called with interrupt disabled.
  */
 IDTVEC(doreti)
-#ifndef XENPV
 	IDEPTH_DECR
 	popl	%ebx			/* get previous priority */
-#endif
 .Ldoreti_resume_stic:
 	movl	$.Ldoreti_resume,%esi	/* address to resume loop at */
 .Ldoreti_resume:
@@ -292,7 +290,6 @@ IDTVEC(doreti)
 #endif /* XENPV */
 #endif /* defined(DEBUG) */
 
-#if !defined(XENPV)
 	movl	%ebx,%eax
 	movl	CPUVAR(IUNMASK)(,%eax,4),%eax
 	andl	CPUVAR(IPENDING),%eax
@@ -301,7 +298,6 @@ IDTVEC(doreti)
 	btrl	%eax,CPUVAR(IPENDING)
 	movl	CPUVAR(ISOURCES)(,%eax, 4),%eax
 	jmp	*IS_RESUME(%eax)
-#endif
 2:
 #if defined(XEN)
 	movl	%ebx,%eax
@@ -340,7 +336,7 @@ END(doreti_checkast)
 	jnz	9f
 	HANDLE_DEFERRED_FPU
 6:
-#ifdef XEN
+#ifdef XENPV
 	STIC(%eax)
 	jz	4f
 	call	_C_LABEL(stipending)

Index: src/sys/arch/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.85.6.1 src/sys/arch/i386/i386/vector.S:1.85.6.2
--- src/sys/arch/i386/i386/vector.S:1.85.6.1	Fri Apr 10 14:42:00 2020
+++ src/sys/arch/i386/i386/vector.S	Sat Apr 11 12:01:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.85.6.1 2020/04/10 14:42:00 bouyer Exp $	*/
+/*	$NetBSD: vector.S,v 1.85.6.2 2020/04/11 12:01:42 bouyer Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.85.6.1 2020/04/10 14:42:00 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.85.6.2 2020/04/11 12:01:42 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -940,38 +940,6 @@ 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		;\
-	subl	$4,%esp			;\
-	pushl	$T_ASTFLT		/* trap # for doing ASTs */	;\
-	INTRENTRY			;\
-	movl	$_C_LABEL(Xdoreti), %esi; /* we now have a trap frame, so loop using doreti instead */ ;\
-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)			;\
-	IDEPTH_DECR			;\
-	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		;\
@@ -999,8 +967,6 @@ IDTVEC(resume_ ## name ## num)		\
 	late_ack(num)			;\
 	jmp