CVS commit: src/sys/arch/amd64/amd64

2024-09-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Sep 24 20:19:30 UTC 2024

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

Log Message:
s/acually/actually/ in comment.

P.S. the comment itself is hardly readable though.


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

2024-09-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Sep 24 20:19:30 UTC 2024

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

Log Message:
s/acually/actually/ in comment.

P.S. the comment itself is hardly readable though.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/amd64/amd64/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/amd64/amd64/copy.S
diff -u src/sys/arch/amd64/amd64/copy.S:1.35 src/sys/arch/amd64/amd64/copy.S:1.36
--- src/sys/arch/amd64/amd64/copy.S:1.35	Sun Dec 18 07:53:30 2022
+++ src/sys/arch/amd64/amd64/copy.S	Tue Sep 24 20:19:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.S,v 1.35 2022/12/18 07:53:30 skrll Exp $	*/
+/*	$NetBSD: copy.S,v 1.36 2024/09/24 20:19:30 andvar Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -150,7 +150,7 @@ ENTRY(kcopy)
 
 /*
  * Using 'rep movs' to copy backwards is not as fast as for forwards copies
- * and ought not be done when the copy doesn't acually overlap.
+ * and ought not be done when the copy doesn't actually overlap.
  * However kcopy() isn't used any that looks even vaguely used often.
  * I'm also not sure it is ever asked to do overlapping copies!
  */



CVS commit: src/sys/arch/amd64/stand/prekern

2024-06-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun 24 18:00:32 UTC 2024

Modified Files:
src/sys/arch/amd64/stand/prekern: Makefile

Log Message:
amd64/prekern: Add ldscript to DPADD since it affects build output.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amd64/stand/prekern/Makefile

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

Modified files:

Index: src/sys/arch/amd64/stand/prekern/Makefile
diff -u src/sys/arch/amd64/stand/prekern/Makefile:1.8 src/sys/arch/amd64/stand/prekern/Makefile:1.9
--- src/sys/arch/amd64/stand/prekern/Makefile:1.8	Wed Jul 25 23:45:32 2018
+++ src/sys/arch/amd64/stand/prekern/Makefile	Mon Jun 24 18:00:32 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2018/07/25 23:45:32 kamil Exp $
+#	$NetBSD: Makefile,v 1.9 2024/06/24 18:00:32 riastradh Exp $
 
 PROG=		prekern
 SRCS=		locore.S trap.S prekern.c mm.c console.c elf.c prng.c
@@ -29,6 +29,7 @@ CFLAGS+=	-mno-red-zone -mno-mmx -mno-sse
 STRIPFLAG=
 LINKFLAGS=	-X -z max-page-size=0x10 -Ttext 0x10 \
 		-T ${S}/arch/amd64/stand/prekern/prekern.ldscript
+DPADD+=		prekern.ldscript
 
 KERN_AS=	library
 .include	"${S}/lib/libkern/Makefile.inc"



CVS commit: src/sys/arch/amd64/stand/prekern

2024-06-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun 24 18:00:32 UTC 2024

Modified Files:
src/sys/arch/amd64/stand/prekern: Makefile

Log Message:
amd64/prekern: Add ldscript to DPADD since it affects build output.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amd64/stand/prekern/Makefile

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



CVS commit: src/sys/arch/amd64/include

2024-06-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun  9 22:35:17 UTC 2024

Modified Files:
src/sys/arch/amd64/include: asm.h

Log Message:
amd64/asm.h: Respect _NETBSD_REVISIONID.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/include/asm.h

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

Modified files:

Index: src/sys/arch/amd64/include/asm.h
diff -u src/sys/arch/amd64/include/asm.h:1.22 src/sys/arch/amd64/include/asm.h:1.23
--- src/sys/arch/amd64/include/asm.h:1.22	Sat Apr 17 20:12:55 2021
+++ src/sys/arch/amd64/include/asm.h	Sun Jun  9 22:35:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: asm.h,v 1.22 2021/04/17 20:12:55 rillig Exp $	*/
+/*	$NetBSD: asm.h,v 1.23 2024/06/09 22:35:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -112,9 +112,16 @@
 
 #define	ASMSTR		.asciz
 
-#define RCSID(x)	.pushsection ".ident","MS",@progbits,1;		\
+#define _IDENTSTR(x)	.pushsection ".ident","MS",@progbits,1;		\
 			.asciz x;	\
 			.popsection
+#ifdef _NETBSD_REVISIONID
+#define	RCSID(_s)			  \
+	_IDENTSTR(_s);			  \
+	_IDENTSTR("$" "NetBSD: " __FILE__ " " _NETBSD_REVISIONID " $")
+#else
+#define	RCSID(_s)			_IDENTSTR(_s)
+#endif
 
 #define	WEAK_ALIAS(alias,sym)		\
 	.weak alias;			\



CVS commit: src/sys/arch/amd64/include

2024-06-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun  9 22:35:17 UTC 2024

Modified Files:
src/sys/arch/amd64/include: asm.h

Log Message:
amd64/asm.h: Respect _NETBSD_REVISIONID.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/include/asm.h

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



CVS commit: src/sys/arch/amd64/amd64

2023-07-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Jul 31 02:38:16 UTC 2023

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

Log Message:
when cpus are paused (spinning) in DDB, call x86_pause() in the loop,
hopefully this can reduce power usage while doing nothing.

ok chs@

XXX: pullup-*
XXX: apply to i386


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/amd64/amd64/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/amd64/amd64/db_interface.c
diff -u src/sys/arch/amd64/amd64/db_interface.c:1.41 src/sys/arch/amd64/amd64/db_interface.c:1.42
--- src/sys/arch/amd64/amd64/db_interface.c:1.41	Wed Oct 26 23:38:06 2022
+++ src/sys/arch/amd64/amd64/db_interface.c	Mon Jul 31 02:38:16 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.41 2022/10/26 23:38:06 riastradh Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.42 2023/07/31 02:38:16 mrg Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.41 2022/10/26 23:38:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.42 2023/07/31 02:38:16 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -303,7 +303,7 @@ ddb_suspend(struct trapframe *frame)
 	atomic_or_32(&ci->ci_flags, CPUF_PAUSE);
 
 	while (ci->ci_flags & CPUF_PAUSE)
-		;
+		x86_pause();
 	ci->ci_ddb_regs = 0;
 	tlbflushg();
 }



CVS commit: src/sys/arch/amd64/amd64

2023-07-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Jul 31 02:38:16 UTC 2023

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

Log Message:
when cpus are paused (spinning) in DDB, call x86_pause() in the loop,
hopefully this can reduce power usage while doing nothing.

ok chs@

XXX: pullup-*
XXX: apply to i386


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/amd64/amd64/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/amd64/conf

2023-07-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 22 15:18:48 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOMU

Log Message:
amd64/XEN3_DOMU: Pass -g to build debug data like GENERIC.

Needed for CTF data by dtrace when MKDEBUG=no MKDEBUGKERNEL=no.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/amd64/conf/XEN3_DOMU

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

Modified files:

Index: src/sys/arch/amd64/conf/XEN3_DOMU
diff -u src/sys/arch/amd64/conf/XEN3_DOMU:1.101 src/sys/arch/amd64/conf/XEN3_DOMU:1.102
--- src/sys/arch/amd64/conf/XEN3_DOMU:1.101	Fri Jul 21 02:04:52 2023
+++ src/sys/arch/amd64/conf/XEN3_DOMU	Sat Jul 22 15:18:48 2023
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOMU,v 1.101 2023/07/21 02:04:52 riastradh Exp $
+# $NetBSD: XEN3_DOMU,v 1.102 2023/07/22 15:18:48 riastradh Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -11,7 +11,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOMU-$Revision: 1.101 $"
+#ident		"XEN3_DOMU-$Revision: 1.102 $"
 
 maxusers	32		# estimated number of users
 
@@ -51,7 +51,7 @@ options 	DDB_ONPANIC=1	# see also sysctl
 options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB
 #options 	KGDB		# remote debugger
 #options 	KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x2f8,KGDB_DEVRATE=57600
-#makeoptions	DEBUG="-g"	# compile full symbol table
+makeoptions	DEBUG="-g"	# compile full symbol table for CTF
 makeoptions	COPTS="-O2 -fno-omit-frame-pointer"
 options DDB_COMMANDONENTER="trace;show registers"
 options 	KDTRACE_HOOKS	# kernel DTrace hooks



CVS commit: src/sys/arch/amd64/conf

2023-07-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 22 15:18:48 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOMU

Log Message:
amd64/XEN3_DOMU: Pass -g to build debug data like GENERIC.

Needed for CTF data by dtrace when MKDEBUG=no MKDEBUGKERNEL=no.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/amd64/conf/XEN3_DOMU

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



CVS commit: src/sys/arch/amd64/conf

2023-07-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jul 21 02:04:52 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOMU

Log Message:
amd64/XEN3_DOMU: Enable KDTRACE_HOOKS.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/amd64/conf/XEN3_DOMU

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

Modified files:

Index: src/sys/arch/amd64/conf/XEN3_DOMU
diff -u src/sys/arch/amd64/conf/XEN3_DOMU:1.100 src/sys/arch/amd64/conf/XEN3_DOMU:1.101
--- src/sys/arch/amd64/conf/XEN3_DOMU:1.100	Thu Feb  9 14:09:48 2023
+++ src/sys/arch/amd64/conf/XEN3_DOMU	Fri Jul 21 02:04:52 2023
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOMU,v 1.100 2023/02/09 14:09:48 abs Exp $
+# $NetBSD: XEN3_DOMU,v 1.101 2023/07/21 02:04:52 riastradh Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -11,7 +11,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOMU-$Revision: 1.100 $"
+#ident		"XEN3_DOMU-$Revision: 1.101 $"
 
 maxusers	32		# estimated number of users
 
@@ -54,6 +54,7 @@ options 	DDB_HISTORY_SIZE=512	# enable h
 #makeoptions	DEBUG="-g"	# compile full symbol table
 makeoptions	COPTS="-O2 -fno-omit-frame-pointer"
 options DDB_COMMANDONENTER="trace;show registers"
+options 	KDTRACE_HOOKS	# kernel DTrace hooks
 
 # Compatibility options
 include 	"conf/compat_netbsd15.config"



CVS commit: src/sys/arch/amd64/conf

2023-07-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jul 21 02:04:52 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOMU

Log Message:
amd64/XEN3_DOMU: Enable KDTRACE_HOOKS.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/amd64/conf/XEN3_DOMU

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



CVS commit: src/sys/arch/amd64/conf

2023-07-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 15 22:16:00 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
amd64: Enable HEARTBEAT option, not just a HEARTBEAT option comment.


To generate a diff of this commit:
cvs rdiff -u -r1.603 -r1.604 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.603 src/sys/arch/amd64/conf/GENERIC:1.604
--- src/sys/arch/amd64/conf/GENERIC:1.603	Sat Jul 15 22:14:39 2023
+++ src/sys/arch/amd64/conf/GENERIC	Sat Jul 15 22:16:00 2023
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.603 2023/07/15 22:14:39 riastradh Exp $
+# $NetBSD: GENERIC,v 1.604 2023/07/15 22:16:00 riastradh Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.603 $"
+#ident		"GENERIC-$Revision: 1.604 $"
 
 maxusers	64		# estimated number of users
 
@@ -172,8 +172,8 @@ options 	KDTRACE_HOOKS	# kernel DTrace h
 #options 	FAULT
 
 # Heartbeat checks
-#options 	HEARTBEAT
-#options 	HEARTBEAT_MAX_PERIOD_DEFAULT=15
+options 	HEARTBEAT
+options 	HEARTBEAT_MAX_PERIOD_DEFAULT=15
 
 # Compatibility options
 # x86_64 never shipped with a.out binaries; the two options below are



CVS commit: src/sys/arch/amd64/conf

2023-07-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 15 22:16:00 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
amd64: Enable HEARTBEAT option, not just a HEARTBEAT option comment.


To generate a diff of this commit:
cvs rdiff -u -r1.603 -r1.604 src/sys/arch/amd64/conf/GENERIC

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



CVS commit: src/sys/arch/amd64/conf

2023-07-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jul  7 12:46:50 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
amd64/ALL: Turn on heartbeat checks.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/arch/amd64/conf/ALL

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

Modified files:

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.177 src/sys/arch/amd64/conf/ALL:1.178
--- src/sys/arch/amd64/conf/ALL:1.177	Thu Feb  9 14:09:48 2023
+++ src/sys/arch/amd64/conf/ALL	Fri Jul  7 12:46:50 2023
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.177 2023/02/09 14:09:48 abs Exp $
+# $NetBSD: ALL,v 1.178 2023/07/07 12:46:50 riastradh Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.177 $"
+#ident		"ALL-$Revision: 1.178 $"
 
 maxusers	64		# estimated number of users
 
@@ -142,6 +142,10 @@ options		KCOV
 # Fault Injection Driver.
 options 	FAULT
 
+# Heartbeat checks
+options 	HEARTBEAT
+options 	HEARTBEAT_MAX_PERIOD_DEFAULT=15
+
 # Compatibility options
 options 	EXEC_AOUT	# required by binaries from before 1.5
 options 	COMPAT_386BSD_MBRPART # recognize old partition ID



CVS commit: src/sys/arch/amd64/conf

2023-07-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jul  7 12:46:50 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
amd64/ALL: Turn on heartbeat checks.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/arch/amd64/conf/ALL

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



CVS commit: src/sys/arch/amd64/conf

2023-06-05 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun  5 13:59:55 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: NOCOMPAT

Log Message:
Un-comment the ident line


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/conf/NOCOMPAT

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

Modified files:

Index: src/sys/arch/amd64/conf/NOCOMPAT
diff -u src/sys/arch/amd64/conf/NOCOMPAT:1.6 src/sys/arch/amd64/conf/NOCOMPAT:1.7
--- src/sys/arch/amd64/conf/NOCOMPAT:1.6	Wed Jan 20 21:38:44 2021
+++ src/sys/arch/amd64/conf/NOCOMPAT	Mon Jun  5 13:59:54 2023
@@ -1,6 +1,6 @@
 include "arch/amd64/conf/GENERIC"
 
-#ident		"NOCOMPAT-$Revision: 1.6 $"
+ident		"NOCOMPAT-$Revision: 1.7 $"
 
 no options 	SYSVMSG		# System V-like message queues
 no options 	SYSVSEM		# System V-like semaphores



CVS commit: src/sys/arch/amd64/conf

2023-06-05 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun  5 13:59:55 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: NOCOMPAT

Log Message:
Un-comment the ident line


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/conf/NOCOMPAT

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



CVS commit: src/sys/arch/amd64/include

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 08:17:56 UTC 2023

Modified Files:
src/sys/arch/amd64/include: cpu.h

Log Message:
amd64: Make curlwp and curcpu() flushable.

The only effect of the `volatile' qualifier on an asm block with
outputs is to force the instructions to appear in the generated code,
even if the outputs end up being unused.  Since these instructions
have no (architectural) side effects -- provided %gs is set
correctly, which must be the case here -- there's no need for the
volatile qualifier, so nix it.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/amd64/include/cpu.h

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

Modified files:

Index: src/sys/arch/amd64/include/cpu.h
diff -u src/sys/arch/amd64/include/cpu.h:1.70 src/sys/arch/amd64/include/cpu.h:1.71
--- src/sys/arch/amd64/include/cpu.h:1.70	Tue Nov  2 11:26:03 2021
+++ src/sys/arch/amd64/include/cpu.h	Sun Apr  9 08:17:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.70 2021/11/02 11:26:03 ryo Exp $	*/
+/*	$NetBSD: cpu.h,v 1.71 2023/04/09 08:17:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -53,7 +53,7 @@ x86_curcpu(void)
 {
 	struct cpu_info *ci;
 
-	__asm volatile("movq %%gs:%1, %0" :
+	__asm("movq %%gs:%1, %0" :
 	"=r" (ci) :
 	"m"
 	(*(struct cpu_info * const *)offsetof(struct cpu_info, ci_self)));
@@ -65,7 +65,7 @@ x86_curlwp(void)
 {
 	lwp_t *l;
 
-	__asm volatile("movq %%gs:%1, %0" :
+	__asm("movq %%gs:%1, %0" :
 	"=r" (l) :
 	"m"
 	(*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp)));



CVS commit: src/sys/arch/amd64/include

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 08:17:56 UTC 2023

Modified Files:
src/sys/arch/amd64/include: cpu.h

Log Message:
amd64: Make curlwp and curcpu() flushable.

The only effect of the `volatile' qualifier on an asm block with
outputs is to force the instructions to appear in the generated code,
even if the outputs end up being unused.  Since these instructions
have no (architectural) side effects -- provided %gs is set
correctly, which must be the case here -- there's no need for the
volatile qualifier, so nix it.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/amd64/include/cpu.h

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



CVS commit: src/sys/arch/amd64/amd64

2023-02-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 27 16:24:28 UTC 2023

Modified Files:
src/sys/arch/amd64/amd64: amd64_trap.S

Log Message:
amd64_trap.S: Annotate trap vectors with their mnemonics.

Derived from Intel and AMD manuals.

Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3
(3A, 3B, 3C, & 3D: System Programming Guide, Order Number:
325384-077US, April 2022.
https://cdrdv2.intel.com/v1/dl/getContent/671447

AMD64 Technology: AMD64 Architecture Programmers' Manual, Volume 2:
System Programming, Publication No. 24953, Revision 3.40, January 2023.
https://www.amd.com/system/files/TechDocs/24593.pdf

No functional change intended.

XXX Should apply the same treatment to i386_trap.S.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/amd64/amd64/amd64_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/amd64/amd64/amd64_trap.S
diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.54 src/sys/arch/amd64/amd64/amd64_trap.S:1.55
--- src/sys/arch/amd64/amd64/amd64_trap.S:1.54	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/amd64/amd64/amd64_trap.S	Mon Feb 27 16:24:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amd64_trap.S,v 1.54 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: amd64_trap.S,v 1.55 2023/02/27 16:24:28 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc.
@@ -159,7 +159,7 @@
 
 	TEXT_USER_BEGIN
 
-IDTVEC(trap00)
+IDTVEC(trap00)		/* #DE - Divide-by-zero error */
 	ZTRAP(T_DIVIDE)
 IDTVEC_END(trap00)
 
