CVS commit: src/sys/arch/i386/i386

2024-04-22 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Apr 22 22:47:00 UTC 2024

Modified Files:
src/sys/arch/i386/i386: i386_mainbus.c

Log Message:
Add (defined(MPBIOS) || NACPICA > 0) check around mp_pci_childdetached().
Fixes the build without MPBIOS or ACPI. Modified patch from Paolo Pisati in
current-users@.

While here:
Remove obsolete  include with its guard.
Add comments for multiple endifs for better readability.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/i386/i386_mainbus.c

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



CVS commit: src/sys/arch/i386/i386

2024-04-22 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Apr 22 22:47:00 UTC 2024

Modified Files:
src/sys/arch/i386/i386: i386_mainbus.c

Log Message:
Add (defined(MPBIOS) || NACPICA > 0) check around mp_pci_childdetached().
Fixes the build without MPBIOS or ACPI. Modified patch from Paolo Pisati in
current-users@.

While here:
Remove obsolete  include with its guard.
Add comments for multiple endifs for better readability.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/i386/i386_mainbus.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/i386/i386/i386_mainbus.c
diff -u src/sys/arch/i386/i386/i386_mainbus.c:1.6 src/sys/arch/i386/i386/i386_mainbus.c:1.7
--- src/sys/arch/i386/i386/i386_mainbus.c:1.6	Sat Aug  7 16:18:55 2021
+++ src/sys/arch/i386/i386/i386_mainbus.c	Mon Apr 22 22:47:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386_mainbus.c,v 1.6 2021/08/07 16:18:55 thorpej Exp $	*/
+/*	$NetBSD: i386_mainbus.c,v 1.7 2024/04/22 22:47:00 andvar Exp $	*/
 /*	NetBSD: mainbus.c,v 1.104 2018/12/02 08:19:44 cherry Exp 	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i386_mainbus.c,v 1.6 2021/08/07 16:18:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_mainbus.c,v 1.7 2024/04/22 22:47:00 andvar Exp $");
 
 #include 
 #include 
@@ -87,12 +87,9 @@ __KERNEL_RCSID(0, "$NetBSD: i386_mainbus
 #include 
 #if defined(PCI_ADDR_FIXUP)
 #include 
-#endif
-#endif
-#ifdef __HAVE_PCI_MSI_MSIX
-#include 
-#endif /* __HAVE_PCI_MSI_MSIX */
-#endif
+#endif /* PCI_ADDR_FIXUP */
+#endif /* PCI_BUS_FIXUP */
+#endif /* NPCI > 0 */
 
 void	i386_mainbus_childdetached(device_t, device_t);
 int	i386_mainbus_match(device_t, cfdata_t, void *);
@@ -178,7 +175,7 @@ i386_mainbus_childdetached(device_t self
 	if (sc->sc_pci == child)
 		sc->sc_pci = NULL;
 
-#if NPCI > 0
+#if NPCI > 0 && (defined(MPBIOS) || NACPICA > 0)
 	mp_pci_childdetached(self, child);
 #endif
 }



CVS commit: src/sys/arch/i386/i386

2023-03-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar  3 14:32:27 UTC 2023

Modified Files:
src/sys/arch/i386/i386: genassym.cf locore.S

Log Message:
Revert "x86: Add kthread_fpu_enter/exit support, take two -- forgot i386 bits."

kthread_fpu_enter/exit changes broke some hardware, unclear why, to
investigate before fixing and reapplying these changes.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.193 -r1.194 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: src/sys/arch/i386/i386

2023-03-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar  3 14:32:27 UTC 2023

Modified Files:
src/sys/arch/i386/i386: genassym.cf locore.S

Log Message:
Revert "x86: Add kthread_fpu_enter/exit support, take two -- forgot i386 bits."

kthread_fpu_enter/exit changes broke some hardware, unclear why, to
investigate before fixing and reapplying these changes.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.193 -r1.194 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/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.132 src/sys/arch/i386/i386/genassym.cf:1.133
--- src/sys/arch/i386/i386/genassym.cf:1.132	Sat Feb 25 18:35:54 2023
+++ src/sys/arch/i386/i386/genassym.cf	Fri Mar  3 14:32:27 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.132 2023/02/25 18:35:54 riastradh Exp $
+#	$NetBSD: genassym.cf,v 1.133 2023/03/03 14:32:27 riastradh Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -175,7 +175,6 @@ define	L_MD_FLAGS		offsetof(struct lwp, 
 define	L_MD_ASTPENDING		offsetof(struct lwp, l_md.md_astpending)
 
 define	LW_SYSTEM		LW_SYSTEM
-define	LW_SYSTEM_FPU		LW_SYSTEM_FPU
 define	MDL_FPU_IN_CPU		MDL_FPU_IN_CPU
 
 define	P_FLAG			offsetof(struct proc, p_flag)

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.193 src/sys/arch/i386/i386/locore.S:1.194
--- src/sys/arch/i386/i386/locore.S:1.193	Wed Mar  1 08:38:50 2023
+++ src/sys/arch/i386/i386/locore.S	Fri Mar  3 14:32:27 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.193 2023/03/01 08:38:50 riastradh Exp $	*/
+/*	$NetBSD: locore.S,v 1.194 2023/03/03 14:32:27 riastradh Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.193 2023/03/01 08:38:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.194 2023/03/03 14:32:27 riastradh Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1471,7 +1471,7 @@ ENTRY(cpu_switchto)
 
 	/* Don't bother with the rest if switching to a system process. */
 	testl	$LW_SYSTEM,L_FLAG(%edi)
-	jnz	.Lswitch_system
+	jnz	switch_return
 
 #ifndef XENPV
 	/* Restore thread-private %fs/%gs descriptors. */
@@ -1525,21 +1525,6 @@ switch_return:
 	popl	%ebx
 	ret
 
-.Lswitch_system:
-	/*
-	 * If it has LWP_SYSTEM_FPU set, meaning it's running in
-	 * kthread_fpu_enter/exit, we need to restore the FPU state
-	 * and enable FPU instructions with fpu_handle_deferred.
-	 *
-	 * No need to test MDL_FPU_IN_CPU via HANDLE_DEFERRED_FPU --
-	 * fpu_switch guarantees it is clear, so we can just call
-	 * fpu_handle_deferred unconditionally.
-	 */
-	testl	$LW_SYSTEM_FPU,L_FLAG(%edi)
-	jz	switch_return
-	call	_C_LABEL(fpu_handle_deferred)
-	jmp	switch_return
-
 .Lcopy_iobitmap:
 	/* Copy I/O bitmap. */
 	incl	_C_LABEL(pmap_iobmp_evcnt)+EV_COUNT



CVS commit: src/sys/arch/i386/i386

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:35:54 UTC 2023

Modified Files:
src/sys/arch/i386/i386: genassym.cf locore.S

Log Message:
x86: Add kthread_fpu_enter/exit support, take two -- forgot i386 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.191 -r1.192 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/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.131 src/sys/arch/i386/i386/genassym.cf:1.132
--- src/sys/arch/i386/i386/genassym.cf:1.131	Tue Dec 27 08:40:40 2022
+++ src/sys/arch/i386/i386/genassym.cf	Sat Feb 25 18:35:54 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.131 2022/12/27 08:40:40 msaitoh Exp $
+#	$NetBSD: genassym.cf,v 1.132 2023/02/25 18:35:54 riastradh Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -175,6 +175,7 @@ define	L_MD_FLAGS		offsetof(struct lwp, 
 define	L_MD_ASTPENDING		offsetof(struct lwp, l_md.md_astpending)
 
 define	LW_SYSTEM		LW_SYSTEM
+define	LW_SYSTEM_FPU		LW_SYSTEM_FPU
 define	MDL_FPU_IN_CPU		MDL_FPU_IN_CPU
 
 define	P_FLAG			offsetof(struct proc, p_flag)

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.191 src/sys/arch/i386/i386/locore.S:1.192
--- src/sys/arch/i386/i386/locore.S:1.191	Fri Feb  3 09:21:58 2023
+++ src/sys/arch/i386/i386/locore.S	Sat Feb 25 18:35:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.191 2023/02/03 09:21:58 mlelstv Exp $	*/
+/*	$NetBSD: locore.S,v 1.192 2023/02/25 18:35:54 riastradh Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.191 2023/02/03 09:21:58 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.192 2023/02/25 18:35:54 riastradh Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1447,7 +1447,7 @@ ENTRY(cpu_switchto)
 
 	/* Don't bother with the rest if switching to a system process. */
 	testl	$LW_SYSTEM,L_FLAG(%edi)
-	jnz	switch_return
+	jnz	.Lswitch_system
 
 #ifndef XENPV
 	/* Restore thread-private %fs/%gs descriptors. */
@@ -1501,6 +1501,21 @@ switch_return:
 	popl	%ebx
 	ret
 
+.Lswitch_system:
+	/*
+	 * If it has LWP_SYSTEM_FPU set, meaning it's running in
+	 * kthread_fpu_enter/exit, we need to restore the FPU state
+	 * and enable FPU instructions with fpu_handle_deferred.
+	 *
+	 * No need to test MDL_FPU_IN_CPU via HANDLE_DEFERRED_FPU --
+	 * fpu_switch guarantees it is clear, so we can just call
+	 * fpu_handle_deferred unconditionally.
+	 */
+	testl	$LW_SYSTEM_FPU,L_FLAG(%edi)
+	jz	switch_return
+	call	_C_LABEL(fpu_handle_deferred)
+	jmp	switch_return
+
 .Lcopy_iobitmap:
 	/* Copy I/O bitmap. */
 	incl	_C_LABEL(pmap_iobmp_evcnt)+EV_COUNT



CVS commit: src/sys/arch/i386/i386

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:35:54 UTC 2023

Modified Files:
src/sys/arch/i386/i386: genassym.cf locore.S

Log Message:
x86: Add kthread_fpu_enter/exit support, take two -- forgot i386 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.191 -r1.192 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: src/sys/arch/i386/i386

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 13:52:09 UTC 2023

Modified Files:
src/sys/arch/i386/i386: bioscall.S

Log Message:
i386/bioscall: Disable preemption while we load the kernel pmap.

Fixes crash on boot in new KASSERT(kpreempt_disabled()) in
cpu_load_pmap.

We could do KASSERT(kpreempt_disabled() || cold), but I don't know if
bioscall is ever reachable after warm boot; this way is safer.

XXX Would be nice if bioscall were a C function, not asm -- I don't
see any reason why we need it to be asm?


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/i386/bioscall.S

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



CVS commit: src/sys/arch/i386/i386

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 13:52:09 UTC 2023

Modified Files:
src/sys/arch/i386/i386: bioscall.S

Log Message:
i386/bioscall: Disable preemption while we load the kernel pmap.

Fixes crash on boot in new KASSERT(kpreempt_disabled()) in
cpu_load_pmap.

We could do KASSERT(kpreempt_disabled() || cold), but I don't know if
bioscall is ever reachable after warm boot; this way is safer.

XXX Would be nice if bioscall were a C function, not asm -- I don't
see any reason why we need it to be asm?


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/i386/bioscall.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/bioscall.S
diff -u src/sys/arch/i386/i386/bioscall.S:1.10 src/sys/arch/i386/i386/bioscall.S:1.11
--- src/sys/arch/i386/i386/bioscall.S:1.10	Sat Jul 14 14:29:40 2018
+++ src/sys/arch/i386/i386/bioscall.S	Sat Feb 25 13:52:09 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bioscall.S,v 1.10 2018/07/14 14:29:40 maxv Exp $ */
+/*	$NetBSD: bioscall.S,v 1.11 2023/02/25 13:52:09 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bioscall.S,v 1.10 2018/07/14 14:29:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bioscall.S,v 1.11 2023/02/25 13:52:09 riastradh Exp $");
 
 #include 
 
@@ -67,6 +67,8 @@ ENTRY(bioscall)
 	pushl	%ebp
 	movl	%esp,%ebp		/* set up frame ptr */
 
+	call	_C_LABEL(kpreempt_disable)
+
 	/* install lwp0 pmap */
 	movl	_C_LABEL(kernel_pmap_ptr),%eax
 	pushl	%eax
@@ -85,5 +87,7 @@ ENTRY(bioscall)
 	call	_C_LABEL(cpu_load_pmap)
 	addl	$4,%esp
 
+	call	_C_LABEL(kpreempt_enable)
+
 	leave
 	ret



CVS commit: src/sys/arch/i386/i386

2023-02-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Feb  3 09:21:58 UTC 2023

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Make multiboot1 continue with common boot code and not skip CPU type
detection.

Fixes PR 57017 and PR 56935.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 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: src/sys/arch/i386/i386

2023-02-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Feb  3 09:21:58 UTC 2023

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Make multiboot1 continue with common boot code and not skip CPU type
detection.

Fixes PR 57017 and PR 56935.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.190 src/sys/arch/i386/i386/locore.S:1.191
--- src/sys/arch/i386/i386/locore.S:1.190	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/i386/i386/locore.S	Fri Feb  3 09:21:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.190 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: locore.S,v 1.191 2023/02/03 09:21:58 mlelstv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.190 2022/09/07 00:40:18 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.191 2023/02/03 09:21:58 mlelstv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -415,7 +415,7 @@ multiboot1_loader:
 	pushl	%ebx		/* Address of Multiboot information */
 	call	_C_LABEL(multiboot1_pre_reloc)
 	addl	$4,%esp
-	jmp	2f
+	jmp	.Lstart_common
 
 efi_multiboot2_loader:
 	/*



CVS commit: src/sys/arch/i386/i386

2022-12-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 26 08:59:01 UTC 2022

Modified Files:
src/sys/arch/i386/i386: genassym.cf

Log Message:
Remove duplicated IPL_SCHED. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/i386/i386/genassym.cf

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



CVS commit: src/sys/arch/i386/i386

2022-12-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 26 08:59:01 UTC 2022

Modified Files:
src/sys/arch/i386/i386: genassym.cf

Log Message:
Remove duplicated IPL_SCHED. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/i386/i386/genassym.cf

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/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.126 src/sys/arch/i386/i386/genassym.cf:1.127
--- src/sys/arch/i386/i386/genassym.cf:1.126	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/i386/i386/genassym.cf	Mon Dec 26 08:59:01 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.126 2022/09/07 00:40:18 knakahara Exp $
+#	$NetBSD: genassym.cf,v 1.127 2022/12/26 08:59:01 msaitoh Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -321,7 +321,6 @@ define	IS_MASK_COUNT		offsetof(struct in
 define	IPL_NONE		IPL_NONE
 define	IPL_PREEMPT		IPL_PREEMPT
 define	IPL_NET			IPL_NET
-define	IPL_SCHED		IPL_SCHED
 define	IPL_CLOCK		IPL_CLOCK
 define	IPL_VM			IPL_VM
 define	IPL_SCHED		IPL_SCHED



CVS commit: src/sys/arch/i386/i386

2022-09-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Sep  8 06:57:44 UTC 2022

Modified Files:
src/sys/arch/i386/i386: lock_stubs.S spl.S

Log Message:
Fix PR port-i386/57000 (boot failure on qemu).


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/i386/i386/lock_stubs.S
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/i386/i386/spl.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/lock_stubs.S
diff -u src/sys/arch/i386/i386/lock_stubs.S:1.37 src/sys/arch/i386/i386/lock_stubs.S:1.38
--- src/sys/arch/i386/i386/lock_stubs.S:1.37	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/i386/i386/lock_stubs.S	Thu Sep  8 06:57:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.S,v 1.37 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: lock_stubs.S,v 1.38 2022/09/08 06:57:44 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.37 2022/09/07 00:40:18 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.38 2022/09/08 06:57:44 knakahara Exp $");
 
 #include "opt_lockdebug.h"
 
@@ -255,10 +255,10 @@ END(mutex_spin_enter)
 
 #ifndef XENPV
 /*
- * Release a spin mutex and post a store fence. Must occupy 96 bytes.
+ * Release a spin mutex and post a store fence. Must occupy 128 bytes.
  */
 ENTRY(mutex_spin_exit)