@@ -178,7 +178,7 @@ IDTVEC_END(trap00)
  * not a problem, because in this particular case, the frame is known not
  * to contain secrets.
  */
-IDTVEC(trap01)
+IDTVEC(trap01)		/* #DB - Debug */
 #ifndef XENPV
 	subq	$(TF_REGSIZE+16),%rsp
 
@@ -247,7 +247,7 @@ IDTVEC_END(trap01)
  * We need to be careful about %gs too, because it is possible that we were
  * running in kernel mode with a userland %gs.
  */
-IDTVEC(trap02)
+IDTVEC(trap02)		/* NMI - Non-maskable interrupt */
 #if defined(XENPV)
 	ZTRAP(T_NMI)
 #else /* XENPV */
@@ -302,7 +302,7 @@ IDTVEC(trap02)
 #endif /* XENPV */
 IDTVEC_END(trap02)
 
-IDTVEC(trap03)
+IDTVEC(trap03)		/* #BP - Breakpoint */
 #ifndef KDTRACE_HOOKS
 	ZTRAP(T_BPTFLT)
 #else
@@ -331,19 +331,19 @@ IDTVEC(trap03)
 #endif
 IDTVEC_END(trap03)
 
-IDTVEC(trap04)
+IDTVEC(trap04)		/* #OF - Overflow */
 	ZTRAP(T_OFLOW)
 IDTVEC_END(trap04)
 
-IDTVEC(trap05)
+IDTVEC(trap05)		/* #BR - BOUND range exceeded */
 	ZTRAP(T_BOUND)
 IDTVEC_END(trap05)
 
-IDTVEC(trap06)
+IDTVEC(trap06)		/* #UD - Invalid opcode */
 	ZTRAP(T_PRIVINFLT)
 IDTVEC_END(trap06)
 
-IDTVEC(trap07)
+IDTVEC(trap07)		/* #NM - Device not available (x87) */
 	ZTRAP_NJ(T_DNA)
 	INTRENTRY
 #ifdef DIAGNOSTIC
@@ -358,7 +358,7 @@ IDTVEC_END(trap07)
  * Double faults execute on a particular stack, and we must not jump out
  * of it. So don't enable interrupts.
  */
-IDTVEC(trap08)
+IDTVEC(trap08)		/* #DF - Double fault */
 #if defined(XENPV)
 	TRAP(T_DOUBLEFLT)
 #else /* XENPV */
@@ -399,11 +399,11 @@ IDTVEC(trap08)
 #endif /* XENPV */
 IDTVEC_END(trap08)
 
-IDTVEC(trap09)
+IDTVEC(trap09)		/* Coprocessor segment overrun (legacy x87) */
 	ZTRAP(T_FPOPFLT)
 IDTVEC_END(trap09)
 
-IDTVEC(trap10)
+IDTVEC(trap10)		/* #TS - Invalid TSS */
 	TRAP(T_TSSFLT)
 IDTVEC_END(trap10)
 
@@ -416,26 +416,26 @@ IDTVEC_END(trap10)
 #define kernuser_reenter alltraps
 #endif /* XENPV */
 
-IDTVEC(trap11)		/* #NP() Segment not present */
+IDTVEC(trap11)		/* #NP - Segment not present */
 	TRAP_NJ(T_SEGNPFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap11)
 
-IDTVEC(trap12)		/* #SS() Stack exception */
+IDTVEC(trap12)		/* #SS - Stack fault */
 	TRAP_NJ(T_STKFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap12)
 
-IDTVEC(trap13)		/* #GP() General protection */
+IDTVEC(trap13)		/* #GP - General protection */
 	TRAP_NJ(T_PROTFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap13)
 
-IDTVEC(trap14)
+IDTVEC(trap14)		/* #PF - Page fault */
 	TRAP(T_PAGEFLT)
 IDTVEC_END(trap14)
 
-IDTVEC(trap15)
+IDTVEC(trap15)		/* XXX ??? */
 	ZTRAP_NJ(T_ASTFLT)
 	INTRENTRY
 #ifdef DIAGNOSTIC
@@ -444,7 +444,7 @@ IDTVEC(trap15)
 	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap15)
 
-IDTVEC(trap16)
+IDTVEC(trap16)		/* #MF - x87 floating-point exception */
 	ZTRAP_NJ(T_ARITHTRAP)
 .Ldo_fputrap:
 	INTRENTRY
@@ -464,30 +464,30 @@ IDTVEC(trap16)
 	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap16)
 
-IDTVEC(trap17)
+IDTVEC(trap17)		/* #AC - Alignment check */
 	TRAP(T_ALIGNFLT)
 IDTVEC_END(trap17)
 
-IDTVEC(trap18)
+IDTVEC(trap18)		/* #MC - Machine check */
 	ZTRAP(T_MCA)
 IDTVEC_END(trap18)
 
-IDTVEC(trap19)
+IDTVEC(trap19)		/* #XM - SIMD floating-point exception */
 	ZTRAP_NJ(T_XMM)
 	jmp	.Ldo_fputrap
 IDTVEC_END(trap19)
 
-IDTVEC(trap20)
-IDTVEC(trap21)
+IDTVEC(trap20)		/* #VE - Virtualization (Intel) */
+IDTVEC(trap21)		/* #CP - Control protection */
 IDTVEC(trap22)
 IDTVEC(trap23)
 IDTVEC(trap24)
 IDTVEC(tra

CVS commit: src/sys/arch/amd64/amd64

2023-02-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 27 16:24:28 UTC 2023

Modified Files:
src/sys/arch/amd64/amd64: amd64_trap.S

Log Message:
amd64_trap.S: Annotate trap vectors with their mnemonics.

Derived from Intel and AMD manuals.

Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3
(3A, 3B, 3C, & 3D: System Programming Guide, Order Number:
325384-077US, April 2022.
https://cdrdv2.intel.com/v1/dl/getContent/671447

AMD64 Technology: AMD64 Architecture Programmers' Manual, Volume 2:
System Programming, Publication No. 24953, Revision 3.40, January 2023.
https://www.amd.com/system/files/TechDocs/24593.pdf

No functional change intended.

XXX Should apply the same treatment to i386_trap.S.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/amd64/amd64/amd64_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/amd64/amd64

2022-12-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 26 17:46:00 UTC 2022

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

Log Message:
sysret -> sysretl for new binutils


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/arch/amd64/amd64/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/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.214 src/sys/arch/amd64/amd64/locore.S:1.215
--- src/sys/arch/amd64/amd64/locore.S:1.214	Tue Sep  6 20:40:18 2022
+++ src/sys/arch/amd64/amd64/locore.S	Mon Dec 26 12:46:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.214 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: locore.S,v 1.215 2022/12/26 17:46:00 christos Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1527,7 +1527,7 @@ SYSCALL_ENTRY	syscall_svs,is_svs=1
 #endif
 
 IDTVEC(syscall32)
-	sysret		/* go away please */
+	sysretl		/* go away please */
 IDTVEC_END(syscall32)
 
 	TEXT_USER_END



CVS commit: src/sys/arch/amd64/amd64

2022-12-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 26 17:46:00 UTC 2022

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

Log Message:
sysret -> sysretl for new binutils


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

2022-12-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Dec 18 07:53:31 UTC 2022

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

Log Message:
Typo in comment


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

2022-12-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Dec 18 07:53:31 UTC 2022

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

Log Message:
Typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/amd64/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/amd64/amd64/copy.S
diff -u src/sys/arch/amd64/amd64/copy.S:1.34 src/sys/arch/amd64/amd64/copy.S:1.35
--- src/sys/arch/amd64/amd64/copy.S:1.34	Tue Jun 30 16:20:00 2020
+++ src/sys/arch/amd64/amd64/copy.S	Sun Dec 18 07:53:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.S,v 1.34 2020/06/30 16:20:00 maxv Exp $	*/
+/*	$NetBSD: copy.S,v 1.35 2022/12/18 07:53:30 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -120,7 +120,7 @@ END(do_pmap_load)
  * However the use of 'rep movsb' for the final bytes should be killed.
  *
  * Newer Intel cpus have a much lower setup time, and may (someday)
- * be ably to do cache-line size copies
+ * be able to do cache-line size copies
  */
 
 /*



CVS commit: src/sys/arch/amd64/include

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:39:50 UTC 2022

Modified Files:
src/sys/arch/amd64/include: asan.h msan.h

Log Message:
amd64/asan.h, amd64/msan.h: Add include guards.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/include/asan.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/include/msan.h

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

Modified files:

Index: src/sys/arch/amd64/include/asan.h
diff -u src/sys/arch/amd64/include/asan.h:1.11 src/sys/arch/amd64/include/asan.h:1.12
--- src/sys/arch/amd64/include/asan.h:1.11	Mon Aug 22 13:57:24 2022
+++ src/sys/arch/amd64/include/asan.h	Tue Sep 13 09:39:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.11 2022/08/22 13:57:24 hannken Exp $	*/
+/*	$NetBSD: asan.h,v 1.12 2022/09/13 09:39:49 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -28,6 +28,9 @@
  * SUCH DAMAGE.
  */
 
+#ifndef	_AMD64_ASAN_H_
+#define	_AMD64_ASAN_H_
+
 #include 
 
 #include 
@@ -294,3 +297,5 @@ kasan_md_unwind(void)
 		}
 	}
 }
+
+#endif	/* _AMD64_ASAN_H_ */

Index: src/sys/arch/amd64/include/msan.h
diff -u src/sys/arch/amd64/include/msan.h:1.7 src/sys/arch/amd64/include/msan.h:1.8
--- src/sys/arch/amd64/include/msan.h:1.7	Mon Aug 22 13:21:47 2022
+++ src/sys/arch/amd64/include/msan.h	Tue Sep 13 09:39:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msan.h,v 1.7 2022/08/22 13:21:47 riastradh Exp $	*/
+/*	$NetBSD: msan.h,v 1.8 2022/09/13 09:39:49 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019-2020 Maxime Villard, m00nbsd.net
@@ -28,6 +28,9 @@
  * SUCH DAMAGE.
  */
 
+#ifndef	_AMD64_MSAN_H_
+#define	_AMD64_MSAN_H_
+
 #include 
 
 #include 
@@ -275,3 +278,5 @@ kmsan_md_unwind(void)
 		}
 	}
 }
+
+#endif	/* _AMD64_MSAN_H_ */



CVS commit: src/sys/arch/amd64/include

2022-09-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep 13 09:39:50 UTC 2022

Modified Files:
src/sys/arch/amd64/include: asan.h msan.h

Log Message:
amd64/asan.h, amd64/msan.h: Add include guards.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/include/asan.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/include/msan.h

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



CVS commit: src/sys/arch/amd64/amd64

2022-09-12 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Sep 13 05:36:29 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: lock_stubs.S

Log Message:
Fix PR kern/57007.  I missed applying a part of the original patch.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/lock_stubs.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/amd64/amd64/lock_stubs.S
diff -u src/sys/arch/amd64/amd64/lock_stubs.S:1.37 src/sys/arch/amd64/amd64/lock_stubs.S:1.38
--- src/sys/arch/amd64/amd64/lock_stubs.S:1.37	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/amd64/amd64/lock_stubs.S	Tue Sep 13 05:36:29 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/13 05:36:29 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -124,13 +124,13 @@ ENTRY(mutex_spin_exit)
 	movl	CPU_INFO_MTX_OLDSPL(%r8), %edi
 	incl	CPU_INFO_MTX_COUNT(%r8)
 	jnz	1f
-	cmpl	CPU_INFO_ILEVEL(%r8), %edi
+	cmpb	CPU_INFO_ILEVEL(%r8), %dil
 	jae	1f
-	movl	CPU_INFO_IUNMASK(%r8,%rdi,4), %esi
+	movq	CPU_INFO_IUNMASK(%r8,%rdi,8), %rsi
 	CLI(ax)
-	testl	CPU_INFO_IPENDING(%r8), %esi
+	testq	CPU_INFO_IPENDING(%r8), %rsi
 	jnz	_C_LABEL(Xspllower)
-	movl	%edi, CPU_INFO_ILEVEL(%r8)
+	movb	%dil, CPU_INFO_ILEVEL(%r8)
 	STI(ax)
 1:	rep	/* double byte ret as branch */
 	ret	/* target: see AMD docs */
@@ -141,23 +141,27 @@ ENTRY(mutex_spin_exit)
 	movb	$0x00, MTX_LOCK(%rdi)
 	movl	CPU_INFO_MTX_OLDSPL(%rsi), %ecx
 	incl	CPU_INFO_MTX_COUNT(%rsi)
-	movl	CPU_INFO_ILEVEL(%rsi),%edx
+	movzbl	CPU_INFO_ILEVEL(%rsi),%edx
 	cmovnzl	%edx,%ecx
-	pushq	%rbx
 	cmpl	%edx,%ecx			/* new level is lower? */
 	jae	2f
+	xorq	%rdi,%rdi			/* rdi: ci_ipending mask */
+	notq	%rdi
+	shrq	$8,%rdi
+	movq	%rcx,%r9			/* r9: shifted new level */
+	shlq	$56,%r9
 1:
-	movl	CPU_INFO_IPENDING(%rsi),%eax
-	testl	%eax,CPU_INFO_IUNMASK(%rsi,%rcx,4)/* deferred interrupts? */
+	movq	CPU_INFO_IPENDING(%rsi),%rax
+	testq	%rax,CPU_INFO_IUNMASK(%rsi,%rcx,8)/* deferred interrupts? */
 	jnz	3f
-	movl	%eax,%ebx
-	cmpxchg8b CPU_INFO_ISTATE(%rsi)		/* swap in new ilevel */
+	movq	%rax,%r8
+	andq	%rdi,%r8
+	orq	%r9,%r8
+	cmpxchgq %r8,CPU_INFO_ISTATE(%rsi)	/* swap in new ilevel */
 	jnz	4f
 2:
-	popq	%rbx
 	ret
 3:
-	popq	%rbx
 	movl	%ecx, %edi
 	jmp	_C_LABEL(Xspllower)
 4:



CVS commit: src/sys/arch/amd64/amd64

2022-09-12 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Sep 13 05:36:29 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: lock_stubs.S

Log Message:
Fix PR kern/57007.  I missed applying a part of the original patch.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/lock_stubs.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/amd64/amd64

2022-09-11 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Sep 12 02:21:11 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: vector.S

Log Message:
Update register name at fault.  Pointed out by hgutch@n.o, thanks.

In vetor.S:r1.78

IDTVEC(handle_hypervisor_callback)
  movlCPUVAR(ILEVEL),%edi
  pushq   %rdi /* for Xdoreti */

So, use %edi as before.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/amd64/amd64/vector.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/amd64/amd64

2022-09-11 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Sep 12 02:21:11 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: vector.S

Log Message:
Update register name at fault.  Pointed out by hgutch@n.o, thanks.

In vetor.S:r1.78

IDTVEC(handle_hypervisor_callback)
  movlCPUVAR(ILEVEL),%edi
  pushq   %rdi /* for Xdoreti */

So, use %edi as before.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/amd64/amd64/vector.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/vector.S
diff -u src/sys/arch/amd64/amd64/vector.S:1.79 src/sys/arch/amd64/amd64/vector.S:1.80
--- src/sys/arch/amd64/amd64/vector.S:1.79	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/amd64/amd64/vector.S	Mon Sep 12 02:21:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.79 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: vector.S,v 1.80 2022/09/12 02:21:11 knakahara Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -728,7 +728,7 @@ ENTRY(hypervisor_callback)
 	pushq	$T_ASTFLT
 	INTRENTRY
 IDTVEC(handle_hypervisor_callback)
-	movzbl	CPUVAR(ILEVEL),%rdi
+	movzbl	CPUVAR(ILEVEL),%edi
 	pushq   %rdi /* for Xdoreti */
 	incl	CPUVAR(IDEPTH)
 	movq	%rsp,%rdi



CVS commit: src/sys/arch/amd64/conf

2022-09-01 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Sep  1 12:35:02 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Add commented out experimental PVH dom0 options and pseudo-device


To generate a diff of this commit:
cvs rdiff -u -r1.596 -r1.597 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.596 src/sys/arch/amd64/conf/GENERIC:1.597
--- src/sys/arch/amd64/conf/GENERIC:1.596	Sun Aug  7 02:52:23 2022
+++ src/sys/arch/amd64/conf/GENERIC	Thu Sep  1 12:35:02 2022
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.596 2022/08/07 02:52:23 simonb Exp $
+# $NetBSD: GENERIC,v 1.597 2022/09/01 12:35:02 bouyer Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.596 $"
+#ident		"GENERIC-$Revision: 1.597 $"
 
 maxusers	64		# estimated number of users
 
@@ -91,7 +91,7 @@ hyperv0 	at cpu0		# Microsoft Hyper-V
 powernow0	at cpu0		# AMD PowerNow! and Cool'n'Quiet (non-ACPI)
 vmt0		at cpu0		# VMware Tools
 
-#Xen PV support for HVM guests
+#Xen PV support for PVH and HVM guests
 options 	XENPVHVM
 options 	XEN
 hypervisor*	at mainbus?		# Xen hypervisor
@@ -99,6 +99,12 @@ xenbus*	 	at hypervisor?		# Xen virtual 
 xencons*	at hypervisor?		# Xen virtual console
 xennet*  	at xenbus?		# Xen virtual network interface
 xbd*		at xenbus?		# Xen virtual block device
+# experimental: PVH dom0 support
+#options 	DOM0OPS
+#pseudo-device  xenevt
+#pseudo-device  xvif
+#pseudo-device  xbdback
+
 
 # Alternate buffer queue strategies for better responsiveness under high
 # disk I/O load.



CVS commit: src/sys/arch/amd64/conf

2022-09-01 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Sep  1 12:35:02 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Add commented out experimental PVH dom0 options and pseudo-device


To generate a diff of this commit:
cvs rdiff -u -r1.596 -r1.597 src/sys/arch/amd64/conf/GENERIC

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



CVS commit: src/sys/arch/amd64/include

2022-08-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 22 13:21:47 UTC 2022

Modified Files:
src/sys/arch/amd64/include: msan.h

Log Message:
amd64/msan.h: Fix includes for private pmap.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/include/msan.h

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

Modified files:

Index: src/sys/arch/amd64/include/msan.h
diff -u src/sys/arch/amd64/include/msan.h:1.6 src/sys/arch/amd64/include/msan.h:1.7
--- src/sys/arch/amd64/include/msan.h:1.6	Wed Nov 18 16:13:34 2020
+++ src/sys/arch/amd64/include/msan.h	Mon Aug 22 13:21:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msan.h,v 1.6 2020/11/18 16:13:34 hannken Exp $	*/
+/*	$NetBSD: msan.h,v 1.7 2022/08/22 13:21:47 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019-2020 Maxime Villard, m00nbsd.net
@@ -32,8 +32,12 @@
 
 #include 
 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
 
 #ifdef __HAVE_PCPU_AREA
 #error "PCPU area not allowed with KMSAN"



CVS commit: src/sys/arch/amd64/include

2022-08-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 22 13:21:47 UTC 2022

Modified Files:
src/sys/arch/amd64/include: msan.h

Log Message:
amd64/msan.h: Fix includes for private pmap.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/include/msan.h

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



CVS commit: src/sys/arch/amd64

2022-08-21 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 21 14:05:52 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: prekern.c
src/sys/arch/amd64/stand/prekern: pdir.h prekern.h

Log Message:
Adapt to pmap/bootspace migrations.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amd64/amd64/prekern.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/stand/prekern/pdir.h
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/amd64/stand/prekern/prekern.h

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

Modified files:

Index: src/sys/arch/amd64/amd64/prekern.c
diff -u src/sys/arch/amd64/amd64/prekern.c:1.5 src/sys/arch/amd64/amd64/prekern.c:1.6
--- src/sys/arch/amd64/amd64/prekern.c:1.5	Sun Aug 12 15:31:01 2018
+++ src/sys/arch/amd64/amd64/prekern.c	Sun Aug 21 14:05:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: prekern.c,v 1.5 2018/08/12 15:31:01 maxv Exp $	*/
+/*	$NetBSD: prekern.c,v 1.6 2022/08/21 14:05:52 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -40,9 +40,12 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 

Index: src/sys/arch/amd64/stand/prekern/pdir.h
diff -u src/sys/arch/amd64/stand/prekern/pdir.h:1.7 src/sys/arch/amd64/stand/prekern/pdir.h:1.8
--- src/sys/arch/amd64/stand/prekern/pdir.h:1.7	Sat May 23 08:25:32 2020
+++ src/sys/arch/amd64/stand/prekern/pdir.h	Sun Aug 21 14:05:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pdir.h,v 1.7 2020/05/23 08:25:32 maxv Exp $	*/
+/*	$NetBSD: pdir.h,v 1.8 2022/08/21 14:05:52 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -70,7 +70,3 @@
 #define VA_SIGN_MASK		0x
 #define VA_SIGN_NEG(va)		((va) | VA_SIGN_MASK)
 
-#define pl1_i(va)	(((va) & L1_FRAME) >> L1_SHIFT)
-#define pl2_i(va)	(((va) & L2_FRAME) >> L2_SHIFT)
-#define pl3_i(va)	(((va) & L3_FRAME) >> L3_SHIFT)
-#define pl4_i(va)	(((va) & L4_FRAME) >> L4_SHIFT)

Index: src/sys/arch/amd64/stand/prekern/prekern.h
diff -u src/sys/arch/amd64/stand/prekern/prekern.h:1.24 src/sys/arch/amd64/stand/prekern/prekern.h:1.25
--- src/sys/arch/amd64/stand/prekern/prekern.h:1.24	Tue May  4 21:09:16 2021
+++ src/sys/arch/amd64/stand/prekern/prekern.h	Sun Aug 21 14:05:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: prekern.h,v 1.24 2021/05/04 21:09:16 khorben Exp $	*/
+/*	$NetBSD: prekern.h,v 1.25 2022/08/21 14:05:52 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -32,8 +32,12 @@
 #include 
 #include 
 #include 
+
+#include 
 #include 
 
+#include 
+
 #include "pdir.h"
 #include "redef.h"
 
@@ -59,34 +63,6 @@ typedef enum
 
 /* -- */
 
-#define BTSEG_NONE	0
-#define BTSEG_TEXT	1
-#define BTSEG_RODATA	2
-#define BTSEG_DATA	3
-#define BTSPACE_NSEGS	64
-struct bootspace {
-	struct {
-		vaddr_t va;
-		paddr_t pa;
-		size_t sz;
-	} head;
-	struct {
-		int type;
-		vaddr_t va;
-		paddr_t pa;
-		size_t sz;
-	} segs[BTSPACE_NSEGS];
-	struct {
-		vaddr_t va;
-		paddr_t pa;
-		size_t sz;
-	} boot;
-	vaddr_t spareva;
-	vaddr_t pdir;
-	vaddr_t smodule;
-	vaddr_t emodule;
-};
-
 /* console.c */
 void init_cons(void);
 void print_ext(int, char *);



CVS commit: src/sys/arch/amd64

2022-08-21 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 21 14:05:52 UTC 2022

Modified Files:
src/sys/arch/amd64/amd64: prekern.c
src/sys/arch/amd64/stand/prekern: pdir.h prekern.h

Log Message:
Adapt to pmap/bootspace migrations.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amd64/amd64/prekern.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/stand/prekern/pdir.h
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/amd64/stand/prekern/prekern.h

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



CVS commit: src/sys/arch/amd64/amd64

2022-06-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun 27 23:36:48 UTC 2022

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

Log Message:
amd64: Handle __syscall trap frames specially too.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/amd64/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/amd64/amd64/db_machdep.c
diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.12 src/sys/arch/amd64/amd64/db_machdep.c:1.13
--- src/sys/arch/amd64/amd64/db_machdep.c:1.12	Sun Jun 26 22:31:12 2022
+++ src/sys/arch/amd64/amd64/db_machdep.c	Mon Jun 27 23:36:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.12 2022/06/26 22:31:12 riastradh Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.13 2022/06/27 23:36:48 riastradh Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,7 +26,7 @@
  * rights to redistribute these changes.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.12 2022/06/26 22:31:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.13 2022/06/27 23:36:48 riastradh Exp $");
 
 #include 
 #include 