-	HOTPATCH(HP_NAME_MUTEX_EXIT, 96)
+	HOTPATCH(HP_NAME_MUTEX_EXIT, 128)
 	movl	4(%esp), %edx
 	movl	CPUVAR(MTX_OLDSPL), %ecx
 	incl	CPUVAR(MTX_COUNT)
@@ -284,7 +284,7 @@ STRONG_ALIAS(mutex_spin_exit, i686_mutex
 
 /*
  * Patch for i686 CPUs where cli/sti is prohibitively expensive.
- * Must be the same size as mutex_spin_exit(), that is, 96 bytes.
+ * Must be the same size as mutex_spin_exit(), that is, 128 bytes.
  */
 ENTRY(i686_mutex_spin_exit)
 	mov	4(%esp),%edx

Index: src/sys/arch/i386/i386/spl.S
diff -u src/sys/arch/i386/i386/spl.S:1.56 src/sys/arch/i386/i386/spl.S:1.57
--- src/sys/arch/i386/i386/spl.S:1.56	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/i386/i386/spl.S	Thu Sep  8 06:57:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.56 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: spl.S,v 1.57 2022/09/08 06:57:44 knakahara Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.56 2022/09/07 00:40:18 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.57 2022/09/08 06:57:44 knakahara Exp $");
 
 #include "opt_ddb.h"
 #include "opt_spldebug.h"
@@ -72,11 +72,11 @@ END(splraise)
  * void spllower(int s);
  *
  * spllower() for i486 and Pentium. Must be the same size as cx8_spllower(),
- * that is, 64 bytes. This must use pushf/cli/popf as it is used early in boot
+ * that is, 96 bytes. This must use pushf/cli/popf as it is used early in boot
  * where interrupts are disabled via eflags/IE.
  */
 ENTRY(spllower)
-	HOTPATCH(HP_NAME_SPLLOWER, 64)
+	HOTPATCH(HP_NAME_SPLLOWER, 96)
 #ifdef SPLDEBUG
 	movl	4(%esp),%ecx
 	pushl	%ebp
@@ -115,7 +115,7 @@ STRONG_ALIAS(spllower, cx8_spllower)
  *
  * spllower() optimized for Pentium Pro and later, which have long pipelines
  * that will be stalled by pushf/cli/popf.  Must be the same size as
- * spllower(), ie 64 bytes.  Does not need to restore eflags/IE as is patched
+ * spllower(), ie 96 bytes.  Does not need to restore eflags/IE as is patched
  * in once autoconf is underway.
  *
  * For cmpxchg8b, edx/ecx are the high words and eax/ebx the low.



CVS commit: src/sys/arch/i386/i386

2022-09-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Sep  8 06:57:44 UTC 2022

Modified Files:
src/sys/arch/i386/i386: lock_stubs.S spl.S

Log Message:
Fix PR port-i386/57000 (boot failure on qemu).


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/i386/i386/lock_stubs.S
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/i386/i386/spl.S

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



CVS commit: src/sys/arch/i386/i386

2022-05-31 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 31 18:04:11 UTC 2022

Modified Files:
src/sys/arch/i386/i386: locore.S machdep.c

Log Message:
For some reason on my system, the guest starts with a pending event in
the shared structure. On i386, this cause hypervisor_callback to be
entered before cpu_info_primary is fully initialised, especially on i386
ci_intrstack is still NULL, which cause a crash when we try to use it.
Work around by recycling the boot's tmp stack for this until cpu_attach()
is called.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.834 -r1.835 src/sys/arch/i386/i386/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/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.187 src/sys/arch/i386/i386/locore.S:1.188
--- src/sys/arch/i386/i386/locore.S:1.187	Wed Nov 10 15:59:08 2021
+++ src/sys/arch/i386/i386/locore.S	Tue May 31 18:04:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.187 2021/11/10 15:59:08 msaitoh Exp $	*/
+/*	$NetBSD: locore.S,v 1.188 2022/05/31 18:04:11 bouyer Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.187 2021/11/10 15:59:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.188 2022/05/31 18:04:11 bouyer Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -326,6 +326,7 @@ LABEL(PDPpaddr)		.long	0	/* paddr of PDP
 END(PDPpaddr)
 
 	/* Space for the temporary stack */
+	.globl	_C_LABEL(tmpstk)
 	.size	tmpstk, tmpstk - .
 	.space	512
 tmpstk:

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.834 src/sys/arch/i386/i386/machdep.c:1.835
--- src/sys/arch/i386/i386/machdep.c:1.834	Sun Dec 26 21:33:48 2021
+++ src/sys/arch/i386/i386/machdep.c	Tue May 31 18:04:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.834 2021/12/26 21:33:48 riastradh Exp $	*/
+/*	$NetBSD: machdep.c,v 1.835 2022/05/31 18:04:11 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.834 2021/12/26 21:33:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.835 2022/05/31 18:04:11 bouyer Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -1423,6 +1423,8 @@ init386(paddr_t first_avail)
 #endif
 
 #ifdef XENPV
+	extern int tmpstk;
+	cpu_info_primary.ci_intrstack = 
 	events_default_setup();
 #else
 	intr_default_setup();



CVS commit: src/sys/arch/i386/i386

2021-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 23 11:56:28 UTC 2021

Modified Files:
src/sys/arch/i386/i386: db_disasm.c

Log Message:
ddb/i386: Don't go out of the way to detect invalid addresses.

db_read_bytes already does this better (but didn't at the time this
check was originally added back in 1998).  Not sure if this code had
the same mistake as the amd64 code causing it to trip over its own
shoelaces, but there should be no need for it here.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/i386/i386/db_disasm.c

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



CVS commit: src/sys/arch/i386/i386

2021-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 23 11:56:28 UTC 2021

Modified Files:
src/sys/arch/i386/i386: db_disasm.c

Log Message:
ddb/i386: Don't go out of the way to detect invalid addresses.

db_read_bytes already does this better (but didn't at the time this
check was originally added back in 1998).  Not sure if this code had
the same mistake as the amd64 code causing it to trip over its own
shoelaces, but there should be no need for it here.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/i386/i386/db_disasm.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/i386/i386/db_disasm.c
diff -u src/sys/arch/i386/i386/db_disasm.c:1.48 src/sys/arch/i386/i386/db_disasm.c:1.49
--- src/sys/arch/i386/i386/db_disasm.c:1.48	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/i386/i386/db_disasm.c	Sun May 23 11:56:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.48 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.49 2021/05/23 11:56:28 riastradh Exp $	*/
 
 /* 
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.48 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.49 2021/05/23 11:56:28 riastradh Exp $");
 
 #include 
 #include 
@@ -1132,26 +1132,6 @@ db_disasm(db_addr_t loc, bool altfmt)
 	int	len;
 	struct i_addr	address;
 
-#ifdef _KERNEL
-	pt_entry_t *pte, *pde;
-
-	/*
-	 * Don't try to disassemble the location if the mapping is invalid.
-	 * If we do, we'll fault, and end up debugging the debugger!
-	 * in the case of largepages, "pte" is really the pde and "pde" is
-	 * really the entry for the pdp itself.
-	 */
-	if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS)
-		pte = kvtopte((vaddr_t)loc);
-	else
-		pte = vtopte((vaddr_t)loc);
-	pde = vtopte((vaddr_t)pte);
-	if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) {
-		db_printf("invalid address\n");
-		return (loc);
-	}
-#endif
-
 	get_value_inc(inst, loc, 1, false);
 	short_addr = false;
 	size = LONG;



CVS commit: src/sys/arch/i386/i386

2020-08-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 11 04:30:16 UTC 2020

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
- fix lcall test
- refactor all the TRAP_SIGDEBUG printfs and use hexdump like we did on
  amd64


To generate a diff of this commit:
cvs rdiff -u -r1.305 -r1.306 src/sys/arch/i386/i386/trap.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/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.305 src/sys/arch/i386/i386/trap.c:1.306
--- src/sys/arch/i386/i386/trap.c:1.305	Sat Aug  8 15:08:48 2020
+++ src/sys/arch/i386/i386/trap.c	Tue Aug 11 00:30:16 2020
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.305 2020/08/08 19:08:48 christos Exp $	*/
+/*	$NetBSD: trap.c,v 1.306 2020/08/11 04:30:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.305 2020/08/08 19:08:48 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.306 2020/08/11 04:30:16 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -165,7 +165,10 @@ int	trapdebug = 0;
 #define	IDTVEC(name)	__CONCAT(X, name)
 
 #ifdef TRAP_SIGDEBUG
-static void frame_dump(struct trapframe *, struct pcb *);
+static void sigdebug(const struct trapframe *, const ksiginfo_t *, int);
+#define SIGDEBUG(a, b, c) sigdebug(a, b, c)
+#else
+#define SIGDEBUG(a, b, c)
 #endif
 
 void
@@ -285,7 +288,7 @@ trap(struct trapframe *frame)
 	struct trapframe *vframe;
 	ksiginfo_t ksi;
 	void *onfault;
-	int type, error;
+	int type, error = 0;
 	uint32_t cr2;
 	bool pfail;
 
@@ -440,6 +443,7 @@ kernelfault:
 		if (!pmap_exec_fixup(>p_vmspace->vm_map, vframe, pcb)) {
 			/* Save outer frame for any signal return */
 			l->l_md.md_regs = vframe;
+			SIGDEBUG(vframe, , error);
 			(*p->p_emul->e_trapsignal)(l, );
 		}
 		/* Return to user by reloading the user frame */
@@ -452,7 +456,7 @@ kernelfault:
 #define LCALLSZ 7
 		/* Check for the osyscall lcall instruction. */
 		if (frame->tf_eip < VM_MAXUSER_ADDRESS - LCALLSZ &&
-		x86_cpu_is_lcall((const void *)frame->tf_eip)) {
+		x86_cpu_is_lcall((const void *)frame->tf_eip) == 0) {
 
 			/* Advance past the lcall. */
 			frame->tf_eip += LCALLSZ;
@@ -468,12 +472,6 @@ kernelfault:
 	case T_SEGNPFLT|T_USER:
 	case T_STKFLT|T_USER:
 	case T_ALIGNFLT|T_USER:
-#ifdef TRAP_SIGDEBUG
-		printf("pid %d.%d (%s): BUS/SEGV (%#x) at eip %#x addr %#"
-		PRIxREGISTER "\n", p->p_pid, l->l_lid, p->p_comm,
-		type, frame->tf_eip, rcr2());
-		frame_dump(frame, pcb);
-#endif
 		KSI_INIT_TRAP();
 
 		ksi.ksi_addr = (void *)rcr2();
@@ -510,12 +508,6 @@ kernelfault:
 
 	case T_PRIVINFLT|T_USER:	/* privileged instruction fault */
 	case T_FPOPFLT|T_USER:		/* coprocessor operand fault */
-#ifdef TRAP_SIGDEBUG
-		printf("pid %d.%d (%s): ILL at eip %#x addr %#"
-		PRIxREGISTER "\n", p->p_pid, l->l_lid, p->p_comm,
-		frame->tf_eip, rcr2());
-		frame_dump(frame, pcb);
-#endif
 		KSI_INIT_TRAP();
 		ksi.ksi_signo = SIGILL;
 		ksi.ksi_addr = (void *) frame->tf_eip;
@@ -732,12 +724,7 @@ faultcommon:
 			break;
 		}
 
-#ifdef TRAP_SIGDEBUG
-		printf("pid %d.%d (%s): signal %d at eip %#x addr %#lx "
-		"error %d\n", p->p_pid, l->l_lid, p->p_comm, ksi.ksi_signo,
-		frame->tf_eip, va, error);
-		frame_dump(frame, pcb);
-#endif
+		SIGDEBUG(frame, , error);
 		(*p->p_emul->e_trapsignal)(l, );
 		break;
 	}
@@ -776,6 +763,7 @@ faultcommon:
 			else
 ksi.ksi_code = TRAP_TRACE;
 			ksi.ksi_addr = (void *)frame->tf_eip;
+			SIGDEBUG(frame, , error);
 			(*p->p_emul->e_trapsignal)(l, );
 		}
 		break;
@@ -802,6 +790,7 @@ out:
 	return;
 trapsignal:
 	ksi.ksi_trap = type & ~T_USER;
+	SIGDEBUG(frame, , error);
 	(*p->p_emul->e_trapsignal)(l, );
 	userret(l);
 }
@@ -824,11 +813,9 @@ startlwp(void *arg)
 }
 
 #ifdef TRAP_SIGDEBUG