@@ -130,7 +130,7 @@ db_nextframe(long **nextframe, long **re
 	case SYSCALL:
 		tf = (struct trapframe *)argp;
 		syscallno = db_get_value((long)&tf->tf_rax, 8, false);
-		if (syscallno == SYS_syscall) {
+		if (syscallno == SYS_syscall || syscallno == SYS___syscall) {
 			syscallno = db_get_value((long)&tf->tf_rdi, 8, false);
 			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u"
 			" via SYS_syscall) ---\n",



CVS commit: src/sys/arch/amd64/amd64

2022-06-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun 27 23:36:48 UTC 2022

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

Log Message:
amd64: Handle __syscall trap frames specially too.


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

2022-06-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun 26 22:31:12 UTC 2022

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

Log Message:
amd64: Print effective syscall number for SYS_syscall stack traces.

This time with compile-testing, at least.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/amd64/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/amd64/amd64/db_machdep.c
diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.11 src/sys/arch/amd64/amd64/db_machdep.c:1.12
--- src/sys/arch/amd64/amd64/db_machdep.c:1.11	Sun Jun 26 22:29:28 2022
+++ src/sys/arch/amd64/amd64/db_machdep.c	Sun Jun 26 22:31:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.11 2022/06/26 22:29:28 riastradh Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.12 2022/06/26 22:31:12 riastradh Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,11 +26,12 @@
  * rights to redistribute these changes.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.11 2022/06/26 22:29:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.12 2022/06/26 22:31:12 riastradh Exp $");
 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -111,6 +112,7 @@ db_nextframe(long **nextframe, long **re
 	struct x86_64_frame *fp;
 	struct intrframe *ifp;
 	int traptype, trapno, err, i;
+	db_expr_t syscallno;
 
 	switch (is_trap) {
 	case NONE:
@@ -127,8 +129,16 @@ db_nextframe(long **nextframe, long **re
 
 	case SYSCALL:
 		tf = (struct trapframe *)argp;
-		(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
-		db_get_value((long)&tf->tf_rax, 8, false));
+		syscallno = db_get_value((long)&tf->tf_rax, 8, false);
+		if (syscallno == SYS_syscall) {
+			syscallno = db_get_value((long)&tf->tf_rdi, 8, false);
+			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u"
+			" via SYS_syscall) ---\n",
+			syscallno);
+		} else {
+			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
+			syscallno);
+		}
 		return 0;
 
 	case TRAP:



CVS commit: src/sys/arch/amd64/amd64

2022-06-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun 26 22:31:12 UTC 2022

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

Log Message:
amd64: Print effective syscall number for SYS_syscall stack traces.

This time with compile-testing, at least.


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

2022-06-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun 26 22:29:28 UTC 2022

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

Log Message:
Revert "amd64: Print effective syscall number for SYS_syscall stack traces."

Built the wrong kernel (arm64 is not amd64), oops.  Will redo.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/amd64/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/amd64/amd64/db_machdep.c
diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.10 src/sys/arch/amd64/amd64/db_machdep.c:1.11
--- src/sys/arch/amd64/amd64/db_machdep.c:1.10	Sun Jun 26 22:18:30 2022
+++ src/sys/arch/amd64/amd64/db_machdep.c	Sun Jun 26 22:29:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.10 2022/06/26 22:18:30 riastradh Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.11 2022/06/26 22:29:28 riastradh Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,7 +26,7 @@
  * rights to redistribute these changes.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.10 2022/06/26 22:18:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.11 2022/06/26 22:29:28 riastradh Exp $");
 
 #include 
 #include 
@@ -111,7 +111,6 @@ db_nextframe(long **nextframe, long **re
 	struct x86_64_frame *fp;
 	struct intrframe *ifp;
 	int traptype, trapno, err, i;
-	db_expr_t syscallno;
 
 	switch (is_trap) {
 	case NONE:
@@ -128,16 +127,8 @@ db_nextframe(long **nextframe, long **re
 
 	case SYSCALL:
 		tf = (struct trapframe *)argp;
-		syscallno = db_get_value((long)&tf->tf_rax, 8, false);
-		if (syscallno == SYS_syscall) {
-			syscallno = db_get_value((long)&tf->tf_rdi, 8, false);
-			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u"
-			" via SYS_syscall) ---\n",
-			syscallno);
-		} else {
-			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
-			syscallno);
-		}
+		(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
+		db_get_value((long)&tf->tf_rax, 8, false));
 		return 0;
 
 	case TRAP:



CVS commit: src/sys/arch/amd64/amd64

2022-06-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun 26 22:29:28 UTC 2022

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

Log Message:
Revert "amd64: Print effective syscall number for SYS_syscall stack traces."

Built the wrong kernel (arm64 is not amd64), oops.  Will redo.


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

2022-06-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun 26 22:18:30 UTC 2022

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

Log Message:
amd64: Print effective syscall number for SYS_syscall stack traces.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/amd64/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/amd64/amd64/db_machdep.c
diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.9 src/sys/arch/amd64/amd64/db_machdep.c:1.10
--- src/sys/arch/amd64/amd64/db_machdep.c:1.9	Mon Dec 13 01:25:29 2021
+++ src/sys/arch/amd64/amd64/db_machdep.c	Sun Jun 26 22:18:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.9 2021/12/13 01:25:29 chs Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.10 2022/06/26 22:18:30 riastradh Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,7 +26,7 @@
  * rights to redistribute these changes.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.9 2021/12/13 01:25:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.10 2022/06/26 22:18:30 riastradh Exp $");
 
 #include 
 #include 
@@ -111,6 +111,7 @@ db_nextframe(long **nextframe, long **re
 	struct x86_64_frame *fp;
 	struct intrframe *ifp;
 	int traptype, trapno, err, i;
+	db_expr_t syscallno;
 
 	switch (is_trap) {
 	case NONE:
@@ -127,8 +128,16 @@ db_nextframe(long **nextframe, long **re
 
 	case SYSCALL:
 		tf = (struct trapframe *)argp;
-		(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
-		db_get_value((long)&tf->tf_rax, 8, false));
+		syscallno = db_get_value((long)&tf->tf_rax, 8, false);
+		if (syscallno == SYS_syscall) {
+			syscallno = db_get_value((long)&tf->tf_rdi, 8, false);
+			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u"
+			" via SYS_syscall) ---\n",
+			syscallno);
+		} else {
+			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
+			syscallno);
+		}
 		return 0;
 
 	case TRAP:



CVS commit: src/sys/arch/amd64/amd64

2022-06-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun 26 22:18:30 UTC 2022

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

Log Message:
amd64: Print effective syscall number for SYS_syscall stack traces.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/amd64/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/amd64/conf

2022-05-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun May 29 08:06:40 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
Add missing Hyper-V devices from GENERIC.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/arch/amd64/conf/ALL

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

Modified files:

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.171 src/sys/arch/amd64/conf/ALL:1.172
--- src/sys/arch/amd64/conf/ALL:1.171	Fri May 13 10:45:24 2022
+++ src/sys/arch/amd64/conf/ALL	Sun May 29 08:06:40 2022
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.171 2022/05/13 10:45:24 msaitoh Exp $
+# $NetBSD: ALL,v 1.172 2022/05/29 08:06:40 rin Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.171 $"
+#ident		"ALL-$Revision: 1.172 $"
 
 maxusers	64		# estimated number of users
 
@@ -1575,6 +1575,18 @@ viornd* at virtio?			# Virtio entropy de
 vioscsi* at virtio?			# Virtio SCSI device
 vio9p*	at virtio?			# Virtio 9P device
 
+# Hyper-V devices
+vmbus*		at acpi?		# Hyper-V VMBus
+genfb*		at vmbus?		# Hyper-V Synthetic Video Framebuffer
+hvkbd*		at vmbus?		# Hyper-V Synthetic Keyboard
+wskbd*		at hvkbd? console ? mux 1
+hvn*		at vmbus?		# Hyper-V NetVSC
+hvs*		at vmbus?		# Hyper-V StorVSC
+hvheartbeat*	at vmbus?		# Hyper-V Heartbeat Service
+hvshutdown*	at vmbus?		# Hyper-V Guest Shutdown Service
+hvtimesync*	at vmbus?		# Hyper-V Time Synchronization Service
+#hvkvp*		at vmbus?		# Hyper-V Data Exchange Service
+
 # Flash subsystem
 flash* at flashbus?
 



CVS commit: src/sys/arch/amd64/conf

2022-05-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun May 29 08:06:40 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
Add missing Hyper-V devices from GENERIC.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/arch/amd64/conf/ALL

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



CVS commit: src/sys/arch/amd64/conf

2022-05-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 24 16:01:25 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOM0

Log Message:
Looks like we finally can enable MSI/MSI-X on Xen
Should fix PR kern/56793 and PR kern/55667


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/sys/arch/amd64/conf/XEN3_DOM0

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

Modified files:

Index: src/sys/arch/amd64/conf/XEN3_DOM0
diff -u src/sys/arch/amd64/conf/XEN3_DOM0:1.194 src/sys/arch/amd64/conf/XEN3_DOM0:1.195
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.194	Fri Sep 24 00:29:46 2021
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Tue May 24 16:01:25 2022
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.194 2021/09/24 00:29:46 manu Exp $
+# $NetBSD: XEN3_DOM0,v 1.195 2022/05/24 16:01:25 bouyer Exp $
 
 # XEN3_DOM0 machine description file
 #
@@ -14,7 +14,7 @@ include 	"arch/amd64/conf/std.xen"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"XEN3_DOM0-$Revision: 1.194 $"
+#ident		"XEN3_DOM0-$Revision: 1.195 $"
 
 maxusers	32		# estimated number of users
 
@@ -384,9 +384,6 @@ pci*	at hypervisor? bus ?
 pci*	at pchb? bus ?
 pci*	at ppb? bus ?
 
-# MSIX bugs with XEN3_DOM0: kern/55667, kern/56291
-options NO_PCI_MSI_MSIX
-
 # PCI bridges
 pchb*	at pci? dev ? function ?	# PCI-Host bridges
 #options 	AGP_X86			# INTENTIONAL OMISSION - crashes reported with agp



CVS commit: src/sys/arch/amd64/conf

2022-05-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 24 16:01:25 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOM0

Log Message:
Looks like we finally can enable MSI/MSI-X on Xen
Should fix PR kern/56793 and PR kern/55667


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/sys/arch/amd64/conf/XEN3_DOM0

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



CVS commit: src/sys/arch/amd64/conf

2022-05-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May  7 04:32:29 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
Add MODULAR_DEFAULT_VERBOSE.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/arch/amd64/conf/ALL

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



CVS commit: src/sys/arch/amd64/conf

2022-05-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May  7 04:32:29 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
Add MODULAR_DEFAULT_VERBOSE.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/arch/amd64/conf/ALL

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

Modified files:

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.169 src/sys/arch/amd64/conf/ALL:1.170
--- src/sys/arch/amd64/conf/ALL:1.169	Thu Dec 23 17:13:13 2021
+++ src/sys/arch/amd64/conf/ALL	Sat May  7 04:32:29 2022
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.169 2021/12/23 17:13:13 hannken Exp $
+# $NetBSD: ALL,v 1.170 2022/05/07 04:32:29 rin Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.169 $"
+#ident		"ALL-$Revision: 1.170 $"
 
 maxusers	64		# estimated number of users
 
@@ -97,6 +97,7 @@ options 	SYSVSHM		# System V-like memory
 
 options 	MODULAR		# new style module(7) framework
 options 	MODULAR_DEFAULT_AUTOLOAD
+options 	MODULAR_DEFAULT_VERBOSE
 
 options 	USERCONF	# userconf(4) support
 options 	PIPE_SOCKETPAIR	# smaller, but slower pipe(2)



CVS commit: src/sys/arch/amd64/conf

2021-11-29 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Nov 29 20:03:15 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOMU

Log Message:
enable UFS_ACL option for XEN3_DOMU, it's useful for e.g. running Samba in DomU

idea from Matthias Petermann via current-users@


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/amd64/conf/XEN3_DOMU

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

Modified files:

Index: src/sys/arch/amd64/conf/XEN3_DOMU
diff -u src/sys/arch/amd64/conf/XEN3_DOMU:1.97 src/sys/arch/amd64/conf/XEN3_DOMU:1.98
--- src/sys/arch/amd64/conf/XEN3_DOMU:1.97	Wed Jan 20 13:22:08 2021
+++ src/sys/arch/amd64/conf/XEN3_DOMU	Mon Nov 29 20:03:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOMU,v 1.97 2021/01/20 13:22:08 nia Exp $
+# $NetBSD: XEN3_DOMU,v 1.98 2021/11/29 20:03:15 jdolecek Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -11,7 +11,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOMU-$Revision: 1.97 $"
+#ident		"XEN3_DOMU-$Revision: 1.98 $"
 
 maxusers	32		# estimated number of users
 
@@ -80,6 +80,7 @@ options 	QUOTA2		# new, in-filesystem UF
 #options 	FFS_EI		# FFS Endian Independent support
 options 	WAPBL		# File system journaling support
 #options 	UFS_DIRHASH	# UFS Large Directory Hashing - Experimental
+options		UFS_ACL		# UFS Access Control Lists
 options 	NFSSERVER	# Network File System server
 #options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
 options 	UFS_EXTATTR	# Extended attribute support for UFS1



CVS commit: src/sys/arch/amd64/conf

2021-11-29 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Nov 29 20:03:15 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOMU

Log Message:
enable UFS_ACL option for XEN3_DOMU, it's useful for e.g. running Samba in DomU

idea from Matthias Petermann via current-users@


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/amd64/conf/XEN3_DOMU

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



CVS commit: src/sys/arch/amd64/conf

2021-11-24 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Nov 25 02:36:35 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
add missing options EXEC_ELF32


To generate a diff of this commit:
cvs rdiff -u -r1.167 -r1.168 src/sys/arch/amd64/conf/ALL

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

Modified files:

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.167 src/sys/arch/amd64/conf/ALL:1.168
--- src/sys/arch/amd64/conf/ALL:1.167	Tue Jun 29 10:22:34 2021
+++ src/sys/arch/amd64/conf/ALL	Thu Nov 25 02:36:35 2021
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.167 2021/06/29 10:22:34 nia Exp $
+# $NetBSD: ALL,v 1.168 2021/11/25 02:36:35 ryo Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.167 $"
+#ident		"ALL-$Revision: 1.168 $"
 
 maxusers	64		# estimated number of users
 
@@ -150,6 +150,7 @@ options 	COMPAT_OSSAUDIO	# OSS (Voxware)
 options 	COMPAT_NETBSD32 # NetBSD 32-bit
 options 	COMPAT_LINUX	# binary compatibility with Linux
 options 	COMPAT_LINUX32	# binary compatibility with Linux 32-bit
+options 	EXEC_ELF32
 
 # Wedge support
 options 	DKWEDGE_AUTODISCOVER	# Automatically add dk(4) instances



CVS commit: src/sys/arch/amd64/conf

2021-11-24 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Nov 25 02:36:35 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
add missing options EXEC_ELF32


To generate a diff of this commit:
cvs rdiff -u -r1.167 -r1.168 src/sys/arch/amd64/conf/ALL

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



CVS commit: src/sys/arch/amd64/conf

2021-10-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Oct 31 00:31:48 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
options


To generate a diff of this commit:
cvs rdiff -u -r1.592 -r1.593 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.592 src/sys/arch/amd64/conf/GENERIC:1.593
--- src/sys/arch/amd64/conf/GENERIC:1.592	Sat Oct 16 13:09:40 2021
+++ src/sys/arch/amd64/conf/GENERIC	Sun Oct 31 00:31:48 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.592 2021/10/16 13:09:40 jmcneill Exp $
+# $NetBSD: GENERIC,v 1.593 2021/10/31 00:31:48 simonb Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.592 $"
+#ident		"GENERIC-$Revision: 1.593 $"
 
 maxusers	64		# estimated number of users
 
@@ -138,7 +138,7 @@ options 	KDTRACE_HOOKS	# kernel DTrace h
 # Use KASAN_PANIC if you want panics instead of warnings.
 #makeoptions 	KASAN=1		# mandatory
 #options 	KASAN		# mandatory
-#no options	SVS		# mandatory
+#no options 	SVS		# mandatory
 #options 	POOL_QUARANTINE	# optional
 #options 	KASAN_PANIC	# optional
 
@@ -152,7 +152,7 @@ options 	KDTRACE_HOOKS	# kernel DTrace h
 # memory in pool caches. Note that KMSAN requires at least 4GB of RAM.
 #makeoptions 	KMSAN=1		# mandatory
 #options 	KMSAN		# mandatory
-#no options	SVS		# mandatory
+#no options 	SVS		# mandatory
 #no options 	MODULAR		# mandatory
 #no options 	MODULAR_DEFAULT_AUTOLOAD	# mandatory
 #options 	POOL_NOCACHE	# optional
@@ -201,7 +201,7 @@ options 	WAPBL		# File system journaling
 # Note that UFS_DIRHASH is suspected of causing kernel memory corruption.
 # It is not recommended for general use.
 #options 	UFS_DIRHASH	# UFS Large Directory Hashing - Experimental
-options		UFS_ACL		# UFS Access Control Lists
+options 	UFS_ACL		# UFS Access Control Lists
 #options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
 options 	UFS_EXTATTR	# Extended attribute support for UFS1
 # ext2fs
@@ -1153,7 +1153,7 @@ options 	RAID_AUTOCONFIG		# auto-configu
 pseudo-device	fss			# file system snapshot device
 
 pseudo-device	md			# memory disk device (ramdisk)
-options		MEMORY_DISK_HOOKS	# enable md specific hooks
+options 	MEMORY_DISK_HOOKS	# enable md specific hooks
 options 	MEMORY_DISK_DYNAMIC	# enable dynamic resizing
 
 pseudo-device	vnd			# disk-like interface to files



CVS commit: src/sys/arch/amd64/conf

2021-10-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Oct 31 00:31:48 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
options


To generate a diff of this commit:
cvs rdiff -u -r1.592 -r1.593 src/sys/arch/amd64/conf/GENERIC

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



CVS commit: src/sys/arch/amd64/conf

2021-10-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 16 13:09:41 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Enable com and lpt at ACPI attachments.


To generate a diff of this commit:
cvs rdiff -u -r1.591 -r1.592 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.591 src/sys/arch/amd64/conf/GENERIC:1.592
--- src/sys/arch/amd64/conf/GENERIC:1.591	Fri Oct 15 19:22:12 2021
+++ src/sys/arch/amd64/conf/GENERIC	Sat Oct 16 13:09:40 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.591 2021/10/15 19:22:12 jmcneill Exp $
+# $NetBSD: GENERIC,v 1.592 2021/10/16 13:09:40 jmcneill Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.591 $"
+#ident		"GENERIC-$Revision: 1.592 $"
 
 maxusers	64		# estimated number of users
 
@@ -337,7 +337,9 @@ acpiwmi*	at acpi?		# ACPI WMI Mapper
 aibs*		at acpi?		# ASUSTeK AI Booster hardware monitor
 asus*		at acpi?		# ASUS hotkeys
 attimer*	at acpi?		# AT Timer
-#com*		at acpi?		# Serial communications interface
+com0		at acpi?		# Serial communications interface
+com1		at acpi?		# Serial communications interface
+com*		at acpi?		# Serial communications interface
 fdc*		at acpi?		# Floppy disk controller
 fd*		at fdc? drive ?		# the drives themselves
 fujbp*		at acpi?		# Fujitsu Brightness & Pointer
@@ -347,7 +349,9 @@ fujhk*		at acpi?		# Fujitsu Hotkeys
 hpet*		at acpihpetbus?		# High Precision Event Timer (table)
 hpet*		at acpinodebus?		# High Precision Event Timer (device)
 joy*		at acpi?		# Joystick/Game port
-#lpt*		at acpi?		# Parallel port
+lpt0		at acpi?		# Parallel port
+lpt1		at acpi?		# Parallel port
+lpt*		at acpi?		# Parallel port
 mpu*		at acpi?		# Roland MPU-401 MIDI UART
 pckbc*		at acpi?		# PC keyboard controller
 pcppi*		at acpi?		# AT-style speaker sound



CVS commit: src/sys/arch/amd64/conf

2021-10-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 16 13:09:41 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Enable com and lpt at ACPI attachments.


To generate a diff of this commit:
cvs rdiff -u -r1.591 -r1.592 src/sys/arch/amd64/conf/GENERIC

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



CVS commit: src/sys/arch/amd64/conf

2021-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 15 19:22:12 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Swap fdc@isa for fdc@acpi as the former takes over a second to probe.


To generate a diff of this commit:
cvs rdiff -u -r1.590 -r1.591 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.590 src/sys/arch/amd64/conf/GENERIC:1.591
--- src/sys/arch/amd64/conf/GENERIC:1.590	Thu Sep  9 13:22:50 2021
+++ src/sys/arch/amd64/conf/GENERIC	Fri Oct 15 19:22:12 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.590 2021/09/09 13:22:50 jakllsch Exp $
+# $NetBSD: GENERIC,v 1.591 2021/10/15 19:22:12 jmcneill Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.590 $"
+#ident		"GENERIC-$Revision: 1.591 $"
 
 maxusers	64		# estimated number of users
 
@@ -338,7 +338,8 @@ aibs*		at acpi?		# ASUSTeK AI Booster ha
 asus*		at acpi?		# ASUS hotkeys
 attimer*	at acpi?		# AT Timer
 #com*		at acpi?		# Serial communications interface
-#fdc*		at acpi?		# Floppy disk controller
+fdc*		at acpi?		# Floppy disk controller
+fd*		at fdc? drive ?		# the drives themselves
 fujbp*		at acpi?		# Fujitsu Brightness & Pointer
 fujhk*		at acpi?		# Fujitsu Hotkeys
 #hpacel* 	at acpi?		# HP 3D DriveGuard accelerometer
@@ -784,11 +785,8 @@ ld*	at nvme? nsid ?
 # Miscellaneous mass storage devices
 
 # ISA floppy
-fdc0	at isa? port 0x3f0 irq 6 drq 2	# standard PC floppy controllers
+#fdc0	at isa? port 0x3f0 irq 6 drq 2	# standard PC floppy controllers
 #fdc1	at isa? port 0x370 irq ? drq ?
-fd*	at fdc? drive ?			# the drives themselves
-# some machines need you to do this instead of fd*
-#fd0	at fdc0 drive 0
 
 # Network Interfaces
 



CVS commit: src/sys/arch/amd64/conf

2021-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 15 19:22:12 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Swap fdc@isa for fdc@acpi as the former takes over a second to probe.


To generate a diff of this commit:
cvs rdiff -u -r1.590 -r1.591 src/sys/arch/amd64/conf/GENERIC

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



CVS commit: src/sys/arch/amd64/conf

2021-09-23 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 24 00:29:46 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOM0

Log Message:
Move XEN3_DOM0 as close as possible to GENERIC.
Document why some options are disabled
Set NO_PCI_MSI_MSIX to work around crashes reported in multiple PR


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/sys/arch/amd64/conf/XEN3_DOM0

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

Modified files:

Index: src/sys/arch/amd64/conf/XEN3_DOM0
diff -u src/sys/arch/amd64/conf/XEN3_DOM0:1.193 src/sys/arch/amd64/conf/XEN3_DOM0:1.194
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.193	Tue Jun 29 10:22:34 2021
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Fri Sep 24 00:29:46 2021
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.193 2021/06/29 10:22:34 nia Exp $
+# $NetBSD: XEN3_DOM0,v 1.194 2021/09/24 00:29:46 manu Exp $
 
 # XEN3_DOM0 machine description file
 #
@@ -14,7 +14,7 @@ include 	"arch/amd64/conf/std.xen"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"XEN3_DOM0-$Revision: 1.193 $"
+#ident		"XEN3_DOM0-$Revision: 1.194 $"
 
 maxusers	32		# estimated number of users
 
@@ -86,14 +86,15 @@ options 	SYSVSEM		# System V-like semaph
 options 	SYSVSHM		# System V-like memory sharing
 
 options 	MODULAR		# new style module(7) framework
-#options 	MODULAR_DEFAULT_AUTOLOAD
+options 	MODULAR_DEFAULT_AUTOLOAD
 options 	USERCONF	# userconf(4) support
 #options 	PIPE_SOCKETPAIR	# smaller, but slower pipe(2)
 options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 
 # CPU features
 #acpicpu*	at cpu?		# ACPI CPU (including frequency scaling)
-#coretemp*	at cpu?		# Intel on-die thermal sensor
+# needs x86_cpu_idle_halt in cpu.c (!xenpv)
+coretemp*	at cpu?		# Intel on-die thermal sensor
 est0		at cpu0		# Intel Enhanced SpeedStep (non-ACPI)
 #hyperv0 	at cpu0		# Microsoft Hyper-V
 #odcm0		at cpu0		# On-demand clock modulation
@@ -117,16 +118,17 @@ options 	DIAGNOSTIC	# inexpensive kernel
 #
 makeoptions	COPTS="-O2 -fno-omit-frame-pointer"
 options 	DDB		# in-kernel debugger
-options		DDB_COMMANDONENTER="show registers"
-options 	DDB_ONPANIC=1	# see also sysctl(7): `ddb.onpanic'
+#options 	DDB_COMMANDONENTER="bt"	# execute command when ddb is entered
+#options 	DDB_ONPANIC=1	# see also sysctl(7): `ddb.onpanic'
 options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB
 #options 	KGDB		# remote debugger
 #options 	KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x2f8,KGDB_DEVRATE=57600
-#makeoptions	DEBUG="-g"	# compile full symbol table
+makeoptions	DEBUG="-g"	# compile full symbol table for CTF
+options DDB_COMMANDONENTER="trace;show registers"
 #options 	SYSCALL_STATS	# per syscall counts
 #options 	SYSCALL_TIMES	# per syscall times
 #options 	SYSCALL_TIMES_HASCOUNTER	# use 'broken' rdtsc (soekris)
-#options 	KDTRACE_HOOKS	# kernel DTrace hooks
+options 	KDTRACE_HOOKS	# kernel DTrace hooks
 
 # Kernel Undefined Behavior Sanitizer (kUBSan).
 #options 	KUBSAN			# mandatory
@@ -195,19 +197,19 @@ include "conf/filesystems.config"
 # ffs
 options 	QUOTA		# legacy UFS quotas
 options 	QUOTA2		# new, in-filesystem UFS quotas
-#options 	FFS_EI		# FFS Endian Independent support
+options 	FFS_EI		# FFS Endian Independent support
 options 	WAPBL		# File system journaling support
 # Note that UFS_DIRHASH is suspected of causing kernel memory corruption.
 # It is not recommended for general use.
 #options 	UFS_DIRHASH	# UFS Large Directory Hashing - Experimental
-#options		UFS_ACL		# UFS Access Control Lists
+options		UFS_ACL		# UFS Access Control Lists
 #options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
 options 	UFS_EXTATTR	# Extended attribute support for UFS1
 # ext2fs
 #options 	EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
 # immutable) behave as system flags.
 # other
-#options 	DISKLABEL_EI	# disklabel Endian Independent support
+options 	DISKLABEL_EI	# disklabel Endian Independent support
 options 	NFSSERVER	# Network File System server
 
 # Networking options
@@ -252,12 +254,6 @@ options 	SCSIVERBOSE	# human readable SC
 #options 	HDAUDIOVERBOSE	# verbose HDAUDIO driver messages
 
 options 	NFS_BOOT_DHCP,NFS_BOOT_BOOTPARAM
-#options 	NFS_BOOT_BOOTSTATIC
-#options 	NFS_BOOTSTATIC_MYIP="\"169.254.1.2\""
-#options 	NFS_BOOTSTATIC_GWIP="\"169.254.1.1\""
-#options 	NFS_BOOTSTATIC_MASK="\"255.255.255.0\""
-#options 	NFS_BOOTSTATIC_SERVADDR="\"169.254.1.1\""
-#options 	NFS_BOOTSTATIC_SERVER="\"server:/path/to/root\""
 
 #
 # wscons options
@@ -329,11 +325,7 @@ options 	MPBIOS_SCANPCI		# MPBIOS config
 #options 	PCI_BUS_FIXUP		# fixup PCI bus numbering
 #options 	PCI_ADDR_FIXUP		# fixup PCI I/O addresses
 #options 	ACPI_ACTIVATE_DEV	# If set, activate inactive devices
-#options 	VGA_POST		# in-kernel support for VGA POST
-
-#options 	ACPICA_PEDANTIC		# force strict conformance to the Spec.
-#options 	MPDEBUG			# MPBIOS configures PCI roots
-#options 	MPVERBOS

CVS commit: src/sys/arch/amd64/conf

2021-09-23 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 24 00:29:46 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: XEN3_DOM0

Log Message:
Move XEN3_DOM0 as close as possible to GENERIC.
Document why some options are disabled
Set NO_PCI_MSI_MSIX to work around crashes reported in multiple PR


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/sys/arch/amd64/conf/XEN3_DOM0

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



CVS commit: src/sys/arch/amd64/conf

2021-09-09 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Sep  9 13:22:50 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Enable WSDISPLAY_CUSTOM_OUTPUT and WSDISPLAY_CUSTOM_BORDER on
amd64 GENERIC as i386 GENERIC already does.


To generate a diff of this commit:
cvs rdiff -u -r1.589 -r1.590 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.589 src/sys/arch/amd64/conf/GENERIC:1.590
--- src/sys/arch/amd64/conf/GENERIC:1.589	Mon May 17 04:07:42 2021
+++ src/sys/arch/amd64/conf/GENERIC	Thu Sep  9 13:22:50 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.589 2021/05/17 04:07:42 yamaguchi Exp $
+# $NetBSD: GENERIC,v 1.590 2021/09/09 13:22:50 jakllsch Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.589 $"
+#ident		"GENERIC-$Revision: 1.590 $"
 
 maxusers	64		# estimated number of users
 
@@ -262,8 +262,11 @@ options 	WSEMUL_VT100		# VT100 / VT220 e
 #options 	WSEMUL_SUN		# sun terminal emulation
 #options 	WSEMUL_DEFAULT="\"vt100\""  # NB: default is "sun" if enabled
 # different kernel output - see dev/wscons/wsdisplayvar.h
+options 	WSDISPLAY_CUSTOM_OUTPUT	# color customization from wsconsctl(8)
 options 	WS_KERNEL_FG=WSCOL_GREEN
 #options 	WS_KERNEL_BG=WSCOL_BLACK
+# customization of console border color
+options 	WSDISPLAY_CUSTOM_BORDER	# custom border colors via wsconsctl(8)
 # compatibility to other console drivers
 options 	WSDISPLAY_COMPAT_PCVT		# emulate some ioctls
 options 	WSDISPLAY_COMPAT_SYSCONS	# emulate some ioctls



CVS commit: src/sys/arch/amd64/conf

2021-09-09 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Sep  9 13:22:50 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Enable WSDISPLAY_CUSTOM_OUTPUT and WSDISPLAY_CUSTOM_BORDER on
amd64 GENERIC as i386 GENERIC already does.


To generate a diff of this commit:
cvs rdiff -u -r1.589 -r1.590 src/sys/arch/amd64/conf/GENERIC

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



Re: CVS commit: src/sys/arch/amd64/conf

2021-03-05 Thread Greg Troxel

matthew green  writes:

> could this be done with include and "no foo" statement?
> eg, like sys/arch/sparc/conf/INSTALL does.

Maybe, but I'm not sure it will end up working.  Right now we don't know
if any of the missing things will be trouble, and even if we do move to
include/no I'd like to do that via an intermediate step of a config with
small differences.

Also I think we should also consider extracting lots of things into
includable files, similar to how

  include "dev/usb/usbdevices.config"

is used now in GENERIC.   That will raise interesting cross-arch issues
about value vs kernel memory usage probably.

These include files would allow a simplification of XEN3_DOMU which as I
see it should have ~no drivers but all the rest of the options.


signature.asc
Description: PGP signature


re: CVS commit: src/sys/arch/amd64/conf

2021-03-05 Thread matthew green
"Greg Troxel" writes:
> Module Name:  src
> Committed By: gdt
> Date: Fri Mar  5 20:30:56 UTC 2021
>
> Modified Files:
>   src/sys/arch/amd64/conf: XEN3_DOM0
>
> Log Message:
> XEN3_DOM0: Approach GENERIC
>
> When processed to remove comments, blank lines, normalize whitespace,
> and sort/uniq (one line was previously duplicated), this file is
> identical to the previous version.  It has been reorganized to reduce
> diffs to GENERIC, and many missing lines from GENERIC have been added
> but commented out.

could this be done with include and "no foo" statement?
eg, like sys/arch/sparc/conf/INSTALL does.


.mrg.


Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-04 Thread Kamil Rytarowski
On 04.06.2020 23:41, Andrew Doran wrote:
> On Thu, Jun 04, 2020 at 02:35:17AM +0200, Kamil Rytarowski wrote:
> 
>> On 04.06.2020 00:42, Andrew Doran wrote:
>>> On Wed, Jun 03, 2020 at 02:03:22AM +0200, Kamil Rytarowski wrote:
>>>
 On 03.06.2020 01:49, Andrew Doran wrote:
> On the assembly thing recall that recently you expressed a desire to 
> remove
> all of the amd64 assembly string functions from libc because of 
> sanitizers -
> I invested my time to do up a little demo to try and show you why that's 
> not
> a good idea:
>
>   http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html

 Please note that interceptors for string functions are not just some
 extra burden, but also very useful approach to feedback a fuzzer through
 additional coverage.

 At least libFuzzer and honggfuzz wrap many kinds of string functions and
 use it for fuzzing. We should add a special mode in KCOV to feedback
 userland (syzkaller) with traces from string functions.

 https://github.com/google/honggfuzz/blob/bbb476eec95ad927d6d7d3d367d2b3e38eed3569/libhfuzz/memorycmp.c#L24
>>>
>>> No argument from me there at all.  I think that's a great idea and was
>>> looking at the interceptors in TSAN recently to see how they work.
>>>
>>> Andrew
>>>
>>
>> My note was not about switching away from ASM functions for certain
>> functions, but rather giving an option to disable them under a sanitizer
>> and adding an interceptor that can be useful for feedbacking a fuzzer.
>> It's still not clear whether we will create such interface in KCOV as it
>> has to be coordinated with Google+Linux as we would like to have a
>> compatible interface for syzkaller.
>>
>> TSAN - do you mean the userland ones?
> 
> Right, the userland one.
>  

Great.

We used to pass around 95% of upstream LLVM TSan tests. The remaining
ones were hard and I had no time to look into them.

>> BTW. There is a work-in-progress MKSANITIZER support for TSan, but it
>> used to create unkillable processes (kernel bug). Basically when using a
>> TSanitized userland applications, you will quickly end up with such
>> processes (from AFAIR calling ls(1) and other simple applications are
>> enough).
>>
>> If you are interested, I can share a reproducer.
> 
> Yes please.  Is the setup difficult?  I plan to look at some of the
> remaining issues noted on syzbot over the next while too.
> 

 ./build.sh -j8 -N0 -U -u -V MAKECONF=/dev/null -V MKCOMPAT=no -V
MKDEBUGLIB=yes -V MKDEBUG=yes -V MKSANITIZER=yes -V USE_SANITIZER=thread
-V MKLLVM=yes -V MKGCC=no -V HAVE_LLVM=yes -O /public/netbsd.fuzzer
distribution

Null mount /dev /dev/pts /tmp and chroot into it.

Try to run some basic applications and see creation unkillable
processes. Unless that was fixed by an accident/indirectly, you will
quickly reproduce it.

> Cheers,
> Andrew
> 



Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-04 Thread Andrew Doran
On Thu, Jun 04, 2020 at 02:35:17AM +0200, Kamil Rytarowski wrote:

> On 04.06.2020 00:42, Andrew Doran wrote:
> > On Wed, Jun 03, 2020 at 02:03:22AM +0200, Kamil Rytarowski wrote:
> > 
> >> On 03.06.2020 01:49, Andrew Doran wrote:
> >>> On the assembly thing recall that recently you expressed a desire to 
> >>> remove
> >>> all of the amd64 assembly string functions from libc because of 
> >>> sanitizers -
> >>> I invested my time to do up a little demo to try and show you why that's 
> >>> not
> >>> a good idea:
> >>>
> >>>   http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html
> >>
> >> Please note that interceptors for string functions are not just some
> >> extra burden, but also very useful approach to feedback a fuzzer through
> >> additional coverage.
> >>
> >> At least libFuzzer and honggfuzz wrap many kinds of string functions and
> >> use it for fuzzing. We should add a special mode in KCOV to feedback
> >> userland (syzkaller) with traces from string functions.
> >>
> >> https://github.com/google/honggfuzz/blob/bbb476eec95ad927d6d7d3d367d2b3e38eed3569/libhfuzz/memorycmp.c#L24
> > 
> > No argument from me there at all.  I think that's a great idea and was
> > looking at the interceptors in TSAN recently to see how they work.
> > 
> > Andrew
> > 
> 
> My note was not about switching away from ASM functions for certain
> functions, but rather giving an option to disable them under a sanitizer
> and adding an interceptor that can be useful for feedbacking a fuzzer.
> It's still not clear whether we will create such interface in KCOV as it
> has to be coordinated with Google+Linux as we would like to have a
> compatible interface for syzkaller.
> 
> TSAN - do you mean the userland ones?

Right, the userland one.
 
> BTW. There is a work-in-progress MKSANITIZER support for TSan, but it
> used to create unkillable processes (kernel bug). Basically when using a
> TSanitized userland applications, you will quickly end up with such
> processes (from AFAIR calling ls(1) and other simple applications are
> enough).
> 
> If you are interested, I can share a reproducer.

Yes please.  Is the setup difficult?  I plan to look at some of the
remaining issues noted on syzbot over the next while too.

Cheers,
Andrew


Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-03 Thread Kamil Rytarowski
On 04.06.2020 00:42, Andrew Doran wrote:
> On Wed, Jun 03, 2020 at 02:03:22AM +0200, Kamil Rytarowski wrote:
> 
>> On 03.06.2020 01:49, Andrew Doran wrote:
>>> On the assembly thing recall that recently you expressed a desire to remove
>>> all of the amd64 assembly string functions from libc because of sanitizers -
>>> I invested my time to do up a little demo to try and show you why that's not
>>> a good idea:
>>>
>>> http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html
>>
>> Please note that interceptors for string functions are not just some
>> extra burden, but also very useful approach to feedback a fuzzer through
>> additional coverage.
>>
>> At least libFuzzer and honggfuzz wrap many kinds of string functions and
>> use it for fuzzing. We should add a special mode in KCOV to feedback
>> userland (syzkaller) with traces from string functions.
>>
>> https://github.com/google/honggfuzz/blob/bbb476eec95ad927d6d7d3d367d2b3e38eed3569/libhfuzz/memorycmp.c#L24
> 
> No argument from me there at all.  I think that's a great idea and was
> looking at the interceptors in TSAN recently to see how they work.
> 
> Andrew
> 

My note was not about switching away from ASM functions for certain
functions, but rather giving an option to disable them under a sanitizer
and adding an interceptor that can be useful for feedbacking a fuzzer.
It's still not clear whether we will create such interface in KCOV as it
has to be coordinated with Google+Linux as we would like to have a
compatible interface for syzkaller.

TSAN - do you mean the userland ones?

BTW. There is a work-in-progress MKSANITIZER support for TSan, but it
used to create unkillable processes (kernel bug). Basically when using a
TSanitized userland applications, you will quickly end up with such
processes (from AFAIR calling ls(1) and other simple applications are
enough).

If you are interested, I can share a reproducer.


Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-03 Thread Andrew Doran
Maxime,

I read your e-mail carefully and conclude that the best way forward here is
put this one to core@ for a technical decision.

Cheers,
Andrew

On Wed, Jun 03, 2020 at 08:25:32AM +0200, Maxime Villard wrote:
> Le 03/06/2020 ? 01:49, Andrew Doran a ?crit?:
> > On Tue, Jun 02, 2020 at 08:41:53AM +0200, Maxime Villard wrote:
> > 
> > > Le 02/06/2020 ? 00:58, Andrew Doran a ?crit?:
> > > > Module Name:src
> > > > Committed By:   ad
> > > > Date:   Mon Jun  1 22:58:06 UTC 2020
> > > > 
> > > > Modified Files:
> > > > src/sys/arch/amd64/amd64: cpufunc.S
> > > > src/sys/arch/amd64/include: frameasm.h
> > > > 
> > > > Log Message:
> > > > Reported-by: syzbot+6dd5a230d19f0cbc7...@syzkaller.appspotmail.com
> > > > 
> > > > Instrument STOS/MOVS for KMSAN to unbreak it.
> > > > 
> > > > 
> > > > To generate a diff of this commit:
> > > > cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amd64/amd64/cpufunc.S
> > > > cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amd64/include/frameasm.h
> > > > 
> > > > Please note that diffs are not public domain; they are subject to the
> > > > copyright notices on the relevant files.
> > > 
> > > Can you just stop ignoring the remarks that are made?
> > 
> > That's up to you Maxime.  If you habitually make it difficult for people to
> > come to a reasonable compromise with you, then you're asking to not be taken
> > seriously and will find yourself being ignored.
> 
> You are confused. I asked for KMSAN to be unbroken, and proposed an 
> alternative,
> which is atomic_load_relaxed. You were free to explain why my point was a bad
> idea or why it didn't matter, but you refused, and just added a hack on top of
> another. I'm afraid that's up to you.
> 
> But whatever, it doesn't matter. Thanks for reverting the pmap.c changes, it
> is more correct now than before.
> 
> > > I said explicitly
> > > that adding manual instrumentation here is _wrong_.
> > 
> > I don't share your assessment in the general sense.  It should be possible
> > to instrument assembly code because KMSAN is useful AND we can't get by
> > without assembly - there are some things that C just can't do (or do well
> > enough).
> > 
> > On the assembly thing recall that recently you expressed a desire to remove
> > all of the amd64 assembly string functions from libc because of sanitizers -
> > I invested my time to do up a little demo to try and show you why that's not
> > a good idea:
> > 
> > http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html
> 
> I saw, yes. I answered explaining that a conversation with Ryo Shimizu had
> changed my mind a bit, and seeing your results (which as far as I can tell
> do not indicate a performance improvement significant enough to not be
> considered as noise), I asked you whether it was that relevant. You didn't
> follow up though.
> 
> > The system is a balancing act.  There are lots of factors to be taken into
> > account: maintainability, tooling like KMSAN, user's varying needs, the
> > capabilites of different machines, performance, feature set and so on, and
> > dare I say it even the enjoyment of the people working on the project is
> > important too.  Myopic focus on one factor only to the detriment of others
> > is no good.
> 
> I am well aware of that.
> 
> > > The kMSan ASM fixups
> > > are limited to args/returns, and that is part of a sensical policy that
> > > _should not_ be changed without a good reason.
> > > 
> > > x86_movs/x86_stos have strictly _no reason_ to exist. Of the 18 
> > > conversions
> > > you made to them in pmap.c, not one is justified. memcpy/memset were all
> > > correct.
> > 
> > I introduced these functions as a compromise because you were unhappy with
> > use of memcpy() to copy PDEs.  See:
> > 
> > http://mail-index.netbsd.org/port-amd64/2020/05/23/msg003280.html
> > 
> > You wrote:
> > 
> > In the [XXX] window, the PTEs could be used by userland.  If you
> > copied them using memcpy(), some parts of the bytes could contain
> > stale values.
> 
> Sure, I was explicitly referring to SVS, which has an unusual way of
> accessing PTEs (contrary to pmap), which is why it needs special atomic
> care that other places do not.
> 
> > Live PDEs are also copied in pmap.c so I made a change there too.  After
> > that I decided "why not" and used the new functions everywhere PDEs/PTEs or
> > pages are block zeroed / copied.  But I'm also happy with memcpy()/memset().
> > Either way will work.  In fairness I do work too fast sometimes.
> > 
> > > The only reason you made these big unneeded changes is for SVS not to take
> > > the bus lock,
> > 
> > There is no bus lock on x86 (not since the 1990s anyway).
> > 
> > > but as was said already, atomic_load_relaxed will do what
> > > you want without the need for these functions.
> > > 
> > > Please revert _both changes now_, this one and the previous one which
> > > introduced both functions, and let's use atomic_load_relaxed.
> > 
> > You're focusing on only o

Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-03 Thread Andrew Doran
On Wed, Jun 03, 2020 at 02:03:22AM +0200, Kamil Rytarowski wrote:

> On 03.06.2020 01:49, Andrew Doran wrote:
> > On the assembly thing recall that recently you expressed a desire to remove
> > all of the amd64 assembly string functions from libc because of sanitizers -
> > I invested my time to do up a little demo to try and show you why that's not
> > a good idea:
> > 
> > http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html
> 
> Please note that interceptors for string functions are not just some
> extra burden, but also very useful approach to feedback a fuzzer through
> additional coverage.
>
> At least libFuzzer and honggfuzz wrap many kinds of string functions and
> use it for fuzzing. We should add a special mode in KCOV to feedback
> userland (syzkaller) with traces from string functions.
> 
> https://github.com/google/honggfuzz/blob/bbb476eec95ad927d6d7d3d367d2b3e38eed3569/libhfuzz/memorycmp.c#L24

No argument from me there at all.  I think that's a great idea and was
looking at the interceptors in TSAN recently to see how they work.

Andrew


Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-02 Thread Maxime Villard

Le 03/06/2020 à 02:03, Kamil Rytarowski a écrit :

On 03.06.2020 01:49, Andrew Doran wrote:

On the assembly thing recall that recently you expressed a desire to remove
all of the amd64 assembly string functions from libc because of sanitizers -
I invested my time to do up a little demo to try and show you why that's not
a good idea:

http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html


Please note that interceptors for string functions are not just some
extra burden, but also very useful approach to feedback a fuzzer through
additional coverage.

At least libFuzzer and honggfuzz wrap many kinds of string functions and
use it for fuzzing. We should add a special mode in KCOV to feedback
userland (syzkaller) with traces from string functions.

https://github.com/google/honggfuzz/blob/bbb476eec95ad927d6d7d3d367d2b3e38eed3569/libhfuzz/memorycmp.c#L24


Yes, and not just that either.

When you use ASM instead of C, you basically prevent _any kind_ of useful
transformation the compiler could make.

It includes sanitizers, but also coverage as you said; and also retpoline,
PAC, BTI, CET, SafeStack, and in short, a very big bunch of modern
features.

Favoring C rather than ASM in the general sense offers much bigger
benefits than just "it accomodates kMSan".

Maxime


Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-02 Thread Maxime Villard

Le 03/06/2020 à 01:49, Andrew Doran a écrit :

On Tue, Jun 02, 2020 at 08:41:53AM +0200, Maxime Villard wrote:


Le 02/06/2020 ? 00:58, Andrew Doran a ?crit?:

Module Name:src
Committed By:   ad
Date:   Mon Jun  1 22:58:06 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/amd64/include: frameasm.h

Log Message:
Reported-by: syzbot+6dd5a230d19f0cbc7...@syzkaller.appspotmail.com

Instrument STOS/MOVS for KMSAN to unbreak it.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amd64/include/frameasm.h

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


Can you just stop ignoring the remarks that are made?


That's up to you Maxime.  If you habitually make it difficult for people to
come to a reasonable compromise with you, then you're asking to not be taken
seriously and will find yourself being ignored.


You are confused. I asked for KMSAN to be unbroken, and proposed an alternative,
which is atomic_load_relaxed. You were free to explain why my point was a bad
idea or why it didn't matter, but you refused, and just added a hack on top of
another. I'm afraid that's up to you.

But whatever, it doesn't matter. Thanks for reverting the pmap.c changes, it
is more correct now than before.


I said explicitly
that adding manual instrumentation here is _wrong_.


I don't share your assessment in the general sense.  It should be possible
to instrument assembly code because KMSAN is useful AND we can't get by
without assembly - there are some things that C just can't do (or do well
enough).

On the assembly thing recall that recently you expressed a desire to remove
all of the amd64 assembly string functions from libc because of sanitizers -
I invested my time to do up a little demo to try and show you why that's not
a good idea:

http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html


I saw, yes. I answered explaining that a conversation with Ryo Shimizu had
changed my mind a bit, and seeing your results (which as far as I can tell
do not indicate a performance improvement significant enough to not be
considered as noise), I asked you whether it was that relevant. You didn't
follow up though.


The system is a balancing act.  There are lots of factors to be taken into
account: maintainability, tooling like KMSAN, user's varying needs, the
capabilites of different machines, performance, feature set and so on, and
dare I say it even the enjoyment of the people working on the project is
important too.  Myopic focus on one factor only to the detriment of others
is no good.


I am well aware of that.


The kMSan ASM fixups
are limited to args/returns, and that is part of a sensical policy that
_should not_ be changed without a good reason.

x86_movs/x86_stos have strictly _no reason_ to exist. Of the 18 conversions
you made to them in pmap.c, not one is justified. memcpy/memset were all
correct.


I introduced these functions as a compromise because you were unhappy with
use of memcpy() to copy PDEs.  See:

http://mail-index.netbsd.org/port-amd64/2020/05/23/msg003280.html

You wrote:

In the [XXX] window, the PTEs could be used by userland.  If you
copied them using memcpy(), some parts of the bytes could contain
stale values.


Sure, I was explicitly referring to SVS, which has an unusual way of
accessing PTEs (contrary to pmap), which is why it needs special atomic
care that other places do not.


Live PDEs are also copied in pmap.c so I made a change there too.  After
that I decided "why not" and used the new functions everywhere PDEs/PTEs or
pages are block zeroed / copied.  But I'm also happy with memcpy()/memset().
Either way will work.  In fairness I do work too fast sometimes.


The only reason you made these big unneeded changes is for SVS not to take
the bus lock,


There is no bus lock on x86 (not since the 1990s anyway).


but as was said already, atomic_load_relaxed will do what
you want without the need for these functions.

Please revert _both changes now_, this one and the previous one which
introduced both functions, and let's use atomic_load_relaxed.


You're focusing on only one factor.  I'll explain in detail.  Here is the
original code I replaced:

 685 static inline pt_entry_t
 686 svs_pte_atomic_read(struct pmap *pmap, size_t idx)
 687 {
 688/*
 689 * XXX: We don't have a basic atomic_fetch_64 function?
 690 */
 691return atomic_cas_64(&pmap->pm_pdir[idx], 666, 666);
 692 }
...
 717/* User slots. */
 718for (i = 0; i < PDIR_SLOT_USERLIM; i++) {
 719pte = svs_pte_atomic_read(pmap, i);
 720ci->ci_svs_updir[i] = pte;
 721}

There's no need for an atomic op there because fetches on x86 are by
definition atomic, an

Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-02 Thread Kamil Rytarowski
On 03.06.2020 01:49, Andrew Doran wrote:
> On the assembly thing recall that recently you expressed a desire to remove
> all of the amd64 assembly string functions from libc because of sanitizers -
> I invested my time to do up a little demo to try and show you why that's not
> a good idea:
> 
>   http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html

Please note that interceptors for string functions are not just some
extra burden, but also very useful approach to feedback a fuzzer through
additional coverage.

At least libFuzzer and honggfuzz wrap many kinds of string functions and
use it for fuzzing. We should add a special mode in KCOV to feedback
userland (syzkaller) with traces from string functions.

https://github.com/google/honggfuzz/blob/bbb476eec95ad927d6d7d3d367d2b3e38eed3569/libhfuzz/memorycmp.c#L24


Re: [stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-02 Thread Andrew Doran
On Tue, Jun 02, 2020 at 08:41:53AM +0200, Maxime Villard wrote:

> Le 02/06/2020 ? 00:58, Andrew Doran a ?crit?:
> > Module Name:src
> > Committed By:   ad
> > Date:   Mon Jun  1 22:58:06 UTC 2020
> > 
> > Modified Files:
> > src/sys/arch/amd64/amd64: cpufunc.S
> > src/sys/arch/amd64/include: frameasm.h
> > 
> > Log Message:
> > Reported-by: syzbot+6dd5a230d19f0cbc7...@syzkaller.appspotmail.com
> > 
> > Instrument STOS/MOVS for KMSAN to unbreak it.
> > 
> > 
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amd64/amd64/cpufunc.S
> > cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amd64/include/frameasm.h
> > 
> > Please note that diffs are not public domain; they are subject to the
> > copyright notices on the relevant files.
> 
> Can you just stop ignoring the remarks that are made?

That's up to you Maxime.  If you habitually make it difficult for people to
come to a reasonable compromise with you, then you're asking to not be taken
seriously and will find yourself being ignored.

> I said explicitly
> that adding manual instrumentation here is _wrong_.

I don't share your assessment in the general sense.  It should be possible
to instrument assembly code because KMSAN is useful AND we can't get by
without assembly - there are some things that C just can't do (or do well
enough).

On the assembly thing recall that recently you expressed a desire to remove
all of the amd64 assembly string functions from libc because of sanitizers -
I invested my time to do up a little demo to try and show you why that's not
a good idea:

http://mail-index.netbsd.org/port-amd64/2020/04/19/msg003226.html

The system is a balancing act.  There are lots of factors to be taken into
account: maintainability, tooling like KMSAN, user's varying needs, the
capabilites of different machines, performance, feature set and so on, and
dare I say it even the enjoyment of the people working on the project is
important too.  Myopic focus on one factor only to the detriment of others
is no good.

> The kMSan ASM fixups
> are limited to args/returns, and that is part of a sensical policy that
> _should not_ be changed without a good reason.
>
> x86_movs/x86_stos have strictly _no reason_ to exist. Of the 18 conversions
> you made to them in pmap.c, not one is justified. memcpy/memset were all
> correct.

I introduced these functions as a compromise because you were unhappy with
use of memcpy() to copy PDEs.  See:

http://mail-index.netbsd.org/port-amd64/2020/05/23/msg003280.html

You wrote:

In the [XXX] window, the PTEs could be used by userland.  If you
copied them using memcpy(), some parts of the bytes could contain
stale values.

Live PDEs are also copied in pmap.c so I made a change there too.  After
that I decided "why not" and used the new functions everywhere PDEs/PTEs or
pages are block zeroed / copied.  But I'm also happy with memcpy()/memset(). 
Either way will work.  In fairness I do work too fast sometimes.

> The only reason you made these big unneeded changes is for SVS not to take
> the bus lock,

There is no bus lock on x86 (not since the 1990s anyway).

> but as was said already, atomic_load_relaxed will do what
> you want without the need for these functions.
>
> Please revert _both changes now_, this one and the previous one which
> introduced both functions, and let's use atomic_load_relaxed.

You're focusing on only one factor.  I'll explain in detail.  Here is the
original code I replaced:

685 static inline pt_entry_t
686 svs_pte_atomic_read(struct pmap *pmap, size_t idx)
687 {
688 /*
689  * XXX: We don't have a basic atomic_fetch_64 function?
690  */
691 return atomic_cas_64(&pmap->pm_pdir[idx], 666, 666);
692 }
...
717 /* User slots. */
718 for (i = 0; i < PDIR_SLOT_USERLIM; i++) {
719 pte = svs_pte_atomic_read(pmap, i);
720 ci->ci_svs_updir[i] = pte;
721 }

There's no need for an atomic op there because fetches on x86 are by
definition atomic, and it does nothing to alter the memory ordering in this
case.  There are side effects to the atomic op: it's serializing and always
generates an unbuffered writeback, even in the failure case.  So the source
is being copied into itself, as well as into the destination, and the CPU's
store buffer is rendered ineffective.

A cut-n-paste replacement to use the relaxed functions predictably ties the
compiler in knots and the generated code is bad.

/* User slots. */
for (i = 0; i < PDIR_SLOT_USERLIM; i++) {
pte = atomic_load_relaxed(&pmap->pm_pdir[i]);
atomic_store_relaxed(&ci->ci_svs_updir[i], pte);
}

00400c9f :
  400c9f:   48 8b 06mov(%rsi),%rax
  400ca2:   48 8b 17mov(%rdi),%rdx
  400ca5:   48 8d b0 00 00 40 06lea0x640

[stos, again] Re: CVS commit: src/sys/arch/amd64

2020-06-01 Thread Maxime Villard

Le 02/06/2020 à 00:58, Andrew Doran a écrit :

Module Name:src
Committed By:   ad
Date:   Mon Jun  1 22:58:06 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/amd64/include: frameasm.h

Log Message:
Reported-by: syzbot+6dd5a230d19f0cbc7...@syzkaller.appspotmail.com

Instrument STOS/MOVS for KMSAN to unbreak it.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amd64/include/frameasm.h

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


Can you just stop ignoring the remarks that are made? I said explicitly
that adding manual instrumentation here is _wrong_. The kMSan ASM fixups
are limited to args/returns, and that is part of a sensical policy that
_should not_ be changed without a good reason.

x86_movs/x86_stos have strictly _no reason_ to exist. Of the 18 conversions
you made to them in pmap.c, not one is justified. memcpy/memset were all
correct.

The only reason you made these big unneeded changes is for SVS not to take
the bus lock, but as was said already, atomic_load_relaxed will do what
you want without the need for these functions.

Please revert _both changes now_, this one and the previous one which
introduced both functions, and let's use atomic_load_relaxed.

Maxime


Re: CVS commit: src/sys/arch/amd64

2020-01-08 Thread Emmanuel Dreyfus
Ryo ONODERA  wrote:

> However I need multiboot support for amd64.
> I am waiting well-tested implementation.

At this point the problems are more about code style and cleaning, as we
have a fix for the boot bugs that has been reported. 

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org


Re: CVS commit: src/sys/arch/amd64

2020-01-08 Thread Ryo ONODERA
Hi,

However I need multiboot support for amd64.
I am waiting well-tested implementation.

"Emmanuel Dreyfus"  writes:

> Module Name:  src
> Committed By: manu
> Date: Thu Jan  9 00:42:24 UTC 2020
>
> Modified Files:
>   src/sys/arch/amd64/amd64: locore.S machdep.c
>   src/sys/arch/amd64/conf: GENERIC files.amd64 kern.ldscript
>
> Log Message:
> Rollback multiboot2 for amd64, as requested by core
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.197 -r1.198 src/sys/arch/amd64/amd64/locore.S
> cvs rdiff -u -r1.344 -r1.345 src/sys/arch/amd64/amd64/machdep.c
> cvs rdiff -u -r1.553 -r1.554 src/sys/arch/amd64/conf/GENERIC
> cvs rdiff -u -r1.114 -r1.115 src/sys/arch/amd64/conf/files.amd64
> cvs rdiff -u -r1.30 -r1.31 src/sys/arch/amd64/conf/kern.ldscript
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>
> Modified files:
>
> Index: src/sys/arch/amd64/amd64/locore.S
> diff -u src/sys/arch/amd64/amd64/locore.S:1.197 
> src/sys/arch/amd64/amd64/locore.S:1.198
> --- src/sys/arch/amd64/amd64/locore.S:1.197   Wed Jan  8 20:59:18 2020
> +++ src/sys/arch/amd64/amd64/locore.S Thu Jan  9 00:42:24 2020
> @@ -1,4 +1,4 @@
> -/*   $NetBSD: locore.S,v 1.197 2020/01/08 20:59:18 skrll Exp $   */
> +/*   $NetBSD: locore.S,v 1.198 2020/01/09 00:42:24 manu Exp $*/
>  
>  /*
>   * Copyright-o-rama!
> @@ -158,7 +158,6 @@
>  
>  #include "opt_compat_netbsd.h"
>  #include "opt_compat_netbsd32.h"
> -#include "opt_multiboot.h"
>  #include "opt_xen.h"
>  #include "opt_svs.h"
>  
> @@ -178,13 +177,6 @@
>  #include 
>  #include 
>  
> -#ifndef XENPV
> -#include 
> -#endif 
> -
> -#define CODE_SEGMENT 0x08
> -#define DATA_SEGMENT 0x10
> -
>  #if NLAPIC > 0
>  #include 
>  #endif
> @@ -432,50 +424,6 @@ END(farjmp64)
>   .space  512
>  tmpstk:
>  
> -.section multiboot,"a"
> -#if defined(MULTIBOOT)
> - .align  8
> - .globl  Multiboot2_Header
> -_C_LABEL(Multiboot2_Header):
> - .intMULTIBOOT2_HEADER_MAGIC
> - .intMULTIBOOT2_ARCHITECTURE_I386
> - .intMultiboot2_Header_end - Multiboot2_Header
> - .int-(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \
> - + (Multiboot2_Header_end - Multiboot2_Header))
> -
> - .int1   /* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */
> - .int12  /* sizeof(multiboot_header_tag_information_request) */
> - /* + sizeof(uint32_t) * requests */
> - .int4   /* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */
> - .align  8
> -
> - .int3   /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS */
> - .int16  /* sizeof(struct multiboot_tag_efi64) */
> - .quad   (multiboot2_entry - KERNBASE)
> - .align  8
> -
> - .int9   /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 */
> - .int16  /* sizeof(struct multiboot_tag_efi64) */
> - .quad   (multiboot2_entry - KERNBASE)
> - .align  8
> -
> -#if notyet
> - /*
> -  * Could be used to get an early console for debug,
> -  * but this is broken.
> -  */
> - .int7   /* MULTIBOOT_HEADER_TAG_EFI_BS */
> - .int8   /* sizeof(struct multiboot_tag) */
> - .align  8
> -#endif
> -
> - .int0   /* MULTIBOOT_HEADER_TAG_END */
> - .int8   /* sizeof(struct multiboot_tag) */
> - .align  8
> - .globl  Multiboot2_Header_end
> -_C_LABEL(Multiboot2_Header_end):
> -#endif   /* MULTIBOOT */
> -
>  /*
>   * Some hackage to deal with 64bit symbols in 32 bit mode.
>   * This may not be needed if things are cleaned up a little.
> @@ -492,700 +440,6 @@ ENTRY(start)
>   /* Warm boot */
>   movw$0x1234,0x472
>  
> -#if defined(MULTIBOOT)
> - jmp .Lnative_loader
> -
> -
> -multiboot2_entry:
> - .code64
> - /*
> -  * multiboot2 entry point. We are left here without
> -  * stack and with no idea of where we were loaded in memory.
> -  * The only inputs are
> -  * %eax MULTIBOOT2_BOOTLOADER_MAGIC
> -  * %ebx pointer to multiboot_info
> -  *
> -  * Here we will:
> -  * - copy the kernel to 0x20 (KERNTEXTOFF - KERNBASE)
> -  *  as almost all the code in locore.S assume it is there. 
> -  *  This is derived from 
> -  *  src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S
> -  * - copy multiboot_info, as done in multiboot_pre_reloc() from
> -  *  src/sys/arch/x86/x86/multiboot2.c
> -  *  Unfortunately we cannot call that function as there is 
> -  *  no simple way to build it as 32 bit code in a 64 bit kernel.
> -  * - Copy ELF symbols, also as in multiboot_pre_reloc()
> -  */
> -
> - cli
> -
> - /*
> -  * Discover our load address and use it to get start address
> -  */
> - mov $_RELOC(tmpstk),%rsp
> - callnext
> -next:pop %r8
> - sub $(next - start), %r8
> -
> - /*
> -  * Save multiboot_info for later. We

Re: CVS commit: src/sys/arch/amd64

2020-01-05 Thread Emmanuel Dreyfus
On Sun, Jan 05, 2020 at 02:43:43PM +0100, Maxime Villard wrote:
> I have now requested to core@ that multiboot in amd64 be reverted entirely.

So far I privilegied working on a fix to the boot problem that was
reported, rather than spending time on a revert. This was not a futile
effort, since at this point we have a fix that we agree on. My idea was
to commit it and then to address the other points you raised, but if
you cannot stand that, feel free to do the revert on your own.

There is also this problem that seems worth spending time to me:
http://mail-index.netbsd.org/tech-kern/2020/01/02/msg025911.html

I hit this bug 100% reliabily with qemu/EFI, even with the multiboot
stuff removed, and it seems to match what Masanobu Saitoh reported. 
I suspect the multiboot changes just undercovered it.

-- 
Emmanuel Dreyfus
m...@netbsd.org


Re: CVS commit: src/sys/arch/amd64

2020-01-05 Thread Maxime Villard
Le 05/01/2020 à 13:56, Maxime Villard a écrit :
> Le 05/01/2020 à 02:03, Emmanuel Dreyfus a écrit :
>> On Sat, Jan 04, 2020 at 08:43:16AM +0100, Maxime Villard wrote:
>>> +.section multiboot,"",@note
>>> Why @note? It will be in the .text anyway. Also why no dot in the section
>>> name? That's supposed to be the naming convention.
>>
>> The idea is that one day if ld gets more reasonable, it could go in
>> non-loading note ection at the beginning of the binary, but if you
>> prefer .text, let us go with that.
> 
> I think .text.multiboot is fine, and @note should be dropped
> 
>> Attached is my latest change set, including the locore cleanup you asked
>> for.
> 
> Notice how, after cleanup, the big copy crap comes down to literally just
> two instructions. Unfortunately that's not exactly it:
> 
>  - As I said more than three weeks ago [1], I think it's the whole
>MULTIBOOT block that should be moved in a separate file, not just the
>32bit copy function. Only the '.Lbegin' label (to be renamed) needs to
>be in locore.S, the rest can (and should) be outside.
>  - multiboot2_pre_reloc_would_be_built_as_ia32 should be removed.
>  - The code is still not entirely KNF, search for "\t\n".
>  - Local labels should begin with ".L".
>  - Now I'm wondering why KEEP() in the ldscript? Why doesn't
>"*(.text.multiboot)" suffice?
> 
> And also... Recovering from the heart attack I got after looking at
> multiboot2_copy_syms32, I'm a bit confused; did you just objdump the
> function and copy-paste it in the kernel? How did you obtain this
> code? [Is it normal that I am already worried about your next answer?]
> 
> Overall, I'm irritated, yes, because instead of reverting the change and
> taking just one peaceful hour to fix things correctly, you have decided to
> waste everybody's time with the breakage and absurd patch-work. I find
> myself having to _insist_ for you to clean up the junk, and now I'm even
> quoting emails from one month ago.
> 
> Maxime
> 
> [1] https://mail-index.netbsd.org/source-changes-d/2019/12/12/msg011882.html

Sorry, but not gonna waste more of my time.

I have now requested to core@ that multiboot in amd64 be reverted entirely.

The correct way to add multiboot can be discussed afterwards, when the patch
will have been shared and will have been agreed upon beforehand, in a way
that it at least isn't total junk and doesn't break other things.

Maxime


Re: CVS commit: src/sys/arch/amd64

2020-01-05 Thread Maxime Villard
Le 05/01/2020 à 02:03, Emmanuel Dreyfus a écrit :
> On Sat, Jan 04, 2020 at 08:43:16AM +0100, Maxime Villard wrote:
>> +.section multiboot,"",@note
>> Why @note? It will be in the .text anyway. Also why no dot in the section
>> name? That's supposed to be the naming convention.
>
> The idea is that one day if ld gets more reasonable, it could go in
> non-loading note ection at the beginning of the binary, but if you
> prefer .text, let us go with that.

I think .text.multiboot is fine, and @note should be dropped

> Attached is my latest change set, including the locore cleanup you asked
> for.

Notice how, after cleanup, the big copy crap comes down to literally just
two instructions. Unfortunately that's not exactly it:

 - As I said more than three weeks ago [1], I think it's the whole
   MULTIBOOT block that should be moved in a separate file, not just the
   32bit copy function. Only the '.Lbegin' label (to be renamed) needs to
   be in locore.S, the rest can (and should) be outside.
 - multiboot2_pre_reloc_would_be_built_as_ia32 should be removed.
 - The code is still not entirely KNF, search for "\t\n".
 - Local labels should begin with ".L".
 - Now I'm wondering why KEEP() in the ldscript? Why doesn't
   "*(.text.multiboot)" suffice?

And also... Recovering from the heart attack I got after looking at
multiboot2_copy_syms32, I'm a bit confused; did you just objdump the
function and copy-paste it in the kernel? How did you obtain this
code? [Is it normal that I am already worried about your next answer?]

Overall, I'm irritated, yes, because instead of reverting the change and
taking just one peaceful hour to fix things correctly, you have decided to
waste everybody's time with the breakage and absurd patch-work. I find
myself having to _insist_ for you to clean up the junk, and now I'm even
quoting emails from one month ago.

Maxime

[1] https://mail-index.netbsd.org/source-changes-d/2019/12/12/msg011882.html


Re: CVS commit: src/sys/arch/amd64

2020-01-04 Thread Emmanuel Dreyfus
On Sat, Jan 04, 2020 at 08:43:16AM +0100, Maxime Villard wrote:
> +.section multiboot,"",@note
> Why @note? It will be in the .text anyway. Also why no dot in the section
> name? That's supposed to be the naming convention.

The idea is that one day if ld gets more reasonable, it could go in 
non-loading note ection at the beginning of the binary, but if you 
prefer .text, let us go with that.

On the section name, ELF specification says "Section names with a dot (.)
prefix are reserved for the system" (TIS ELF specification version 1.2), 
section names without a dot are allowed, and we use plenty of them in 
our kernels (e.g.: link_set_* sections). Our naming convention is not
obvious to me, nor what the specification means by "the system" here. 
My hunch would be to avoid using an abitratry name inside a reserved
namespace, althought we already did it. If you have a strong opinion 
on it, I can stand a leading dot in the multiboot section name.

> I don't know if you realize, but you landed a huge pile
> of crap in the middle of the amd64 locore

I have been working on this, but the priority was obviously the
boot problem. Attached is my latest change set, including the 
locore cleanup you asked for.

-- 
Emmanuel Dreyfus
m...@netbsd.org
Index: sys/arch/amd64/amd64/locore.S
===
RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v
retrieving revision 1.195
diff -U4 -r1.195 locore.S
--- sys/arch/amd64/amd64/locore.S   15 Dec 2019 02:58:21 -  1.195
+++ sys/arch/amd64/amd64/locore.S   5 Jan 2020 00:41:18 -
@@ -431,10 +431,10 @@
.size   tmpstk, tmpstk - .
.space  512
 tmpstk:
 
-.section multiboot,"a"
 #if defined(MULTIBOOT)
+.section multiboot
.align  8
.globl  Multiboot2_Header
 _C_LABEL(Multiboot2_Header):
.intMULTIBOOT2_HEADER_MAGIC
@@ -473,9 +473,9 @@
.int8   /* sizeof(struct multiboot_tag) */
.align  8
.globl  Multiboot2_Header_end
 _C_LABEL(Multiboot2_Header_end):
-#endif /* MULTIBOOT */
+#endif /* MULTIBOOT */
 
 /*
  * Some hackage to deal with 64bit symbols in 32 bit mode.
  * This may not be needed if things are cleaned up a little.
@@ -544,109 +544,13 @@
mov $(KERNTEXTOFF - KERNBASE), %rdi /* dest */
mov %r8, %rsi   
sub $(start - kernel_text), %rsi/* src */
mov $(__kernel_end - kernel_text), %rcx /* size */
-   mov %rcx, %r12  
-   movq%rdi, %r11  /* for misaligned check */
-
-#if !defined(NO_OVERLAP)
-   movq%rdi, %r13
-   subq%rsi, %r13
-#endif
-
-   shrq$3, %rcx/* count for copy by words */
-   jz  8f  /* j if less than 8 bytes */
-
-   lea -8(%rdi, %r12), %r14/* target address of last 8 */
-   mov -8(%rsi, %r12), %r15/* get last word */
-#if !defined(NO_OVERLAP)
-   cmpq%r12, %r13  /* overlapping? */
-   jb  10f
-#endif
-
-/*
- * Non-overlaping, copy forwards.
- * Newer Intel cpus (Nehalem) will do 16byte read/write transfers
- * if %ecx is more than 76.
- * AMD might do something similar some day.
- */
-   and $7, %r11/* destination misaligned ? */
-   jnz 12f
-   rep
-   movsq
-   mov %r15, (%r14)/* write last word */
-   jmp .Lcopy_done
 
-/*
- * Destination misaligned
- * AMD say it is better to align the destination (not the source).
- * This will also re-align copies if the source and dest are both
- * misaligned by the same amount)
- * (I think Nehalem will use its accelerated copy if the source
- * and destination have the same alignment.)
- */
-12:
-   lea -9(%r11, %r12), %rcx/* post re-alignment count */
-   neg %r11/* now -1 .. -7 */
-   mov (%rsi), %r12/* get first word */
-   mov %rdi, %r13  /* target for first word */
-   lea 8(%rsi, %r11), %rsi
-   lea 8(%rdi, %r11), %rdi
-   shr $3, %rcx
-   rep
-   movsq
-   mov %r12, (%r13)/* write first word */
-   mov %r15, (%r14)/* write last word */
-   jmp .Lcopy_done
-
-#if !defined(NO_OVERLAP)
-/* Must copy backwards.
- * Reverse copy is probably easy to code faster than 'rep movds'
- * since that requires (IIRC) an extra clock every 3 iterations (AMD).
- * However I don't suppose anything cares that much!
- * The big cost is the std/cld pair - reputedly 50+ cycles on Netburst P4.
- * The copy is aligned with the buffer start (more likely to
- * be a multiple of 8 than the end).
- */
-10:
-   lea -8(%rsi, %rcx, 8), %rsi
-   lea -8(%rdi, %rcx, 8), %rdi
-   std
+   /* Assume non overlap and aligned size */
+   shrq$3, %rcx
rep
movsq
-   cld

Re: CVS commit: src/sys/arch/amd64

2020-01-04 Thread Martin Husemann
On Sat, Jan 04, 2020 at 08:43:16AM +0100, Maxime Villard wrote:
> As said repeatedly, the option should be enabled only _after_ the garbage
> has been cleaned up.

This is not easy if you just call it that. To me it looks like Emanuel
is trying very hard to address all technical issues brought up explicitly
and clear. If this patch does not totaly "clean up the garbage", it would
help if you raise specific issues. If it does, why not include the re-enabling
in the patch?

Martin



Re: CVS commit: src/sys/arch/amd64

2020-01-04 Thread Maxime Villard

Le 04/01/2020 à 03:33, Emmanuel Dreyfus a écrit :

On Tue, Dec 31, 2019 at 09:32:05AM +0100, Maxime Villard wrote:

I think max-page-size=0x1000 is the right thing to do, but someone needs to
verify that the resulting binary is correct and that the resulting in-memory
layout is correct too.


Attached is an updated patch with this approach. I tested at mine and
it seems fine.


Come on... "I tested and it seems fine"... Whatever.

I have now verified that the resulting binary layout is correct, that
the in-memory layout is correct, and that libsa doesn't do crazy things
with this binary. As far as my concerns were concerned, the max-page-size
change is good to go.

The rest is confused:

+.section multiboot,"",@note

Why @note? It will be in the .text anyway. Also why no dot in the section
name? That's supposed to be the naming convention.

+EXTRA_LINKFLAGS=   --split-by-file=0x10 -z max-page-size=0x1000 -r -d

KASLR kernels to not have a PHDR, so this is not relevant -- there was a
reason this parameter wasn't getting passed in the first place.

+optionsMULTIBOOT   # Multiboot support (see multiboot(8))

As said repeatedly, the option should be enabled only _after_ the garbage
has been cleaned up.

In fact, why don't you revert your change, fix it correctly locally, and
then re-submit it? I don't know if you realize, but you landed a huge pile
of crap in the middle of the amd64 locore, not only does this crap not
work but it also breaks EFI boot, and for two weeks you've been wondering
what's wrong in it and you have consistently proposed absurd workarounds.

Please revert your change entirely and put back the code in a clean and
functional state. Thanks.

Maxime


Re: CVS commit: src/sys/arch/amd64

2020-01-03 Thread Emmanuel Dreyfus
On Tue, Dec 31, 2019 at 09:32:05AM +0100, Maxime Villard wrote:
> I think max-page-size=0x1000 is the right thing to do, but someone needs to
> verify that the resulting binary is correct and that the resulting in-memory
> layout is correct too.

Attached is an updated patch with this approach. I tested at mine and
it seems fine.

I am especially interested by feedback from msaitoh@ who reported the
crash at cpu attacch that I suspect to be the (probably unrelated) 
problem describred here:
http://mail-index.netbsd.org/tech-kern/2020/01/02/msg025911.html

-- 
Emmanuel Dreyfus
m...@netbsd.org
Index: sys/arch/amd64/amd64/locore.S
===
RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v
retrieving revision 1.195
diff -U4 -r1.195 locore.S
--- sys/arch/amd64/amd64/locore.S   15 Dec 2019 02:58:21 -  1.195
+++ sys/arch/amd64/amd64/locore.S   4 Jan 2020 01:48:11 -
@@ -431,10 +431,10 @@
.size   tmpstk, tmpstk - .
.space  512
 tmpstk:
 
-.section multiboot,"a"
 #if defined(MULTIBOOT)
+.section multiboot,"",@note
.align  8
.globl  Multiboot2_Header
 _C_LABEL(Multiboot2_Header):
.intMULTIBOOT2_HEADER_MAGIC
Index: sys/arch/amd64/conf/GENERIC
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.551
diff -U4 -r1.551 GENERIC
--- sys/arch/amd64/conf/GENERIC 14 Dec 2019 07:45:20 -  1.551
+++ sys/arch/amd64/conf/GENERIC 4 Jan 2020 01:48:11 -
@@ -25,9 +25,9 @@
 #ident "GENERIC-$Revision: 1.551 $"
 
 maxusers   64  # estimated number of users
 
-#options   MULTIBOOT   # Multiboot support (see multiboot(8)) 
+optionsMULTIBOOT   # Multiboot support (see multiboot(8)) 
 
 # delay between "rebooting ..." message and hardware reset, in milliseconds
 #options   CPURESET_DELAY=2000
 
Index: sys/arch/amd64/conf/Makefile.amd64
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/Makefile.amd64,v
retrieving revision 1.80
diff -U4 -r1.80 Makefile.amd64
--- sys/arch/amd64/conf/Makefile.amd64  14 Nov 2019 16:23:52 -  1.80
+++ sys/arch/amd64/conf/Makefile.amd64  4 Jan 2020 01:48:11 -
@@ -90,12 +90,12 @@
 ## (5) link settings
 ##
 TEXTADDR?= 0x8020
 .if defined(KASLR)
-EXTRA_LINKFLAGS=   --split-by-file=0x10 -r -d
+EXTRA_LINKFLAGS=   --split-by-file=0x10 -z max-page-size=0x1000 -r -d
 KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
 .else
-EXTRA_LINKFLAGS=   -z max-page-size=0x20
+EXTRA_LINKFLAGS=   -z max-page-size=0x1000
 KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
 .endif
 LINKFLAGS_NORMAL=  -X
 
Index: sys/arch/amd64/conf/kern.ldscript
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/kern.ldscript,v
retrieving revision 1.30
diff -U4 -r1.30 kern.ldscript
--- sys/arch/amd64/conf/kern.ldscript   15 Dec 2019 02:56:40 -  1.30
+++ sys/arch/amd64/conf/kern.ldscript   4 Jan 2020 01:48:11 -
@@ -12,20 +12,11 @@
 
 ENTRY(_start)
 SECTIONS
 {
-   /*
-* multiboot (file_offset) : AT (load_address) 
-* file_offset must be below 32k for multiboot 2 specification
-* BIOS boot requires load_address above 0x20
-*/
-   multiboot 0x1000 : AT (0x20)
+   .text : AT (ADDR(.text) & 0x0fff)
{
-   . = ALIGN(8);
KEEP(*(multiboot));
-   }
-   .text : AT (0x20 + SIZEOF(multiboot))
-   {
. = ALIGN(__PAGE_SIZE);
__text_user_start = . ;
*(.text.user)
. = ALIGN(__PAGE_SIZE);


Re: CVS commit: src/sys/arch/amd64

2020-01-02 Thread Emmanuel Dreyfus
Masanobu SAITOH  wrote:

>  I have a UEFI boot machine and it also doesn't boot well.
> 
>  - It hangs after attaching ioapic0, cpu0 or acpi0 (or something else).
>The possibility is about 65%
>  - It sometimes panic in acpi_attach(), acpimcfg_probe or something else.
>The possibility is about 10%
>  - It sometimes boot up.
>The possibility is about 25%

I suspect this is a second bug that was undercovered by the multiboot
change. I get crashes like the one you report 100% reproductible with
qemu UEFI boot. I described the thing here:
http://mail-index.netbsd.org/tech-kern/2020/01/02/msg025911.html

Could you check with ddb the physical address accessed? Here is the
relevant excerpt in the message I posted:

db{0}> x/i $rip
netbsd:kmem_intr_alloc+0x64:movq%r12,0(%rax)
db{0}> print $rax
92057868
db{0}> call vtophys(92057868)
108

If you can add a #define DEBUG_MEMMAP 1 at the beginning of
src/sys/arch/x86/x86/efi.c and x86_machdep.c you will also have the
memory map provided by UEFI.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org


Re: CVS commit: src/sys/arch/amd64

2019-12-31 Thread Maxime Villard
Le 30/12/2019 à 16:15, Emmanuel Dreyfus a écrit :
> On Sat, Dec 28, 2019 at 02:22:21AM +, Emmanuel Dreyfus wrote:
>>> Regardless of whether it is needed in this specific case, cutting the 2MBs
>>> of zero in the binary is wanted. Unfortunately last I looked at this (two
>>> years ago) there were some non-obvious consequences, and it needs to be
>>> carefully done.
>>
>> Any hints about the problems you encountered? Perhaps we can work it
>> around with an . = ALIGN(__LARGEE_PAGE_SIZE); before including .text.user ?
> 
> No anwser here? It is difficult to address an unknown problem...

Sorry for the delay. I don't remember the specifics, but it had to do with
misaligned sections in the end. There is also some pretty retarded code in
loadfile_elf32.c that should like some investigation, at least for this
kind of change.

I think max-page-size=0x1000 is the right thing to do, but someone needs to
verify that the resulting binary is correct and that the resulting in-memory
layout is correct too.


Re: CVS commit: src/sys/arch/amd64

2019-12-30 Thread Emmanuel Dreyfus
On Sat, Dec 28, 2019 at 02:22:21AM +, Emmanuel Dreyfus wrote:
> > Regardless of whether it is needed in this specific case, cutting the 2MBs
> > of zero in the binary is wanted. Unfortunately last I looked at this (two
> > years ago) there were some non-obvious consequences, and it needs to be
> > carefully done.
> 
> Any hints about the problems you encountered? Perhaps we can work it
> around with an . = ALIGN(__LARGEE_PAGE_SIZE); before including .text.user ?

No anwser here? It is difficult to address an unknown problem...

-- 
Emmanuel Dreyfus
m...@netbsd.org


Re: CVS commit: src/sys/arch/amd64

2019-12-27 Thread Emmanuel Dreyfus
On Fri, Dec 27, 2019 at 06:24:07PM +0100, Maxime Villard wrote:
> Now that I'm looking at i386 I see you've indeed made the same nonsensical
> changes there, with all the unnecessary garbage in the code.

Here I assume you refer to the starting at efi_multiboot2_loader, since
most of the other significant  multiboot stuff has been there for 13 years.

It is copied from bootloader's startprog.S. How do you suggest to
improve it?


-- 
Emmanuel Dreyfus
m...@netbsd.org


Re: CVS commit: src/sys/arch/amd64

2019-12-27 Thread Emmanuel Dreyfus
On Fri, Dec 27, 2019 at 06:24:07PM +0100, Maxime Villard wrote:
>   .text : AT (ADDR(.text) & 0x0fff)
>   {
> + *(.multiboot)
> +
>   . = ALIGN(__PAGE_SIZE);
>   __text_user_start = . ;
>   ...
> 
> This guarantees that the structure is at the beginning of text.

That works. We can even make the multiboot section a note, for the sake
on cleanliness. (see attached patch. MULTIBOOT is enabled for testing).

> Regardless of whether it is needed in this specific case, cutting the 2MBs
> of zero in the binary is wanted. Unfortunately last I looked at this (two
> years ago) there were some non-obvious consequences, and it needs to be
> carefully done.

Any hints about the problems you encountered? Perhaps we can work it
around with an . = ALIGN(__LARGEE_PAGE_SIZE); before including .text.user ?

> Also, my previous remarks haven't been addressed entirely, and still stand.

Sure, it's just next in the todo list.

-- 
Emmanuel Dreyfus
m...@netbsd.org
? sys/arch/amd64/compile/obj
? sys/arch/amd64/stand/prekern/obj
Index: sys/arch/amd64/amd64/locore.S
===
RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v
retrieving revision 1.195
diff -U4 -r1.195 locore.S
--- sys/arch/amd64/amd64/locore.S   15 Dec 2019 02:58:21 -  1.195
+++ sys/arch/amd64/amd64/locore.S   28 Dec 2019 01:41:03 -
@@ -431,10 +431,10 @@
.size   tmpstk, tmpstk - .
.space  512
 tmpstk:
 
-.section multiboot,"a"
 #if defined(MULTIBOOT)
+.section multiboot,"",@note
.align  8
.globl  Multiboot2_Header
 _C_LABEL(Multiboot2_Header):
.intMULTIBOOT2_HEADER_MAGIC
Index: sys/arch/amd64/conf/GENERIC
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.551
diff -U4 -r1.551 GENERIC
--- sys/arch/amd64/conf/GENERIC 14 Dec 2019 07:45:20 -  1.551
+++ sys/arch/amd64/conf/GENERIC 28 Dec 2019 01:41:03 -
@@ -25,9 +25,9 @@
 #ident "GENERIC-$Revision: 1.551 $"
 
 maxusers   64  # estimated number of users
 
-#options   MULTIBOOT   # Multiboot support (see multiboot(8)) 
+optionsMULTIBOOT   # Multiboot support (see multiboot(8)) 
 
 # delay between "rebooting ..." message and hardware reset, in milliseconds
 #options   CPURESET_DELAY=2000
 
Index: sys/arch/amd64/conf/Makefile.amd64
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/Makefile.amd64,v
retrieving revision 1.80
diff -U4 -r1.80 Makefile.amd64
--- sys/arch/amd64/conf/Makefile.amd64  14 Nov 2019 16:23:52 -  1.80
+++ sys/arch/amd64/conf/Makefile.amd64  28 Dec 2019 01:41:03 -
@@ -90,12 +90,12 @@
 ## (5) link settings
 ##
 TEXTADDR?= 0x8020
 .if defined(KASLR)
-EXTRA_LINKFLAGS=   --split-by-file=0x10 -r -d
+EXTRA_LINKFLAGS=   --split-by-file=0x10 -r -d -n
 KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
 .else
-EXTRA_LINKFLAGS=   -z max-page-size=0x20
+EXTRA_LINKFLAGS=   -z max-page-size=0x20 -n
 KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
 .endif
 LINKFLAGS_NORMAL=  -X
 
Index: sys/arch/amd64/conf/kern.ldscript
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/kern.ldscript,v
retrieving revision 1.30
diff -U4 -r1.30 kern.ldscript
--- sys/arch/amd64/conf/kern.ldscript   15 Dec 2019 02:56:40 -  1.30
+++ sys/arch/amd64/conf/kern.ldscript   28 Dec 2019 01:41:03 -
@@ -12,20 +12,11 @@
 
 ENTRY(_start)
 SECTIONS
 {
-   /*
-* multiboot (file_offset) : AT (load_address) 
-* file_offset must be below 32k for multiboot 2 specification
-* BIOS boot requires load_address above 0x20
-*/
-   multiboot 0x1000 : AT (0x20)
+   .text : AT (ADDR(.text) & 0x0fff)
{
-   . = ALIGN(8);
KEEP(*(multiboot));
-   }
-   .text : AT (0x20 + SIZEOF(multiboot))
-   {
. = ALIGN(__PAGE_SIZE);
__text_user_start = . ;
*(.text.user)
. = ALIGN(__PAGE_SIZE);


Re: CVS commit: src/sys/arch/amd64

2019-12-27 Thread Maxime Villard
Le 27/12/2019 à 17:45, Emmanuel Dreyfus a écrit :
> On Fri, Dec 27, 2019 at 09:02:17AM +0100, Maxime Villard wrote:
>> Please stop with the nonsense... In this patch you are making the multiboot
>> header executable, and putting it in a section shared with userland under
>> SVS. Neither should be required; more than that, both are absolutely _not_
>> wanted.
>
> What are the actual drawbacks?

You are moving the structure to an area where it does not belong _at all_.
We don't want to map things in userland for no reason.

Now that I'm looking at the thing closely, I see why we are forced to make
it executable. So, that's fine for that part.

> FWIW, this is in line with how it was done on i386: it is just stored
> at the beginning of .text. Xen does the same. Of course it seems more
> natural to store that in a note section this is not loaded, but after
> experimenting a lot, I am not sure it can be done, since ld really
> want to push notes at the end of the file.

Now that I'm looking at i386 I see you've indeed made the same nonsensical
changes there, with all the unnecessary garbage in the code.

To me, you only need

.section .multiboot,"ax",@progbits

and

.text : AT (ADDR(.text) & 0x0fff)
{
+   *(.multiboot)
+
. = ALIGN(__PAGE_SIZE);
__text_user_start = . ;
...

This guarantees that the structure is at the beginning of text.

Regardless of whether it is needed in this specific case, cutting the 2MBs
of zero in the binary is wanted. Unfortunately last I looked at this (two
years ago) there were some non-obvious consequences, and it needs to be
carefully done.

Also, my previous remarks haven't been addressed entirely, and still stand.

Maxime


Re: CVS commit: src/sys/arch/amd64

2019-12-27 Thread Emmanuel Dreyfus
On Fri, Dec 27, 2019 at 09:02:17AM +0100, Maxime Villard wrote:
> Please stop with the nonsense... In this patch you are making the multiboot
> header executable, and putting it in a section shared with userland under
> SVS. Neither should be required; more than that, both are absolutely _not_
> wanted.

What are the actual drawbacks? 

FWIW, this is in line with how it was done on i386: it is just stored
at the beginning of .text. Xen does the same. Of course it seems more
natural to store that in a note section this is not loaded, but after
experimenting a lot, I am not sure it can be done, since ld really
want to push notes at the end of the file.

-- 
Emmanuel Dreyfus
m...@netbsd.org


Re: CVS commit: src/sys/arch/amd64

2019-12-27 Thread Ryo ONODERA
Hi,

Your patch works fine for my laptop too.

Thank you.

Masanobu SAITOH  writes:

> On 2019/12/27 1:55, Emmanuel Dreyfus wrote:
>> On Wed, Dec 25, 2019 at 05:05:11PM +0900, Masanobu SAITOH wrote:
> After this change, amd64 kernel does not boot on my HP Spectre x360
> 13-inch ae019TU laptop with pure UEFI boot mode.
>>>  I have a UEFI boot machine and it also doesn't boot well.
>> 
>> Please try the attached patch.
>> 
>> It adds the -n flag to ld, which disable auto-alignment of sections
>> in the file. I undestand alignement is highly desirable for userland
>> programs that may be mapped from file, but useless for the kernel,
>> which is just readen once by the bootloader.
>> 
>> Without auto-alignement, the .text segment starts right after the
>> ELF headers. This means the multiboot header can go in .text and
>> stay below 32k (as required by the multiboot specification). There
>> is no need for a multiboot section for that, and therefore no 
>> need to modify the linker script.
>> 
>> A side effect is that the kernel file shrinks of 2 MB, because there
>> is not an alignement hole between ELF headers and the .text section
>> anymore.
>> 
>> My patch also enable the MULTIBOOT option so that we can check
>> nothing gets broken with it. You can also try with the option
>> disabled, of course.
>> 
>
> Both with and without MULTIBOOT works fine. No any hangup/panic.
>
>  Thanks.
>
> -- 
> ---
> SAITOH Masanobu (msai...@execsw.org
>  msai...@netbsd.org)

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


Re: CVS commit: src/sys/arch/amd64

2019-12-27 Thread Maxime Villard
Le 26/12/2019 à 17:55, Emmanuel Dreyfus a écrit :
> On Wed, Dec 25, 2019 at 05:05:11PM +0900, Masanobu SAITOH wrote:
 After this change, amd64 kernel does not boot on my HP Spectre x360
 13-inch ae019TU laptop with pure UEFI boot mode.
>>  I have a UEFI boot machine and it also doesn't boot well.
> 
> Please try the attached patch.
> 
> It adds the -n flag to ld, which disable auto-alignment of sections
> in the file. I undestand alignement is highly desirable for userland
> programs that may be mapped from file, but useless for the kernel,
> which is just readen once by the bootloader.
> 
> Without auto-alignement, the .text segment starts right after the
> ELF headers. This means the multiboot header can go in .text and
> stay below 32k (as required by the multiboot specification). There
> is no need for a multiboot section for that, and therefore no 
> need to modify the linker script.
> 
> A side effect is that the kernel file shrinks of 2 MB, because there
> is not an alignement hole between ELF headers and the .text section
> anymore.
> 
> My patch also enable the MULTIBOOT option so that we can check
> nothing gets broken with it. You can also try with the option
> disabled, of course.

Please stop with the nonsense... In this patch you are making the multiboot
header executable, and putting it in a section shared with userland under
SVS. Neither should be required; more than that, both are absolutely _not_
wanted.

Instead of trying to patch-work the thing over and over, you should
probably revert it all, take an hour to peacefully write it correctly, and
then submit it again. Given the way multiboot was written so far I don't
see how we can accept to enable it by default.

Maxime


Re: CVS commit: src/sys/arch/amd64

2019-12-26 Thread Masanobu SAITOH
On 2019/12/27 1:55, Emmanuel Dreyfus wrote:
> On Wed, Dec 25, 2019 at 05:05:11PM +0900, Masanobu SAITOH wrote:
 After this change, amd64 kernel does not boot on my HP Spectre x360
 13-inch ae019TU laptop with pure UEFI boot mode.
>>  I have a UEFI boot machine and it also doesn't boot well.
> 
> Please try the attached patch.
> 
> It adds the -n flag to ld, which disable auto-alignment of sections
> in the file. I undestand alignement is highly desirable for userland
> programs that may be mapped from file, but useless for the kernel,
> which is just readen once by the bootloader.
> 
> Without auto-alignement, the .text segment starts right after the
> ELF headers. This means the multiboot header can go in .text and
> stay below 32k (as required by the multiboot specification). There
> is no need for a multiboot section for that, and therefore no 
> need to modify the linker script.
> 
> A side effect is that the kernel file shrinks of 2 MB, because there
> is not an alignement hole between ELF headers and the .text section
> anymore.
> 
> My patch also enable the MULTIBOOT option so that we can check
> nothing gets broken with it. You can also try with the option
> disabled, of course.
> 

Both with and without MULTIBOOT works fine. No any hangup/panic.

 Thanks.

-- 
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


Re: CVS commit: src/sys/arch/amd64

2019-12-26 Thread Emmanuel Dreyfus
On Wed, Dec 25, 2019 at 05:05:11PM +0900, Masanobu SAITOH wrote:
> >> After this change, amd64 kernel does not boot on my HP Spectre x360
> >> 13-inch ae019TU laptop with pure UEFI boot mode.
>  I have a UEFI boot machine and it also doesn't boot well.

Please try the attached patch.

It adds the -n flag to ld, which disable auto-alignment of sections
in the file. I undestand alignement is highly desirable for userland
programs that may be mapped from file, but useless for the kernel,
which is just readen once by the bootloader.

Without auto-alignement, the .text segment starts right after the
ELF headers. This means the multiboot header can go in .text and
stay below 32k (as required by the multiboot specification). There
is no need for a multiboot section for that, and therefore no 
need to modify the linker script.

A side effect is that the kernel file shrinks of 2 MB, because there
is not an alignement hole between ELF headers and the .text section
anymore.

My patch also enable the MULTIBOOT option so that we can check
nothing gets broken with it. You can also try with the option
disabled, of course.

-- 
Emmanuel Dreyfus
m...@netbsd.org
? sys/arch/amd64/compile/obj
? sys/arch/amd64/stand/prekern/obj
Index: sys/arch/amd64/amd64/locore.S
===
RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v
retrieving revision 1.195
diff -U4 -r1.195 locore.S
--- sys/arch/amd64/amd64/locore.S   15 Dec 2019 02:58:21 -  1.195
+++ sys/arch/amd64/amd64/locore.S   26 Dec 2019 16:44:10 -
@@ -431,51 +431,8 @@
.size   tmpstk, tmpstk - .
.space  512
 tmpstk:
 
-.section multiboot,"a"
-#if defined(MULTIBOOT)
-   .align  8
-   .globl  Multiboot2_Header
-_C_LABEL(Multiboot2_Header):
-   .intMULTIBOOT2_HEADER_MAGIC
-   .intMULTIBOOT2_ARCHITECTURE_I386
-   .intMultiboot2_Header_end - Multiboot2_Header
-   .int-(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \
-   + (Multiboot2_Header_end - Multiboot2_Header))
-
-   .int1   /* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */
-   .int12  /* sizeof(multiboot_header_tag_information_request) */
-   /* + sizeof(uint32_t) * requests */
-   .int4   /* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */
-   .align  8
-
-   .int3   /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS */
-   .int16  /* sizeof(struct multiboot_tag_efi64) */
-   .quad   (multiboot2_entry - KERNBASE)
-   .align  8
-
-   .int9   /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 */
-   .int16  /* sizeof(struct multiboot_tag_efi64) */
-   .quad   (multiboot2_entry - KERNBASE)
-   .align  8
-
-#if notyet
-   /*
-* Could be used to get an early console for debug,
-* but this is broken.
-*/
-   .int7   /* MULTIBOOT_HEADER_TAG_EFI_BS */
-   .int8   /* sizeof(struct multiboot_tag) */
-   .align  8
-#endif
-
-   .int0   /* MULTIBOOT_HEADER_TAG_END */
-   .int8   /* sizeof(struct multiboot_tag) */
-   .align  8
-   .globl  Multiboot2_Header_end
-_C_LABEL(Multiboot2_Header_end):
-#endif /* MULTIBOOT */
 
 /*
  * Some hackage to deal with 64bit symbols in 32 bit mode.
  * This may not be needed if things are cleaned up a little.
@@ -2179,8 +2136,50 @@
 SYSCALL_ENTRY  syscall,is_svs=0
 
TEXT_USER_BEGIN
 
+#if defined(MULTIBOOT)
+   .align  8
+   .globl  Multiboot2_Header
+_C_LABEL(Multiboot2_Header):
+   .intMULTIBOOT2_HEADER_MAGIC
+   .intMULTIBOOT2_ARCHITECTURE_I386
+   .intMultiboot2_Header_end - Multiboot2_Header
+   .int-(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \
+   + (Multiboot2_Header_end - Multiboot2_Header))
+
+   .int1   /* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */
+   .int12  /* sizeof(multiboot_header_tag_information_request) */
+   /* + sizeof(uint32_t) * requests */
+   .int4   /* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */
+   .align  8
+
+   .int3   /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS */
+   .int16  /* sizeof(struct multiboot_tag_efi64) */
+   .quad   (multiboot2_entry - KERNBASE)
+   .align  8
+
+   .int9   /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 */
+   .int16  /* sizeof(struct multiboot_tag_efi64) */
+   .quad   (multiboot2_entry - KERNBASE)
+   .align  8
+
+#if notyet
+   /*
+* Could be used to get an early console for debug,
+* but this is broken.
+*/
+   .int7   /* MULTIBOOT_HEADER_TAG_EFI_BS */
+   .int8   /* sizeof(struct multiboot_tag) */
+   .align  8
+#endif
+
+   .int0   /* MULTIBOOT_HEADER_TAG_END */
+   .int8   /* sizeof(struct multiboot_tag) */
+   .align  8
+   .globl  Multiboot2_Hea

Re: CVS commit: src/sys/arch/amd64

2019-12-26 Thread Emmanuel Dreyfus
On Wed, Dec 25, 2019 at 05:05:11PM +0900, Masanobu SAITOH wrote:
>  - It hangs after attaching ioapic0, cpu0 or acpi0 (or something else).
>The possibility is about 65%

What is the backtace? Does it goes through svs_init?

-- 
Emmanuel Dreyfus
m...@netbsd.org


Re: CVS commit: src/sys/arch/amd64

2019-12-25 Thread Ryo ONODERA
Sorry for confusing.

My attached patch does not improve my situation.
My mail is mistake. Sorry.

Reverting linker script fixes the kernel boot.

Thank you.

On December 26, 2019 1:23:34 AM GMT+09:00, Emmanuel Dreyfus  
wrote:
>On Wed, Dec 25, 2019 at 07:42:47PM +0900, Ryo ONODERA wrote:
>> The attached patch works for me.
>> However I have no idea about the meaning.
>
>It changes the multiboot section from DATA to CODE, which is
>odd but perfectly fine. I cannot understand how it can change
>the situation, though. Did it really fix the problem? Your 
>next message about reverted kern.ldscript  confuses me.

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB FD1B F404 27FA C7D1 15F3


  1   2   3   4   >