-void
-frame_dump(struct trapframe *tf, struct pcb *pcb)
+static void
+frame_dump(const struct trapframe *tf, const struct pcb *pcb)
 {
-	int i;
-	unsigned long *p;
 	uint64_t fsd, gsd;
 
 	printf("trapframe %p\n", tf);
@@ -848,11 +835,19 @@ frame_dump(struct trapframe *tf, struct 
 	memcpy(, >pcb_gsd, sizeof(gsd));
 	printf("fsbase 0x%016llx gsbase 0x%016llx\n", fsd, gsd);
 	printf("\n");
-	printf("Stack dump:\n");
-	for (i = 0, p = (unsigned long *) tf; i < 20; i ++, p += 8)
-		printf(" 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx"
-		   " 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx\n",
-		   p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
-	printf("\n");
+	hexdump(printf, "Stack dump", tf, 256);
+}
+
+static void
+sigdebug(const struct trapframe *tf, const ksiginfo_t *ksi, int e)
+{
+	struct lwp *l = curlwp;
+	struct proc *p = l->l_proc;
+
+	printf("pid %d.%d (%s): signal %d code=%d (trap %x) "
+	"@eip %#x addr %#x error=%d\n",
+	p->p_pid, l->l_lid, p->p_comm, ksi->ksi_signo, ksi->ksi_code,
+	tf->tf_trapno, tf->tf_eip, 

CVS commit: src/sys/arch/i386/i386

2020-08-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 11 04:30:16 UTC 2020

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
- fix lcall test
- refactor all the TRAP_SIGDEBUG printfs and use hexdump like we did on
  amd64


To generate a diff of this commit:
cvs rdiff -u -r1.305 -r1.306 src/sys/arch/i386/i386/trap.c

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



CVS commit: src/sys/arch/i386/i386

2020-05-28 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu May 28 20:03:19 UTC 2020

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
PR port-i386/55314: i386 no longer boots

Oops, EDI and ESI are callee saved on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/i386/i386/cpufunc.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/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.44 src/sys/arch/i386/i386/cpufunc.S:1.45
--- src/sys/arch/i386/i386/cpufunc.S:1.44	Wed May 27 20:49:14 2020
+++ src/sys/arch/i386/i386/cpufunc.S	Thu May 28 20:03:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.44 2020/05/27 20:49:14 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.45 2020/05/28 20:03:19 ad Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2020 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.44 2020/05/27 20:49:14 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.45 2020/05/28 20:03:19 ad Exp $");
 
 #include "opt_xen.h"
 
@@ -322,11 +322,15 @@ END(outl)
 ENTRY(x86_stos)
 	pushl	%ebp
 	movl	%esp,%ebp
+	pushl	%edi
+	pushl	%esi
 	movl	8(%ebp),%edi
 	movl	12(%ebp),%eax
 	movl	16(%ebp),%ecx
 	rep
 	stosl
+	popl	%esi
+	popl	%edi
 	leave
 	ret
 END(x86_stos)
@@ -334,11 +338,15 @@ END(x86_stos)
 ENTRY(x86_movs)
 	pushl	%ebp
 	movl	%esp,%ebp
+	pushl	%edi
+	pushl	%esi
 	movl	8(%ebp),%edi
 	movl	12(%ebp),%esi
 	movl	16(%ebp),%ecx
 	rep
 	movsl
+	popl	%esi
+	popl	%edi
 	leave
 	ret
 END(x86_movs)



CVS commit: src/sys/arch/i386/i386

2020-05-28 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu May 28 20:03:19 UTC 2020

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
PR port-i386/55314: i386 no longer boots

Oops, EDI and ESI are callee saved on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/i386/i386/cpufunc.S

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



CVS commit: src/sys/arch/i386/i386

2020-05-27 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed May 27 20:49:14 UTC 2020

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
mismatched END pointed out by maxv@


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/i386/i386/cpufunc.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/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.43 src/sys/arch/i386/i386/cpufunc.S:1.44
--- src/sys/arch/i386/i386/cpufunc.S:1.43	Wed May 27 19:33:40 2020
+++ src/sys/arch/i386/i386/cpufunc.S	Wed May 27 20:49:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.43 2020/05/27 19:33:40 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.44 2020/05/27 20:49:14 ad Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2020 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.43 2020/05/27 19:33:40 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.44 2020/05/27 20:49:14 ad Exp $");
 
 #include "opt_xen.h"
 
@@ -341,4 +341,4 @@ ENTRY(x86_movs)
 	movsl
 	leave
 	ret
-END(x86_stos)
+END(x86_movs)



CVS commit: src/sys/arch/i386/i386

2020-05-27 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed May 27 20:49:14 UTC 2020

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
mismatched END pointed out by maxv@


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/i386/i386/cpufunc.S

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



CVS commit: src/sys/arch/i386/i386

2020-05-27 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed May 27 18:47:13 UTC 2020

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
tsc_get_timecount(): fix 64-bit return


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/i386/i386/cpufunc.S

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



CVS commit: src/sys/arch/i386/i386

2020-05-27 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed May 27 18:47:13 UTC 2020

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
tsc_get_timecount(): fix 64-bit return


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/i386/i386/cpufunc.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/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.41 src/sys/arch/i386/i386/cpufunc.S:1.42
--- src/sys/arch/i386/i386/cpufunc.S:1.41	Tue May 19 21:40:55 2020
+++ src/sys/arch/i386/i386/cpufunc.S	Wed May 27 18:47:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.41 2020/05/19 21:40:55 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.42 2020/05/27 18:47:13 ad Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2020 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.41 2020/05/19 21:40:55 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.42 2020/05/27 18:47:13 ad Exp $");
 
 #include "opt_xen.h"
 
@@ -164,19 +164,19 @@ ENTRY(msr_onfault)
 END(msr_onfault)
 
 ENTRY(tsc_get_timecount)
+	pushl	%ebx
 	movl	CPUVAR(CURLWP), %ecx
 1:
-	pushl	L_NCSW(%ecx)
+	movl	L_NCSW(%ecx), %ebx
 	rdtsc
 	addl	CPUVAR(CC_SKEW), %eax
 	adcl	CPUVAR(CC_SKEW+4), %edx
-	popl	%edx
-	cmpl	%edx, L_NCSW(%ecx)
+	cmpl	%ebx, L_NCSW(%ecx)
 	jne	2f
+	popl	%ebx
 	ret
 2:
 	jmp	1b
-	ret
 END(tsc_get_timecount)
 
 STRONG_ALIAS(cpu_counter, tsc_get_timecount)



CVS commit: src/sys/arch/i386/i386

2020-05-17 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun May 17 12:12:22 UTC 2020

Modified Files:
src/sys/arch/i386/i386: spl.S

Log Message:
comments


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/i386/i386/spl.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.54 src/sys/arch/i386/i386/spl.S:1.55
--- src/sys/arch/i386/i386/spl.S:1.54	Fri May  1 09:40:47 2020
+++ src/sys/arch/i386/i386/spl.S	Sun May 17 12:12:22 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: spl.S,v 1.54 2020/05/01 09:40:47 maxv Exp $	*/
+/*	$NetBSD: spl.S,v 1.55 2020/05/17 12:12:22 ad Exp $	*/
 
 /*
- * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.54 2020/05/01 09:40:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.55 2020/05/17 12:12:22 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_spldebug.h"
@@ -359,7 +359,13 @@ IDTVEC(softintr)
 	CLI(%ecx)
 	movl	L_PCB(%esi),%ecx
 	movl	PCB_ESP(%ecx),%esp
-	xchgl	%esi,CPUVAR(CURLWP)	/* must be globally visible */
+
+	/*
+	 * for non-interlocked mutex release to work safely the change
+	 * to ci_curlwp must not languish in the store buffer. therefore
+	 * we use XCHG and not MOV here.  see kern_mutex.c.
+	 */
+	xchgl	%esi,CPUVAR(CURLWP)	/* restore ci_curlwp */
 	popl	%edi			/* unwind switchframe */
 	popl	%esi
 	addl	$8,%esp



CVS commit: src/sys/arch/i386/i386

2020-05-17 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun May 17 12:12:22 UTC 2020

Modified Files:
src/sys/arch/i386/i386: spl.S

Log Message:
comments


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/i386/i386/spl.S

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



CVS commit: src/sys/arch/i386/i386

2020-05-05 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May  5 09:07:35 UTC 2020

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
build start_xenpvh only if XEN. Fixes NET4501 build issue reported by
John D. Baker


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.183 src/sys/arch/i386/i386/locore.S:1.184
--- src/sys/arch/i386/i386/locore.S:1.183	Sat May  2 18:49:57 2020
+++ src/sys/arch/i386/i386/locore.S	Tue May  5 09:07:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.183 2020/05/02 18:49:57 bouyer Exp $	*/
+/*	$NetBSD: locore.S,v 1.184 2020/05/05 09:07:35 bouyer Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.183 2020/05/02 18:49:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.184 2020/05/05 09:07:35 bouyer Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1164,6 +1164,7 @@ begin:
 #endif /* XENPV */
 END(start)
 
+#if defined(XEN)
 #ifndef XENPV
 /* entry point for Xen PVH */
 ENTRY(start_xenpvh)
@@ -1229,10 +1230,9 @@ gdt_xenpvh:
 	.long   0x00cf9200
 gdt_xenpvhend:
 	.align 4
-#endif /* XENPV */
+#endif /* !XENPV */
 
 
-#if defined(XEN)
 /* space for the hypercall call page */
 #define HYPERCALL_PAGE_OFFSET 0x1000
 .align HYPERCALL_PAGE_OFFSET



CVS commit: src/sys/arch/i386/i386

2020-05-05 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May  5 09:07:35 UTC 2020

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
build start_xenpvh only if XEN. Fixes NET4501 build issue reported by
John D. Baker


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 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: src/sys/arch/i386/i386

2020-05-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat May  2 18:49:57 UTC 2020

Modified Files:
src/sys/arch/i386/i386: i386_trap.S locore.S

Log Message:
HANDLE_DEFERRED_FPU has to be donne with interrupt disabled;
move it before STIC.
Fix fpudna panic on i386 PV


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.182 -r1.183 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.21 src/sys/arch/i386/i386/i386_trap.S:1.22
--- src/sys/arch/i386/i386/i386_trap.S:1.21	Sat Apr 25 15:26:17 2020
+++ src/sys/arch/i386/i386/i386_trap.S	Sat May  2 18:49:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386_trap.S,v 1.21 2020/04/25 15:26:17 bouyer Exp $	*/
+/*	$NetBSD: i386_trap.S,v 1.22 2020/05/02 18: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.21 2020/04/25 15:26:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.22 2020/05/02 18:49:57 bouyer Exp $");
 #endif
 
 /*
@@ -434,6 +434,8 @@ calltrap:
 3:	CHECK_DEFERRED_SWITCH
 	jnz	9f
 
+	HANDLE_DEFERRED_FPU
+
 #ifdef XENPV
 	STIC(%eax)
 	jz	22f
@@ -458,8 +460,6 @@ calltrap:
 22:
 #endif /* XEN */
 
-	HANDLE_DEFERRED_FPU
-
 6:
 #ifdef DIAGNOSTIC
 	cmpl	CPUVAR(ILEVEL),%ebx

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.182 src/sys/arch/i386/i386/locore.S:1.183
--- src/sys/arch/i386/i386/locore.S:1.182	Sat May  2 16:44:35 2020
+++ src/sys/arch/i386/i386/locore.S	Sat May  2 18:49:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.182 2020/05/02 16:44:35 bouyer Exp $	*/
+/*	$NetBSD: locore.S,v 1.183 2020/05/02 18:49:57 bouyer Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.182 2020/05/02 16:44:35 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.183 2020/05/02 18:49:57 bouyer Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1560,6 +1560,8 @@ IDTVEC(syscall)
 	orl	CPUVAR(WANT_PMAPLOAD), %eax
 	jnz	9f
 
+	HANDLE_DEFERRED_FPU
+
 #ifdef XENPV
 	STIC(%eax)
 	jz	14f
@@ -1589,8 +1591,6 @@ IDTVEC(syscall)
 	jne	3f
 #endif
 
-	HANDLE_DEFERRED_FPU
-
 	INTRFASTEXIT
 
 #ifdef DIAGNOSTIC



CVS commit: src/sys/arch/i386/i386

2020-05-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat May  2 18:49:57 UTC 2020

Modified Files:
src/sys/arch/i386/i386: i386_trap.S locore.S

Log Message:
HANDLE_DEFERRED_FPU has to be donne with interrupt disabled;
move it before STIC.
Fix fpudna panic on i386 PV


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.182 -r1.183 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: src/sys/arch/i386/i386

2020-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May  1 09:23:43 UTC 2020

Modified Files:
src/sys/arch/i386/i386: spl.S

Log Message:
Remove dead code, we are in an #ifndef XENPV block here.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/i386/i386/spl.S

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



CVS commit: src/sys/arch/i386/i386

2020-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May  1 09:23:43 UTC 2020

Modified Files:
src/sys/arch/i386/i386: spl.S

Log Message:
Remove dead code, we are in an #ifndef XENPV block here.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/i386/i386/spl.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.52 src/sys/arch/i386/i386/spl.S:1.53
--- src/sys/arch/i386/i386/spl.S:1.52	Fri May  1 09:17:58 2020
+++ src/sys/arch/i386/i386/spl.S	Fri May  1 09:23:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.52 2020/05/01 09:17:58 maxv Exp $	*/
+/*	$NetBSD: spl.S,v 1.53 2020/05/01 09:23:43 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.52 2020/05/01 09:17:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.53 2020/05/01 09:23:43 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_spldebug.h"
@@ -98,15 +98,7 @@ ENTRY(spllower)
 1:
 	ret
 2:
-#ifdef XENPV
-	/*
-	 * no need to call stipending, we're going to CLI again
-	 * just drop the saved value on stack
-	 */
-	addl	$4,%esp
-#else
 	popf
-#endif
 	jmp	_C_LABEL(Xspllower)
 	.align	32
 LABEL(spllower_end)



CVS commit: src/sys/arch/i386/i386

2020-03-27 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Mar 27 21:05:03 UTC 2020

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
PR kern/55114: Install fails with "cpu_switchto: switching above IPL_SCHED (8)"

cpu_switch(): Remove stuff dealing with interrupt levels.  From memory it
was something to do with TLB shootdown interrupts but they have long been
outside the SPL framework.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.178 src/sys/arch/i386/i386/locore.S:1.179
--- src/sys/arch/i386/i386/locore.S:1.178	Mon Feb 10 22:13:50 2020
+++ src/sys/arch/i386/i386/locore.S	Fri Mar 27 21:05:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.178 2020/02/10 22:13:50 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.179 2020/03/27 21:05:03 ad Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.178 2020/02/10 22:13:50 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.179 2020/03/27 21:05:03 ad Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1301,17 +1301,6 @@ ENTRY(cpu_switchto)
 	pushl	%esi
 	pushl	%edi
 
-#if defined(DIAGNOSTIC) && !defined(XENPV)
-	cmpl	$IPL_SCHED,CPUVAR(ILEVEL)
-	jbe	0f
-	pushl	CPUVAR(ILEVEL)
-	pushl	$.Lstr
-	call	_C_LABEL(panic)
-	addl	$8,%esp
-.Lstr:	.string	"cpu_switchto: switching above IPL_SCHED (%d)\0"
-0:
-#endif
-
 	movl	16(%esp),%esi		/* oldlwp */
 	movl	20(%esp),%edi		/* newlwp */
 	movl	24(%esp),%edx		/* returning */
@@ -1408,10 +1397,6 @@ no_RAS:
 	pushl	%edi
 	call	_C_LABEL(i386_tls_switch)
 	addl	$4,%esp
-#else
-	/* Raise the IPL to IPL_HIGH. Dropping the priority is deferred until
-	 * mi_switch(), when cpu_switchto() returns. XXX Still needed? */
-	movl	$IPL_HIGH,CPUVAR(ILEVEL)
 #endif
 
 switch_return:



CVS commit: src/sys/arch/i386/i386

2020-03-27 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Mar 27 21:05:03 UTC 2020

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
PR kern/55114: Install fails with "cpu_switchto: switching above IPL_SCHED (8)"

cpu_switch(): Remove stuff dealing with interrupt levels.  From memory it
was something to do with TLB shootdown interrupts but they have long been
outside the SPL framework.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 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: src/sys/arch/i386/i386

2020-02-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Feb 10 22:13:50 UTC 2020

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Fix a comment


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 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: src/sys/arch/i386/i386

2020-02-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Feb 10 22:13:50 UTC 2020

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Fix a comment


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.177 src/sys/arch/i386/i386/locore.S:1.178
--- src/sys/arch/i386/i386/locore.S:1.177	Wed Jan 15 18:47:23 2020
+++ src/sys/arch/i386/i386/locore.S	Mon Feb 10 22:13:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.177 2020/01/15 18:47:23 ad Exp $	*/
+/*	$NetBSD: locore.S,v 1.178 2020/02/10 22:13:50 skrll Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.177 2020/01/15 18:47:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.178 2020/02/10 22:13:50 skrll Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1289,8 +1289,8 @@ END(dumpsys)
  * struct lwp *cpu_switchto(struct lwp *oldlwp, struct lwp *newlwp,
  * bool returning)
  *
- *	1. if (oldlwp != NULL), save its context.
- *	2. then, restore context of newlwp.
+ *	1. save context of oldlwp.
+ *	2. restore context of newlwp.
  *
  * Note that the stack frame layout is known to "struct switchframe" in
  *  and to the code in cpu_lwp_fork() which initializes



CVS commit: src/sys/arch/i386/i386

2020-01-13 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Jan 13 12:03:42 UTC 2020

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
It looks like Xen cpu_hatch() calls cpu_switchto() with prevlwp=NULL,
instead of calling idle_loop() directly.  I can't test a change to
cpu_hatch() right now so allow for prevlwp=NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.175 -r1.176 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.175 src/sys/arch/i386/i386/locore.S:1.176
--- src/sys/arch/i386/i386/locore.S:1.175	Wed Jan  8 17:38:41 2020
+++ src/sys/arch/i386/i386/locore.S	Mon Jan 13 12:03:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.175 2020/01/08 17:38:41 ad Exp $	*/
+/*	$NetBSD: locore.S,v 1.176 2020/01/13 12:03:41 ad Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.175 2020/01/08 17:38:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.176 2020/01/13 12:03:41 ad Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1316,10 +1316,14 @@ ENTRY(cpu_switchto)
 	movl	20(%esp),%edi		/* newlwp */
 	movl	24(%esp),%edx		/* returning */
 
+	testl	%esi,%esi		/* oldlwp = NULL ? */
+	jz	skip_save
+
 	/* Save old context. */
 	movl	L_PCB(%esi),%eax
 	movl	%esp,PCB_ESP(%eax)
 	movl	%ebp,PCB_EBP(%eax)
+skip_save:
 
 	/* Switch to newlwp's stack. */
 	movl	L_PCB(%edi),%ebx



CVS commit: src/sys/arch/i386/i386

2020-01-13 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Jan 13 12:03:42 UTC 2020

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
It looks like Xen cpu_hatch() calls cpu_switchto() with prevlwp=NULL,
instead of calling idle_loop() directly.  I can't test a change to
cpu_hatch() right now so allow for prevlwp=NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.175 -r1.176 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: src/sys/arch/i386/i386

2019-12-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Tue Dec 10 18:04:54 UTC 2019

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
pg->phys_addr -> VM_PAGE_TO_PHYS(pg)


To generate a diff of this commit:
cvs rdiff -u -r1.823 -r1.824 src/sys/arch/i386/i386/machdep.c

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



CVS commit: src/sys/arch/i386/i386

2019-12-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Tue Dec 10 18:04:54 UTC 2019

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
pg->phys_addr -> VM_PAGE_TO_PHYS(pg)


To generate a diff of this commit:
cvs rdiff -u -r1.823 -r1.824 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.823 src/sys/arch/i386/i386/machdep.c:1.824
--- src/sys/arch/i386/i386/machdep.c:1.823	Fri Oct 18 01:38:28 2019
+++ src/sys/arch/i386/i386/machdep.c	Tue Dec 10 18:04:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.823 2019/10/18 01:38:28 manu Exp $	*/
+/*	$NetBSD: machdep.c,v 1.824 2019/12/10 18:04:54 ad Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.823 2019/10/18 01:38:28 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.824 2019/12/10 18:04:54 ad Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -1680,7 +1680,7 @@ cpu_alloc_l3_page(struct cpu_info *ci)
 		panic("%s: failed to allocate L3 pglist for CPU %d (ret %d)\n",
 			__func__, cpu_index(ci), ret);
 
-	ci->ci_pae_l3_pdirpa = vmap->phys_addr;
+	ci->ci_pae_l3_pdirpa = VM_PAGE_TO_PHYS(vmap);
 
 	ci->ci_pae_l3_pdir = (paddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
 		UVM_KMF_VAONLY | UVM_KMF_NOWAIT);



CVS commit: src/sys/arch/i386/i386

2019-10-17 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Oct 18 01:19:00 UTC 2019

Modified Files:
src/sys/arch/i386/i386: multiboot.c

Log Message:
Fix multiboot1 kernel symbol load

ELF_Shdr's sh_type field is a value, not a flag field


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/i386/i386/multiboot.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/i386/i386/multiboot.c
diff -u src/sys/arch/i386/i386/multiboot.c:1.24 src/sys/arch/i386/i386/multiboot.c:1.25
--- src/sys/arch/i386/i386/multiboot.c:1.24	Thu Nov  8 06:23:48 2018
+++ src/sys/arch/i386/i386/multiboot.c	Fri Oct 18 01:19:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: multiboot.c,v 1.24 2018/11/08 06:23:48 msaitoh Exp $	*/
+/*	$NetBSD: multiboot.c,v 1.25 2019/10/18 01:19:00 manu Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.24 2018/11/08 06:23:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.25 2019/10/18 01:19:00 manu Exp $");
 
 #include "opt_multiboot.h"
 
@@ -302,14 +302,14 @@ copy_syms(struct multiboot_info *mi)
 
 		shdrp = &((Elf32_Shdr *)mi->mi_elfshdr_addr)[i];
 
-		if ((shdrp->sh_type & SHT_SYMTAB) &&
+		if ((shdrp->sh_type == SHT_SYMTAB) &&
 		shdrp->sh_link != SHN_UNDEF) {
 			Elf32_Shdr *shdrp2;
 
 			shdrp2 = &((Elf32_Shdr *)mi->mi_elfshdr_addr)
 			[shdrp->sh_link];
 
-			if (shdrp2->sh_type & SHT_STRTAB) {
+			if (shdrp2->sh_type == SHT_STRTAB) {
 symtabp = shdrp;
 strtabp = shdrp2;
 			}



CVS commit: src/sys/arch/i386/i386

2019-10-17 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Oct 18 01:19:00 UTC 2019

Modified Files:
src/sys/arch/i386/i386: multiboot.c

Log Message:
Fix multiboot1 kernel symbol load

ELF_Shdr's sh_type field is a value, not a flag field


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/i386/i386/multiboot.c

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



CVS commit: src/sys/arch/i386/i386

2019-10-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Oct  4 15:28:00 UTC 2019

Modified Files:
src/sys/arch/i386/i386: i386_trap.S locore.S spl.S

Log Message:
Misc reordering, to clarify and reduce the diff against amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.170 -r1.171 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/i386/i386/spl.S

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



CVS commit: src/sys/arch/i386/i386

2019-10-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Oct  4 15:28:00 UTC 2019

Modified Files:
src/sys/arch/i386/i386: i386_trap.S locore.S spl.S

Log Message:
Misc reordering, to clarify and reduce the diff against amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.170 -r1.171 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/i386/i386/spl.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.18 src/sys/arch/i386/i386/i386_trap.S:1.19
--- src/sys/arch/i386/i386/i386_trap.S:1.18	Mon Feb 11 17:28:52 2019
+++ src/sys/arch/i386/i386/i386_trap.S	Fri Oct  4 15:28:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $	*/
+/*	$NetBSD: i386_trap.S,v 1.19 2019/10/04 15:28:00 maxv Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
 
 #if 0
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.19 2019/10/04 15:28:00 maxv Exp $");
 #endif
 
 /*
@@ -220,7 +220,7 @@ IDTVEC(trap07)
 	pushl	%esp
 	call	_C_LABEL(fpudna)
 	addl	$4,%esp
-	jmp	_C_LABEL(trapreturn)
+	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap07)
 
 IDTVEC(trap08)
@@ -282,7 +282,7 @@ IDTVEC(trap0f)
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
 #endif
-	jmp	_C_LABEL(trapreturn)
+	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap0f)
 IDTVEC_END(intrspurious)
 
@@ -302,7 +302,7 @@ IDTVEC(trap10)
 	adcl	$0,CPUVAR(NTRAP)+4
 	call	_C_LABEL(fputrap)
 	addl	$4,%esp
-	jmp	_C_LABEL(trapreturn)
+	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap10)
 
 IDTVEC(trap11)
@@ -394,13 +394,14 @@ IDTVEC_END(tss_trap08)
 	.type	_C_LABEL(trap_return_fault_return),@function
 LABEL(trap_return_fault_return)
 	mov	4(%esp),%esp	/* frame for user return */
-	jmp	_C_LABEL(trapreturn)
+	jmp	.Lalltraps_checkusr
 END(trap_return_fault_return)
 
 /* LINTSTUB: Ignore */
 ENTRY(alltraps)
 	INTRENTRY
 	STI(%eax)
+
 calltrap:
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
@@ -410,16 +411,18 @@ calltrap:
 	pushl	%esp
 	call	_C_LABEL(trap)
 	addl	$4,%esp
-_C_LABEL(trapreturn):	.globl	trapreturn
+
+.Lalltraps_checkusr:
 	testb	$CHK_UPL,TF_CS(%esp)
 	jnz	.Lalltraps_checkast
 	jmp	6f
+
 .Lalltraps_checkast:
 	/* Check for ASTs on exit to user mode. */
 	CLI(%eax)
 	CHECK_ASTPENDING(%eax)
 	jz	3f
-5:	CLEAR_ASTPENDING(%eax)
+	CLEAR_ASTPENDING(%eax)
 	STI(%eax)
 	movl	$T_ASTFLT,TF_TRAPNO(%esp)
 	addl	$1,CPUVAR(NTRAP)	/* statistical info */
@@ -430,6 +433,7 @@ _C_LABEL(trapreturn):	.globl	trapreturn
 	jmp	.Lalltraps_checkast	/* re-check ASTs */
 3:	CHECK_DEFERRED_SWITCH
 	jnz	9f
+
 #ifdef XEN
 	STIC(%eax)
 	jz	6f
@@ -450,15 +454,23 @@ _C_LABEL(trapreturn):	.globl	trapreturn
 	movl	CPUVAR(XSOURCES)(,%eax,4),%eax
 	jmp	*IS_RESUME(%eax)
 7:	movl	%ebx,CPUVAR(ILEVEL)	/* restore cpl */
-	jmp	_C_LABEL(trapreturn)
-#endif /* XEN */
-#ifndef DIAGNOSTIC
-6:	INTRFASTEXIT
-#else
-6:	cmpl	CPUVAR(ILEVEL),%ebx
-	jne	3f
+	jmp	.Lalltraps_checkusr
+#endif
+
+6:
+#ifdef DIAGNOSTIC
+	cmpl	CPUVAR(ILEVEL),%ebx
+	jne	.Lspl_error
+#endif
 	INTRFASTEXIT
-3:	STI(%eax)
+
+9:	STI(%eax)
+	call	_C_LABEL(pmap_load)
+	jmp	.Lalltraps_checkast	/* re-check ASTs */
+
+#ifdef DIAGNOSTIC
+.Lspl_error:
+	STI(%eax)
 	pushl	$4f
 	call	_C_LABEL(panic)
 	addl	$4,%esp
@@ -467,8 +479,5 @@ _C_LABEL(trapreturn):	.globl	trapreturn
 	addl	$4,%esp
 	jmp	.Lalltraps_checkast	/* re-check ASTs */
 4:	.asciz	"SPL NOT LOWERED ON TRAP EXIT\n"
-#endif /* DIAGNOSTIC */
-9:	STI(%eax)
-	call	_C_LABEL(pmap_load)
-	jmp	.Lalltraps_checkast	/* re-check ASTs */
+#endif
 END(alltraps)

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.170 src/sys/arch/i386/i386/locore.S:1.171
--- src/sys/arch/i386/i386/locore.S:1.170	Fri Oct  4 11:47:07 2019
+++ src/sys/arch/i386/i386/locore.S	Fri Oct  4 15:28:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.170 2019/10/04 11:47:07 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.171 2019/10/04 15:28:00 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.170 2019/10/04 11:47:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.171 2019/10/04 15:28:00 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1264,6 +1264,7 @@ IDTVEC(syscall)
 	pushl	$T_ASTFLT	/* trap # for doing ASTs */
 	INTRENTRY
 	STI(%eax)
+
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
 	testl	%ebx,%ebx
@@ -1276,6 +1277,7 @@ IDTVEC(syscall)
 #endif
 1:
 #endif /* DIAGNOSTIC */
+
 	addl	$1,CPUVAR(NSYSCALL)	/* count it atomically */
 	adcl	$0,CPUVAR(NSYSCALL)+4	/* count it atomically */
 	movl	CPUVAR(CURLWP),%edi
@@ -1290,6 +1292,7 @@ IDTVEC(syscall)
 	movl	L_MD_ASTPENDING(%edi), %eax
 	orl	CPUVAR(WANT_PMAPLOAD), %eax
 	jnz	9f
+
 #ifdef XEN
 	STIC(%eax)
 	jz	14f

CVS commit: src/sys/arch/i386/i386

2019-08-05 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Aug  6 02:04:43 UTC 2019

Modified Files:
src/sys/arch/i386/i386: process_machdep.c

Log Message:
Do not dereference user pointer in ptrace_machdep_dorequest()/i386

Always use copyin(9) for reading user memory.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/i386/i386/process_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/i386/i386/process_machdep.c
diff -u src/sys/arch/i386/i386/process_machdep.c:1.93 src/sys/arch/i386/i386/process_machdep.c:1.94
--- src/sys/arch/i386/i386/process_machdep.c:1.93	Wed Jun 26 12:30:12 2019
+++ src/sys/arch/i386/i386/process_machdep.c	Tue Aug  6 02:04:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.93 2019/06/26 12:30:12 mgorny Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.94 2019/08/06 02:04:43 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.93 2019/06/26 12:30:12 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.94 2019/08/06 02:04:43 kamil Exp $");
 
 #include "opt_ptrace.h"
 
@@ -281,7 +281,7 @@ ptrace_machdep_dorequest(
 {
 	struct uio uio;
 	struct iovec iov;
-	struct iovec *user_iov = (struct iovec*)addr;
+	struct iovec user_iov;
 	struct vmspace *vm;
 	int error;
 	int write = 0;
@@ -319,12 +319,14 @@ ptrace_machdep_dorequest(
 		/* write = 0 done above. */
 		if (!process_machdep_validxstate(lt->l_proc))
 			return EINVAL;
+		if ((error = copyin(addr, _iov, sizeof(user_iov))) != 0)
+			return error;
 		error = proc_vmspace_getref(l->l_proc, );
 		if (error) {
 			return error;
 		}
-		iov.iov_base = user_iov->iov_base;
-		iov.iov_len = user_iov->iov_len;
+		iov.iov_base = user_iov.iov_base;
+		iov.iov_len = user_iov.iov_len;
 		if (iov.iov_len > sizeof(struct xstate))
 			iov.iov_len = sizeof(struct xstate);
 		uio.uio_iov = 



CVS commit: src/sys/arch/i386/i386

2019-08-05 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Aug  6 02:04:43 UTC 2019

Modified Files:
src/sys/arch/i386/i386: process_machdep.c

Log Message:
Do not dereference user pointer in ptrace_machdep_dorequest()/i386

Always use copyin(9) for reading user memory.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/i386/i386/process_machdep.c

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



CVS commit: src/sys/arch/i386/i386

2019-07-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jul 13 17:04:21 UTC 2019

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
Use common code for SMEP/SMAP panic to print more information and
allow debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/sys/arch/i386/i386/trap.c

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



CVS commit: src/sys/arch/i386/i386

2019-07-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jul 13 17:04:21 UTC 2019

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
Use common code for SMEP/SMAP panic to print more information and
allow debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/sys/arch/i386/i386/trap.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/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.301 src/sys/arch/i386/i386/trap.c:1.302
--- src/sys/arch/i386/i386/trap.c:1.301	Wed May 29 14:28:37 2019
+++ src/sys/arch/i386/i386/trap.c	Sat Jul 13 17:04:21 2019
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.301 2019/05/29 14:28:37 msaitoh Exp $	*/
+/*	$NetBSD: trap.c,v 1.302 2019/07/13 17:04:21 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.301 2019/05/29 14:28:37 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.302 2019/07/13 17:04:21 mlelstv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -582,17 +582,20 @@ kernelfault:
 
 		if (frame->tf_err & PGEX_X) {
 			/* SMEP might have brought us here */
-			if (cr2 > VM_MIN_ADDRESS && cr2 <= VM_MAXUSER_ADDRESS)
-panic("prevented execution of %p (SMEP)",
+			if (cr2 > VM_MIN_ADDRESS && cr2 <= VM_MAXUSER_ADDRESS) {
+printf("prevented execution of %p (SMEP)\n",
 (void *)cr2);
+goto we_re_toast;
+			}
 		}
 
 		if ((frame->tf_err & PGEX_P) &&
 		cr2 < VM_MAXUSER_ADDRESS) {
 			/* SMAP might have brought us here */
 			if (onfault_handler(pcb, frame) == NULL) {
-panic("prevented access to %p (SMAP)",
+printf("prevented access to %p (SMAP)\n",
 (void *)cr2);
+goto we_re_toast;
 			}
 		}
 



CVS commit: src/sys/arch/i386/i386

2019-05-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 29 14:28:37 UTC 2019

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
 Use PRIxREGISTER suggested by Kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/sys/arch/i386/i386/trap.c

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



CVS commit: src/sys/arch/i386/i386

2019-05-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 29 14:28:37 UTC 2019

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
 Use PRIxREGISTER suggested by Kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/sys/arch/i386/i386/trap.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/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.300 src/sys/arch/i386/i386/trap.c:1.301
--- src/sys/arch/i386/i386/trap.c:1.300	Sat Apr  6 03:06:25 2019
+++ src/sys/arch/i386/i386/trap.c	Wed May 29 14:28:37 2019
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.300 2019/04/06 03:06:25 thorpej Exp $	*/
+/*	$NetBSD: trap.c,v 1.301 2019/05/29 14:28:37 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.300 2019/04/06 03:06:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.301 2019/05/29 14:28:37 msaitoh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -467,8 +467,9 @@ kernelfault:
 	case T_STKFLT|T_USER:
 	case T_ALIGNFLT|T_USER:
 #ifdef TRAP_SIGDEBUG
-		printf("pid %d.%d (%s): BUS/SEGV (%#x) at eip %#x addr %#lx\n",
-		p->p_pid, l->l_lid, p->p_comm, type, frame->tf_eip, rcr2());
+		printf("pid %d.%d (%s): BUS/SEGV (%#x) at eip %#x addr %#"
+		PRIxREGISTER "\n", p->p_pid, l->l_lid, p->p_comm,
+		type, frame->tf_eip, rcr2());
 		frame_dump(frame, pcb);
 #endif
 		KSI_INIT_TRAP();
@@ -508,8 +509,9 @@ kernelfault:
 	case T_PRIVINFLT|T_USER:	/* privileged instruction fault */
 	case T_FPOPFLT|T_USER:		/* coprocessor operand fault */
 #ifdef TRAP_SIGDEBUG
-		printf("pid %d.%d (%s): ILL at eip %#x addr %#lx\n",
-		p->p_pid, l->l_lid, p->p_comm, frame->tf_eip, rcr2());
+		printf("pid %d.%d (%s): ILL at eip %#x addr %#"
+		PRIxREGISTER "\n", p->p_pid, l->l_lid, p->p_comm,
+		frame->tf_eip, rcr2());
 		frame_dump(frame, pcb);
 #endif
 		KSI_INIT_TRAP();



CVS commit: src/sys/arch/i386/i386

2019-05-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 19 08:49:08 UTC 2019

Modified Files:
src/sys/arch/i386/i386: compat_16_machdep.c

Log Message:
Remove useless call to fpu_sigreset(), buildcontext() already calls it.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/i386/i386/compat_16_machdep.c

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



CVS commit: src/sys/arch/i386/i386

2019-05-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 19 08:49:08 UTC 2019

Modified Files:
src/sys/arch/i386/i386: compat_16_machdep.c

Log Message:
Remove useless call to fpu_sigreset(), buildcontext() already calls it.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/i386/i386/compat_16_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/i386/i386/compat_16_machdep.c
diff -u src/sys/arch/i386/i386/compat_16_machdep.c:1.31 src/sys/arch/i386/i386/compat_16_machdep.c:1.32
--- src/sys/arch/i386/i386/compat_16_machdep.c:1.31	Sun May 19 08:46:15 2019
+++ src/sys/arch/i386/i386/compat_16_machdep.c	Sun May 19 08:49:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.31 2019/05/19 08:46:15 maxv Exp $	*/
+/*	$NetBSD: compat_16_machdep.c,v 1.32 2019/05/19 08:49:08 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.31 2019/05/19 08:46:15 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.32 2019/05/19 08:49:08 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -232,7 +232,6 @@ sendsig_sigcontext(const ksiginfo_t *ksi
 		/* NOTREACHED */
 	}
 
-	fpu_sigreset(l);
 	buildcontext(l, sel, catcher, fp);
 
 	/* Remember that we're now on the signal stack. */



CVS commit: src/sys/arch/i386/i386

2019-02-11 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Mon Feb 11 17:28:52 UTC 2019

Modified Files:
src/sys/arch/i386/i386: i386_trap.S

Log Message:
Remove redundant conditional IDT_VEC() entries.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/i386/i386_trap.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.17 src/sys/arch/i386/i386/i386_trap.S:1.18
--- src/sys/arch/i386/i386/i386_trap.S:1.17	Mon Feb 11 14:59:32 2019
+++ src/sys/arch/i386/i386/i386_trap.S	Mon Feb 11 17:28:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386_trap.S,v 1.17 2019/02/11 14:59:32 cherry Exp $	*/
+/*	$NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
 
 #if 0
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.17 2019/02/11 14:59:32 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $");
 #endif
 
 /*
@@ -345,13 +345,8 @@ IDTVEC_END(trap17)
 IDTVEC_END(trap16)
 IDTVEC_END(trap15)
 IDTVEC_END(trap14)
-#ifndef XENPV
 IDTVEC_END(trap13)
 IDTVEC_END(trap12)
-#else
-IDTVEC_END(trap13)
-IDTVEC_END(trap12)
-#endif
 IDTVEC_END(trap11)
 
 IDTVEC(exceptions)



CVS commit: src/sys/arch/i386/i386

2019-02-11 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Mon Feb 11 17:28:52 UTC 2019

Modified Files:
src/sys/arch/i386/i386: i386_trap.S

Log Message:
Remove redundant conditional IDT_VEC() entries.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/i386/i386_trap.S

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



CVS commit: src/sys/arch/i386/i386

2018-12-25 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Wed Dec 26 06:37:31 UTC 2018

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Missed a file during previous commit completing transition to
separate handler queues for i386.

This should fix the build (hopefully!)

Thanks to Robert Elz for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.161 src/sys/arch/i386/i386/locore.S:1.162
--- src/sys/arch/i386/i386/locore.S:1.161	Wed Aug  1 13:35:01 2018
+++ src/sys/arch/i386/i386/locore.S	Wed Dec 26 06:37:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.161 2018/08/01 13:35:01 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.162 2018/12/26 06:37:31 cherry Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.161 2018/08/01 13:35:01 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.162 2018/12/26 06:37:31 cherry Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1288,12 +1288,12 @@ IDTVEC(syscall)
 	movl	$.Lsyscall_resume, %esi /* address to resume loop at */
 .Lsyscall_resume:
 	movl	%ebx,%eax		/* get cpl */
-	movl	CPUVAR(IUNMASK)(,%eax,4),%eax
-	andl	CPUVAR(IPENDING),%eax	/* any non-masked bits left? */
+	movl	CPUVAR(XUNMASK)(,%eax,4),%eax
+	andl	CPUVAR(XPENDING),%eax	/* any non-masked bits left? */
 	jz	17f
 	bsrl	%eax,%eax
-	btrl	%eax,CPUVAR(IPENDING)
-	movl	CPUVAR(ISOURCES)(,%eax,4),%eax
+	btrl	%eax,CPUVAR(XPENDING)
+	movl	CPUVAR(XSOURCES)(,%eax,4),%eax
 	jmp	*IS_RESUME(%eax)
 17:	movl	%ebx, CPUVAR(ILEVEL)	/* restore cpl  */
 	jmp	.Lsyscall_checkast



CVS commit: src/sys/arch/i386/i386

2018-12-25 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Wed Dec 26 06:37:31 UTC 2018

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Missed a file during previous commit completing transition to
separate handler queues for i386.

This should fix the build (hopefully!)

Thanks to Robert Elz for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 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: src/sys/arch/i386/i386

2018-11-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  8 06:23:48 UTC 2018

Modified Files:
src/sys/arch/i386/i386: multiboot.c

Log Message:
"s/ is is / is /" in comment. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/i386/i386/multiboot.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/i386/i386/multiboot.c
diff -u src/sys/arch/i386/i386/multiboot.c:1.23 src/sys/arch/i386/i386/multiboot.c:1.24
--- src/sys/arch/i386/i386/multiboot.c:1.23	Mon May 30 17:45:26 2016
+++ src/sys/arch/i386/i386/multiboot.c	Thu Nov  8 06:23:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: multiboot.c,v 1.23 2016/05/30 17:45:26 dholland Exp $	*/
+/*	$NetBSD: multiboot.c,v 1.24 2018/11/08 06:23:48 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.23 2016/05/30 17:45:26 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.24 2018/11/08 06:23:48 msaitoh Exp $");
 
 #include "opt_multiboot.h"
 
@@ -519,7 +519,7 @@ setup_bootpath(struct multiboot_info *mi
  * Sets up the console bootinfo structure if the user gave a 'console'
  * argument on the boot command line.  The Multiboot information
  * structure gives no hint about this, so the only way to know where the
- * console is is to let the user specify it.
+ * console is to let the user specify it.
  *
  * If there wasn't any 'console' argument, this does not generate any
  * bootinfo entry, falling back to the kernel's default console.



CVS commit: src/sys/arch/i386/i386

2018-11-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  8 06:23:48 UTC 2018

Modified Files:
src/sys/arch/i386/i386: multiboot.c

Log Message:
"s/ is is / is /" in comment. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/i386/i386/multiboot.c

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



CVS commit: src/sys/arch/i386/i386

2018-10-17 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Oct 18 04:22:22 UTC 2018

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Use memory allocated for the ldt, not the idt.

This must have been a typo that we got away with because we were not
using the idt[] so far.

This fix should now allow -current i386 XEN to boot, as before.


To generate a diff of this commit:
cvs rdiff -u -r1.811 -r1.812 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.811 src/sys/arch/i386/i386/machdep.c:1.812
--- src/sys/arch/i386/i386/machdep.c:1.811	Sat Sep 29 07:00:20 2018
+++ src/sys/arch/i386/i386/machdep.c	Thu Oct 18 04:22:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.811 2018/09/29 07:00:20 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.812 2018/10/18 04:22:22 cherry Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.811 2018/09/29 07:00:20 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.812 2018/10/18 04:22:22 cherry Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -1326,7 +1326,7 @@ init386(paddr_t first_avail)
 	GSEL(GCODE_SEL, SEL_KPL), (unsigned long)hypervisor_callback,
 	GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback);
 
-	ldtstore = (union descriptor *)idt_vaddr;
+	ldtstore = (union descriptor *)ldt_vaddr;
 #endif /* XEN */
 
 	/* make ldt gates and memory segments */



CVS commit: src/sys/arch/i386/i386

2018-10-17 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Oct 18 04:22:22 UTC 2018

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Use memory allocated for the ldt, not the idt.

This must have been a typo that we got away with because we were not
using the idt[] so far.

This fix should now allow -current i386 XEN to boot, as before.


To generate a diff of this commit:
cvs rdiff -u -r1.811 -r1.812 src/sys/arch/i386/i386/machdep.c

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



CVS commit: src/sys/arch/i386/i386

2018-10-17 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Oct 18 04:11:14 UTC 2018

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
Whitespace self-police.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/i386/i386/cpufunc.S

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



CVS commit: src/sys/arch/i386/i386

2018-10-17 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Oct 18 04:11:14 UTC 2018

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
Whitespace self-police.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/i386/i386/cpufunc.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/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.24 src/sys/arch/i386/i386/cpufunc.S:1.25
--- src/sys/arch/i386/i386/cpufunc.S:1.24	Sun Sep 23 15:28:48 2018
+++ src/sys/arch/i386/i386/cpufunc.S	Thu Oct 18 04:11:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.24 2018/09/23 15:28:48 cherry Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.25 2018/10/18 04:11:14 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.24 2018/09/23 15:28:48 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.25 2018/10/18 04:11:14 cherry Exp $");
 
 #include "opt_xen.h"
 
@@ -66,7 +66,7 @@ ENTRY(x86_mfence)
 END(x86_mfence)
 
 #ifndef XEN
-	ENTRY(lidt)
+ENTRY(lidt)
 	movl	4(%esp), %eax
 	lidt	(%eax)
 	ret



CVS commit: src/sys/arch/i386/i386

2018-09-29 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Sep 29 07:00:20 UTC 2018

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Fix "use before init" of *idt.
This should fix boot time pagefaulting and panic(9)
on XEN kernels due to the boottime idt API reorg.


To generate a diff of this commit:
cvs rdiff -u -r1.810 -r1.811 src/sys/arch/i386/i386/machdep.c

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



CVS commit: src/sys/arch/i386/i386

2018-09-29 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Sep 29 07:00:20 UTC 2018

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Fix "use before init" of *idt.
This should fix boot time pagefaulting and panic(9)
on XEN kernels due to the boottime idt API reorg.


To generate a diff of this commit:
cvs rdiff -u -r1.810 -r1.811 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.810 src/sys/arch/i386/i386/machdep.c:1.811
--- src/sys/arch/i386/i386/machdep.c:1.810	Sun Sep 23 15:28:48 2018
+++ src/sys/arch/i386/i386/machdep.c	Sat Sep 29 07:00:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.810 2018/09/23 15:28:48 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.811 2018/09/29 07:00:20 cherry Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.810 2018/09/23 15:28:48 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.811 2018/09/29 07:00:20 cherry Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -1307,13 +1307,13 @@ init386(paddr_t first_avail)
 	memset((void *)gdt_vaddr, 0, PAGE_SIZE);
 	memset((void *)ldt_vaddr, 0, PAGE_SIZE);
 
-#ifndef XEN
 	pmap_kenter_pa(pentium_idt_vaddr, idt_paddr, VM_PROT_READ, 0);
 	pmap_update(pmap_kernel());
 	pentium_idt = (union descriptor *)pentium_idt_vaddr;
+	idt = (idt_descriptor_t *)idt_vaddr;
 
+#ifndef XEN	
 	tgdt = gdtstore;
-	idt = (struct gate_descriptor *)idt_vaddr;
 	gdtstore = (union descriptor *)gdt_vaddr;
 	ldtstore = (union descriptor *)ldt_vaddr;
 



CVS commit: src/sys/arch/i386/i386

2018-08-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug  1 13:35:01 UTC 2018

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Xen is PAE, so remove ifdefs.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.160 src/sys/arch/i386/i386/locore.S:1.161
--- src/sys/arch/i386/i386/locore.S:1.160	Thu Jul 26 09:29:08 2018
+++ src/sys/arch/i386/i386/locore.S	Wed Aug  1 13:35:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.160 2018/07/26 09:29:08 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.161 2018/08/01 13:35:01 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.160 2018/07/26 09:29:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.161 2018/08/01 13:35:01 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -253,9 +253,7 @@ __KERNEL_RCSID(0, "$NetBSD: locore.S,v 1
 	.ascii	",VIRT_ENTRY=0xc010" /* KERNTEXTOFF */
 	.ascii	",HYPERCALL_PAGE=0x0101"
 		/* (???+HYPERCALL_PAGE_OFFSET)/PAGE_SIZE) */
-#ifdef PAE
 	.ascii	",PAE=yes[extended-cr3]"
-#endif
 	.ascii	",LOADER=generic"
 #if (NKSYMS || defined(DDB) || defined(MODULAR)) && !defined(makeoptions_COPY_SYMTAB)
 	.ascii	",BSD_SYMTAB=yes"
@@ -906,9 +904,7 @@ begin:
 	addl	$(USPACE+PAGE_SIZE),%esi
 	subl	$KERNBASE,%esi		/* init386 wants a physical address */
 
-#ifdef PAE
 	pushl	$0	/* init386() expects a 64 bits paddr_t with PAE */
-#endif
 	pushl	%esi
 	call	_C_LABEL(init_bootspace)
 	call	_C_LABEL(init386)



CVS commit: src/sys/arch/i386/i386

2018-08-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug  1 13:35:01 UTC 2018

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Xen is PAE, so remove ifdefs.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 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: src/sys/arch/i386/i386

2018-06-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jun 14 17:58:22 UTC 2018

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Eager FPU on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.156 src/sys/arch/i386/i386/locore.S:1.157
--- src/sys/arch/i386/i386/locore.S:1.156	Thu Jan  4 14:02:23 2018
+++ src/sys/arch/i386/i386/locore.S	Thu Jun 14 17:58:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.156 2018/01/04 14:02:23 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.157 2018/06/14 17:58:22 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.156 2018/01/04 14:02:23 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.157 2018/06/14 17:58:22 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1089,6 +1089,19 @@ ENTRY(cpu_switchto)
 	movl	%ebp,PCB_EBP(%eax)
 skip_save:
 
+#ifndef XEN
+	pushl	%edx
+	movb	_C_LABEL(x86_fpu_eager),%dl
+	testb	%dl,%dl
+	jz	.Lno_eagerfpu
+	pushl	%edi
+	pushl	%esi
+	call	_C_LABEL(fpu_eagerswitch)
+	addl	$8,%esp
+.Lno_eagerfpu:
+	popl	%edx
+#endif
+
 	/* Switch to newlwp's stack. */
 	movl	L_PCB(%edi),%ebx
 	movl	PCB_EBP(%ebx),%ebp



CVS commit: src/sys/arch/i386/i386

2018-06-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jun 14 17:58:22 UTC 2018

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Eager FPU on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 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: src/sys/arch/i386/i386

2018-05-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 16 16:33:23 UTC 2018

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
Fix compilation on Xen.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/arch/i386/i386/trap.c

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



CVS commit: src/sys/arch/i386/i386

2018-05-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 16 16:33:23 UTC 2018

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
Fix compilation on Xen.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/arch/i386/i386/trap.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/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.294 src/sys/arch/i386/i386/trap.c:1.295
--- src/sys/arch/i386/i386/trap.c:1.294	Wed May 16 08:16:36 2018
+++ src/sys/arch/i386/i386/trap.c	Wed May 16 16:33:23 2018
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.294 2018/05/16 08:16:36 maxv Exp $	*/
+/*	$NetBSD: trap.c,v 1.295 2018/05/16 16:33:23 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.294 2018/05/16 08:16:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.295 2018/05/16 16:33:23 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -128,7 +128,9 @@ dtrace_doubletrap_func_t	dtrace_doubletr
 void trap(struct trapframe *);
 void trap_tss(struct i386tss *, int, int);
 void trap_return_fault_return(struct trapframe *) __dead;
+#ifndef XEN
 int ss_shadow(struct trapframe *tf);
+#endif
 
 const char * const trap_type[] = {
 	"privileged instruction fault",		/*  0 T_PRIVINFLT */
@@ -237,6 +239,7 @@ trap_print(const struct trapframe *frame
 	l, l->l_proc->p_pid, l->l_lid, KSTACK_LOWEST_ADDR(l));
 }
 
+#ifndef XEN
 int
 ss_shadow(struct trapframe *tf)
 {
@@ -255,6 +258,7 @@ ss_shadow(struct trapframe *tf)
 
 	return 0;
 }
+#endif
 
 /*
  * trap(frame): exception, fault, and trap interface to BSD kernel.



CVS commit: src/sys/arch/i386/i386

2018-05-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 16 08:16:36 UTC 2018

Modified Files:
src/sys/arch/i386/i386: i386_trap.S trap.c

Log Message:
Mitigation for CVE-2018-8897 on i386. Contrary to amd64 there is no clear
way to determine if we are in kernel mode but with the user context; so we
go the hard way, and scan the IDT.

On i386 the bug is less of a problem, since we don't have GSBASE. All an
attacker can do is panicking the system.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.293 -r1.294 src/sys/arch/i386/i386/trap.c

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



CVS commit: src/sys/arch/i386/i386

2018-05-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 16 08:16:36 UTC 2018

Modified Files:
src/sys/arch/i386/i386: i386_trap.S trap.c

Log Message:
Mitigation for CVE-2018-8897 on i386. Contrary to amd64 there is no clear
way to determine if we are in kernel mode but with the user context; so we
go the hard way, and scan the IDT.

On i386 the bug is less of a problem, since we don't have GSBASE. All an
attacker can do is panicking the system.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.293 -r1.294 src/sys/arch/i386/i386/trap.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/i386/i386/i386_trap.S
diff -u src/sys/arch/i386/i386/i386_trap.S:1.13 src/sys/arch/i386/i386/i386_trap.S:1.14
--- src/sys/arch/i386/i386/i386_trap.S:1.13	Fri Mar 16 12:48:54 2018
+++ src/sys/arch/i386/i386/i386_trap.S	Wed May 16 08:16:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386_trap.S,v 1.13 2018/03/16 12:48:54 maxv Exp $	*/
+/*	$NetBSD: i386_trap.S,v 1.14 2018/05/16 08:16:36 maxv Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
 
 #if 0
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.13 2018/03/16 12:48:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.14 2018/05/16 08:16:36 maxv Exp $");
 #endif
 
 /*
@@ -88,8 +88,49 @@ IDTVEC(trap00)
 	ZTRAP(T_DIVIDE)
 IDTVEC_END(trap00)
 
+/*
+ * Handle the SS shadow, CVE-2018-8897.
+ *
+ * We scan the IDT to determine if we hit an entry point. If so, we leave
+ * without restoring the segregs, because we could fault while doing that.
+ */
 IDTVEC(trap01)
+#ifndef XEN
+	pushl	$0
+	pushl	$T_TRCTRAP
+	INTRENTRY
+
+	testb	$SEL_UPL,TF_CS(%esp)
+	jnz	.Lnormal_dbentry
+
+	pushl	%esp
+	call	ss_shadow
+	addl	$4,%esp
+
+	cmpl	$1,%eax
+	jne	.Lnormal_dbentry
+
+	/* SS shadow, ignore the exception. */
+	xorl	%eax,%eax
+	movl	%eax,%dr6
+
+	/* INTRFASTEXIT, but without segregs. */
+	movl	TF_EDI(%esp),%edi
+	movl	TF_ESI(%esp),%esi
+	movl	TF_EBP(%esp),%ebp
+	movl	TF_EBX(%esp),%ebx
+	movl	TF_EDX(%esp),%edx
+	movl	TF_ECX(%esp),%ecx
+	movl	TF_EAX(%esp),%eax
+	addl	$(TF_PUSHSIZE+8),%esp
+	iret
+
+.Lnormal_dbentry:
+	STI(%eax)
+	jmp _C_LABEL(calltrap)
+#else
 	ZTRAP(T_TRCTRAP)
+#endif
 IDTVEC_END(trap01)
 
 /*

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.293 src/sys/arch/i386/i386/trap.c:1.294
--- src/sys/arch/i386/i386/trap.c:1.293	Tue Feb 13 01:05:18 2018
+++ src/sys/arch/i386/i386/trap.c	Wed May 16 08:16:36 2018
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.293 2018/02/13 01:05:18 christos Exp $	*/
+/*	$NetBSD: trap.c,v 1.294 2018/05/16 08:16:36 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.293 2018/02/13 01:05:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.294 2018/05/16 08:16:36 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -128,6 +128,7 @@ dtrace_doubletrap_func_t	dtrace_doubletr
 void trap(struct trapframe *);
 void trap_tss(struct i386tss *, int, int);
 void trap_return_fault_return(struct trapframe *) __dead;
+int ss_shadow(struct trapframe *tf);
 
 const char * const trap_type[] = {
 	"privileged instruction fault",		/*  0 T_PRIVINFLT */
@@ -236,6 +237,25 @@ trap_print(const struct trapframe *frame
 	l, l->l_proc->p_pid, l->l_lid, KSTACK_LOWEST_ADDR(l));
 }
 
+int
+ss_shadow(struct trapframe *tf)
+{
+	struct gate_descriptor *gd;
+	uintptr_t eip, func;
+	size_t i;
+
+	eip = tf->tf_eip;
+
+	for (i = 0; i < 256; i++) {
+		gd = [i];
+		func = (gd->gd_hioffset << 16) | gd->gd_looffset;
+		if (eip == func)
+			return 1;
+	}
+
+	return 0;
+}
+
 /*
  * trap(frame): exception, fault, and trap interface to BSD kernel.
  *



CVS commit: src/sys/arch/i386/i386

2018-02-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 13 01:05:18 UTC 2018

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
Unconditionally print the trap like we do for amdt64 (Dimitris Karagkasidis)


To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 src/sys/arch/i386/i386/trap.c

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



CVS commit: src/sys/arch/i386/i386

2018-02-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 13 01:05:18 UTC 2018

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
Unconditionally print the trap like we do for amdt64 (Dimitris Karagkasidis)


To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 src/sys/arch/i386/i386/trap.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/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.292 src/sys/arch/i386/i386/trap.c:1.293
--- src/sys/arch/i386/i386/trap.c:1.292	Sat Jan 27 04:33:25 2018
+++ src/sys/arch/i386/i386/trap.c	Mon Feb 12 20:05:18 2018
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.292 2018/01/27 09:33:25 maxv Exp $	*/
+/*	$NetBSD: trap.c,v 1.293 2018/02/13 01:05:18 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.292 2018/01/27 09:33:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.293 2018/02/13 01:05:18 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -307,8 +307,7 @@ trap(struct trapframe *frame)
 
 	default:
 	we_re_toast:
-		if (type != T_TRCTRAP)
-			trap_print(frame, l);
+		trap_print(frame, l);
 
 		if (kdb_trap(type, 0, frame))
 			return;



CVS commit: src/sys/arch/i386/i386

2018-02-10 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Feb 10 11:50:39 UTC 2018

Modified Files:
src/sys/arch/i386/i386: db_interface.c

Log Message:
Do for i386 what was done for amd64 (but in a more KNF conformant way...)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/i386/i386/db_interface.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/i386/i386/db_interface.c
diff -u src/sys/arch/i386/i386/db_interface.c:1.77 src/sys/arch/i386/i386/db_interface.c:1.78
--- src/sys/arch/i386/i386/db_interface.c:1.77	Fri Feb  9 09:36:42 2018
+++ src/sys/arch/i386/i386/db_interface.c	Sat Feb 10 11:50:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.77 2018/02/09 09:36:42 maxv Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.78 2018/02/10 11:50:39 kre Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.77 2018/02/09 09:36:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.78 2018/02/10 11:50:39 kre Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -195,7 +195,9 @@ int
 kdb_trap(int type, int code, db_regs_t *regs)
 {
 	int s, flags;
+#ifdef MULTIPROCESSOR
 	db_regs_t dbreg;
+#endif
 
 	flags = regs->tf_err & TC_FLAGMASK;
 	regs->tf_err &= ~TC_FLAGMASK;



CVS commit: src/sys/arch/i386/i386

2018-02-10 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Feb 10 11:50:39 UTC 2018

Modified Files:
src/sys/arch/i386/i386: db_interface.c

Log Message:
Do for i386 what was done for amd64 (but in a more KNF conformant way...)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/i386/i386/db_interface.c

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



CVS commit: src/sys/arch/i386/i386

2018-01-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jan 27 18:44:19 UTC 2018

Modified Files:
src/sys/arch/i386/i386: spl.S

Log Message:
style


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/i386/i386/spl.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.41 src/sys/arch/i386/i386/spl.S:1.42
--- src/sys/arch/i386/i386/spl.S:1.41	Sat Aug 12 07:07:53 2017
+++ src/sys/arch/i386/i386/spl.S	Sat Jan 27 18:44:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.41 2017/08/12 07:07:53 maxv Exp $	*/
+/*	$NetBSD: spl.S,v 1.42 2018/01/27 18:44:19 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.41 2017/08/12 07:07:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.42 2018/01/27 18:44:19 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_spldebug.h"
@@ -61,7 +61,7 @@ ENTRY(splraise)
 	pushl	%eax
 	pushl	%edx
 	call	_C_LABEL(spldebug_raise)
-	addl	$4, %esp
+	addl	$4,%esp
 	popl	%eax
 	popl	%ebp
 #endif /* SPLDEBUG */
@@ -77,23 +77,23 @@ END(splraise)
  */
 ENTRY(spllower)
 #ifdef SPLDEBUG
-	movl	4(%esp), %ecx
+	movl	4(%esp),%ecx
 	pushl	%ebp
 	movl	%esp,%ebp
 	pushl	%ecx
 	call	_C_LABEL(spldebug_lower)
-	addl	$4, %esp
+	addl	$4,%esp
 	popl	%ebp
 #endif /* SPLDEBUG */
-	movl	4(%esp), %ecx
-	cmpl	CPUVAR(ILEVEL), %ecx
+	movl	4(%esp),%ecx
+	cmpl	CPUVAR(ILEVEL),%ecx
 	jae	1f
-	movl	CPUVAR(IUNMASK)(,%ecx,4), %edx
+	movl	CPUVAR(IUNMASK)(,%ecx,4),%edx
 	pushf
 	cli
-	testl	CPUVAR(IPENDING), %edx
+	testl	CPUVAR(IPENDING),%edx
 	jnz	2f
-	movl	%ecx, CPUVAR(ILEVEL)
+	movl	%ecx,CPUVAR(ILEVEL)
 	popf
 1:
 	ret
@@ -114,7 +114,7 @@ END(spllower)
  *
  * For cmpxchg8b, edx/ecx are the high words and eax/ebx the low.
  *
- * edx : eax = old level / old ipending 
+ * edx : eax = old level / old ipending
  * ecx : ebx = new level / old ipending
  */
 ENTRY(cx8_spllower)
@@ -147,7 +147,7 @@ END(cx8_spllower)
 
 /*
  * void Xspllower(int s);
- * 
+ *
  * Process pending interrupts.
  *
  * Important registers:
@@ -173,11 +173,13 @@ IDTVEC(spllower)
 	pushl	%esi
 	pushl	%edi
 	movl	8(%ebp),%ebx
-	movl	$.Lspllower_resume,%esi		# address to resume loop at
+	movl	$.Lspllower_resume,%esi		/* address to resume loop at */
 1:
-# because of the way Xen interrupts works *%esi will in fact be called
-# from Xdoreti via iret. So we have to always disable interrupts here
-# for Xen
+	/*
+	 * Because of the way Xen interrupts work *%esi will in fact be called
+	 * from Xdoreti via iret. So we have to always disable interrupts here
+	 * for Xen.
+	 */
 #ifndef XEN
 	CLI(%eax)
 #endif
@@ -193,14 +195,14 @@ IDTVEC(spllower)
 	jnz	.Lspllower_panic
 #else
 	movlCPUVAR(VCPU),%eax
-	movb	EVTCHN_UPCALL_MASK(%eax), %al
-	andb	%al, %al
+	movb	EVTCHN_UPCALL_MASK(%eax),%al
+	andb	%al,%al
 	jz	.Lspllower_panic
 #endif /* XEN */
 #endif /* defined(DEBUG) */
-	movl	%ebx,%eax		# get cpl
+	movl	%ebx,%eax			/* get cpl */
 	movl	CPUVAR(IUNMASK)(,%eax,4),%eax
-	andl	CPUVAR(IPENDING),%eax		# any non-masked bits left?
+	andl	CPUVAR(IPENDING),%eax		/* any non-masked bits left? */
 	jz	2f
 	bsrl	%eax,%eax
 	btrl	%eax,CPUVAR(IPENDING)
@@ -217,7 +219,7 @@ IDTVEC(spllower)
 4:
 #else
 	STI(%eax)
-#endif /* XEN */
+#endif
 	popl	%edi
 	popl	%esi
 	popl	%ebx
@@ -228,7 +230,7 @@ IDTVEC(spllower)
 	pushl	$1f
 	call	_C_LABEL(panic)
 1:	.asciz	"SPLLOWER: INTERRUPT ENABLED"
-#endif /* defined(DEBUG) */
+#endif
 IDTVEC_END(spllower)
 
 /*
@@ -244,10 +246,10 @@ IDTVEC_END(spllower)
 IDTVEC(doreti)
 #ifndef XEN
 	IDEPTH_DECR
-	popl	%ebx			# get previous priority
+	popl	%ebx			/* get previous priority */
 #endif
 .Ldoreti_resume_stic:
-	movl	$.Ldoreti_resume,%esi	# address to resume loop at
+	movl	$.Ldoreti_resume,%esi	/* address to resume loop at */
 .Ldoreti_resume:
 #if defined(DEBUG)
 #ifndef XEN
@@ -256,9 +258,9 @@ IDTVEC(doreti)
 	testl	$PSL_I,%eax
 	jnz	.Ldoreti_panic
 #else
-	movlCPUVAR(VCPU),%eax
-	movb	EVTCHN_UPCALL_MASK(%eax), %al
-	andb	%al, %al
+	movl	CPUVAR(VCPU),%eax
+	movb	EVTCHN_UPCALL_MASK(%eax),%al
+	andb	%al,%al
 	jz	.Ldoreti_panic
 #endif /* XEN */
 #endif /* defined(DEBUG) */
@@ -266,14 +268,14 @@ IDTVEC(doreti)
 	movl	CPUVAR(IUNMASK)(,%eax,4),%eax
 	andl	CPUVAR(IPENDING),%eax
 	jz	2f
-	bsrl%eax,%eax   # slow, but not worth optimizing
-	btrl%eax,CPUVAR(IPENDING)
+	bsrl	%eax,%eax		/* slow, but not worth optimizing */
+	btrl	%eax,CPUVAR(IPENDING)
 	movl	CPUVAR(ISOURCES)(,%eax, 4),%eax
 	jmp	*IS_RESUME(%eax)
 2:	/* Check for ASTs on exit to user mode. */
 	movl	%ebx,CPUVAR(ILEVEL)
 5:
-	testb   $CHK_UPL,TF_CS(%esp)
+	testb	$CHK_UPL,TF_CS(%esp)
 	jnz	doreti_checkast
 	jmp	6f
 	.type	_C_LABEL(doreti_checkast), @function
@@ -299,12 +301,12 @@ END(doreti_checkast)
 	STIC(%eax)
 	jz	4f
 	call	_C_LABEL(stipending)
-	testl   %eax,%eax
-	jz 4f

CVS commit: src/sys/arch/i386/i386

2018-01-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jan 27 18:44:19 UTC 2018

Modified Files:
src/sys/arch/i386/i386: spl.S

Log Message:
style


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/i386/i386/spl.S

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



CVS commit: src/sys/arch/i386/i386

2018-01-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jan 27 07:45:58 UTC 2018

Modified Files:
src/sys/arch/i386/i386: copy.S

Log Message:
Sync with amd64, in particular, add END() markers, don't fall through
functions, narrow the copy windows, and remove suword.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/i386/copy.S

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



CVS commit: src/sys/arch/i386/i386

2018-01-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jan 27 07:45:58 UTC 2018

Modified Files:
src/sys/arch/i386/i386: copy.S

Log Message:
Sync with amd64, in particular, add END() markers, don't fall through
functions, narrow the copy windows, and remove suword.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/i386/copy.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/copy.S
diff -u src/sys/arch/i386/i386/copy.S:1.25 src/sys/arch/i386/i386/copy.S:1.26
--- src/sys/arch/i386/i386/copy.S:1.25	Fri Sep 16 12:28:41 2016
+++ src/sys/arch/i386/i386/copy.S	Sat Jan 27 07:45:57 2018
@@ -1,7 +1,6 @@
-/*	$NetBSD: copy.S,v 1.25 2016/09/16 12:28:41 maxv Exp $	*/
-/*	NetBSD: locore.S,v 1.34 2005/04/01 11:59:31 yamt Exp $	*/
+/*	$NetBSD: copy.S,v 1.26 2018/01/27 07:45:57 maxv Exp $	*/
 
-/*-
+/*
  * Copyright (c) 1998, 2000, 2004, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -30,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*-
+/*
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
  *
@@ -65,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copy.S,v 1.25 2016/09/16 12:28:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copy.S,v 1.26 2018/01/27 07:45:57 maxv Exp $");
 
 #include "assym.h"
 
@@ -75,8 +74,8 @@ __KERNEL_RCSID(0, "$NetBSD: copy.S,v 1.2
 #include 
 
 #define GET_CURPCB(reg)	\
-	movl	CPUVAR(CURLWP), reg; \
-	movl	L_PCB(reg), reg
+	movl	CPUVAR(CURLWP),reg; \
+	movl	L_PCB(reg),reg
 
 /*
  * These are arranged so that the abnormal case is a forwards
@@ -86,10 +85,10 @@ __KERNEL_RCSID(0, "$NetBSD: copy.S,v 1.2
 #define DEFERRED_SWITCH_CHECK \
 	CHECK_DEFERRED_SWITCH			; \
 	jnz	99f; \
-	98:
+98:
 
 #define DEFERRED_SWITCH_CALL \
-	99:		; \
+99:		; \
 	call	_C_LABEL(do_pmap_load)		; \
 	jmp	98b
 
@@ -109,25 +108,26 @@ LABEL(x86_copyfunc_start)
  */
 NENTRY(do_pmap_load)
 	pushl	%ebp
-	movl	%esp, %ebp
+	movl	%esp,%ebp
 	pushl	%ebx
-	movl	CPUVAR(CURLWP), %ebx
+	movl	CPUVAR(CURLWP),%ebx
 1:
 	incl	L_NOPREEMPT(%ebx)
 	call	_C_LABEL(pmap_load)
 	decl	L_NOPREEMPT(%ebx)
 	jnz	2f
-	cmpl	$0, L_DOPREEMPT(%ebx)
+	cmpl	$0,L_DOPREEMPT(%ebx)
 	jz	2f
 	pushl	$0
 	call	_C_LABEL(kpreempt)
-	addl	$4, %esp
+	addl	$4,%esp
 2:
-	cmpl	$0, CPUVAR(WANT_PMAPLOAD)
+	cmpl	$0,CPUVAR(WANT_PMAPLOAD)
 	jnz	1b
 	popl	%ebx
 	leave
 	ret
+END(do_pmap_load)
 
 /*
  * void *return_address(unsigned int level);
@@ -151,12 +151,12 @@ ENTRY(return_address)
 	movl	0x4(%eax),%eax
 	movl	$0,PCB_ONFAULT(%edx)
 	ret
+END(return_address)
 
 /*
  * int kcopy(const void *from, void *to, size_t len);
- * Copy len bytes, abort on fault.
+ * Copy len bytes from and to kernel memory, and abort on fault.
  */
-/* LINTSTUB: Func: int kcopy(const void *from, void *to, size_t len) */
 ENTRY(kcopy)
 	pushl	%esi
 	pushl	%edi
@@ -206,6 +206,7 @@ ENTRY(kcopy)
 	popl	%esi
 	xorl	%eax,%eax
 	ret
+END(kcopy)
 
 /*/
 
@@ -219,110 +220,107 @@ ENTRY(kcopy)
  * Copy len bytes into the user's address space.
  * see copyout(9)
  */
-
-/* LINTSTUB: Func: int copyout(const void *kaddr, void *uaddr, size_t len) */
 ENTRY(copyout)
 	DEFERRED_SWITCH_CHECK
 	pushl	%esi
 	pushl	%edi
-	movl	12(%esp),%esi
-	movl	16(%esp),%edi
-	movl	20(%esp),%eax
-.Lcopyout_start:
-	/*
-	 * We check that the end of the destination buffer is not past the end
-	 * of the user's address space.
-	 */
+	movl	12(%esp),%esi	/* from */
+	movl	16(%esp),%edi	/* to */
+	movl	20(%esp),%eax	/* len */
+
 	movl	%edi,%edx
 	addl	%eax,%edx
 	jc	_C_LABEL(copy_efault)
 	cmpl	$VM_MAXUSER_ADDRESS,%edx
 	ja	_C_LABEL(copy_efault)
+
+.Lcopyout_start:
 	movl	%eax,%ecx
 	shrl	$2,%ecx
 	rep
 	movsl
 	andl	$3,%eax
-	jz	1f
+	jz	.Lcopyout_end
 	movl	%eax,%ecx
 	rep
 	movsb
-1:
 .Lcopyout_end:
+
 	popl	%edi
 	popl	%esi
 	xorl	%eax,%eax
 	ret
 	DEFERRED_SWITCH_CALL
+END(copyout)
 
 /*
  * int copyin(const void *from, void *to, size_t len);
  * Copy len bytes from the user's address space.
  * see copyin(9)
  */
-
-/* LINTSTUB: Func: int copyin(const void *uaddr, void *kaddr, size_t len) */
 ENTRY(copyin)
 	DEFERRED_SWITCH_CHECK
 	pushl	%esi
 	pushl	%edi
-	movl	12(%esp),%esi
-	movl	16(%esp),%edi
-	movl	20(%esp),%eax
-	/*
-	 * We check that the end of the source buffer is not past the end of
-	 * the user's address space.  If it's not, then we only need to check
-	 * that each page is readable, and the CPU will do that for us.
-	 */
-.Lcopyin_start:
+	movl	12(%esp),%esi	/* from */
+	movl	16(%esp),%edi	/* to */
+	movl	20(%esp),%eax	/* len */
+
 	movl	%esi,%edx
 	addl	%eax,%edx
 	jc	_C_LABEL(copy_efault)
 	cmpl	$VM_MAXUSER_ADDRESS,%edx
 	ja	_C_LABEL(copy_efault)
+
+.Lcopyin_start:
 	movl	%eax,%ecx
 	shrl	$2,%ecx
 	rep
 	movsl
 	andl	$3,%eax
-	jz	1f
+	jz	.Lcopyin_end
 	movl	%eax,%ecx
 	rep
 	movsb
-1:
 .Lcopyin_end:
+
 	popl	

CVS commit: src/sys/arch/i386/i386

2018-01-13 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jan 13 14:12:57 UTC 2018

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Xen now needs cpu_init_tss() too. Makes XEN3PAE_DOMU boot again.


To generate a diff of this commit:
cvs rdiff -u -r1.802 -r1.803 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.802 src/sys/arch/i386/i386/machdep.c:1.803
--- src/sys/arch/i386/i386/machdep.c:1.802	Thu Jan  4 13:36:30 2018
+++ src/sys/arch/i386/i386/machdep.c	Sat Jan 13 14:12:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.802 2018/01/04 13:36:30 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.803 2018/01/13 14:12:57 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.802 2018/01/04 13:36:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.803 2018/01/13 14:12:57 bouyer Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -453,8 +453,8 @@ cpu_startup(void)
 	gdt_init();
 	i386_proc0_pcb_ldt_init();
 
-#ifndef XEN
 	cpu_init_tss(_info_primary);
+#ifndef XEN
 	ltr(cpu_info_primary.ci_tss_sel);
 #endif
 
@@ -613,6 +613,7 @@ cpu_set_tss_gates(struct cpu_info *ci)
 	GSEL(GIPITSS_SEL, SEL_KPL));
 #endif
 }
+#endif /* XEN */
 
 /*
  * Set up TSS and I/O bitmap.
@@ -626,14 +627,17 @@ cpu_init_tss(struct cpu_info *ci)
 	sizeof(struct cpu_tss), 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
 
 	cputss->tss.tss_iobase = IOMAP_INVALOFF << 16;
+#ifndef XEN
 	cputss->tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
 	cputss->tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL);
 	cputss->tss.tss_cr3 = rcr3();
+#endif
 
 	ci->ci_tss = cputss;
+#ifndef XEN
 	ci->ci_tss_sel = tss_alloc(>tss);
+#endif
 }
-#endif /* XEN */
 
 void *
 getframe(struct lwp *l, int sig, int *onstack)



CVS commit: src/sys/arch/i386/i386

2018-01-13 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jan 13 14:12:57 UTC 2018

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Xen now needs cpu_init_tss() too. Makes XEN3PAE_DOMU boot again.


To generate a diff of this commit:
cvs rdiff -u -r1.802 -r1.803 src/sys/arch/i386/i386/machdep.c

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



CVS commit: src/sys/arch/i386/i386

2017-10-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Oct  2 17:48:01 UTC 2017

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Fix (once again) Xen boot


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 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: src/sys/arch/i386/i386

2017-10-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Oct  2 17:48:01 UTC 2017

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Fix (once again) Xen boot


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.153 src/sys/arch/i386/i386/locore.S:1.154
--- src/sys/arch/i386/i386/locore.S:1.153	Sat Sep 30 11:43:57 2017
+++ src/sys/arch/i386/i386/locore.S	Mon Oct  2 17:48:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.153 2017/09/30 11:43:57 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.154 2017/10/02 17:48:01 bouyer Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.153 2017/09/30 11:43:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.154 2017/10/02 17:48:01 bouyer Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -910,6 +910,7 @@ begin:
 	pushl	$0	/* init386() expects a 64 bits paddr_t with PAE */
 #endif
 	pushl	%esi
+	call	_C_LABEL(init_bootspace)
 	call	_C_LABEL(init386)
 	addl	$PDE_SIZE,%esp		/* pop paddr_t */
 	call 	_C_LABEL(main)



CVS commit: src/sys/arch/i386/i386

2017-09-12 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Tue Sep 12 14:10:49 UTC 2017

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
Don't use a const variable as an array size, because it is not a
constant expression and will cause the array to needlessly become a
variable-size one.  Fixes "error: stack protector not protecting local
variables: variable length buffer [-Werror=stack-protector]" when
building i386 with MKDEBUG=YES -V COPTS="-g".


To generate a diff of this commit:
cvs rdiff -u -r1.289 -r1.290 src/sys/arch/i386/i386/trap.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/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.289 src/sys/arch/i386/i386/trap.c:1.290
--- src/sys/arch/i386/i386/trap.c:1.289	Sat Aug 12 07:07:53 2017
+++ src/sys/arch/i386/i386/trap.c	Tue Sep 12 14:10:49 2017
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.289 2017/08/12 07:07:53 maxv Exp $	*/
+/*	$NetBSD: trap.c,v 1.290 2017/09/12 14:10:49 gson Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.289 2017/08/12 07:07:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.290 2017/09/12 14:10:49 gson Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -421,7 +421,7 @@ kernelfault:
 	{
 		static const char lcall[7] = { 0x9a, 0, 0, 0, 0, 7, 0 };
 		const size_t sz = sizeof(lcall);
-		char tmp[sz];
+		char tmp[sizeof(lcall)];
 
 		/* Check for the osyscall lcall instruction. */
 		if (frame->tf_eip < VM_MAXUSER_ADDRESS - sz &&



CVS commit: src/sys/arch/i386/i386

2017-09-12 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Tue Sep 12 14:10:49 UTC 2017

Modified Files:
src/sys/arch/i386/i386: trap.c

Log Message:
Don't use a const variable as an array size, because it is not a
constant expression and will cause the array to needlessly become a
variable-size one.  Fixes "error: stack protector not protecting local
variables: variable length buffer [-Werror=stack-protector]" when
building i386 with MKDEBUG=YES -V COPTS="-g".


To generate a diff of this commit:
cvs rdiff -u -r1.289 -r1.290 src/sys/arch/i386/i386/trap.c

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



CVS commit: src/sys/arch/i386/i386

2017-08-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 30 15:34:57 UTC 2017

Modified Files:
src/sys/arch/i386/i386: i386_trap.S

Log Message:
Pfff, use %ss and not %ds. The latter is controlled by userland, the former
contains the kernel value (flat); FreeBSD fixed this too a few weeks ago.

As I said earlier, this dtrace code is complete bullshit.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/i386/i386_trap.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.11 src/sys/arch/i386/i386/i386_trap.S:1.12
--- src/sys/arch/i386/i386/i386_trap.S:1.11	Fri Aug 18 14:52:19 2017
+++ src/sys/arch/i386/i386/i386_trap.S	Wed Aug 30 15:34:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386_trap.S,v 1.11 2017/08/18 14:52:19 maxv Exp $	*/
+/*	$NetBSD: i386_trap.S,v 1.12 2017/08/30 15:34:57 maxv Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
 
 #if 0
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.11 2017/08/18 14:52:19 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.12 2017/08/30 15:34:57 maxv Exp $");
 #endif
 
 /*
@@ -139,7 +139,7 @@ IDTVEC_END(trap05)
 	SUPERALIGN_TEXT
 IDTVEC(trap06)
 	/* Check if there is no DTrace hook registered. */
-	cmpl	$0,dtrace_invop_jump_addr
+	cmpl	$0,%ss:dtrace_invop_jump_addr
 	je	norm_ill
 
 	/* Check if this is a user fault. */



CVS commit: src/sys/arch/i386/i386

2017-08-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 30 15:34:57 UTC 2017

Modified Files:
src/sys/arch/i386/i386: i386_trap.S

Log Message:
Pfff, use %ss and not %ds. The latter is controlled by userland, the former
contains the kernel value (flat); FreeBSD fixed this too a few weeks ago.

As I said earlier, this dtrace code is complete bullshit.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/i386/i386_trap.S

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



CVS commit: src/sys/arch/i386/i386

2017-08-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Aug 15 06:39:37 UTC 2017

Modified Files:
src/sys/arch/i386/i386: db_machdep.c

Log Message:
Remove __ELF__ vestige.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/i386/db_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/i386/i386/db_machdep.c
diff -u src/sys/arch/i386/i386/db_machdep.c:1.5 src/sys/arch/i386/i386/db_machdep.c:1.6
--- src/sys/arch/i386/i386/db_machdep.c:1.5	Sat Jan 11 17:11:50 2014
+++ src/sys/arch/i386/i386/db_machdep.c	Tue Aug 15 06:39:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.5 2014/01/11 17:11:50 christos Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.6 2017/08/15 06:39:37 maxv Exp $	*/
 
 /* 
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.5 2014/01/11 17:11:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.6 2017/08/15 06:39:37 maxv Exp $");
 
 #include 
 #include 
@@ -131,7 +131,6 @@ db_frame_info(long *frame, db_addr_t cal
 		 * locations rather than on trap, since some traps
 		 * (e.g., npxdna) don't go through trap()
 		 */
-#ifdef __ELF__
 		if (!strcmp(name, "trap_tss")) {
 			*is_trap = TRAP_TSS;
 			narg = 0;
@@ -158,34 +157,6 @@ db_frame_info(long *frame, db_addr_t cal
 narg = 0;
 			}
 		}
-#else
-		if (!strcmp(name, "_trap_tss")) {
-			*is_trap = TRAP_TSS;
-			narg = 0;
-		} else if (!strcmp(name, "_trap")) {
-			*is_trap = TRAP;
-			narg = 0;
-		} else if (!strcmp(name, "_syscall")) {
-			*is_trap = SYSCALL;
-			narg = 0;
-		} else if (name[0] == '_' && name[1] == 'X') {
-			if (!strncmp(name, "_Xintr", 6) ||
-			!strncmp(name, "_Xresume", 8) ||
-			!strncmp(name, "_Xstray", 7) ||
-			!strncmp(name, "_Xhold", 6) ||
-			!strncmp(name, "_Xrecurse", 9) ||
-			!strcmp(name, "_Xdoreti")) {
-*is_trap = INTERRUPT;
-narg = 0;
-			} else if (!strcmp(name, "_Xsoftintr")) {
-*is_trap = SOFTINTR;
-narg = 0;
-			} else if (!strncmp(name, "_Xtss_", 6)) {
-*is_trap = INTERRUPT_TSS;
-narg = 0;
-			}
-		}
-#endif /* __ELF__ */
 	}
 
 	if (offp != NULL)



CVS commit: src/sys/arch/i386/i386

2017-08-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Aug 15 06:39:37 UTC 2017

Modified Files:
src/sys/arch/i386/i386: db_machdep.c

Log Message:
Remove __ELF__ vestige.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/i386/db_machdep.c

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



CVS commit: src/sys/arch/i386/i386

2017-08-12 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Aug 12 19:06:23 UTC 2017

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Remove what is now an unused variable.   One less build issue...


To generate a diff of this commit:
cvs rdiff -u -r1.790 -r1.791 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.790 src/sys/arch/i386/i386/machdep.c:1.791
--- src/sys/arch/i386/i386/machdep.c:1.790	Sat Aug 12 13:16:14 2017
+++ src/sys/arch/i386/i386/machdep.c	Sat Aug 12 19:06:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.790 2017/08/12 13:16:14 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.791 2017/08/12 19:06:23 kre Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.790 2017/08/12 13:16:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.791 2017/08/12 19:06:23 kre Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -629,7 +629,6 @@ sendsig_siginfo(const ksiginfo_t *ksi, c
 	int sig = ksi->ksi_signo;
 	struct sigframe_siginfo *fp = getframe(l, sig, ), frame;
 	sig_t catcher = SIGACTION(p, sig).sa_handler;
-	struct trapframe *tf = l->l_md.md_regs;
 
 	KASSERT(mutex_owned(p->p_lock));
 



CVS commit: src/sys/arch/i386/i386

2017-08-12 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Aug 12 19:06:23 UTC 2017

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Remove what is now an unused variable.   One less build issue...


To generate a diff of this commit:
cvs rdiff -u -r1.790 -r1.791 src/sys/arch/i386/i386/machdep.c

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



CVS commit: src/sys/arch/i386/i386

2017-08-12 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 12 13:16:14 UTC 2017

Modified Files:
src/sys/arch/i386/i386: genassym.cf machdep.c

Log Message:
Remove references to PSL_VM (implicitly vm86).


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.789 -r1.790 src/sys/arch/i386/i386/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/i386/i386/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.102 src/sys/arch/i386/i386/genassym.cf:1.103
--- src/sys/arch/i386/i386/genassym.cf:1.102	Tue Aug  8 08:04:05 2017
+++ src/sys/arch/i386/i386/genassym.cf	Sat Aug 12 13:16:14 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.102 2017/08/08 08:04:05 maxv Exp $
+#	$NetBSD: genassym.cf,v 1.103 2017/08/12 13:16:14 maxv Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -355,7 +355,6 @@ define	IREENT_MAGIC		IREENT_MAGIC
 define	PSL_AC			PSL_AC
 define	PSL_MBO			PSL_MBO
 define	PSL_ID			PSL_ID
-define	PSL_VM			PSL_VM
 define	PSL_I			PSL_I
 
 define	MTX_IPL			offsetof(struct kmutex, u.s.mtxs_ipl)

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.789 src/sys/arch/i386/i386/machdep.c:1.790
--- src/sys/arch/i386/i386/machdep.c:1.789	Sat Aug 12 07:07:53 2017
+++ src/sys/arch/i386/i386/machdep.c	Sat Aug 12 13:16:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.789 2017/08/12 07:07:53 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.790 2017/08/12 13:16:14 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.789 2017/08/12 07:07:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.790 2017/08/12 13:16:14 maxv Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -647,8 +647,6 @@ sendsig_siginfo(const ksiginfo_t *ksi, c
 	? _UC_SETSTACK : _UC_CLRSTACK;
 	memset(_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack));
 
-	if (tf->tf_eflags & PSL_VM)
-		(*p->p_emul->e_syscall_intern)(p);
 	sendsig_reset(l, sig);
 
 	mutex_exit(p->p_lock);



CVS commit: src/sys/arch/i386/i386

2017-08-12 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 12 13:16:14 UTC 2017

Modified Files:
src/sys/arch/i386/i386: genassym.cf machdep.c

Log Message:
Remove references to PSL_VM (implicitly vm86).


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.789 -r1.790 src/sys/arch/i386/i386/machdep.c

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



CVS commit: src/sys/arch/i386/i386

2017-08-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Aug 10 14:13:45 UTC 2017

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Switch to the temporary stack right away when booted via multiboot. GRUB
happens to give a correct stack, but it is not guaranteed by the spec. This
temporary stack will be reset later, which is fine.

Fixes PR/50245.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.149 src/sys/arch/i386/i386/locore.S:1.150
--- src/sys/arch/i386/i386/locore.S:1.149	Sat Jul 29 12:34:34 2017
+++ src/sys/arch/i386/i386/locore.S	Thu Aug 10 14:13:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.149 2017/07/29 12:34:34 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.150 2017/08/10 14:13:45 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.149 2017/07/29 12:34:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.150 2017/08/10 14:13:45 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -342,11 +342,13 @@ _C_LABEL(Multiboot_Header):
 	jne	1f
 
 	/*
-	 * Indeed, a multiboot-compliant boot loader executed us.  We copy
-	 * the received Multiboot information structure into kernel's data
-	 * space to process it later -- after we are relocated.  It will
-	 * be safer to run complex C code than doing it at this point.
+	 * Indeed, a multiboot-compliant boot loader executed us. We switch
+	 * to the temporary stack, and copy the received Multiboot information
+	 * structure into kernel's data space to process it later -- after we
+	 * are relocated. It will be safer to run complex C code than doing it
+	 * at this point.
 	 */
+	movl	$_RELOC(tmpstk),%esp
 	pushl	%ebx		/* Address of Multiboot information */
 	call	_C_LABEL(multiboot_pre_reloc)
 	addl	$4,%esp



CVS commit: src/sys/arch/i386/i386

2017-08-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Aug 10 14:13:45 UTC 2017

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Switch to the temporary stack right away when booted via multiboot. GRUB
happens to give a correct stack, but it is not guaranteed by the spec. This
temporary stack will be reset later, which is fine.

Fixes PR/50245.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 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: src/sys/arch/i386/i386

2017-07-29 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jul 29 12:34:34 UTC 2017

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Remove undocumented hack.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 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/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.148 src/sys/arch/i386/i386/locore.S:1.149
--- src/sys/arch/i386/i386/locore.S:1.148	Sat Jul 29 11:54:14 2017
+++ src/sys/arch/i386/i386/locore.S	Sat Jul 29 12:34:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.148 2017/07/29 11:54:14 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.149 2017/07/29 12:34:34 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.148 2017/07/29 11:54:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.149 2017/07/29 12:34:34 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -841,24 +841,6 @@ begin:
 	addl	$PDE_SIZE,%esp		/* pop paddr_t */
 	addl	$NGDT*8,%esp		/* pop temporary gdt */
 
-#ifdef SAFARI_FIFO_HACK
-	movb	$5,%al
-	movw	$0x37b,%dx
-	outb	%al,%dx
-	movw	$0x37f,%dx
-	inb	%dx,%al
-	movb	%al,%cl
-
-	orb	$1,%cl
-
-	movb	$5,%al
-	movw	$0x37b,%dx
-	outb	%al,%dx
-	movw	$0x37f,%dx
-	movb	%cl,%al
-	outb	%al,%dx
-#endif /* SAFARI_FIFO_HACK */
-
 	call 	_C_LABEL(main)
 #else /* XEN */
 	/* First, reset the PSL. */



CVS commit: src/sys/arch/i386/i386

2017-07-29 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jul 29 12:34:34 UTC 2017

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Remove undocumented hack.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 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: src/sys/arch/i386/i386

2017-07-06 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Jul  6 20:23:57 UTC 2017

Modified Files:
src/sys/arch/i386/i386: gdt.c

Log Message:
gdt_size is now in bytes, but the HYPERVISOR_set_gdt() expects a number
of entries and has not been converted.
Xen/i386 now boots again.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/i386/i386/gdt.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/i386/i386/gdt.c
diff -u src/sys/arch/i386/i386/gdt.c:1.64 src/sys/arch/i386/i386/gdt.c:1.65
--- src/sys/arch/i386/i386/gdt.c:1.64	Sun Jul  2 11:21:13 2017
+++ src/sys/arch/i386/i386/gdt.c	Thu Jul  6 20:23:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.64 2017/07/02 11:21:13 maxv Exp $	*/
+/*	$NetBSD: gdt.c,v 1.65 2017/07/06 20:23:57 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.64 2017/07/02 11:21:13 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.65 2017/07/06 20:23:57 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -202,13 +202,14 @@ gdt_init_cpu(struct cpu_info *ci)
 	setregion(, ci->ci_gdt, max_len - 1);
 	lgdt();
 #else
-	size_t len = gdt_size;
+	size_t len = roundup(gdt_size, PAGE_SIZE);
 	unsigned long frames[len >> PAGE_SHIFT];
 	vaddr_t va;
 	pt_entry_t *ptp;
 	size_t f;
 
-	for (va = (vaddr_t)ci->ci_gdt, f = 0; va < (vaddr_t)ci->ci_gdt + len;
+	for (va = (vaddr_t)ci->ci_gdt, f = 0;
+	va < (vaddr_t)ci->ci_gdt + gdt_size;
 	va += PAGE_SIZE, f++) {
 		KASSERT(va >= VM_MIN_KERNEL_ADDRESS);
 		ptp = kvtopte(va);
@@ -226,7 +227,7 @@ gdt_init_cpu(struct cpu_info *ci)
 		}
 	}
 
-	if (HYPERVISOR_set_gdt(frames, gdt_size))
+	if (HYPERVISOR_set_gdt(frames, gdt_size / sizeof(gdtstore[0])))
 		panic("HYPERVISOR_set_gdt failed!\n");
 	lgdt_finish();
 #endif



  1   2   3   4   >