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

2021-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 23 08:59:08 UTC 2021

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

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

db_disasm had logic to detect invalid addresses before trying to
disassemble them.  But when disassembling a null instruction address,
the logic to detect invalid addresses itself tried to dereference an
invalid address.

db_get_value can already handle this situation gracefully, so there is
no need for this faulty fault-avoidance logic.

Fixes double-fault in ddb on calling null function pointers.  With
any luck, this should make diagnosing such bugs easier in the future!


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amd64/amd64/db_disasm.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/db_disasm.c
diff -u src/sys/arch/amd64/amd64/db_disasm.c:1.27 src/sys/arch/amd64/amd64/db_disasm.c:1.28
--- src/sys/arch/amd64/amd64/db_disasm.c:1.27	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/amd64/amd64/db_disasm.c	Sun May 23 08:59:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.28 2021/05/23 08:59:08 riastradh Exp $	*/
 
 /* 
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.28 2021/05/23 08:59:08 riastradh Exp $");
 
 #ifndef _KERNEL
 #include 
@@ -1191,33 +1191,8 @@ db_disasm(db_addr_t loc, bool altfmt)
 	uint64_t imm64;
 	int	len;
 	struct i_addr	address;
-#ifdef _KERNEL
-	pt_entry_t *pte, *pde;
-#endif
 	u_int	rex = 0;
 
-#ifdef _KERNEL
-	/*
-	 * Don't try to disassemble the location if the mapping is invalid.
-	 * If we do, we'll fault, and end up debugging the debugger!
-	 * in the case of largepages, "pte" is really the pde and "pde" is
-	 * really the entry for the pdp itself.
-	 */
-	if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS)
-		pte = kvtopte((vaddr_t)loc);
-	else
-		pte = vtopte((vaddr_t)loc);
-	if ((vaddr_t)pte >= VM_MIN_KERNEL_ADDRESS)
-		pde = kvtopte((vaddr_t)pte);
-	else
-		pde = vtopte((vaddr_t)pte);
-
-	if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) {
-		db_printf("invalid address\n");
-		return (loc);
-	}
-#endif
-
 	get_value_inc(inst, loc, 1, false);
 	short_addr = false;
 	size = LONG;



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

2021-05-04 Thread Pierre Pronchery
Module Name:src
Committed By:   khorben
Date:   Tue May  4 21:13:38 UTC 2021

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

Log Message:
prekern: add warnings upon problems collecting entropy

As submitted on port-amd64@ (part 3/3)

Tested on NetBSD/amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/stand/prekern/prng.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/stand/prekern/prng.c
diff -u src/sys/arch/amd64/stand/prekern/prng.c:1.4 src/sys/arch/amd64/stand/prekern/prng.c:1.5
--- src/sys/arch/amd64/stand/prekern/prng.c:1.4	Tue May  4 21:10:25 2021
+++ src/sys/arch/amd64/stand/prekern/prng.c	Tue May  4 21:13:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: prng.c,v 1.4 2021/05/04 21:10:25 khorben Exp $	*/
+/*	$NetBSD: prng.c,v 1.5 2021/05/04 21:13:38 khorben Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -84,6 +84,7 @@ prng_get_entropy_file(SHA512_CTX *ctx)
 	uint8_t digest[SHA1_DIGEST_LENGTH];
 	rndsave_t *rndsave;
 	SHA1_CTX sig;
+	size_t count = 0;
 
 	biml =
 	(struct btinfo_modulelist *)prng_lookup_bootinfo(BTINFO_MODULELIST);
@@ -117,7 +118,10 @@ prng_get_entropy_file(SHA512_CTX *ctx)
 		}
 
 		SHA512_Update(ctx, rndsave->data, sizeof(rndsave->data));
+		count++;
 	}
+	if (count == 0)
+		print_state(STATE_WARNING, "No entropy file could be loaded");
 }
 
 /*
@@ -168,6 +172,8 @@ prng_init(void)
 		cpuid(0x01, 0x00, descs);
 		has_rdrand = (descs[2] & CPUID2_RDRAND) != 0;
 	}
+	if (!has_rdseed && !has_rdrand)
+		print_state(STATE_WARNING, "No CPU entropy feature detected");
 
 	SHA512_Init();
 	prng_get_entropy_file();



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

2021-05-04 Thread Pierre Pronchery
Module Name:src
Committed By:   khorben
Date:   Tue May  4 21:10:25 UTC 2021

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

Log Message:
prekern: do not choke on bad entropy files

As submitted on port-amd64@ (part 2/3)

Tested on NetBSD/amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/stand/prekern/prng.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/stand/prekern/prng.c
diff -u src/sys/arch/amd64/stand/prekern/prng.c:1.3 src/sys/arch/amd64/stand/prekern/prng.c:1.4
--- src/sys/arch/amd64/stand/prekern/prng.c:1.3	Thu May 21 08:20:25 2020
+++ src/sys/arch/amd64/stand/prekern/prng.c	Tue May  4 21:10:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: prng.c,v 1.3 2020/05/21 08:20:25 maxv Exp $	*/
+/*	$NetBSD: prng.c,v 1.4 2021/05/04 21:10:25 khorben Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -98,7 +98,9 @@ prng_get_entropy_file(SHA512_CTX *ctx)
 			continue;
 		}
 		if (bi->len != sizeof(rndsave_t)) {
-			fatal("rndsave_t size mismatch");
+			print_state(STATE_WARNING,
+	"size mismatch in entropy file");
+			continue;
 		}
 		rndsave = (rndsave_t *)(vaddr_t)bi->base;
 
@@ -109,7 +111,9 @@ prng_get_entropy_file(SHA512_CTX *ctx)
 		SHA1Update(, rndsave->data, sizeof(rndsave->data));
 		SHA1Final(digest, );
 		if (memcmp(digest, rndsave->digest, sizeof(digest))) {
-			fatal("bad SHA1 checksum");
+			print_state(STATE_WARNING,
+	"bad SHA1 checksum in entropy file");
+			continue;
 		}
 
 		SHA512_Update(ctx, rndsave->data, sizeof(rndsave->data));



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

2021-05-04 Thread Pierre Pronchery
Module Name:src
Committed By:   khorben
Date:   Tue May  4 21:09:16 UTC 2021

Modified Files:
src/sys/arch/amd64/stand/prekern: console.c elf.c mm.c prekern.c
prekern.h

Log Message:
prekern: add support for warning messages

As submitted on port-amd64@ (part 1/3)

Tested on NetBSD/amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/stand/prekern/console.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/amd64/stand/prekern/elf.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amd64/stand/prekern/mm.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/amd64/stand/prekern/prekern.c
cvs rdiff -u -r1.23 -r1.24 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/stand/prekern/console.c
diff -u src/sys/arch/amd64/stand/prekern/console.c:1.6 src/sys/arch/amd64/stand/prekern/console.c:1.7
--- src/sys/arch/amd64/stand/prekern/console.c:1.6	Sat May 23 08:25:32 2020
+++ src/sys/arch/amd64/stand/prekern/console.c	Tue May  4 21:09:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: console.c,v 1.6 2020/05/23 08:25:32 maxv Exp $	*/
+/*	$NetBSD: console.c,v 1.7 2021/05/04 21:09:16 khorben Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -100,13 +100,24 @@ void print(char *buf)
 	print_ext(WHITE_ON_BLACK, buf);
 }
 
-void print_state(bool ok, char *buf)
+void print_state(state_t state, char *buf)
 {
 	print("[");
-	if (ok)
-		print_ext(GREEN_ON_BLACK, "+");
-	else
-		print_ext(RED_ON_BLACK, "!");
+	switch (state)
+	{
+		case STATE_NORMAL:
+			print_ext(GREEN_ON_BLACK, "+");
+			break;
+		case STATE_ERROR:
+			print_ext(RED_ON_BLACK, "!");
+			break;
+		case STATE_WARNING:
+			print_ext(YELLOW_ON_BLACK, "*");
+			break;
+		default:
+			print_ext(WHITE_ON_BLACK, "?");
+			break;
+	}
 	print("] ");
 	print(buf);
 	print("\n");

Index: src/sys/arch/amd64/stand/prekern/elf.c
diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.21 src/sys/arch/amd64/stand/prekern/elf.c:1.22
--- src/sys/arch/amd64/stand/prekern/elf.c:1.21	Thu May  7 17:58:26 2020
+++ src/sys/arch/amd64/stand/prekern/elf.c	Tue May  4 21:09:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf.c,v 1.21 2020/05/07 17:58:26 maxv Exp $	*/
+/*	$NetBSD: elf.c,v 1.22 2021/05/04 21:09:16 khorben Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -426,7 +426,7 @@ elf_kernel_reloc(void)
 	Elf_Sym *sym;
 	size_t i, j;
 
-	print_state(true, "ELF info created");
+	print_state(STATE_NORMAL, "ELF info created");
 
 	/*
 	 * Update all symbol values with the appropriate offset.
@@ -447,7 +447,7 @@ elf_kernel_reloc(void)
 		}
 	}
 
-	print_state(true, "Symbol values updated");
+	print_state(STATE_NORMAL, "Symbol values updated");
 
 	/*
 	 * Perform relocations without addend if there are any.
@@ -482,7 +482,7 @@ elf_kernel_reloc(void)
 		}
 	}
 
-	print_state(true, "REL relocations applied");
+	print_state(STATE_NORMAL, "REL relocations applied");
 
 	/*
 	 * Perform relocations with addend if there are any.
@@ -517,7 +517,7 @@ elf_kernel_reloc(void)
 		}
 	}
 
-	print_state(true, "RELA relocations applied");
+	print_state(STATE_NORMAL, "RELA relocations applied");
 
 	/*
 	 * Get the entry point.
@@ -527,7 +527,7 @@ elf_kernel_reloc(void)
 		fatal("elf_kernel_reloc: entry point not found");
 	}
 
-	print_state(true, "Entry point found");
+	print_state(STATE_NORMAL, "Entry point found");
 
 	return ent;
 }

Index: src/sys/arch/amd64/stand/prekern/mm.c
diff -u src/sys/arch/amd64/stand/prekern/mm.c:1.27 src/sys/arch/amd64/stand/prekern/mm.c:1.28
--- src/sys/arch/amd64/stand/prekern/mm.c:1.27	Thu May  7 17:58:26 2020
+++ src/sys/arch/amd64/stand/prekern/mm.c	Tue May  4 21:09:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mm.c,v 1.27 2020/05/07 17:58:26 maxv Exp $	*/
+/*	$NetBSD: mm.c,v 1.28 2021/05/04 21:09:16 khorben Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -148,7 +148,7 @@ mm_bootspace_mprotect(void)
 		mm_mprotect(bootspace.segs[i].va, bootspace.segs[i].sz, prot);
 	}
 
-	print_state(true, "Segments protection updated");
+	print_state(STATE_NORMAL, "Segments protection updated");
 }
 
 static size_t
@@ -493,9 +493,9 @@ mm_map_kernel(void)
 {
 	memset(, 0, sizeof(bootspace));
 	mm_map_head();
-	print_state(true, "Head region mapped");
+	print_state(STATE_NORMAL, "Head region mapped");
 	elf_map_sections();
-	print_state(true, "Segments mapped");
+	print_state(STATE_NORMAL, "Segments mapped");
 	mm_map_boot();
-	print_state(true, "Boot region mapped");
+	print_state(STATE_NORMAL, "Boot region mapped");
 }

Index: src/sys/arch/amd64/stand/prekern/prekern.c
diff -u src/sys/arch/amd64/stand/prekern/prekern.c:1.13 src/sys/arch/amd64/stand/prekern/prekern.c:1.14
--- src/sys/arch/amd64/stand/prekern/prekern.c:1.13	Sat May 23 08:25:32 2020
+++ src/sys/arch/amd64/stand/prekern/prekern.c	Tue May  4 

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

2021-04-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Apr 17 20:12:55 UTC 2021

Modified Files:
src/sys/arch/amd64/include: asm.h byte_swap.h cpu.h db_machdep.h
frame_regs.h frameasm.h i82093reg.h int_limits.h profile.h
segments.h

Log Message:
sys/arch/amd64: remove trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/amd64/include/asm.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/include/byte_swap.h \
src/sys/arch/amd64/include/frame_regs.h
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/amd64/include/cpu.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/amd64/include/db_machdep.h
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/amd64/include/frameasm.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/include/i82093reg.h \
src/sys/arch/amd64/include/int_limits.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/amd64/include/profile.h
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/include/segments.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.21 src/sys/arch/amd64/include/asm.h:1.22
--- src/sys/arch/amd64/include/asm.h:1.21	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/include/asm.h	Sat Apr 17 20:12:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: asm.h,v 1.21 2020/04/25 15:26:16 bouyer Exp $	*/
+/*	$NetBSD: asm.h,v 1.22 2021/04/17 20:12:55 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -81,12 +81,12 @@
 	ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name:
 #define	IDTVEC_END(name) \
 	.size X ## name, . - X ## name
-#else 
+#else
 #define	IDTVEC(name) \
 	ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name:
 #define	IDTVEC_END(name) \
 	.size X/**/name, . - X/**/name
-#endif /* __STDC__ */ 
+#endif /* __STDC__ */
 #endif /* _KERNEL */
 
 #ifdef __STDC__

Index: src/sys/arch/amd64/include/byte_swap.h
diff -u src/sys/arch/amd64/include/byte_swap.h:1.7 src/sys/arch/amd64/include/byte_swap.h:1.8
--- src/sys/arch/amd64/include/byte_swap.h:1.7	Thu Jan 14 02:06:04 2010
+++ src/sys/arch/amd64/include/byte_swap.h	Sat Apr 17 20:12:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: byte_swap.h,v 1.7 2010/01/14 02:06:04 joerg Exp $	*/
+/*	$NetBSD: byte_swap.h,v 1.8 2021/04/17 20:12:55 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2010 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@ static __inline uint16_t __byte_swap_u16
 static __inline uint16_t
 __byte_swap_u16_variable(uint16_t x)
 {
-	__asm volatile ("rorw $8, %w1" : "=r" (x) : "0" (x)); 
+	__asm volatile ("rorw $8, %w1" : "=r" (x) : "0" (x));
 	return (x);
 }
 
Index: src/sys/arch/amd64/include/frame_regs.h
diff -u src/sys/arch/amd64/include/frame_regs.h:1.7 src/sys/arch/amd64/include/frame_regs.h:1.8
--- src/sys/arch/amd64/include/frame_regs.h:1.7	Sun Apr 26 18:49:39 2015
+++ src/sys/arch/amd64/include/frame_regs.h	Sat Apr 17 20:12:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: frame_regs.h,v 1.7 2015/04/26 18:49:39 mrg Exp $	*/
+/*	$NetBSD: frame_regs.h,v 1.8 2021/04/17 20:12:55 rillig Exp $	*/
 
 #ifndef _AMD64_FRAME_REGS_H_
 #define _AMD64_FRAME_REGS_H_
@@ -11,7 +11,7 @@
  * has been changed to improve syscall efficiency.
  *
  * Notes:
- * 1) gdb (amd64nbsd-tdep.c) has a lookup table that assumes the __greg_t 
+ * 1) gdb (amd64nbsd-tdep.c) has a lookup table that assumes the __greg_t
  *ordering.
  * 2) src/lib/libc/arch/x86_64/gen/makecontext.c assumes that the first
  *6 entries in the __greg_t array match the registers used to pass

Index: src/sys/arch/amd64/include/cpu.h
diff -u src/sys/arch/amd64/include/cpu.h:1.68 src/sys/arch/amd64/include/cpu.h:1.69
--- src/sys/arch/amd64/include/cpu.h:1.68	Tue Mar 17 17:18:49 2020
+++ src/sys/arch/amd64/include/cpu.h	Sat Apr 17 20:12:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.68 2020/03/17 17:18:49 maxv Exp $	*/
+/*	$NetBSD: cpu.h,v 1.69 2021/04/17 20:12:55 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -84,7 +84,7 @@ x86_curlwp(void)
 #define CLKF_INTR(frame)	(curcpu()->ci_idepth > 0)
 #define LWP_PC(l)		((l)->l_md.md_regs->tf_rip)
 
-void *cpu_uarea_alloc(bool);		
+void *cpu_uarea_alloc(bool);
 bool cpu_uarea_free(void *);
 
 #endif	/* _KERNEL */

Index: src/sys/arch/amd64/include/db_machdep.h
diff -u src/sys/arch/amd64/include/db_machdep.h:1.16 src/sys/arch/amd64/include/db_machdep.h:1.17
--- src/sys/arch/amd64/include/db_machdep.h:1.16	Mon Nov  6 03:47:45 2017
+++ src/sys/arch/amd64/include/db_machdep.h	Sat Apr 17 20:12:55 2021
@@ -1,27 +1,27 @@
-/*	$NetBSD: db_machdep.h,v 1.16 2017/11/06 03:47:45 christos Exp $	*/
+/*	$NetBSD: db_machdep.h,v 1.17 2021/04/17 20:12:55 rillig Exp $	*/
 
-/* 
+/*
  * Mach Operating System
  * Copyright (c) 1991,1990 Carnegie Mellon University
  * All Rights Reserved.
- * 
+ *
  * Permission to use, copy, modify and distribute this software and its
  * 

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

2021-03-05 Thread Greg Troxel
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.


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 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.191 src/sys/arch/amd64/conf/XEN3_DOM0:1.192
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.191	Thu Mar  4 16:02:10 2021
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Fri Mar  5 20:30:56 2021
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.191 2021/03/04 16:02:10 gdt Exp $
+# $NetBSD: XEN3_DOM0,v 1.192 2021/03/05 20:30:56 gdt 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.191 $"
+#ident		"XEN3_DOM0-$Revision: 1.192 $"
 
 maxusers	32		# estimated number of users
 
@@ -43,9 +43,20 @@ maxusers	32		# estimated number of users
 #options 	PHYSMEM_MAX_SIZE=64	# max size of physical memory (in MB)
 #options 	PHYSMEM_MAX_ADDR=2048	# don't use memory above this (in MB)
 
+## Replace std.amd64 content
+
+mainbus0 at root
+cpu* at mainbus?
+ioapic* at mainbus? apid ?
+
+# Atheros HAL options
+include "external/isc/atheros_hal/conf/std.ath_hal"
+
+## end std.amd64
+
 ## Xen-specific options
 
-options		XENPV		# PV dom0 support
+options 	XENPV		# PV dom0 support
 options 	DOM0OPS
 options 	MULTIPROCESSOR
 #options 	NO_PREEMPTION	# needed if MULTIPROCESSOR is disabled
@@ -58,10 +69,6 @@ options 	MULTIPROCESSOR
 # boot messages with MPBIOS, acpi and ioapic can be quite large
 options 	MSGBUFSIZE=24576
 
-# CPU features
-est0		at cpu0		# Intel Enhanced SpeedStep (non-ACPI)
-powernow0	at cpu0		# AMD PowerNow! and Cool'n'Quiet (non-ACPI)
-
 # Standard system options
 
 options 	INSECURE	# disable kernel security levels - X needs this
@@ -79,10 +86,20 @@ 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 	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
+est0		at cpu0		# Intel Enhanced SpeedStep (non-ACPI)
+#hyperv0 	at cpu0		# Microsoft Hyper-V
+#odcm0		at cpu0		# On-demand clock modulation
+powernow0	at cpu0		# AMD PowerNow! and Cool'n'Quiet (non-ACPI)
+#vmt0		at cpu0		# VMware Tools
+
 # Alternate buffer queue strategies for better responsiveness under high
 # disk I/O load.
 #options 	BUFQ_READPRIO
@@ -286,10 +303,6 @@ config		netbsd	root on ? type ?
 #
 
 ## Xen-specific options
-mainbus0 at root
-
-cpu* at mainbus?
-
 hypervisor*	at mainbus?		# Xen hypervisor
 
 vcpu*		at hypervisor?		# Xen virtual CPUs
@@ -306,8 +319,8 @@ ipmi_acpi*	at acpi?
 ipmi0		at ipmi_acpi?
 
 # ACPI will be used if present. If not it will fall back to MPBIOS
-acpi0		at hypervisor?		# ACPI access in PV mode
 acpi0		at mainbus?		# ACPI access in PVH(VM) mode
+acpi0		at hypervisor?		# ACPI access in PV mode
 
 options 	ACPI_SCANPCI		# find PCI roots using ACPI
 options 	MPBIOS			# configure CPUs and APICs using MPBIOS
@@ -322,8 +335,6 @@ options 	MPBIOS_SCANPCI		# MPBIOS config
 #options 	MPDEBUG			# MPBIOS configures PCI roots
 #options 	MPVERBOSE		# verbose MPBIOS autoconfig messages
 
-ioapic* 	at mainbus? apid ?
-
 # ACPI devices
 acpiacad*	at acpi?		# ACPI AC Adapter
 acpibat*	at acpi?		# ACPI Battery
@@ -343,30 +354,44 @@ acpitz* 	at acpi?		# ACPI Thermal Zone
 
 # Mainboard devices
 aibs*		at acpi?		# ASUSTeK AI Booster hardware monitor
+#asus*		at acpi?		# ASUS hotkeys
+#attimer*	at acpi?		# AT Timer
 #com*		at acpi?		# Serial communications interface
 #fdc*		at acpi?		# Floppy disk controller
+#fujbp*		at acpi?		# Fujitsu Brightness & Pointer
+#fujhk*		at acpi?		# Fujitsu Hotkeys
 #hpacel* 	at acpi?		# HP 3D DriveGuard accelerometer
-#hpqlb*		at acpi?		# HP Quick Launch Buttons
 hpqlb*		at acpi?		# HP Quick Launch Buttons
+#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
+#mpu*		at acpi?		# Roland MPU-401 MIDI UART
 #lpt*		at acpi?		# Parallel port
 pckbc*		at acpi?		# PC keyboard controller
 pcppi*		at 

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

2021-03-05 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Fri Mar  5 20:18:39 UTC 2021

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

Log Message:
GENERIC: comment typo fix (spacing)


To generate a diff of this commit:
cvs rdiff -u -r1.585 -r1.586 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.585 src/sys/arch/amd64/conf/GENERIC:1.586
--- src/sys/arch/amd64/conf/GENERIC:1.585	Thu Mar  4 15:58:50 2021
+++ src/sys/arch/amd64/conf/GENERIC	Fri Mar  5 20:18:39 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.585 2021/03/04 15:58:50 gdt Exp $
+# $NetBSD: GENERIC,v 1.586 2021/03/05 20:18:39 gdt 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.585 $"
+#ident		"GENERIC-$Revision: 1.586 $"
 
 maxusers	64		# estimated number of users
 
@@ -1133,7 +1133,7 @@ pseudo-device	ccd			# concatenated/strip
 pseudo-device	cgd			# cryptographic disk devices
 pseudo-device	raid			# RAIDframe disk driver
 options 	RAID_AUTOCONFIG		# auto-configuration of RAID components
-#Options to enable various other RAIDframe RAID types.
+# Options to enable various other RAIDframe RAID types.
 #options 	RF_INCLUDE_EVENODD=1
 #options 	RF_INCLUDE_RAID5_RS=1
 #options 	RF_INCLUDE_PARITYLOGGING=1



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

2021-03-04 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Thu Mar  4 19:01:41 UTC 2021

Modified Files:
src/sys/arch/amd64/conf: std.xen

Log Message:
std.xen: Move towards std.amd64

(No functional change.)


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/amd64/conf/std.xen

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/std.xen
diff -u src/sys/arch/amd64/conf/std.xen:1.13 src/sys/arch/amd64/conf/std.xen:1.14
--- src/sys/arch/amd64/conf/std.xen:1.13	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/conf/std.xen	Thu Mar  4 19:01:41 2021
@@ -1,20 +1,20 @@
-# $NetBSD: std.xen,v 1.13 2020/04/25 15:26:16 bouyer Exp $
-# NetBSD: std.i386,v 1.24 2003/02/26 21:33:36 fvdl Exp 
+# $NetBSD: std.xen,v 1.14 2021/03/04 19:01:41 gdt Exp $
 #
-# standard, required NetBSD/i386 'options'
+# standard, required NetBSD/xen 'options'
+# Note that this file is used by both DOM0 and DOMU.
 
 machine xen amd64 x86
 include 	"conf/std"	# MI standard options
-include		"arch/xen/conf/files.xen.pv"
-
-options 	XEN	#Xen support
-
-include		"arch/xen/conf/std.xenversion"
+include 	"arch/xen/conf/std.xenversion"
 
 options 	CPU_IN_CKSUM
 options 	EXEC_ELF64	# exec ELF binaries
 options 	EXEC_SCRIPT	# exec #! scripts
 options 	MTRR
+#options 	MULTIPROCESSOR
 
 options 	CHILD_MAX=1024	# 160 is too few
 options 	OPEN_MAX=1024	# 128 is too few
+
+options 	XEN		# Xen support
+include 	"arch/xen/conf/files.xen.pv"



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

2021-03-04 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Thu Mar  4 16:02:11 UTC 2021

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

Log Message:
XEN3_DOM0: Move closer to GENERIC (NFC)

This is another step in making XEN3_DOM0 closer to GENERIC.  It is
just reordering lines, adding commented out lines, and adding a few
comments.  (Test-booted with no dmesg change.)

This pass is showing cases where there are substantive and likely
undesired changes (e.g., UFS_ACL is not defined in XEN3_DOM0).  Often
I added them but commented them out to preserve the NFC property of
this commit.  My plan is to finish the easy NFC stuff first before
addressing functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 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.190 src/sys/arch/amd64/conf/XEN3_DOM0:1.191
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.190	Wed Mar  3 12:31:19 2021
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Thu Mar  4 16:02:10 2021
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.190 2021/03/03 12:31:19 gdt Exp $
+# $NetBSD: XEN3_DOM0,v 1.191 2021/03/04 16:02:10 gdt 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.190 $"
+#ident		"XEN3_DOM0-$Revision: 1.191 $"
 
 maxusers	32		# estimated number of users
 
@@ -80,6 +80,7 @@ options 	SYSVSHM		# System V-like memory
 
 options 	MODULAR		# new style module(7) framework
 options 	USERCONF	# userconf(4) support
+#options 	PIPE_SOCKETPAIR	# smaller, but slower pipe(2)
 options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 
 # Alternate buffer queue strategies for better responsiveness under high
@@ -108,9 +109,55 @@ options 	DDB_HISTORY_SIZE=512	# enable h
 #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
+
+# Kernel Undefined Behavior Sanitizer (kUBSan).
+#options 	KUBSAN			# mandatory
+#options 	UBSAN_ALWAYS_FATAL	# optional: panic on all kUBSan reports
+
+# Kernel Address Sanitizer (kASan). You need to disable SVS to use it.
+# The quarantine is optional and can help KASAN find more use-after-frees.
+# Use KASAN_PANIC if you want panics instead of warnings.
+#makeoptions 	KASAN=1		# mandatory
+#options 	KASAN		# mandatory
+#no options	SVS		# mandatory
+#options 	POOL_QUARANTINE	# optional
+#options 	KASAN_PANIC	# optional
+
+# Kernel Concurrency Sanitizer (kCSan).
+#makeoptions 	KCSAN=1		# mandatory
+#options 	KCSAN		# mandatory
+#options 	KCSAN_PANIC	# optional
+
+# Kernel Memory Sanitizer (kMSan). You need to disable SVS and kernel modules
+# to use it. POOL_NOCACHE is optional and can help KMSAN find uninitialized
+# 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 	MODULAR		# mandatory
+#no options 	MODULAR_DEFAULT_AUTOLOAD	# mandatory
+#options 	POOL_NOCACHE	# optional
+#options 	KMSAN_PANIC	# optional
+
+# Kernel Code Coverage Driver.
+#makeoptions	KCOV=1
+#options 	KCOV
+
+# Fault Injection Driver.
+#options 	FAULT
 
 # Compatibility options
+# x86_64 never shipped with a.out binaries; the two options below are
+# only relevant to 32-bit i386 binaries
+#options 	EXEC_AOUT	# required by binaries from before 1.5
+#options 	COMPAT_NOMID	# NetBSD 0.8, 386BSD, and BSDI
+
+# NetBSD backward compatibility. Support goes from COMPAT_15 up until
+# the latest release. Note that really old compat (< COMPAT_16) is only
+# useful for 32-bit i386 binaries.
 include 	"conf/compat_netbsd15.config"
+
 #options 	COMPAT_386BSD_MBRPART # recognize old partition ID
 
 options 	COMPAT_NETBSD32
@@ -128,17 +175,23 @@ options 	DKWEDGE_METHOD_APPLE	# Support 
 include "conf/filesystems.config"
 
 # File system options
+# ffs
 options 	QUOTA		# legacy UFS quotas
 options 	QUOTA2		# new, in-filesystem UFS quotas
-#options 	DISKLABEL_EI	# disklabel 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 	NFSSERVER	# Network File System server
+#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	

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

2021-03-04 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Thu Mar  4 15:58:50 UTC 2021

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

Log Message:
GENERIC: Tiny comment adjustment (NFC)

While making XEN3_DOM0 more like GENERIC, I noticed a few differences
where GENERIC was off -- trivial things like missing spaces in
comments, inconsistent comment workding.  This fixes those, both
because they are valid fixes in their own right once noticed, and to
make the diff to XEN smaller.


To generate a diff of this commit:
cvs rdiff -u -r1.584 -r1.585 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.584 src/sys/arch/amd64/conf/GENERIC:1.585
--- src/sys/arch/amd64/conf/GENERIC:1.584	Mon Mar  1 18:12:58 2021
+++ src/sys/arch/amd64/conf/GENERIC	Thu Mar  4 15:58:50 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.584 2021/03/01 18:12:58 jakllsch Exp $
+# $NetBSD: GENERIC,v 1.585 2021/03/04 15:58:50 gdt 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.584 $"
+#ident		"GENERIC-$Revision: 1.585 $"
 
 maxusers	64		# estimated number of users
 
@@ -297,7 +297,7 @@ config		netbsd	root on ? type ?
 # Device configuration
 #
 
-#IPMI support
+# IPMI support
 ipmi0		at mainbus?
 ipmi_acpi*	at acpi?
 ipmi0		at ipmi_acpi?
@@ -307,7 +307,7 @@ acpi0		at mainbus0
 options 	ACPI_SCANPCI		# find PCI roots using ACPI
 options 	MPBIOS			# configure CPUs and APICs using MPBIOS
 options 	MPBIOS_SCANPCI		# MPBIOS configures PCI roots
-#options 	PCI_INTR_FIXUP		# PCI interrupt routing via ACPI
+#options 	PCI_INTR_FIXUP		# fixup PCI interrupt routing via ACPI
 #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
@@ -317,7 +317,7 @@ options 	VGA_POST		# in-kernel support f
 acpiacad*	at acpi?		# ACPI AC Adapter
 acpibat*	at acpi?		# ACPI Battery
 acpibut*	at acpi?		# ACPI Button
-acpidalb*	at acpi?		# Direct Application Launch Button
+acpidalb*	at acpi?		# ACPI Direct Application Launch Button
 acpiec* 	at acpi?		# ACPI Embedded Controller (late)
 acpiecdt*	at acpi?		# ACPI Embedded Controller (early)
 acpifan*	at acpi?		# ACPI Fan



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

2021-03-03 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Wed Mar  3 12:31:19 UTC 2021

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

Log Message:
XEN3_DOM0: Move closer to GENERIC (NFC)

This commit reorders some lines, and brings in commented lines from
GENERIC to reduce the diff.  It also brings in two agp lines,
commented out, and with a warning that they are intentionally omitted.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 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.189 src/sys/arch/amd64/conf/XEN3_DOM0:1.190
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.189	Tue Mar  2 18:10:31 2021
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Wed Mar  3 12:31:19 2021
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.189 2021/03/02 18:10:31 gdt Exp $
+# $NetBSD: XEN3_DOM0,v 1.190 2021/03/03 12:31:19 gdt Exp $
 
 # XEN3_DOM0 machine description file
 #
@@ -12,22 +12,48 @@
 
 include 	"arch/amd64/conf/std.xen"
 
-options		XENPV		# PV dom0 support
-options 	MULTIPROCESSOR
-#options 	NO_PREEMPTION	# needed if MULTIPROCESSOR is disabled
-
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#options 	UVMHIST
-#options 	UVMHIST_PRINT
-#options 	SYSCALL_DEBUG
-
-#ident		"XEN3_DOM0-$Revision: 1.189 $"
+#ident		"XEN3_DOM0-$Revision: 1.190 $"
 
 maxusers	32		# estimated number of users
 
-#
+# delay between "rebooting ..." message and hardware reset, in milliseconds
+#options 	CPURESET_DELAY=2000
+
+# This option allows you to force a serial console at the specified
+# I/O address.   see console(4) for details.
+#options 	CONSDEVNAME="\"com\"",CONADDR=0x2f8,CONSPEED=57600
+#	you don't want the option below ON iff you are using the
+#	serial console option of the new boot strap code.
+#options 	CONS_OVERRIDE	# Always use above! independent of boot info
+
+# The following options override the memory sizes passed in from the boot
+# block.  Use them *only* if the boot block is unable to determine the correct
+# values.  Note that the BIOS may *correctly* report less than 640k of base
+# memory if the extended BIOS data area is located at the top of base memory
+# (as is the case on most recent systems).
+#options 	REALBASEMEM=639		# size of base memory (in KB)
+#options 	REALEXTMEM=15360	# size of extended memory (in KB)
+
+# The following options limit the overall size of physical memory
+# and/or the maximum address used by the system.
+# Contrary to REALBASEMEM and REALEXTMEM, they still use the BIOS memory map
+# and can deal with holes in the memory layout.
+#options 	PHYSMEM_MAX_SIZE=64	# max size of physical memory (in MB)
+#options 	PHYSMEM_MAX_ADDR=2048	# don't use memory above this (in MB)
+
+## Xen-specific options
+
+options		XENPV		# PV dom0 support
 options 	DOM0OPS
+options 	MULTIPROCESSOR
+#options 	NO_PREEMPTION	# needed if MULTIPROCESSOR is disabled
+
+#options 	CONSDEVNAME="\"xencons\""
+#options 	CONS_OVERRIDE
+
+## end Xen-specific options
 
 # boot messages with MPBIOS, acpi and ioapic can be quite large
 options 	MSGBUFSIZE=24576
@@ -36,10 +62,7 @@ options 	MSGBUFSIZE=24576
 est0		at cpu0		# Intel Enhanced SpeedStep (non-ACPI)
 powernow0	at cpu0		# AMD PowerNow! and Cool'n'Quiet (non-ACPI)
 
-#options 	MTRR		# memory-type range register syscall support
-
-#options 	CONSDEVNAME="\"xencons\""
-#options 	CONS_OVERRIDE
+# Standard system options
 
 options 	INSECURE	# disable kernel security levels - X needs this
 
@@ -50,6 +73,7 @@ options 	KTRACE		# system call tracing v
 
 options 	CPU_UCODE	# cpu ucode loading support
 
+# Note: SysV IPC parameters could be changed dynamically, see sysctl(8).
 options 	SYSVMSG		# System V-like message queues
 options 	SYSVSEM		# System V-like semaphores
 options 	SYSVSHM		# System V-like memory sharing
@@ -65,15 +89,25 @@ options 	BUFQ_PRIOCSCAN
 
 # Diagnostic/debugging support options
 options 	DIAGNOSTIC	# inexpensive kernel consistency checks
+# XXX to be commented out on release branch
 #options 	DEBUG		# expensive debugging checks/support
+#options 	LOCKDEBUG	# expensive locking checks/support
+
+#
+# Because gcc omits the frame pointer for any -O level, the line below
+# is needed to make backtraces in DDB work.
+#
+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_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	COPTS="-O2 -fno-omit-frame-pointer"
-options DDB_COMMANDONENTER="show registers"
+#options 	SYSCALL_STATS	# per syscall counts
+#options 	SYSCALL_TIMES	# per syscall times
+#options 	

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

2021-03-02 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Tue Mar  2 18:10:31 UTC 2021

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

Log Message:
XEN3_DOM0: Fix pckbc console attachment logic

Copy PCKBD_CNATTACH_MAY_FAIL lines from GENERIC to XEN3_DOM0.

GENERIC defines PCKBD_CNATTACH_MAY_FAIL, which means that an attempt
to activate console input on pckbc will fail if there is no keyboard
present.  This is a problem on semi-modern machines that have pckbc
silicon but not ports, and thus almost always have a USB keyboard
also.  What I suspect are bugs in console attachment logic lead to
attempting to attach a ukbd while there already is a console keyboard,
and with DIAGNOSTIC this is (properly) fatal, so XEN3_DOM0 blows up
with a USB keyboard in current, and probably not in 9.

Live tested on a machine that previously paniced on boot.


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 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.188 src/sys/arch/amd64/conf/XEN3_DOM0:1.189
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.188	Tue Mar  2 18:06:12 2021
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Tue Mar  2 18:10:31 2021
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.188 2021/03/02 18:06:12 gdt Exp $
+# $NetBSD: XEN3_DOM0,v 1.189 2021/03/02 18:10:31 gdt Exp $
 
 # XEN3_DOM0 machine description file
 #
@@ -22,7 +22,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOM0-$Revision: 1.188 $"
+#ident		"XEN3_DOM0-$Revision: 1.189 $"
 
 maxusers	32		# estimated number of users
 
@@ -166,6 +166,8 @@ options 	WSDISPLAY_COMPAT_PCVT		# emulat
 options 	WSDISPLAY_COMPAT_SYSCONS	# emulate some ioctls
 options 	WSDISPLAY_COMPAT_USL		# wsconscfg VT handling
 options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
+# don't attach pckbd as the console if no PS/2 keyboard is found
+options 	PCKBD_CNATTACH_MAY_FAIL
 # see dev/pckbport/wskbdmap_mfii.c for implemented layouts
 #options 	PCKBD_LAYOUT="(KB_DE | KB_NODEAD)"
 # allocate a number of virtual screens at autoconfiguration time



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

2021-03-02 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Tue Mar  2 18:06:12 UTC 2021

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

Log Message:
XEN3_DOM0: Sync VERBOSE with GENERIC

Copy the *VERBOSE option block from GENERIC, and prune the scattered
verbose options in XEN3_DOM0, surely dating from a time they were
copied from an earlier GENERIC.  This amounts to adding PCIVERBOSE and
SCSIVERBOSE, and the diff from GENERIC to DOM0 boots is markedly
reduced.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 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.187 src/sys/arch/amd64/conf/XEN3_DOM0:1.188
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.187	Mon Mar  1 13:52:50 2021
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Tue Mar  2 18:06:12 2021
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.187 2021/03/01 13:52:50 gdt Exp $
+# $NetBSD: XEN3_DOM0,v 1.188 2021/03/02 18:06:12 gdt Exp $
 
 # XEN3_DOM0 machine description file
 #
@@ -22,7 +22,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOM0-$Revision: 1.187 $"
+#ident		"XEN3_DOM0-$Revision: 1.188 $"
 
 maxusers	32		# estimated number of users
 
@@ -133,6 +133,17 @@ options 	PPP_FILTER	# Active filter supp
 #options 	ALTQ_RIO	# RED with IN/OUT
 #options 	ALTQ_WFQ	# Weighted Fair Queueing
 
+# These options enable verbose messages for several subsystems.
+# Warning, these may compile large string tables into the kernel!
+#options 	ACPIVERBOSE	# verbose ACPI configuration messages
+#options 	MIIVERBOSE	# verbose PHY autoconfig messages
+options 	PCIVERBOSE	# verbose PCI device autoconfig messages
+#options 	PCI_CONFIG_DUMP	# verbosely dump PCI config space
+#options 	PCMCIAVERBOSE	# verbose PCMCIA configuration messages
+options 	SCSIVERBOSE	# human readable SCSI error messages
+#options 	USBVERBOSE	# verbose USB device autoconfig messages
+#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\""
@@ -197,8 +208,6 @@ acpi0		at mainbus?		# ACPI access in PVH
 #options 	ACPI_ACTIVATE_DEV	# If set, activate inactive devices
 options 	ACPI_SCANPCI		# find PCI roots using ACPI
 #options 	ACPICA_PEDANTIC		# force strict conformance to the Spec.
-#options 	ACPIVERBOSE		# verbose ACPI configuration messages
-#options 	MIIVERBOSE		# verbose PHY autoconfig messages
 options 	MPBIOS			# configure CPUs and APICs using MPBIOS
 #options 	MPDEBUG			# MPBIOS configures PCI roots
 #options 	MPVERBOSE		# verbose MPBIOS autoconfig messages
@@ -206,9 +215,6 @@ options 	MPBIOS_SCANPCI		# MPBIOS config
 #options 	PCI_ADDR_FIXUP		# fixup PCI I/O addresses
 #options 	PCI_BUS_FIXUP		# fixup PCI bus numbering
 #options 	PCI_INTR_FIXUP		# fixup PCI interrupt routing
-#options 	PCIVERBOSE		# verbose PCI device autoconfig messages
-#options 	USBVERBOSE		# verbose USB device autoconfig messages
-#options 	HDAUDIOVERBOSE		# verbose HDAUDIO driver messages
 
 ioapic* 	at mainbus? apid ?
 



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

2021-03-01 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Mon Mar  1 13:52:50 UTC 2021

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

Log Message:
amd64/conf/XEN3_DOM0: Add comment

This commit merely adds a comment explaining how XEN3_DOM0 ought to
relate to GENERIC.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 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.186 src/sys/arch/amd64/conf/XEN3_DOM0:1.187
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.186	Wed Jan 20 13:22:08 2021
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Mon Mar  1 13:52:50 2021
@@ -1,4 +1,14 @@
-# $NetBSD: XEN3_DOM0,v 1.186 2021/01/20 13:22:08 nia Exp $
+# $NetBSD: XEN3_DOM0,v 1.187 2021/03/01 13:52:50 gdt Exp $
+
+# XEN3_DOM0 machine description file
+#
+# This machine description file is used to generate a kernel to be
+# used as a PV dom0 under Xen.  It is similar to GENERIC in that it is
+# intended to be useful for most applications.  Generally, besides
+# changes that are specifically required for Xen (e.g., XENPV), it
+# should be similar to GENERIC.  Some differences are currently
+# necessary, such as drivers that fail under Xen but work in GENERIC,
+# for reasons that do not follow from Xen architecture.
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -12,7 +22,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOM0-$Revision: 1.186 $"
+#ident		"XEN3_DOM0-$Revision: 1.187 $"
 
 maxusers	32		# estimated number of users
 



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

2021-01-24 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Jan 24 14:17:11 UTC 2021

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

Log Message:
Fix a tyop in a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/sys/arch/amd64/amd64/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/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.357 src/sys/arch/amd64/amd64/machdep.c:1.358
--- src/sys/arch/amd64/amd64/machdep.c:1.357	Mon Sep  7 00:47:27 2020
+++ src/sys/arch/amd64/amd64/machdep.c	Sun Jan 24 14:17:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $	*/
+/*	$NetBSD: machdep.c,v 1.358 2021/01/24 14:17:10 simonb Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.358 2021/01/24 14:17:10 simonb Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -344,7 +344,7 @@ cpu_startup(void)
 	consinit();
 
 	/*
-	 * Initialize error message buffer (et end of core).
+	 * Initialize error message buffer (at end of core).
 	 */
 	if (msgbuf_p_cnt == 0)
 		panic("msgbuf paddr map has not been set up");



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

2021-01-20 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Jan 20 21:38:44 UTC 2021

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

Log Message:
COMPAT_OSSAUDIO no longer exists; remove dangling reference


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 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.5 src/sys/arch/amd64/conf/NOCOMPAT:1.6
--- src/sys/arch/amd64/conf/NOCOMPAT:1.5	Sun Aug 16 10:27:47 2020
+++ src/sys/arch/amd64/conf/NOCOMPAT	Wed Jan 20 21:38:44 2021
@@ -1,6 +1,6 @@
 include "arch/amd64/conf/GENERIC"
 
-#ident		"NOCOMPAT-$Revision: 1.5 $"
+#ident		"NOCOMPAT-$Revision: 1.6 $"
 
 no options 	SYSVMSG		# System V-like message queues
 no options 	SYSVSEM		# System V-like semaphores
@@ -31,6 +31,5 @@ no options	COMPAT_15
 #no options	COMPAT_80
 #no options	COMPAT_90
  
-no options 	COMPAT_OSSAUDIO
 no options 	COMPAT_NETBSD32
 no options 	EXEC_ELF32	# requires COMPAT_NETBSD32



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

2021-01-15 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jan 16 01:43:42 UTC 2021

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

Log Message:
Enable tpm @ acpi (now that it can match TPM 1.2 devices, which are not,
as the comment implies, experimental).


To generate a diff of this commit:
cvs rdiff -u -r1.580 -r1.581 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.580 src/sys/arch/amd64/conf/GENERIC:1.581
--- src/sys/arch/amd64/conf/GENERIC:1.580	Sun Sep 27 13:48:49 2020
+++ src/sys/arch/amd64/conf/GENERIC	Sat Jan 16 01:43:42 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.580 2020/09/27 13:48:49 roy Exp $
+# $NetBSD: GENERIC,v 1.581 2021/01/16 01:43:42 thorpej 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.580 $"
+#ident		"GENERIC-$Revision: 1.581 $"
 
 maxusers	64		# estimated number of users
 
@@ -354,7 +354,7 @@ sony*		at acpi?		# Sony Notebook Control
 spic*		at acpi?		# Sony Programmable I/O Controller
 wsmouse*	at spic?		# mouse
 thinkpad*	at acpi?		# IBM/Lenovo Thinkpad hotkeys
-#tpm*		at acpi?		# ACPI TPM (Experimental)
+tpm*		at acpi?		# ACPI TPM (Experimental)
 ug*		at acpi?		# Abit uGuru Hardware monitor
 valz*		at acpi?		# Toshiba Dynabook hotkeys
 wb*		at acpi?		# Winbond W83L518D SD/MMC reader



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

2020-12-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec 13 08:23:52 UTC 2020

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

Log Message:
Add atppc* at acpi?


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 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.164 src/sys/arch/amd64/conf/ALL:1.165
--- src/sys/arch/amd64/conf/ALL:1.164	Sun Sep 27 13:48:49 2020
+++ src/sys/arch/amd64/conf/ALL	Sun Dec 13 08:23:52 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.164 2020/09/27 13:48:49 roy Exp $
+# $NetBSD: ALL,v 1.165 2020/12/13 08:23:52 martin 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.164 $"
+#ident		"ALL-$Revision: 1.165 $"
 
 maxusers	64		# estimated number of users
 
@@ -377,6 +377,7 @@ aibs*		at acpi?		# ASUSTeK AI Booster ha
 applesmc*	at acpi?		# Apple System Management Controller
 asus*		at acpi?		# ASUS hotkeys
 attimer*	at acpi?		# AT Timer
+atppc*		at acpi?		# AT-style parallel port
 com*		at acpi?		# Serial communications interface
 fdc*		at acpi?		# Floppy disk controller
 fujbp*		at acpi?		# Fujitsu Brightness & Pointer



CVS commit: src/sys/arch/amd64

2020-11-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Nov 30 17:02:27 UTC 2020

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

Log Message:
Introduce smap_enable()/smap_disable() functions, to be used from
C code.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/amd64/include/cpufunc.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/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.64 src/sys/arch/amd64/amd64/cpufunc.S:1.65
--- src/sys/arch/amd64/amd64/cpufunc.S:1.64	Sun Jul 19 07:35:08 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Mon Nov 30 17:02:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.64 2020/07/19 07:35:08 maxv Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.65 2020/11/30 17:02:27 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -167,6 +167,16 @@ END(x86_write_flags)
 
 STRONG_ALIAS(x86_write_psl,x86_write_flags)
 
+ENTRY(smap_enable)
+	SMAP_ENABLE
+	ret
+END(smap_enable)
+
+ENTRY(smap_disable)
+	SMAP_DISABLE
+	ret
+END(smap_disable)
+
 /*
  * %rdi = name
  * %rsi = sel

Index: src/sys/arch/amd64/include/cpufunc.h
diff -u src/sys/arch/amd64/include/cpufunc.h:1.19 src/sys/arch/amd64/include/cpufunc.h:1.20
--- src/sys/arch/amd64/include/cpufunc.h:1.19	Wed Oct 17 19:53:03 2007
+++ src/sys/arch/amd64/include/cpufunc.h	Mon Nov 30 17:02:27 2020
@@ -1,3 +1,6 @@
-/*	$NetBSD: cpufunc.h,v 1.19 2007/10/17 19:53:03 garbled Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.20 2020/11/30 17:02:27 bouyer Exp $	*/
 
 #include 
+
+void smap_enable(void);
+void smap_disable(void);



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

2020-11-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 26 20:50:45 UTC 2020

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

Log Message:
make the max text size the same as the max data size


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/amd64/include/vmparam.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/vmparam.h
diff -u src/sys/arch/amd64/include/vmparam.h:1.53 src/sys/arch/amd64/include/vmparam.h:1.54
--- src/sys/arch/amd64/include/vmparam.h:1.53	Tue Oct  6 09:42:03 2020
+++ src/sys/arch/amd64/include/vmparam.h	Thu Nov 26 15:50:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.53 2020/10/06 13:42:03 christos Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.54 2020/11/26 20:50:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -88,7 +88,7 @@
 /*
  * Virtual memory related constants, all in bytes
  */
-#define	MAXTSIZ		(256*1024*1024)		/* max text size */
+#define	MAXTSIZ		(8L*1024*1024*1024)	/* max text size */
 #ifndef DFLDSIZ
 #define	DFLDSIZ		(256*1024*1024)		/* initial data size limit */
 #endif



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

2020-11-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov 20 17:44:56 UTC 2020

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

Log Message:
malloc(9) -> kmem(9)


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/amd64/amd64/netbsd32_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/netbsd32_machdep.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.136 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.137
--- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.136	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/amd64/netbsd32_machdep.c	Fri Nov 20 17:44:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.136 2020/04/25 15:26:16 bouyer Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.137 2020/11/20 17:44:56 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.136 2020/04/25 15:26:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.137 2020/11/20 17:44:56 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -632,14 +632,16 @@ x86_64_set_ldt32(struct lwp *l, void *ar
 	if (ua.num < 0 || ua.num > MAX_USERLDT_SLOTS)
 		return EINVAL;
 
-	descv = malloc(sizeof(*descv) * ua.num, M_TEMP, M_WAITOK);
+	const size_t alloc_size = sizeof(*descv) * ua.num;
+
+	descv = kmem_alloc(alloc_size, KM_SLEEP);
 	error = copyin((void *)(uintptr_t)ua32.desc, descv,
 	sizeof(*descv) * ua.num);
 	if (error == 0)
 		error = x86_set_ldt1(l, , descv);
 	*retval = ua.start;
 
-	free(descv, M_TEMP);
+	kmem_free(descv, alloc_size);
 	return error;
 }
 
@@ -660,14 +662,16 @@ x86_64_get_ldt32(struct lwp *l, void *ar
 	if (ua.num < 0 || ua.num > MAX_USERLDT_SLOTS)
 		return EINVAL;
 
-	cp = malloc(ua.num * sizeof(union descriptor), M_TEMP, M_WAITOK);
+	const size_t alloc_size = ua.num * sizeof(union descriptor);
+
+	cp = kmem_alloc(alloc_size, KM_SLEEP);
 	error = x86_get_ldt1(l, , cp);
 	*retval = ua.num;
 	if (error == 0)
 		error = copyout(cp, (void *)(uintptr_t)ua32.desc,
 		ua.num * sizeof(*cp));
 
-	free(cp, M_TEMP);
+	kmem_free(cp, alloc_size);
 	return error;
 }
 #endif



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

2020-11-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Nov 18 16:13:34 UTC 2020

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

Log Message:
Make this at least compile.
Looks like a missing part from "Round of uvm.h cleanup (2020-09-05 18:30)".


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 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.5 src/sys/arch/amd64/include/msan.h:1.6
--- src/sys/arch/amd64/include/msan.h:1.5	Wed Sep  9 16:29:59 2020
+++ src/sys/arch/amd64/include/msan.h	Wed Nov 18 16:13:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: msan.h,v 1.5 2020/09/09 16:29:59 maxv Exp $	*/
+/*	$NetBSD: msan.h,v 1.6 2020/11/18 16:13:34 hannken Exp $	*/
 
 /*
  * Copyright (c) 2019-2020 Maxime Villard, m00nbsd.net
@@ -30,6 +30,8 @@
 
 #include 
 
+#include 
+
 #include 
 #include 
 



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

2020-09-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Sep  7 00:47:27 UTC 2020

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

Log Message:
adjust some fallback code to be slightly less ugly and avoid
upsetting GCC 9.


To generate a diff of this commit:
cvs rdiff -u -r1.356 -r1.357 src/sys/arch/amd64/amd64/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/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.356 src/sys/arch/amd64/amd64/machdep.c:1.357
--- src/sys/arch/amd64/amd64/machdep.c:1.356	Tue Jul 14 00:45:52 2020
+++ src/sys/arch/amd64/amd64/machdep.c	Mon Sep  7 00:47:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.356 2020/07/14 00:45:52 yamaguchi Exp $	*/
+/*	$NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.356 2020/07/14 00:45:52 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -1518,9 +1518,12 @@ init_x86_64_ksyms(void)
 		tesym = (vaddr_t)symtab->esym + KERNBASE;
 #endif
 		ksyms_addsyms_elf(symtab->nsym, (void *)tssym, (void *)tesym);
-	} else
-		ksyms_addsyms_elf(*(long *)(void *),
-		((long *)(void *)) + 1, esym);
+	} else {
+		uintptr_t endp = (uintptr_t)(void *)
+
+		ksyms_addsyms_elf(*(long *)endp,
+		((long *)endp) + 1, esym);
+	}
 #endif
 }
 #endif /* XENPV */



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

2020-08-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 30 11:16:17 UTC 2020

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

Log Message:
typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.577 -r1.578 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.577 src/sys/arch/amd64/conf/GENERIC:1.578
--- src/sys/arch/amd64/conf/GENERIC:1.577	Mon Aug 17 20:43:13 2020
+++ src/sys/arch/amd64/conf/GENERIC	Sun Aug 30 11:16:17 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.577 2020/08/17 20:43:13 christos Exp $
+# $NetBSD: GENERIC,v 1.578 2020/08/30 11:16:17 dholland 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.577 $"
+#ident		"GENERIC-$Revision: 1.578 $"
 
 maxusers	64		# estimated number of users
 
@@ -78,7 +78,7 @@ options 	USER_LDT	# User-settable LDT, u
 options 	SVS		# Separate Virtual Space
 options 	PCPU_IDT	# Per CPU IDTs
 
-# GCC Spectre variant 2 migitation
+# GCC Spectre variant 2 mitigation
 makeoptions	SPECTRE_V2_GCC_MITIGATION=1
 options 	SPECTRE_V2_GCC_MITIGATION
 



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

2020-08-29 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 29 07:16:04 UTC 2020

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

Log Message:
'doreti_checkast' isn't global anymore, localify.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/amd64/amd64/spl.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/spl.S
diff -u src/sys/arch/amd64/amd64/spl.S:1.46 src/sys/arch/amd64/amd64/spl.S:1.47
--- src/sys/arch/amd64/amd64/spl.S:1.46	Sun May 17 12:11:11 2020
+++ src/sys/arch/amd64/amd64/spl.S	Sat Aug 29 07:16:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.46 2020/05/17 12:11:11 ad Exp $	*/
+/*	$NetBSD: spl.S,v 1.47 2020/08/29 07:16:03 maxv Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -331,9 +331,7 @@ IDTVEC(doreti)
 5:
 	testb	$SEL_RPL,TF_CS(%rsp)
 	jz	6f
-
-	.type	_C_LABEL(doreti_checkast), @function
-LABEL(doreti_checkast)
+.Ldoreti_checkast:
 	movq	CPUVAR(CURLWP),%r14
 	CHECK_ASTPENDING(%r14)
 	je	3f
@@ -345,7 +343,7 @@ LABEL(doreti_checkast)
 	KMSAN_INIT_ARG(8)
 	call	_C_LABEL(trap)
 	CLI(si)
-	jmp	doreti_checkast
+	jmp	.Ldoreti_checkast
 3:
 	CHECK_DEFERRED_SWITCH
 	jnz	9f
@@ -356,6 +354,5 @@ LABEL(doreti_checkast)
 	STI(si)
 	call	_C_LABEL(do_pmap_load)
 	CLI(si)
-	jmp	doreti_checkast		/* recheck ASTs */
-END(doreti_checkast)
+	jmp	.Ldoreti_checkast		/* recheck ASTs */
 IDTVEC_END(doreti)



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

2020-08-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 20 21:36:11 UTC 2020

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

Log Message:
Add wg(4) to amd64/ALL.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 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.160 src/sys/arch/amd64/conf/ALL:1.161
--- src/sys/arch/amd64/conf/ALL:1.160	Sat Aug  1 12:28:19 2020
+++ src/sys/arch/amd64/conf/ALL	Thu Aug 20 21:36:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.160 2020/08/01 12:28:19 jdolecek Exp $
+# $NetBSD: ALL,v 1.161 2020/08/20 21:36:11 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.160 $"
+#ident		"ALL-$Revision: 1.161 $"
 
 maxusers	64		# estimated number of users
 
@@ -1641,6 +1641,7 @@ pseudo-device	npf			# NPF packet filter
 pseudo-device	kttcp
 # srt is EXPERIMENTAL
 pseudo-device	srt			# source-address-based routing
+pseudo-device	wg			# WireGuard
 
 pseudo-device	canloop			# CAN loopback interface
 



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

2020-08-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug 17 20:43:13 UTC 2020

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

Log Message:
remove commented out MEMORY_DISK_* entries


To generate a diff of this commit:
cvs rdiff -u -r1.576 -r1.577 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.576 src/sys/arch/amd64/conf/GENERIC:1.577
--- src/sys/arch/amd64/conf/GENERIC:1.576	Mon Aug 17 15:41:32 2020
+++ src/sys/arch/amd64/conf/GENERIC	Mon Aug 17 16:43:13 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.576 2020/08/17 19:41:32 christos Exp $
+# $NetBSD: GENERIC,v 1.577 2020/08/17 20:43:13 christos 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.576 $"
+#ident		"GENERIC-$Revision: 1.577 $"
 
 maxusers	64		# estimated number of users
 
@@ -1143,9 +1143,7 @@ pseudo-device	fss			# file system snapsh
 
 pseudo-device	md			# memory disk device (ramdisk)
 options		MEMORY_DISK_HOOKS	# enable md specific hooks
-#options	MEMORY_DISK_IS_ROOT	# enable root ramdisk
 options 	MEMORY_DISK_DYNAMIC	# enable dynamic resizing
-#options 	MEMORY_DISK_SERVER	# enable userland server hooks
 
 pseudo-device	vnd			# disk-like interface to files
 options 	VND_COMPRESSION		# compressed vnd(4)



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

2020-08-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug 17 19:41:32 UTC 2020

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

Log Message:
correct MEMORY_DISK_* option docs


To generate a diff of this commit:
cvs rdiff -u -r1.575 -r1.576 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.575 src/sys/arch/amd64/conf/GENERIC:1.576
--- src/sys/arch/amd64/conf/GENERIC:1.575	Sun Aug 16 06:27:47 2020
+++ src/sys/arch/amd64/conf/GENERIC	Mon Aug 17 15:41:32 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.575 2020/08/16 10:27:47 jdolecek Exp $
+# $NetBSD: GENERIC,v 1.576 2020/08/17 19:41:32 christos 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.575 $"
+#ident		"GENERIC-$Revision: 1.576 $"
 
 maxusers	64		# estimated number of users
 
@@ -1142,8 +1142,10 @@ options 	RAID_AUTOCONFIG		# auto-configu
 pseudo-device	fss			# file system snapshot device
 
 pseudo-device	md			# memory disk device (ramdisk)
-options 	MEMORY_DISK_HOOKS	# enable root ramdisk
-options 	MEMORY_DISK_DYNAMIC	# loaded via kernel module(7)
+options		MEMORY_DISK_HOOKS	# enable md specific hooks
+#options	MEMORY_DISK_IS_ROOT	# enable root ramdisk
+options 	MEMORY_DISK_DYNAMIC	# enable dynamic resizing
+#options 	MEMORY_DISK_SERVER	# enable userland server hooks
 
 pseudo-device	vnd			# disk-like interface to files
 options 	VND_COMPRESSION		# compressed vnd(4)



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

2020-08-01 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug  1 12:28:19 UTC 2020

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

Log Message:
remove CISS_NO_INTERRUPT_HACK from ALL kernel config too, it's no longer
supported in ciss(4)


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 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.159 src/sys/arch/amd64/conf/ALL:1.160
--- src/sys/arch/amd64/conf/ALL:1.159	Sat Aug  1 08:20:47 2020
+++ src/sys/arch/amd64/conf/ALL	Sat Aug  1 12:28:19 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.159 2020/08/01 08:20:47 maxv Exp $
+# $NetBSD: ALL,v 1.160 2020/08/01 12:28:19 jdolecek 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.159 $"
+#ident		"ALL-$Revision: 1.160 $"
 
 maxusers	64		# estimated number of users
 
@@ -831,7 +831,6 @@ amr*	at pci? dev ? function ?	# AMI/LSI 
 arcmsr* at pci? dev ? function ?	# Areca SATA RAID controllers
 cac*	at pci? dev ? function ?	# Compaq PCI array controllers
 ciss*	at pci? dev ? function ?	# HP Smart Array controllers
-options CISS_NO_INTERRUPT_HACK
 
 icp*	at pci? dev ? function ?	# ICP-Vortex GDT & Intel RAID
 ips*	at pci? dev ? function ?	# Adaptec/IBM ServeRAID



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

2020-07-13 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Jul 14 01:05:07 UTC 2020

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

Log Message:
Enable PCPU_IDT option by default


To generate a diff of this commit:
cvs rdiff -u -r1.571 -r1.572 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.571 src/sys/arch/amd64/conf/GENERIC:1.572
--- src/sys/arch/amd64/conf/GENERIC:1.571	Wed Jun 24 03:38:54 2020
+++ src/sys/arch/amd64/conf/GENERIC	Tue Jul 14 01:05:06 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.571 2020/06/24 03:38:54 thorpej Exp $
+# $NetBSD: GENERIC,v 1.572 2020/07/14 01:05:06 yamaguchi 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.571 $"
+#ident		"GENERIC-$Revision: 1.572 $"
 
 maxusers	64		# estimated number of users
 
@@ -76,6 +76,7 @@ options 	SYSCTL_INCLUDE_DESCR	# Include 
 # CPU-related options
 #options 	USER_LDT	# User-settable LDT, used by Wine
 options 	SVS		# Separate Virtual Space
+options 	PCPU_IDT	# Per CPU IDTs
 
 # GCC Spectre variant 2 migitation
 makeoptions	SPECTRE_V2_GCC_MITIGATION=1



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

2020-06-29 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Jun 29 09:56:51 UTC 2020

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

Log Message:
increase UPAGES (used for lwp kernel stack) for SVS so the the
amount of actually usable kernel stack is the same for SVS and
non-SVS kernels (currently 12 KiB)

discussed with maxv@, part of investigation for PR kern/S55402


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/include/param.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/param.h
diff -u src/sys/arch/amd64/include/param.h:1.37 src/sys/arch/amd64/include/param.h:1.38
--- src/sys/arch/amd64/include/param.h:1.37	Tue Mar 17 17:18:49 2020
+++ src/sys/arch/amd64/include/param.h	Mon Jun 29 09:56:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.37 2020/03/17 17:18:49 maxv Exp $	*/
+/*	$NetBSD: param.h,v 1.38 2020/06/29 09:56:51 jdolecek Exp $	*/
 
 #ifdef __x86_64__
 
@@ -12,6 +12,7 @@
 #if defined(_KERNEL_OPT)
 #include "opt_kasan.h"
 #include "opt_kmsan.h"
+#include "opt_svs.h"
 #endif
 #endif
 
@@ -69,6 +70,8 @@
 
 #if defined(KASAN) || defined(KMSAN)
 #define	UPAGES		8
+#elif defined(SVS)
+#define	UPAGES		6		/* 1 page used internally by SVS */
 #else
 #define	UPAGES		5		/* pages of u-area (1 for redzone) */
 #endif



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

2020-06-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jun 24 03:38:55 UTC 2020

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

Log Message:
Add amdccp at pci.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.570 -r1.571 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/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.153 src/sys/arch/amd64/conf/ALL:1.154
--- src/sys/arch/amd64/conf/ALL:1.153	Sun Jun  7 09:45:19 2020
+++ src/sys/arch/amd64/conf/ALL	Wed Jun 24 03:38:54 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.153 2020/06/07 09:45:19 maxv Exp $
+# $NetBSD: ALL,v 1.154 2020/06/24 03:38:54 thorpej 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.153 $"
+#ident		"ALL-$Revision: 1.154 $"
 
 maxusers	64		# estimated number of users
 
@@ -1539,6 +1539,7 @@ btsco* at bthub?
 # Cryptographic Devices
 
 # PCI cryptographic devices
+amdccp*	at pci? dev ? function ?	# AMD Cryptographic Coprocessor
 hifn*	at pci? dev ? function ?	# Hifn 7755/7811/795x
 qat*	at pci? dev ? function ?	# Intel QuickAssist
 ubsec*	at pci? dev ? function ?	# Broadcom 5501/5601/580x/582x

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.570 src/sys/arch/amd64/conf/GENERIC:1.571
--- src/sys/arch/amd64/conf/GENERIC:1.570	Thu Jun 18 16:23:43 2020
+++ src/sys/arch/amd64/conf/GENERIC	Wed Jun 24 03:38:54 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.570 2020/06/18 16:23:43 maxv Exp $
+# $NetBSD: GENERIC,v 1.571 2020/06/24 03:38:54 thorpej 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.570 $"
+#ident		"GENERIC-$Revision: 1.571 $"
 
 maxusers	64		# estimated number of users
 
@@ -461,6 +461,7 @@ nouveaufb*	at nouveaufbbus?
 # Cryptographic Devices
 
 # PCI cryptographic devices
+amdccp*	at pci? dev ? function ?	# AMD Cryptographic Coprocessor
 hifn*	at pci? dev ? function ?	# Hifn 7755/7811/795x
 #qat*	at pci? dev ? function ?	# Intel QuickAssist
 ubsec*	at pci? dev ? function ?	# Broadcom 5501/5601/580x/582x



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

2020-06-21 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jun 21 16:57:18 UTC 2020

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

Log Message:
On amd64, Xen PV calls syscalls and traps with events enabled.
Disable events on entry to be safe.
It should have been mostly safe for most cases, but for FPU traps
we need to reload the FPU state if we got interrupted at trap entry.

Hopefully fixes:
panic: kernel diagnostic assertion "curlwp->l_md.md_flags & MDL_FPU_IN_CPU" 
failed: file "/home/source/ab/HEAD/src/sys/arch/x86/x86/fpu.c", line 524

when running tests.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/amd64/amd64/amd64_trap.S
cvs rdiff -u -r1.209 -r1.210 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/amd64_trap.S
diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.51 src/sys/arch/amd64/amd64/amd64_trap.S:1.52
--- src/sys/arch/amd64/amd64/amd64_trap.S:1.51	Sat Dec  7 10:19:35 2019
+++ src/sys/arch/amd64/amd64/amd64_trap.S	Sun Jun 21 16:57:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: amd64_trap.S,v 1.51 2019/12/07 10:19:35 maxv Exp $	*/
+/*	$NetBSD: amd64_trap.S,v 1.52 2020/06/21 16:57:18 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #ifdef	XENPV
-#define	PRE_TRAP	movq (%rsp),%rcx ; movq 8(%rsp),%r11 ; addq $0x10,%rsp
+#define	PRE_TRAP	CLI(cx); movq (%rsp),%rcx ; movq 8(%rsp),%r11 ; addq $0x10,%rsp
 #else
 #define	PRE_TRAP
 #endif
@@ -231,9 +231,9 @@ IDTVEC(trap01)
 	movw	%ds,TF_DS(%rsp)
 
 	jmp	.Lalltraps_noentry
-#else
+#else /* !XENPV */
 	ZTRAP(T_TRCTRAP)
-#endif
+#endif /* !XENPV */
 IDTVEC_END(trap01)
 
 /*
@@ -250,7 +250,7 @@ IDTVEC_END(trap01)
 IDTVEC(trap02)
 #if defined(XENPV)
 	ZTRAP(T_NMI)
-#else
+#else /* XENPV */
 	ZTRAP_NJ(T_NMI)
 	subq	$TF_REGSIZE,%rsp
 	INTR_SAVE_GPRS
@@ -299,7 +299,7 @@ IDTVEC(trap02)
 	INTR_RESTORE_GPRS
 	addq	$TF_REGSIZE+16,%rsp
 	iretq
-#endif
+#endif /* XENPV */
 IDTVEC_END(trap02)
 
 IDTVEC(trap03)
@@ -361,7 +361,7 @@ IDTVEC_END(trap07)
 IDTVEC(trap08)
 #if defined(XENPV)
 	TRAP(T_DOUBLEFLT)
-#else
+#else /* XENPV */
 	TRAP_NJ(T_DOUBLEFLT)
 	subq	$TF_REGSIZE,%rsp
 	INTR_SAVE_GPRS
@@ -396,7 +396,7 @@ IDTVEC(trap08)
 	INTR_RESTORE_GPRS
 	addq	$TF_REGSIZE+16,%rsp
 	iretq
-#endif
+#endif /* XENPV */
 IDTVEC_END(trap08)
 
 IDTVEC(trap09)
@@ -414,7 +414,7 @@ IDTVEC_END(trap10)
  * in order to copy the user segment registers into the fault frame.
  */
 #define kernuser_reenter alltraps
-#endif
+#endif /* XENPV */
 
 IDTVEC(trap11)		/* #NP() Segment not present */
 	TRAP_NJ(T_SEGNPFLT)
@@ -448,6 +448,14 @@ IDTVEC(trap16)
 	ZTRAP_NJ(T_ARITHTRAP)
 .Ldo_fputrap:
 	INTRENTRY
+#ifdef XENPV
+	/* traps are called with interrupts enabled, and we may have been
+	 * interrupted just before the CLI in the trap macro.
+	 * we have to check if a FPU reload is needed.
+	 */ 
+	movqCPUVAR(CURLWP),%r14
+	HANDLE_DEFERRED_FPU
+#endif /* XENPV */
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
 #endif

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.209 src/sys/arch/amd64/amd64/locore.S:1.210
--- src/sys/arch/amd64/amd64/locore.S:1.209	Wed May 27 19:33:40 2020
+++ src/sys/arch/amd64/amd64/locore.S	Sun Jun 21 16:57:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.209 2020/05/27 19:33:40 ad Exp $	*/
+/*	$NetBSD: locore.S,v 1.210 2020/06/21 16:57:18 bouyer Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1481,7 +1481,13 @@ IDTVEC(\name)
 	movq	$2,TF_ERR(%rsp)		/* syscall instruction size */
 	movq	$T_ASTFLT,TF_TRAPNO(%rsp)
 #else
-	/* Xen already switched to kernel stack */
+	/*
+	 * Xen already switched to kernel stack.
+	 * But it didn't disable events
+	 */
+	pushq	%rsi
+	CLI(si)
+	popq	%rsi
 	addq	$0x10,%rsp	/* gap to match cs:rip */
 	pushq	$2		/* error code */
 	pushq	$T_ASTFLT
@@ -1524,6 +1530,9 @@ IDTVEC_END(syscall32)
 	TEXT_USER_BEGIN
 IDTVEC(osyscall)
 #ifdef XENPV
+	pushq	%rsi
+	CLI(si)
+	popq	%rsi
 	movq (%rsp),%rcx
 	movq 8(%rsp),%r11
 	addq $0x10,%rsp



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

2020-06-21 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jun 21 16:53:37 UTC 2020

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

Log Message:
Fix comment


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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.

Modified files:

Index: src/sys/arch/amd64/include/frameasm.h
diff -u src/sys/arch/amd64/include/frameasm.h:1.50 src/sys/arch/amd64/include/frameasm.h:1.51
--- src/sys/arch/amd64/include/frameasm.h:1.50	Mon Jun  1 22:58:06 2020
+++ src/sys/arch/amd64/include/frameasm.h	Sun Jun 21 16:53:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: frameasm.h,v 1.50 2020/06/01 22:58:06 ad Exp $	*/
+/*	$NetBSD: frameasm.h,v 1.51 2020/06/21 16:53:37 bouyer Exp $	*/
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 #define _AMD64_MACHINE_FRAMEASM_H
@@ -48,7 +48,7 @@
 #define STI(temp_reg) sti
 #define PUSHF(temp_reg) pushf
 #define POPL popl
-#endif	/* XEN */
+#endif	/* XENPV */
 
 #define HP_NAME_CLAC		1
 #define HP_NAME_STAC		2



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

2020-06-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jun 18 16:23:43 UTC 2020

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

Log Message:
style


To generate a diff of this commit:
cvs rdiff -u -r1.569 -r1.570 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.569 src/sys/arch/amd64/conf/GENERIC:1.570
--- src/sys/arch/amd64/conf/GENERIC:1.569	Sun Jun  7 09:45:19 2020
+++ src/sys/arch/amd64/conf/GENERIC	Thu Jun 18 16:23:43 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.569 2020/06/07 09:45:19 maxv Exp $
+# $NetBSD: GENERIC,v 1.570 2020/06/18 16:23:43 maxv 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.569 $"
+#ident		"GENERIC-$Revision: 1.570 $"
 
 maxusers	64		# estimated number of users
 
@@ -76,8 +76,9 @@ options 	SYSCTL_INCLUDE_DESCR	# Include 
 # CPU-related options
 #options 	USER_LDT	# User-settable LDT, used by Wine
 options 	SVS		# Separate Virtual Space
-makeoptions	SPECTRE_V2_GCC_MITIGATION=1	# GCC Spectre variant 2
-		# migitation
+
+# GCC Spectre variant 2 migitation
+makeoptions	SPECTRE_V2_GCC_MITIGATION=1
 options 	SPECTRE_V2_GCC_MITIGATION
 
 # CPU features
@@ -122,13 +123,15 @@ options 	DDB_HISTORY_SIZE=512	# enable h
 #options 	KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600
 makeoptions	DEBUG="-g"	# compile full symbol table for CTF
 options DDB_COMMANDONENTER="trace;show registers"
-#options 	KUBSAN		# Kernel Undefined Behavior Sanitizer (kUBSan)
-#options 	UBSAN_ALWAYS_FATAL	# (optional) Panic on all kUBSan reports
 #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
 
+# Kernel Undefined Behavior Sanitizer (kUBSan).
+#options 	KUBSAN			# mandatory
+#options 	UBSAN_ALWAYS_FATAL	# optional: panic on all kUBSan reports
+
 # Kernel Address Sanitizer (kASan). You need to disable SVS to use it.
 # The quarantine is optional and can help KASAN find more use-after-frees.
 # Use KASAN_PANIC if you want panics instead of warnings.



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

2020-06-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  7 23:15:51 UTC 2020

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

Log Message:
make this compile.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/sys/arch/amd64/include/msan.h:1.4
--- src/sys/arch/amd64/include/msan.h:1.3	Sat Apr 25 11:26:16 2020
+++ src/sys/arch/amd64/include/msan.h	Sun Jun  7 19:15:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: msan.h,v 1.3 2020/04/25 15:26:16 bouyer Exp $	*/
+/*	$NetBSD: msan.h,v 1.4 2020/06/07 23:15:51 christos Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@ kmsan_md_shadow_map_page(vaddr_t va)
 			L2_BASE[pl2_i(va)] = pa | pteflags | PTE_PS |
 			pmap_pg_g;
 			__insn_barrier();
-			__builtin_memset(va, 0, NBPD_L2);
+			__builtin_memset((void *)va, 0, NBPD_L2);
 			return;
 		}
 		pa = __md_palloc();



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

2020-06-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jun  6 07:03:21 UTC 2020

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

Log Message:
If the frame is not aligned, leave right away. This place probably needs
to be revisited, because %rbp could easily contain garbage.

Reported-by: syzbot+ecb40cf7f8acc102c...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 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.7 src/sys/arch/amd64/amd64/db_machdep.c:1.8
--- src/sys/arch/amd64/amd64/db_machdep.c:1.7	Thu May 14 16:57:53 2020
+++ src/sys/arch/amd64/amd64/db_machdep.c	Sat Jun  6 07:03:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.8 2020/06/06 07:03:21 maxv Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,7 +26,7 @@
  * rights to redistribute these changes.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.8 2020/06/06 07:03:21 maxv Exp $");
 
 #include 
 #include 
@@ -151,6 +151,8 @@ db_nextframe(long **nextframe, long **re
 			db_get_value((long)>tf_rbp, 8, false);
 		if (fp == NULL)
 			return 0;
+		if (((uintptr_t)fp & 7) != 0)
+			return 0;
 		*nextframe = (long *)>f_frame;
 		*retaddr = (long *)>f_retaddr;
 		*arg0 = (long *)>f_arg0;



CVS commit: src/sys/arch/amd64

2020-06-01 Thread Andrew Doran
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.

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.58 src/sys/arch/amd64/amd64/cpufunc.S:1.59
--- src/sys/arch/amd64/amd64/cpufunc.S:1.58	Wed May 27 20:48:42 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Mon Jun  1 22:58:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.58 2020/05/27 20:48:42 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.59 2020/06/01 22:58:06 ad Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -424,6 +424,7 @@ END(outl)
 ENTRY(x86_stos)
 	movq	%rsi,%rax
 	movq	%rdx,%rcx
+	KMSAN_REP_STOS(8)
 	rep
 	stosq
 	ret
@@ -431,6 +432,7 @@ END(x86_stos)
 
 ENTRY(x86_movs)
 	movq	%rdx,%rcx
+	KMSAN_REP_STOS(8)
 	rep
 	movsq
 	ret

Index: src/sys/arch/amd64/include/frameasm.h
diff -u src/sys/arch/amd64/include/frameasm.h:1.49 src/sys/arch/amd64/include/frameasm.h:1.50
--- src/sys/arch/amd64/include/frameasm.h:1.49	Sun Apr 26 14:49:17 2020
+++ src/sys/arch/amd64/include/frameasm.h	Mon Jun  1 22:58:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: frameasm.h,v 1.49 2020/04/26 14:49:17 maxv Exp $	*/
+/*	$NetBSD: frameasm.h,v 1.50 2020/06/01 22:58:06 ad Exp $	*/
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 #define _AMD64_MACHINE_FRAMEASM_H
@@ -222,6 +222,7 @@
 #endif
 
 #ifdef KMSAN
+/* XXX this belongs somewhere else. */
 #define KMSAN_ENTER	\
 	movq	%rsp,%rdi		; \
 	movq	$TF_REGSIZE+16+40,%rsi	; \
@@ -275,11 +276,33 @@
 	popq	%rdx			; \
 	popq	%rcx			; \
 	popq	%rax
+#define KMSAN_REP_STOS(scale)	\
+	pushq	%rax			; \
+	pushq	%rcx			; \
+	pushq	%rdx			; \
+	pushq	%rsi			; \
+	pushq	%rdi			; \
+	pushq	%r8			; \
+	pushq	%r9			; \
+	pushq	%r10			; \
+	pushq	%r11			; \
+	leaq	(,%rcx,scale),%rsi	; \
+	callq	_C_LABEL(__msan_instrument_asm_store); \
+	popq	%r11			; \
+	popq	%r10			; \
+	popq	%r9			; \
+	popq	%r8			; \
+	popq	%rdi			; \
+	popq	%rsi			; \
+	popq	%rdx			; \
+	popq	%rcx			; \
+	popq	%rax
 #else
 #define KMSAN_ENTER		/* nothing */
 #define KMSAN_LEAVE		/* nothing */
 #define KMSAN_INIT_ARG(sz)	/* nothing */
 #define KMSAN_INIT_RET(sz)	/* nothing */
+#define	KMSAN_REP_STOS(scale)	/* nothing */
 #endif
 
 #ifdef KCOV



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

2020-05-30 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat May 30 13:35:31 UTC 2020

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

Log Message:
add bwfm* at pci?, which is present in GENERIC


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 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.151 src/sys/arch/amd64/conf/ALL:1.152
--- src/sys/arch/amd64/conf/ALL:1.151	Mon May 25 07:20:14 2020
+++ src/sys/arch/amd64/conf/ALL	Sat May 30 13:35:31 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.151 2020/05/25 07:20:14 yamaguchi Exp $
+# $NetBSD: ALL,v 1.152 2020/05/30 13:35:31 jdolecek 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.151 $"
+#ident		"ALL-$Revision: 1.152 $"
 
 maxusers	64		# estimated number of users
 
@@ -964,6 +964,7 @@ bce*	at pci? dev ? function ?	# Broadcom
 bge*	at pci? dev ? function ?	# Broadcom 570x gigabit Ethernet
 bnx*	at pci? dev ? function ?	# Broadcom NetXtremeII gigabit Ethernet
 bwi*	at pci? dev ? function ?	# Broadcom BCM43xx wireless
+bwfm*	at pci? dev ? function ?	# Broadcom FullMAC
 cas*	at pci? dev ? function ?	# Sun Cassini/Cassini+ Ethernet
 dge*	at pci? dev ? function ?	# Intel 82597 10GbE LR
 ena*	at pci? dev ? function ?	# Amazon Elastic Network Adapter



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

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

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

Log Message:
- mismatched END pointed out by maxv@
- ditch the frame, tracer should be able to deal without it in leaf on x86_64


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amd64/amd64/cpufunc.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.57 src/sys/arch/amd64/amd64/cpufunc.S:1.58
--- src/sys/arch/amd64/amd64/cpufunc.S:1.57	Wed May 27 19:33:40 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Wed May 27 20:48:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.57 2020/05/27 19:33:40 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.58 2020/05/27 20:48:42 ad Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -422,22 +422,16 @@ ENTRY(outl)
 END(outl)
 
 ENTRY(x86_stos)
-	pushq	%rbp
-	movq	%rsp,%rbp
 	movq	%rsi,%rax
 	movq	%rdx,%rcx
 	rep
 	stosq
-	leave
 	ret
 END(x86_stos)
 
 ENTRY(x86_movs)
-	pushq	%rbp
-	movq	%rsp,%rbp
 	movq	%rdx,%rcx
 	rep
 	movsq
-	leave
 	ret
-END(x86_stos)
+END(x86_movs)



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

2020-05-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat May 23 08:25:32 UTC 2020

Modified Files:
src/sys/arch/amd64/stand/prekern: console.c pdir.h prekern.c prekern.h
redef.h trap.S

Log Message:
Bump copyrights.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amd64/stand/prekern/console.c \
src/sys/arch/amd64/stand/prekern/trap.S
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/stand/prekern/pdir.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/stand/prekern/prekern.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/stand/prekern/prekern.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/stand/prekern/redef.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/stand/prekern/console.c
diff -u src/sys/arch/amd64/stand/prekern/console.c:1.5 src/sys/arch/amd64/stand/prekern/console.c:1.6
--- src/sys/arch/amd64/stand/prekern/console.c:1.5	Sat May 23 08:23:28 2020
+++ src/sys/arch/amd64/stand/prekern/console.c	Sat May 23 08:25:32 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: console.c,v 1.5 2020/05/23 08:23:28 maxv Exp $	*/
+/*	$NetBSD: console.c,v 1.6 2020/05/23 08:25:32 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.
Index: src/sys/arch/amd64/stand/prekern/trap.S
diff -u src/sys/arch/amd64/stand/prekern/trap.S:1.5 src/sys/arch/amd64/stand/prekern/trap.S:1.6
--- src/sys/arch/amd64/stand/prekern/trap.S:1.5	Tue Mar 19 19:15:57 2019
+++ src/sys/arch/amd64/stand/prekern/trap.S	Sat May 23 08:25:32 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: trap.S,v 1.5 2019/03/19 19:15:57 maxv Exp $	*/
+/*	$NetBSD: trap.S,v 1.6 2020/05/23 08:25:32 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.

Index: src/sys/arch/amd64/stand/prekern/pdir.h
diff -u src/sys/arch/amd64/stand/prekern/pdir.h:1.6 src/sys/arch/amd64/stand/prekern/pdir.h:1.7
--- src/sys/arch/amd64/stand/prekern/pdir.h:1.6	Sat Nov  3 08:27:16 2018
+++ src/sys/arch/amd64/stand/prekern/pdir.h	Sat May 23 08:25:32 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: pdir.h,v 1.6 2018/11/03 08:27:16 maxv Exp $	*/
+/*	$NetBSD: pdir.h,v 1.7 2020/05/23 08:25:32 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.

Index: src/sys/arch/amd64/stand/prekern/prekern.c
diff -u src/sys/arch/amd64/stand/prekern/prekern.c:1.12 src/sys/arch/amd64/stand/prekern/prekern.c:1.13
--- src/sys/arch/amd64/stand/prekern/prekern.c:1.12	Sat May 23 08:10:50 2020
+++ src/sys/arch/amd64/stand/prekern/prekern.c	Sat May 23 08:25:32 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: prekern.c,v 1.12 2020/05/23 08:10:50 maxv Exp $	*/
+/*	$NetBSD: prekern.c,v 1.13 2020/05/23 08:25:32 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.

Index: src/sys/arch/amd64/stand/prekern/prekern.h
diff -u src/sys/arch/amd64/stand/prekern/prekern.h:1.22 src/sys/arch/amd64/stand/prekern/prekern.h:1.23
--- src/sys/arch/amd64/stand/prekern/prekern.h:1.22	Thu May  7 21:05:37 2020
+++ src/sys/arch/amd64/stand/prekern/prekern.h	Sat May 23 08:25:32 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: prekern.h,v 1.22 2020/05/07 21:05:37 maxv Exp $	*/
+/*	$NetBSD: prekern.h,v 1.23 2020/05/23 08:25:32 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.

Index: src/sys/arch/amd64/stand/prekern/redef.h
diff -u src/sys/arch/amd64/stand/prekern/redef.h:1.2 src/sys/arch/amd64/stand/prekern/redef.h:1.3
--- src/sys/arch/amd64/stand/prekern/redef.h:1.2	Tue Nov 14 13:58:07 2017
+++ src/sys/arch/amd64/stand/prekern/redef.h	Sat May 23 08:25:32 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: redef.h,v 1.2 2017/11/14 13:58:07 maxv Exp $	*/
+/*	$NetBSD: redef.h,v 1.3 2020/05/23 08:25:32 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.



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

2020-05-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat May 23 08:23:29 UTC 2020

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

Log Message:
Extract putc().


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/stand/prekern/console.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/stand/prekern/console.c
diff -u src/sys/arch/amd64/stand/prekern/console.c:1.4 src/sys/arch/amd64/stand/prekern/console.c:1.5
--- src/sys/arch/amd64/stand/prekern/console.c:1.4	Wed Apr  3 19:14:25 2019
+++ src/sys/arch/amd64/stand/prekern/console.c	Sat May 23 08:23:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: console.c,v 1.4 2019/04/03 19:14:25 maxv Exp $	*/
+/*	$NetBSD: console.c,v 1.5 2020/05/23 08:23:28 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -64,28 +64,34 @@ static void check_scroll(void)
 	memcpy(cons_start, _buffer[0], CONS_WID * 2 * CONS_HEI);
 }
 
-void print_ext(int color, char *buf)
+static void putc(int color, char c)
 {
 	char *ptr, *scr;
-	size_t i;
 
-	for (i = 0; buf[i] != '\0'; i++) {
-		if (buf[i] == '\n') {
+	if (c == '\n') {
+		cons_x = 0;
+		cons_y++;
+		check_scroll();
+	} else {
+		if (cons_x + 1 == CONS_WID) {
 			cons_x = 0;
 			cons_y++;
 			check_scroll();
-		} else {
-			if (cons_x + 1 == CONS_WID) {
-cons_x = 0;
-cons_y++;
-check_scroll();
-			}
-			ptr = (cons_start + 2 * cons_x + 160 * cons_y);
-			scr = (cons_buffer + 2 * cons_x + 160 * cons_y);
-			ptr[0] = scr[0] = buf[i];
-			ptr[1] = scr[1] = color;
-			cons_x++;
 		}
+		ptr = (cons_start + 2 * cons_x + 160 * cons_y);
+		scr = (cons_buffer + 2 * cons_x + 160 * cons_y);
+		ptr[0] = scr[0] = c;
+		ptr[1] = scr[1] = color;
+		cons_x++;
+	}
+}
+
+void print_ext(int color, char *buf)
+{
+	size_t i;
+
+	for (i = 0; buf[i] != '\0'; i++) {
+		putc(color, buf[i]);
 	}
 }
 



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

2020-05-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat May 23 08:10:50 UTC 2020

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

Log Message:
Hum, forgot to include this file in my "Clarify." commit on mm.c:rev1.27
and elf.c:rev1.21.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/stand/prekern/prekern.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/stand/prekern/prekern.c
diff -u src/sys/arch/amd64/stand/prekern/prekern.c:1.11 src/sys/arch/amd64/stand/prekern/prekern.c:1.12
--- src/sys/arch/amd64/stand/prekern/prekern.c:1.11	Tue Mar 19 19:15:57 2019
+++ src/sys/arch/amd64/stand/prekern/prekern.c	Sat May 23 08:10:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: prekern.c,v 1.11 2019/03/19 19:15:57 maxv Exp $	*/
+/*	$NetBSD: prekern.c,v 1.12 2020/05/23 08:10:50 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -297,6 +297,7 @@ init_prekern(paddr_t pa_start)
 	 * Relocate the kernel.
 	 */
 	mm_map_kernel();
+	elf_build_info();
 	ent = elf_kernel_reloc();
 	mm_bootspace_mprotect();
 



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

2020-05-21 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu May 21 09:36:24 UTC 2020

Modified Files:
src/sys/arch/amd64/conf: kern.ldscript.Xen

Log Message:
update Xen ldscript to add kASan .ctors section, so that Xen kernel with
enabled KASAN option at least compiles; no promises on it actually working
though


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/amd64/conf/kern.ldscript.Xen

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/kern.ldscript.Xen
diff -u src/sys/arch/amd64/conf/kern.ldscript.Xen:1.16 src/sys/arch/amd64/conf/kern.ldscript.Xen:1.17
--- src/sys/arch/amd64/conf/kern.ldscript.Xen:1.16	Sun Jun 24 18:24:53 2018
+++ src/sys/arch/amd64/conf/kern.ldscript.Xen	Thu May 21 09:36:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern.ldscript.Xen,v 1.16 2018/06/24 18:24:53 maxv Exp $	*/
+/*	$NetBSD: kern.ldscript.Xen,v 1.17 2020/05/21 09:36:24 jdolecek Exp $	*/
 
 #include "assym.h"
 
@@ -32,6 +32,10 @@ SECTIONS
 	{
 		*(.rodata)
 		*(.rodata.*)
+		. = ALIGN(COHERENCY_UNIT);
+		__CTOR_LIST__ = .;
+		*(.ctors)
+		__CTOR_END__ = .;
 	}
 
 	. = ALIGN(__PAGE_SIZE);



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

2020-05-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May 21 08:20:25 UTC 2020

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

Log Message:
Mmh, should check cpuid_level first.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/stand/prekern/prng.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/stand/prekern/prng.c
diff -u src/sys/arch/amd64/stand/prekern/prng.c:1.2 src/sys/arch/amd64/stand/prekern/prng.c:1.3
--- src/sys/arch/amd64/stand/prekern/prng.c:1.2	Sun Nov 26 11:08:34 2017
+++ src/sys/arch/amd64/stand/prekern/prng.c	Thu May 21 08:20:25 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: prng.c,v 1.2 2017/11/26 11:08:34 maxv Exp $	*/
+/*	$NetBSD: prng.c,v 1.3 2020/05/21 08:20:25 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.
@@ -148,6 +148,7 @@ prng_get_entropy_data(SHA512_CTX *ctx)
 void
 prng_init(void)
 {
+	extern int cpuid_level;
 	uint8_t digest[SHA512_DIGEST_LENGTH];
 	SHA512_CTX ctx;
 	u_int descs[4];
@@ -155,10 +156,14 @@ prng_init(void)
 	memset(, 0, sizeof(rng));
 
 	/* detect cpu features */
-	cpuid(0x07, 0x00, descs);
-	has_rdseed = (descs[1] & CPUID_SEF_RDSEED) != 0;
-	cpuid(0x01, 0x00, descs);
-	has_rdrand = (descs[2] & CPUID2_RDRAND) != 0;
+	if (cpuid_level >= 0x07) {
+		cpuid(0x07, 0x00, descs);
+		has_rdseed = (descs[1] & CPUID_SEF_RDSEED) != 0;
+	}
+	if (cpuid_level >= 0x01) {
+		cpuid(0x01, 0x00, descs);
+		has_rdrand = (descs[2] & CPUID2_RDRAND) != 0;
+	}
 
 	SHA512_Init();
 	prng_get_entropy_file();



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

2020-05-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 20 18:52:48 UTC 2020

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

Log Message:
this is kmsan


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/amd64/amd64/cpufunc.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.55 src/sys/arch/amd64/amd64/cpufunc.S:1.56
--- src/sys/arch/amd64/amd64/cpufunc.S:1.55	Wed May 20 18:39:25 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Wed May 20 18:52:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.55 2020/05/20 18:39:25 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.56 2020/05/20 18:52:48 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -206,7 +206,8 @@ ENTRY(x86_hotpatch)
 END(x86_hotpatch)
 #endif /* !XENPV */
 
-/* Could be exact same as cpu_counter but for KASAN fussiness. */
+/* Could be exact same as cpu_counter, but KMSAN needs to have the correct
+ * size of the return value. */
 ENTRY(cpu_counter32)
 	movq	CPUVAR(CURLWP), %rcx
 1:



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

2020-05-20 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed May 20 18:39:25 UTC 2020

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

Log Message:
Deal with KMSAN fussiness.  Pointed out by msaitoh@.


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

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

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.54 src/sys/arch/amd64/amd64/cpufunc.S:1.55
--- src/sys/arch/amd64/amd64/cpufunc.S:1.54	Tue May 19 21:54:10 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Wed May 20 18:39:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.54 2020/05/19 21:54:10 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.55 2020/05/20 18:39:25 ad Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -206,7 +206,23 @@ ENTRY(x86_hotpatch)
 END(x86_hotpatch)
 #endif /* !XENPV */
 
-ENTRY(tsc_get_timecount)
+/* Could be exact same as cpu_counter but for KASAN fussiness. */
+ENTRY(cpu_counter32)
+	movq	CPUVAR(CURLWP), %rcx
+1:
+	movq	L_NCSW(%rcx), %rdi
+	rdtsc
+	addl	CPUVAR(CC_SKEW), %eax
+	cmpq	%rdi, L_NCSW(%rcx)
+	jne	2f
+	KMSAN_INIT_RET(4)
+	ret
+2:
+	jmp	1b
+END(cpu_counter32)
+STRONG_ALIAS(tsc_get_timecount, cpu_counter32)
+
+ENTRY(cpu_counter)
 	movq	CPUVAR(CURLWP), %rcx
 1:
 	movq	L_NCSW(%rcx), %rdi
@@ -216,14 +232,11 @@ ENTRY(tsc_get_timecount)
 	addq	CPUVAR(CC_SKEW), %rax
 	cmpq	%rdi, L_NCSW(%rcx)
 	jne	2f
-	KMSAN_INIT_RET(4)
+	KMSAN_INIT_RET(8)
 	ret
 2:
 	jmp	1b
-END(tsc_get_timecount)
-
-STRONG_ALIAS(cpu_counter, tsc_get_timecount)
-STRONG_ALIAS(cpu_counter32, tsc_get_timecount)
+END(cpu_counter)
 
 ENTRY(rdmsr_safe)
 	movq	CPUVAR(CURLWP), %r8



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

2020-05-19 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Tue May 19 21:54:10 UTC 2020

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

Log Message:
xen needs the TSC funcs too


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/amd64/amd64/cpufunc.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.53 src/sys/arch/amd64/amd64/cpufunc.S:1.54
--- src/sys/arch/amd64/amd64/cpufunc.S:1.53	Tue May 19 21:40:55 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Tue May 19 21:54:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.53 2020/05/19 21:40:55 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.54 2020/05/19 21:54:10 ad Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -167,25 +167,6 @@ END(x86_write_flags)
 
 STRONG_ALIAS(x86_write_psl,x86_write_flags)
 
-ENTRY(tsc_get_timecount)
-	movq	CPUVAR(CURLWP), %rcx
-1:
-	movq	L_NCSW(%rcx), %rdi
-	rdtsc
-	shlq	$32, %rdx
-	orq	%rdx, %rax
-	addq	CPUVAR(CC_SKEW), %rax
-	cmpq	%rdi, L_NCSW(%rcx)
-	jne	2f
-	KMSAN_INIT_RET(4)
-	ret
-2:
-	jmp	1b
-END(tsc_get_timecount)
-
-STRONG_ALIAS(cpu_counter, tsc_get_timecount)
-STRONG_ALIAS(cpu_counter32, tsc_get_timecount)
-
 /*
  * %rdi = name
  * %rsi = sel
@@ -225,6 +206,25 @@ ENTRY(x86_hotpatch)
 END(x86_hotpatch)
 #endif /* !XENPV */
 
+ENTRY(tsc_get_timecount)
+	movq	CPUVAR(CURLWP), %rcx
+1:
+	movq	L_NCSW(%rcx), %rdi
+	rdtsc
+	shlq	$32, %rdx
+	orq	%rdx, %rax
+	addq	CPUVAR(CC_SKEW), %rax
+	cmpq	%rdi, L_NCSW(%rcx)
+	jne	2f
+	KMSAN_INIT_RET(4)
+	ret
+2:
+	jmp	1b
+END(tsc_get_timecount)
+
+STRONG_ALIAS(cpu_counter, tsc_get_timecount)
+STRONG_ALIAS(cpu_counter32, tsc_get_timecount)
+
 ENTRY(rdmsr_safe)
 	movq	CPUVAR(CURLWP), %r8
 	movq	L_PCB(%r8), %r8



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

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

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

Log Message:
comments


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/amd64/amd64/spl.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/spl.S
diff -u src/sys/arch/amd64/amd64/spl.S:1.45 src/sys/arch/amd64/amd64/spl.S:1.46
--- src/sys/arch/amd64/amd64/spl.S:1.45	Sat May  2 11:12:49 2020
+++ src/sys/arch/amd64/amd64/spl.S	Sun May 17 12:11:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.45 2020/05/02 11:12:49 maxv Exp $	*/
+/*	$NetBSD: spl.S,v 1.46 2020/05/17 12:11:11 ad Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -157,7 +157,12 @@ IDTVEC(softintr)
 	movq	L_PCB(%r15),%rcx
 	movq	PCB_RSP(%rcx),%rsp
 
-	xchgq	%r15,CPUVAR(CURLWP)	/* must be globally visible */
+	/*
+	 * for non-interlocked mutex release to work safely the change
+	 * to ci_curlwp must not languish in the store buffer. therefore
+	 * we use XCHG and not MOV here.  see kern_mutex.c.
+	 */
+	xchgq	%r15,CPUVAR(CURLWP)	/* restore curlwp */
 	popq	%r15			/* unwind switchframe */
 	addq	$(5 * 8),%rsp
 	jmp	*%r13			/* back to Xspllower/Xdoreti */



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

2020-05-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May 14 16:57:53 UTC 2020

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

Log Message:
Don't even try to go past a syscall. Fixes severe panic recursions in
KUBSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/sys/arch/amd64/amd64/db_machdep.c:1.7
--- src/sys/arch/amd64/amd64/db_machdep.c:1.6	Fri Mar 16 08:48:34 2018
+++ src/sys/arch/amd64/amd64/db_machdep.c	Thu May 14 16:57:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.6 2018/03/16 08:48:34 maxv Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,7 +26,7 @@
  * rights to redistribute these changes.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.6 2018/03/16 08:48:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $");
 
 #include 
 #include 
@@ -125,22 +125,23 @@ db_nextframe(long **nextframe, long **re
 		*arg0 = (long *)>f_arg0;
 		break;
 
-	case TRAP:
 	case SYSCALL:
+		tf = (struct trapframe *)argp;
+		(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
+		db_get_value((long)>tf_rax, 8, false));
+		return 0;
+
+	case TRAP:
 	case INTERRUPT:
 	default:
 
-		/* The only argument to trap() or syscall() is the trapframe. */
+		/* The only argument to trap() is the trapframe. */
 		tf = (struct trapframe *)argp;
 		switch (is_trap) {
 		case TRAP:
 			(*pr)("--- trap (number %"DDB_EXPR_FMT"u) ---\n",
 db_get_value((long)>tf_trapno, 8, false));
 			break;
-		case SYSCALL:
-			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
-db_get_value((long)>tf_rax, 8, false));
-			break;
 		case INTERRUPT:
 			(*pr)("--- interrupt ---\n");
 			break;



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

2020-05-08 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri May  8 21:58:03 UTC 2020

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

Log Message:
cpu_counter: only need to clear %eax (zero extends).


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/amd64/amd64/cpufunc.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.51 src/sys/arch/amd64/amd64/cpufunc.S:1.52
--- src/sys/arch/amd64/amd64/cpufunc.S:1.51	Sat May  2 17:14:01 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Fri May  8 21:58:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.51 2020/05/02 17:14:01 bouyer Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.52 2020/05/08 21:58:03 ad Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -253,7 +253,7 @@ ENTRY(msr_onfault)
 END(msr_onfault)
 
 ENTRY(cpu_counter)
-	xorq	%rax, %rax
+	xorl	%eax, %eax
 	rdtsc
 	shlq	$32, %rdx
 	orq	%rdx, %rax



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

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 21:05:37 UTC 2020

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

Log Message:
Forgot to commit this file as part of elf.c::rev1.21 mm.c::rev1.27.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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/stand/prekern/prekern.h
diff -u src/sys/arch/amd64/stand/prekern/prekern.h:1.21 src/sys/arch/amd64/stand/prekern/prekern.h:1.22
--- src/sys/arch/amd64/stand/prekern/prekern.h:1.21	Tue May  5 19:26:47 2020
+++ src/sys/arch/amd64/stand/prekern/prekern.h	Thu May  7 21:05:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: prekern.h,v 1.21 2020/05/05 19:26:47 maxv Exp $	*/
+/*	$NetBSD: prekern.h,v 1.22 2020/05/07 21:05:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -89,8 +89,9 @@ void print_banner(void);
 /* elf.c */
 size_t elf_get_head_size(vaddr_t);
 void elf_build_head(vaddr_t);
+void elf_fixup_boot(vaddr_t, paddr_t);
 void elf_map_sections(void);
-void elf_build_boot(vaddr_t, paddr_t);
+void elf_build_info(void);
 vaddr_t elf_kernel_reloc(void);
 
 /* locore.S */



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

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 17:58:26 UTC 2020

Modified Files:
src/sys/arch/amd64/stand/prekern: elf.c mm.c

Log Message:
Clarify.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/amd64/stand/prekern/elf.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/amd64/stand/prekern/mm.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/stand/prekern/elf.c
diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.20 src/sys/arch/amd64/stand/prekern/elf.c:1.21
--- src/sys/arch/amd64/stand/prekern/elf.c:1.20	Thu May  7 16:49:59 2020
+++ src/sys/arch/amd64/stand/prekern/elf.c	Thu May  7 17:58:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf.c,v 1.20 2020/05/07 16:49:59 maxv Exp $	*/
+/*	$NetBSD: elf.c,v 1.21 2020/05/07 17:58:26 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -300,6 +300,37 @@ elf_build_head(vaddr_t headva)
 }
 
 void
+elf_fixup_boot(vaddr_t bootva, paddr_t bootpa)
+{
+	const paddr_t basepa = kernpa_start;
+	const vaddr_t headva = (vaddr_t)eif.ehdr;
+	size_t i, offboot;
+
+	/*
+	 * Fix up the 'sh_offset' field of the REL/RELA/SYM/STR sections, which
+	 * are all in the "boot" region.
+	 */
+	for (i = 0; i < eif.ehdr->e_shnum; i++) {
+		if (eif.shdr[i].sh_type != SHT_STRTAB &&
+		eif.shdr[i].sh_type != SHT_REL &&
+		eif.shdr[i].sh_type != SHT_RELA &&
+		eif.shdr[i].sh_type != SHT_SYMTAB) {
+			continue;
+		}
+		if (eif.shdr[i].sh_offset == 0) {
+			/* The bootloader dropped it. */
+			continue;
+		}
+
+		/* Offset of the section within the boot region. */
+		offboot = basepa + eif.shdr[i].sh_offset - bootpa;
+
+		/* We want (headva + sh_offset) to be the VA of the region. */
+		eif.shdr[i].sh_offset = (bootva + offboot - headva);
+	}
+}
+
+void
 elf_map_sections(void)
 {
 	const paddr_t basepa = kernpa_start;
@@ -333,45 +364,27 @@ elf_map_sections(void)
 
 		secva = mm_map_segment(segtype, secpa, secsz, secalign);
 
-		/* We want (headva + sh_offset) to be the VA of the section. */
+		/*
+		 * Fix up the 'sh_offset' field of the NOBITS/PROGBITS sections.
+		 * We want (headva + sh_offset) to be the VA of the section.
+		 */
 		ASSERT(secva > headva);
 		shdr->sh_offset = secva - headva;
 	}
 }
 
 void
-elf_build_boot(vaddr_t bootva, paddr_t bootpa)
+elf_build_info(void)
 {
-	const paddr_t basepa = kernpa_start;
-	const vaddr_t headva = (vaddr_t)eif.ehdr;
-	size_t i, j, offboot;
-
-	for (i = 0; i < eif.ehdr->e_shnum; i++) {
-		if (eif.shdr[i].sh_type != SHT_STRTAB &&
-		eif.shdr[i].sh_type != SHT_REL &&
-		eif.shdr[i].sh_type != SHT_RELA &&
-		eif.shdr[i].sh_type != SHT_SYMTAB) {
-			continue;
-		}
-		if (eif.shdr[i].sh_offset == 0) {
-			/* hasn't been loaded */
-			continue;
-		}
-
-		/* Offset of the section within the boot region. */
-		offboot = basepa + eif.shdr[i].sh_offset - bootpa;
-
-		/* We want (headva + sh_offset) to be the VA of the region. */
-		eif.shdr[i].sh_offset = (bootva + offboot - headva);
-	}
+	size_t i, j;
 
 	/* Locate the section names */
 	j = eif.ehdr->e_shstrndx;
 	if (j == SHN_UNDEF) {
-		fatal("elf_build_boot: shstrtab not found");
+		fatal("elf_build_info: shstrtab not found");
 	}
 	if (j >= eif.ehdr->e_shnum) {
-		fatal("elf_build_boot: wrong shstrtab index");
+		fatal("elf_build_info: wrong shstrtab index");
 	}
 	eif.shstrtab = (char *)((uint8_t *)eif.ehdr + eif.shdr[j].sh_offset);
 	eif.shstrsz = eif.shdr[j].sh_size;
@@ -382,10 +395,10 @@ elf_build_boot(vaddr_t bootva, paddr_t b
 			break;
 	}
 	if (i == eif.ehdr->e_shnum) {
-		fatal("elf_build_boot: symtab not found");
+		fatal("elf_build_info: symtab not found");
 	}
 	if (eif.shdr[i].sh_offset == 0) {
-		fatal("elf_build_boot: symtab not loaded");
+		fatal("elf_build_info: symtab not loaded");
 	}
 	eif.symtab = (Elf_Sym *)((uint8_t *)eif.ehdr + eif.shdr[i].sh_offset);
 	eif.symcnt = eif.shdr[i].sh_size / sizeof(Elf_Sym);
@@ -393,13 +406,13 @@ elf_build_boot(vaddr_t bootva, paddr_t b
 	/* Also locate the string table */
 	j = eif.shdr[i].sh_link;
 	if (j == SHN_UNDEF || j >= eif.ehdr->e_shnum) {
-		fatal("elf_build_boot: wrong strtab index");
+		fatal("elf_build_info: wrong strtab index");
 	}
 	if (eif.shdr[j].sh_type != SHT_STRTAB) {
-		fatal("elf_build_boot: wrong strtab type");
+		fatal("elf_build_info: wrong strtab type");
 	}
 	if (eif.shdr[j].sh_offset == 0) {
-		fatal("elf_build_boot: strtab not loaded");
+		fatal("elf_build_info: strtab not loaded");
 	}
 	eif.strtab = (char *)((uint8_t *)eif.ehdr + eif.shdr[j].sh_offset);
 	eif.strsz = eif.shdr[j].sh_size;

Index: src/sys/arch/amd64/stand/prekern/mm.c
diff -u src/sys/arch/amd64/stand/prekern/mm.c:1.26 src/sys/arch/amd64/stand/prekern/mm.c:1.27
--- src/sys/arch/amd64/stand/prekern/mm.c:1.26	Thu May  7 17:10:02 2020
+++ src/sys/arch/amd64/stand/prekern/mm.c	Thu May  7 17:58:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mm.c,v 1.26 

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

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 17:10:02 UTC 2020

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

Log Message:
Explain more.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/amd64/stand/prekern/mm.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/stand/prekern/mm.c
diff -u src/sys/arch/amd64/stand/prekern/mm.c:1.25 src/sys/arch/amd64/stand/prekern/mm.c:1.26
--- src/sys/arch/amd64/stand/prekern/mm.c:1.25	Sat Feb 15 10:41:25 2020
+++ src/sys/arch/amd64/stand/prekern/mm.c	Thu May  7 17:10:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mm.c,v 1.25 2020/02/15 10:41:25 maxv Exp $	*/
+/*	$NetBSD: mm.c,v 1.26 2020/05/07 17:10:02 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -248,7 +248,7 @@ mm_randva_kregion(size_t size, size_t pa
 }
 
 static paddr_t
-bootspace_getend(void)
+bootspace_get_kern_segs_end_pa(void)
 {
 	paddr_t pa, max = 0;
 	size_t i;
@@ -410,21 +410,29 @@ mm_map_boot(void)
 	 * the number of pages entered is lower.
 	 */
 
-	/* Create the page tree */
+	/* Create the page tree, starting at a random VA */
 	size = (NKL2_KIMG_ENTRIES + 1) * NBPD_L2;
 	randva = mm_randva_kregion(size, PAGE_SIZE);
 
-	/* Enter the area and build the ELF info */
-	bootpa = bootspace_getend();
+	/* The "boot" region begins right after the kernel segments */
+	bootpa = bootspace_get_kern_segs_end_pa();
+
+	/* The prekern consumed some memory up until pa_avail, this covers
+	 * SYM+REL and EXTRA */
 	size = (pa_avail - bootpa);
 	npages = size / PAGE_SIZE;
+
+	/* Enter the whole area linearly */
 	for (i = 0; i < npages; i++) {
 		mm_enter_pa(bootpa + i * PAGE_SIZE,
 		randva + i * PAGE_SIZE, MM_PROT_READ|MM_PROT_WRITE);
 	}
+
+	/* At this point both "head" and "boot" are mapped, so we can build
+	 * the ELF info */
 	elf_build_boot(randva, bootpa);
 
-	/* Enter the ISA I/O MEM */
+	/* Map the ISA I/O MEM right after EXTRA */
 	iom_base = randva + npages * PAGE_SIZE;
 	npages = IOM_SIZE / PAGE_SIZE;
 	for (i = 0; i < npages; i++) {
@@ -451,23 +459,25 @@ mm_map_boot(void)
  * ++-+---+--+---+
  * | ELF HEADER | SECTION HEADERS | KERN SECTIONS | SYM+REL SECTIONS | EXTRA |
  * ++-+---+--+---+
- * Which we abstract into several "regions":
+ * This was done in the loadfile_elf32.c:loadfile_dynamic() function.
+ *
+ * We abstract this layout into several "regions":
  * +--+---+--+
- * | Head region  | Several segs  |   Boot region|
+ * | Head region  |  Kernel segs  |   Boot region|
  * +--+---+--+
- * See loadfile_elf32.c:loadfile_dynamic() for the details.
  *
  * There is a variable number of independent regions we create: one head,
  * several kernel segments, one boot. They are all mapped at random VAs.
  *
- * Head contains the ELF Header and ELF Section Headers, and we use them to
- * map the rest of the regions. Head must be placed in both virtual memory
- * and physical memory *before* the rest.
+ * "Head" contains the ELF Header and ELF Section Headers, and we use them to
+ * map the rest of the regions. Head must be placed *before* the other
+ * regions, in both virtual memory and physical memory.
  *
- * The Kernel Sections are mapped at random VAs using individual segments
- * in bootspace.
+ * The "Kernel Segments" contain the kernel SHT_NOBITS and SHT_PROGBITS
+ * sections, in a 1:1 manner (one segment is associated with one section).
+ * The segments are mapped at random VAs and referenced in bootspace.segs[].
  *
- * Boot contains various information, including the ELF Sym+Rel sections,
+ * "Boot" contains various information, including the ELF Sym+Rel sections,
  * plus extra memory the prekern has used so far; it is a region that the
  * kernel will eventually use for module_map. Boot is placed *after* the
  * other regions in physical memory. In virtual memory however there is no



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

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 16:49:59 UTC 2020

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

Log Message:
If we encounter relocations from a section that the bootloader dropped,
AND if the section is a note, then skip the relocations.

Considering a note that the bootloader dropped, there are two possible
sides for the relocations: (1) the relocations from the note towards the
rest of the binary, and (2) the relocations from the rest of the binary
towards the note.

We skip (1), which is correct, because the notes do not play any role at
run time. If we encounter (2) however then there is a bug in the kernel,
so add a sanity check against that.

This fixes KASLR since the latest Xen changes (which introduced .note.Xen).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/amd64/stand/prekern/elf.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/stand/prekern/elf.c
diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.19 src/sys/arch/amd64/stand/prekern/elf.c:1.20
--- src/sys/arch/amd64/stand/prekern/elf.c:1.19	Tue May  5 19:26:47 2020
+++ src/sys/arch/amd64/stand/prekern/elf.c	Thu May  7 16:49:59 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: elf.c,v 1.19 2020/05/05 19:26:47 maxv Exp $	*/
+/*	$NetBSD: elf.c,v 1.20 2020/05/07 16:49:59 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.
@@ -60,6 +60,40 @@ elf_check_header(void)
 	return 0;
 }
 
+static bool
+elf_section_mappable(Elf_Shdr *shdr)
+{
+	if (!(shdr->sh_flags & SHF_ALLOC)) {
+		return false;
+	}
+	if (shdr->sh_type != SHT_NOBITS &&
+	shdr->sh_type != SHT_PROGBITS) {
+		return false;
+	}
+	return true;
+}
+
+static bool
+elf_can_drop_unmappable(Elf_Shdr *shdr)
+{
+	/*
+	 * We found relocations from the section 'shdr' towards the rest of
+	 * the binary, but 'shdr' is not mapped. Decide whether to skip the
+	 * relocations from this section.
+	 *
+	 * We skip only if it is a note. It means that we allow notes to
+	 * have relocations towards the rest of the binary, typically with
+	 * the ".note.Xen" section. Notes do not play any role at run time.
+	 *
+	 * Any section other than a note is the sign there is a design
+	 * mistake in the kernel (variables stored outside of rodata/data).
+	 */
+	if (shdr->sh_type == SHT_NOTE) {
+		return true;
+	}
+	return false;
+}
+
 static vaddr_t
 elf_get_entrypoint(void)
 {
@@ -144,6 +178,12 @@ elf_sym_lookup(size_t symidx)
 
 		fatal("elf_sym_lookup: external symbol");
 	}
+	if (sym->st_shndx >= eif.ehdr->e_shnum) {
+		fatal("elf_sym_lookup: st_shndx is malformed");
+	}
+	if (!elf_section_mappable([sym->st_shndx])) {
+		fatal("elf_sym_lookup: st_shndx not mappable");
+	}
 	if (sym->st_value == 0) {
 		fatal("elf_sym_lookup: zero value");
 	}
@@ -259,19 +299,6 @@ elf_build_head(vaddr_t headva)
 	}
 }
 
-static bool
-elf_section_mappable(Elf_Shdr *shdr)
-{
-	if (!(shdr->sh_flags & SHF_ALLOC)) {
-		return false;
-	}
-	if (shdr->sh_type != SHT_NOBITS &&
-	shdr->sh_type != SHT_PROGBITS) {
-		return false;
-	}
-	return true;
-}
-
 void
 elf_map_sections(void)
 {
@@ -429,6 +456,9 @@ elf_kernel_reloc(void)
 			fatal("elf_kernel_reloc: REL sh_info is malformed");
 		}
 		if (!elf_section_mappable([secidx])) {
+			if (elf_can_drop_unmappable([secidx])) {
+continue;
+			}
 			fatal("elf_kernel_reloc: REL sh_info not mappable");
 		}
 		base = (uintptr_t)eif.ehdr + eif.shdr[secidx].sh_offset;
@@ -461,6 +491,9 @@ elf_kernel_reloc(void)
 			fatal("elf_kernel_reloc: RELA sh_info is malformed");
 		}
 		if (!elf_section_mappable([secidx])) {
+			if (elf_can_drop_unmappable([secidx])) {
+continue;
+			}
 			fatal("elf_kernel_reloc: RELA sh_info not mappable");
 		}
 		base = (uintptr_t)eif.ehdr + eif.shdr[secidx].sh_offset;



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

2020-05-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue May  5 19:26:47 UTC 2020

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

Log Message:
Gather the section filtering in a single function, and add a sanity check
when relocating, to make sure the section we're accessing is mappable.

Currently this check fails, because of the Xen section, which has RELAs but
is an unmappable unallocated note.

Also improve the prekern ASSERTs while here.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/amd64/stand/prekern/elf.c
cvs rdiff -u -r1.20 -r1.21 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/stand/prekern/elf.c
diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.18 src/sys/arch/amd64/stand/prekern/elf.c:1.19
--- src/sys/arch/amd64/stand/prekern/elf.c:1.18	Sat Jan  5 22:11:07 2019
+++ src/sys/arch/amd64/stand/prekern/elf.c	Tue May  5 19:26:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf.c,v 1.18 2019/01/05 22:11:07 maxv Exp $	*/
+/*	$NetBSD: elf.c,v 1.19 2020/05/05 19:26:47 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -259,6 +259,19 @@ elf_build_head(vaddr_t headva)
 	}
 }
 
+static bool
+elf_section_mappable(Elf_Shdr *shdr)
+{
+	if (!(shdr->sh_flags & SHF_ALLOC)) {
+		return false;
+	}
+	if (shdr->sh_type != SHT_NOBITS &&
+	shdr->sh_type != SHT_PROGBITS) {
+		return false;
+	}
+	return true;
+}
+
 void
 elf_map_sections(void)
 {
@@ -273,11 +286,7 @@ elf_map_sections(void)
 	for (i = 0; i < eif.ehdr->e_shnum; i++) {
 		shdr = [i];
 
-		if (!(shdr->sh_flags & SHF_ALLOC)) {
-			continue;
-		}
-		if (shdr->sh_type != SHT_NOBITS &&
-		shdr->sh_type != SHT_PROGBITS) {
+		if (!elf_section_mappable(shdr)) {
 			continue;
 		}
 
@@ -383,10 +392,10 @@ elf_kernel_reloc(void)
 	 * Update all symbol values with the appropriate offset.
 	 */
 	for (i = 0; i < eif.ehdr->e_shnum; i++) {
-		if (eif.shdr[i].sh_type != SHT_NOBITS &&
-		eif.shdr[i].sh_type != SHT_PROGBITS) {
+		if (!elf_section_mappable([i])) {
 			continue;
 		}
+
 		ASSERT(eif.shdr[i].sh_offset != 0);
 		secva = baseva + eif.shdr[i].sh_offset;
 		for (j = 0; j < eif.symcnt; j++) {
@@ -417,7 +426,10 @@ elf_kernel_reloc(void)
 
 		secidx = eif.shdr[i].sh_info;
 		if (secidx >= eif.ehdr->e_shnum) {
-			fatal("elf_kernel_reloc: wrong REL relocation");
+			fatal("elf_kernel_reloc: REL sh_info is malformed");
+		}
+		if (!elf_section_mappable([secidx])) {
+			fatal("elf_kernel_reloc: REL sh_info not mappable");
 		}
 		base = (uintptr_t)eif.ehdr + eif.shdr[secidx].sh_offset;
 
@@ -446,7 +458,10 @@ elf_kernel_reloc(void)
 
 		secidx = eif.shdr[i].sh_info;
 		if (secidx >= eif.ehdr->e_shnum) {
-			fatal("elf_kernel_reloc: wrong RELA relocation");
+			fatal("elf_kernel_reloc: RELA sh_info is malformed");
+		}
+		if (!elf_section_mappable([secidx])) {
+			fatal("elf_kernel_reloc: RELA sh_info not mappable");
 		}
 		base = (uintptr_t)eif.ehdr + eif.shdr[secidx].sh_offset;
 

Index: src/sys/arch/amd64/stand/prekern/prekern.h
diff -u src/sys/arch/amd64/stand/prekern/prekern.h:1.20 src/sys/arch/amd64/stand/prekern/prekern.h:1.21
--- src/sys/arch/amd64/stand/prekern/prekern.h:1.20	Wed Jun 20 11:49:37 2018
+++ src/sys/arch/amd64/stand/prekern/prekern.h	Tue May  5 19:26:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: prekern.h,v 1.20 2018/06/20 11:49:37 maxv Exp $	*/
+/*	$NetBSD: prekern.h,v 1.21 2020/05/05 19:26:47 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -37,7 +37,7 @@
 #include "pdir.h"
 #include "redef.h"
 
-#define ASSERT(a) if (!(a)) fatal("ASSERT");
+#define ASSERT(a) if (!(a)) fatal("ASSERT: " #a);
 typedef uint64_t pte_prot_t;
 #define WHITE_ON_BLACK 0x07
 #define RED_ON_BLACK 0x04



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

2020-05-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue May  5 06:32:43 UTC 2020

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

Log Message:
Fix KASAN, init_xen_early must be called after kasan_early_init.


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 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.207 src/sys/arch/amd64/amd64/locore.S:1.208
--- src/sys/arch/amd64/amd64/locore.S:1.207	Sat May  2 19:01:08 2020
+++ src/sys/arch/amd64/amd64/locore.S	Tue May  5 06:32:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.207 2020/05/02 19:01:08 christos Exp $	*/
+/*	$NetBSD: locore.S,v 1.208 2020/05/05 06:32:43 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -991,14 +991,15 @@ longmode_hi:
 #endif	/* XENPV */
 
 	pushq	%rdi
-#if defined(XEN) && !defined(XENPV)
-	call	_C_LABEL(init_xen_early)
-#endif
 	call	_C_LABEL(init_bootspace)
 #ifdef KASAN
 	movq	_C_LABEL(lwp0uarea)(%rip),%rdi
 	call	_C_LABEL(kasan_early_init)
 #endif
+	/* <-- DO NOT INSERT C CALLS BEFORE THIS POINT --> */
+#if defined(XEN) && !defined(XENPV)
+	call	_C_LABEL(init_xen_early)
+#endif
 	call	_C_LABEL(init_slotspace)
 	popq	%rdi
 	call	_C_LABEL(init_x86_64)



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

2020-05-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  2 19:01:08 UTC 2020

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

Log Message:
Fix build without XEN


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 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.206 src/sys/arch/amd64/amd64/locore.S:1.207
--- src/sys/arch/amd64/amd64/locore.S:1.206	Sat May  2 12:44:34 2020
+++ src/sys/arch/amd64/amd64/locore.S	Sat May  2 15:01:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.206 2020/05/02 16:44:34 bouyer Exp $	*/
+/*	$NetBSD: locore.S,v 1.207 2020/05/02 19:01:08 christos Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1005,7 +1005,8 @@ longmode_hi:
 	call 	_C_LABEL(main)
 END(start)
 
-#ifndef XENPV
+#if defined(XEN)
+# if !defined(XENPV)
 /* entry point for Xen PVH */
 	.code32
 ENTRY(start_xen32)
@@ -1062,8 +1063,7 @@ ENTRY(start_xen32)
 	jmp .Lbiosbasemem_finished
 END(start_xen32)
 	.code64
-#endif /* XENPV */
-#if defined(XEN)
+# endif /* !XENPV */
 /* space for the hypercall call page */
 #define HYPERCALL_PAGE_OFFSET 0x1000
 .align HYPERCALL_PAGE_OFFSET



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

2020-05-02 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat May  2 11:12:50 UTC 2020

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

Log Message:
Remove unused.


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

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

Modified files:

Index: src/sys/arch/amd64/amd64/spl.S
diff -u src/sys/arch/amd64/amd64/spl.S:1.44 src/sys/arch/amd64/amd64/spl.S:1.45
--- src/sys/arch/amd64/amd64/spl.S:1.44	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/amd64/spl.S	Sat May  2 11:12:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.44 2020/04/25 15:26:16 bouyer Exp $	*/
+/*	$NetBSD: spl.S,v 1.45 2020/05/02 11:12:49 maxv Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -187,7 +187,6 @@ ENTRY(softint_trigger)
 	ret
 END(softint_trigger)
 
-
 /*
  * Xrecurse_preempt()
  *
@@ -255,10 +254,7 @@ ENTRY(spllower)
 2:
 	movq	%r8,%rbx
 	jmp	_C_LABEL(Xspllower)
-
-	.align	16
 END(spllower)
-LABEL(spllower_end)
 
 /*
  * void Xspllower(int s);
@@ -277,9 +273,6 @@ LABEL(spllower_end)
  * the sending CPU will never see the that CPU accept the IPI
  * (see pmap_tlb_shootnow).
  */
-	nop
-	.align	4	/* Avoid confusion with cx8_spllower_end */
-
 IDTVEC(spllower)
 	pushq	%rbx
 	pushq	%r13



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

2020-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May  1 07:03:02 UTC 2020

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

Log Message:
Explicitly align to 8 bytes, found by kUBSan.

Reported-by: syzbot+f1e1561ed739db869...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 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.75 src/sys/arch/amd64/amd64/vector.S:1.76
--- src/sys/arch/amd64/amd64/vector.S:1.75	Mon Apr 27 16:55:50 2020
+++ src/sys/arch/amd64/amd64/vector.S	Fri May  1 07:03:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.75 2020/04/27 16:55:50 bouyer Exp $	*/
+/*	$NetBSD: vector.S,v 1.76 2020/05/01 07:03:02 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -630,6 +630,7 @@ INTRSTUB(x2apic_level,31,voidop,x2apic_a
  */
 #define INTRSTUB_ARRAY_16(name) 		; \
 	.type _C_LABEL(name ## _stubs), @object	; \
+	.align 8; \
 LABEL(name ## _stubs); \
 	INTRSTUB_ENTRY(name ## 0)		; \
 	INTRSTUB_ENTRY(name ## 1)		; \
@@ -654,6 +655,7 @@ END(name ## _stubs)
  */
 #define INTRSTUB_ARRAY_32(name) 		; \
 	.type _C_LABEL(name ## _stubs), @object	; \
+	.align 8; \
 LABEL(name ## _stubs); \
 	INTRSTUB_ENTRY(name ## 0)		; \
 	INTRSTUB_ENTRY(name ## 1)		; \
@@ -745,6 +747,7 @@ END(entry_xenev)
 	.quad entry_xenev , _C_LABEL(Xrecurse_ ## name ## sir); \
 	.quad _C_LABEL(Xresume_ ## name ## sir);
 
+	.align 8
 LABEL(xenev_stubs)
 	XENINTRSTUB_ENTRY(xenev, SIR_XENIPL_VM) ;
 	XENINTRSTUB_ENTRY(xenev, SIR_XENIPL_SCHED) ;



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

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 17:21:12 UTC 2020

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

Log Message:
The labels are already global, drop unused.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 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.203 src/sys/arch/amd64/amd64/locore.S:1.204
--- src/sys/arch/amd64/amd64/locore.S:1.203	Thu Apr 30 17:17:33 2020
+++ src/sys/arch/amd64/amd64/locore.S	Thu Apr 30 17:21:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.203 2020/04/30 17:17:33 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.204 2020/04/30 17:21:12 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1610,11 +1610,6 @@ LABEL(hp_stac)
 LABEL(hp_stac_end)
 
 #ifdef SVS
-	.globl	svs_enter, svs_enter_end
-	.globl	svs_enter_altstack, svs_enter_altstack_end
-	.globl	svs_leave, svs_leave_end
-	.globl	svs_leave_altstack, svs_leave_altstack_end
-
 LABEL(svs_enter)
 	movabs	SVS_UTLS+UTLS_KPDIRPA,%rax
 	movq	%rax,%cr3
@@ -1656,9 +1651,6 @@ LABEL(svs_leave_nmi)
 LABEL(svs_leave_nmi_end)
 #endif
 
-	.globl	ibrs_enter, ibrs_enter_end
-	.globl	ibrs_leave, ibrs_leave_end
-
 	/* IBRS <- 1 */
 LABEL(ibrs_enter)
 	movl	$MSR_IA32_SPEC_CTRL,%ecx
@@ -1683,8 +1675,6 @@ LABEL(noibrs_leave)
 	NOIBRS_LEAVE
 LABEL(noibrs_leave_end)
 
-	.globl	mds_leave, mds_leave_end
-
 LABEL(mds_leave)
 	pushq	$GSEL(GDATA_SEL, SEL_KPL)
 	verw	(%rsp)



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

2020-04-27 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Apr 27 16:55:50 UTC 2020

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

Log Message:
Limit the amount of code in TEXT_USER_BEGIN/TEXT_USER_END for
hypervisor_pvhvm_callback, for the benefit of SVS. Suggested by maxv@


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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.74 src/sys/arch/amd64/amd64/vector.S:1.75
--- src/sys/arch/amd64/amd64/vector.S:1.74	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/amd64/vector.S	Mon Apr 27 16:55:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.74 2020/04/25 15:26:16 bouyer Exp $	*/
+/*	$NetBSD: vector.S,v 1.75 2020/04/27 16:55:50 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -761,12 +761,10 @@ ENTRY(hypervisor_callback)
 	movq	(%rsp),%rcx
 	movq	8(%rsp),%r11
 	addq	$16,%rsp
-	jmp _C_LABEL(Xhypervisor_pvhvm_callback)
-	TEXT_USER_BEGIN
-IDTVEC(hypervisor_pvhvm_callback)
 	pushq	$0		/* Dummy error code */
 	pushq	$T_ASTFLT
 	INTRENTRY
+IDTVEC(handle_hypervisor_callback)
 	movlCPUVAR(ILEVEL),%edi
 	pushq   %rdi /* for Xdoreti */
 	incl	CPUVAR(IDEPTH)
@@ -781,9 +779,17 @@ IDTVEC(hypervisor_pvhvm_callback)
 1:
 #endif
 	jmp 	_C_LABEL(Xdoreti)
+IDTVEC_END(handle_hypervisor_callback)
+END(hypervisor_callback)
+
+	TEXT_USER_BEGIN
+IDTVEC(hypervisor_pvhvm_callback)
+	pushq	$0		/* Dummy error code */
+	pushq	$T_ASTFLT
+	INTRENTRY
+	jmp _C_LABEL(Xhandle_hypervisor_callback)
 IDTVEC_END(hypervisor_pvhvm_callback)
 	TEXT_USER_END
-END(hypervisor_callback)
 #endif /* XEN */
 
 #ifdef XENPV



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

2020-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Apr 26 14:07:43 UTC 2020

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

Log Message:
Put the template functions in the rodata section; they get hotpatched
into other places, but never execute directly.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 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.201 src/sys/arch/amd64/amd64/locore.S:1.202
--- src/sys/arch/amd64/amd64/locore.S:1.201	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/amd64/locore.S	Sun Apr 26 14:07:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.201 2020/04/25 15:26:16 bouyer Exp $	*/
+/*	$NetBSD: locore.S,v 1.202 2020/04/26 14:07:43 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1587,6 +1587,8 @@ END(intrfastexit)
 
 	TEXT_USER_END
 
+	.section .rodata
+
 #ifdef SVS
 	.globl	svs_enter, svs_enter_end
 	.globl	svs_enter_altstack, svs_enter_altstack_end



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

2020-04-25 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Apr 25 12:41:58 UTC 2020

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

Log Message:
Add uxrcom.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 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.148 src/sys/arch/amd64/conf/ALL:1.149
--- src/sys/arch/amd64/conf/ALL:1.148	Mon Apr 13 09:30:42 2020
+++ src/sys/arch/amd64/conf/ALL	Sat Apr 25 12:41:57 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.148 2020/04/13 09:30:42 jdolecek Exp $
+# $NetBSD: ALL,v 1.149 2020/04/25 12:41:57 simonb 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.148 $"
+#ident		"ALL-$Revision: 1.149 $"
 
 maxusers	64		# estimated number of users
 
@@ -1289,6 +1289,9 @@ ucom*	at uark? portno ?
 umcs* at uhub? port ?		# Moschip MCS7xxx serial adapter
 ucom*	at umcs? portno ?
 
+uxrcom*	at uhub? port ?		# Exar XR21V141x serial adapter
+ucom*	at uxrcom? portno ?
+
 uhmodem* at uhub?
 ucom*	at uhmodem? portno ?
 



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

2020-04-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 23 16:16:15 UTC 2020

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

Log Message:
use shortcut variables for readability.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/amd64/amd64/netbsd32_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/netbsd32_machdep.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.133 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.134
--- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.133	Wed Dec 11 21:15:42 2019
+++ src/sys/arch/amd64/amd64/netbsd32_machdep.c	Thu Apr 23 12:16:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.133 2019/12/12 02:15:42 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.134 2020/04/23 16:16:14 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.133 2019/12/12 02:15:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.134 2020/04/23 16:16:14 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -214,18 +214,20 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	int onstack, error;
 	int sig = ksi->ksi_signo;
 	struct netbsd32_sigframe_siginfo *fp, frame;
-	sig_t catcher = SIGACTION(p, sig).sa_handler;
+	const struct sigaction *sa = (p, sig);
+	sig_t catcher = sa->sa_handler;
 	struct trapframe *tf = l->l_md.md_regs;
+	struct sigaltstack * const ss = >l_sigstk;
 
 	/* Do we need to jump onto the signal stack? */
 	onstack =
-	(l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
-	(SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
+	(ss->ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
+	(sa->sa_flags & SA_ONSTACK) != 0;
 
 	/* Allocate space for the signal handler context. */
 	if (onstack)
 		fp = (struct netbsd32_sigframe_siginfo *)
-		((char *)l->l_sigstk.ss_sp + l->l_sigstk.ss_size);
+		((char *)ss->ss_sp + ss->ss_size);
 	else
 		fp = (struct netbsd32_sigframe_siginfo *)tf->tf_rsp;
 
@@ -252,7 +254,7 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	frame.sf_uc.uc_flags = _UC_SIGMASK;
 	frame.sf_uc.uc_sigmask = *mask;
 	frame.sf_uc.uc_link = (uint32_t)(uintptr_t)l->l_ctxlink;
-	frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK)
+	frame.sf_uc.uc_flags |= (ss->ss_flags & SS_ONSTACK)
 	? _UC_SETSTACK : _UC_CLRSTACK;
 	sendsig_reset(l, sig);
 



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

2020-04-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 15 17:00:08 UTC 2020

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

Log Message:
Use large pages for the kASan shadow, same as kMSan.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/include/asan.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.3 src/sys/arch/amd64/include/asan.h:1.4
--- src/sys/arch/amd64/include/asan.h:1.3	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/amd64/include/asan.h	Wed Apr 15 17:00:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.3 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: asan.h,v 1.4 2020/04/15 17:00:07 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -92,29 +92,60 @@ __md_palloc(void)
 	else
 		pa = pmap_get_physpage();
 
+	/* The page is zeroed. */
 	return pa;
 }
 
+static inline paddr_t
+__md_palloc_large(void)
+{
+	struct pglist pglist;
+	int ret;
+
+	if (__predict_false(__md_early))
+		return 0;
+	if (!uvm.page_init_done)
+		return 0;
+
+	ret = uvm_pglistalloc(NBPD_L2, 0, ~0UL, NBPD_L2, 0,
+	, 1, 0);
+	if (ret != 0)
+		return 0;
+
+	/* The page may not be zeroed. */
+	return VM_PAGE_TO_PHYS(TAILQ_FIRST());
+}
+
 static void
 kasan_md_shadow_map_page(vaddr_t va)
 {
+	const pt_entry_t pteflags = PTE_W | pmap_pg_nx | PTE_P;
 	paddr_t pa;
 
 	if (!pmap_valid_entry(L4_BASE[pl4_i(va)])) {
 		pa = __md_palloc();
-		L4_BASE[pl4_i(va)] = pa | PTE_W | pmap_pg_nx | PTE_P;
+		L4_BASE[pl4_i(va)] = pa | pteflags;
 	}
 	if (!pmap_valid_entry(L3_BASE[pl3_i(va)])) {
 		pa = __md_palloc();
-		L3_BASE[pl3_i(va)] = pa | PTE_W | pmap_pg_nx | PTE_P;
+		L3_BASE[pl3_i(va)] = pa | pteflags;
 	}
 	if (!pmap_valid_entry(L2_BASE[pl2_i(va)])) {
+		if ((pa = __md_palloc_large()) != 0) {
+			L2_BASE[pl2_i(va)] = pa | pteflags | PTE_PS |
+			pmap_pg_g;
+			__insn_barrier();
+			__builtin_memset((void *)va, 0, NBPD_L2);
+			return;
+		}
 		pa = __md_palloc();
-		L2_BASE[pl2_i(va)] = pa | PTE_W | pmap_pg_nx | PTE_P;
+		L2_BASE[pl2_i(va)] = pa | pteflags;
+	} else if (L2_BASE[pl2_i(va)] & PTE_PS) {
+		return;
 	}
 	if (!pmap_valid_entry(L1_BASE[pl1_i(va)])) {
 		pa = __md_palloc();
-		L1_BASE[pl1_i(va)] = pa | PTE_W | pmap_pg_g | pmap_pg_nx | PTE_P;
+		L1_BASE[pl1_i(va)] = pa | pteflags | pmap_pg_g;
 	}
 }
 



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

2020-04-13 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Apr 13 09:30:42 UTC 2020

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

Log Message:
remove wd* at umass?, it was dropped


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 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.147 src/sys/arch/amd64/conf/ALL:1.148
--- src/sys/arch/amd64/conf/ALL:1.147	Wed Mar 25 17:06:17 2020
+++ src/sys/arch/amd64/conf/ALL	Mon Apr 13 09:30:42 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.147 2020/03/25 17:06:17 jdolecek Exp $
+# $NetBSD: ALL,v 1.148 2020/04/13 09:30:42 jdolecek 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.147 $"
+#ident		"ALL-$Revision: 1.148 $"
 
 maxusers	64		# estimated number of users
 
@@ -1198,7 +1198,6 @@ uhso*	at uhub? port ? configuration ?
 
 # USB Mass Storage
 umass*	at uhub? port ? configuration ? interface ?
-wd*	at umass?
 
 # USB audio
 uaudio* at uhub? port ? configuration ?



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

2020-04-13 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Apr 13 09:34:03 UTC 2020

Modified Files:
src/sys/arch/amd64/conf: Makefile.amd64

Log Message:
Make KASAN compatible with LLVM. Same as GCC, except that LLVM aggressively
inlines the shadow checks, and this causes problems at boot time; so we
pass -asan-instrumentation-with-call-threshold=0 to force callbacks instead
of inlines.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/amd64/conf/Makefile.amd64

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/Makefile.amd64
diff -u src/sys/arch/amd64/conf/Makefile.amd64:1.82 src/sys/arch/amd64/conf/Makefile.amd64:1.83
--- src/sys/arch/amd64/conf/Makefile.amd64:1.82	Sat Apr  4 07:03:57 2020
+++ src/sys/arch/amd64/conf/Makefile.amd64	Mon Apr 13 09:34:02 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.amd64,v 1.82 2020/04/04 07:03:57 maxv Exp $
+#	$NetBSD: Makefile.amd64,v 1.83 2020/04/13 09:34:02 maxv Exp $
 
 # Makefile for NetBSD
 #
@@ -49,12 +49,21 @@ CFLAGS+=  -mindirect-branch=thunk-in
 CFLAGS+=  -mindirect-branch-register
 .endif
 
-.if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
+.if ${KASAN:U0} > 0
+.if ${HAVE_GCC:U0} > 0
 KASANFLAGS=	-fsanitize=kernel-address \
 		--param asan-globals=1 --param asan-stack=1 \
 		--param asan-instrument-allocas=1 \
 		-fsanitize-address-use-after-scope \
 		-fasan-shadow-offset=0xDFFF9000
+.elif ${HAVE_LLVM:Uno} == "yes"
+KASANFLAGS=	-fsanitize=kernel-address \
+		-mllvm -asan-globals=1 -mllvm -asan-stack=1 \
+		-mllvm -asan-instrument-dynamic-allocas=1 \
+		-mllvm -asan-use-after-scope=1 \
+		-mllvm -asan-instrumentation-with-call-threshold=0 \
+		-mllvm -asan-mapping-offset=0xDFFF9000
+.endif
 .for f in subr_asan.c subr_kcov.c
 KASANFLAGS.${f}=	# empty
 .endfor



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

2020-02-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 29 15:00:28 UTC 2020

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

Log Message:
Fix boot -c or -d by avoiding ipi handling before the vector is initialized.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/sys/arch/amd64/amd64/db_interface.c:1.37
--- src/sys/arch/amd64/amd64/db_interface.c:1.36	Thu Feb 14 02:12:40 2019
+++ src/sys/arch/amd64/amd64/db_interface.c	Sat Feb 29 10:00:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.36 2019/02/14 07:12:40 cherry Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.37 2020/02/29 15:00:28 christos Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.36 2019/02/14 07:12:40 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.37 2020/02/29 15:00:28 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -150,7 +150,9 @@ db_suspend_others(void)
 		xen_broadcast_ipi(XEN_IPI_DDB);
 #else
 #if NLAPIC > 0
-		x86_ipi(ddb_vec, LAPIC_DEST_ALLEXCL, LAPIC_DLMODE_FIXED);
+		if (ddb_vec != 0)
+			x86_ipi(ddb_vec, LAPIC_DEST_ALLEXCL,
+			LAPIC_DLMODE_FIXED);
 #endif
 #endif /* XENPV */
 	}



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

2020-02-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb 15 10:41:25 UTC 2020

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

Log Message:
Explain more.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/amd64/stand/prekern/mm.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/stand/prekern/mm.c
diff -u src/sys/arch/amd64/stand/prekern/mm.c:1.24 src/sys/arch/amd64/stand/prekern/mm.c:1.25
--- src/sys/arch/amd64/stand/prekern/mm.c:1.24	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/amd64/stand/prekern/mm.c	Sat Feb 15 10:41:25 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: mm.c,v 1.24 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: mm.c,v 1.25 2020/02/15 10:41:25 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.
@@ -289,6 +289,12 @@ mm_shift_segment(vaddr_t va, size_t page
 	size_t shiftsize, offset;
 	uint64_t rnd;
 
+	/*
+	 * If possible, shift the segment in memory using a random offset. Once
+	 * shifted the segment remains in the same page, of size pagesz. Make
+	 * sure to respect the ELF alignment constraint.
+	 */
+
 	if (elfalign == 0) {
 		elfalign = ELFROUND;
 	}
@@ -317,6 +323,13 @@ mm_map_head(void)
 	vaddr_t randva;
 
 	/*
+	 * The HEAD window is 1GB below the main KASLR window. This is to
+	 * ensure that head always comes first in virtual memory. The reason
+	 * for that is that we use (headva + sh_offset), and sh_offset is
+	 * unsigned.
+	 */
+
+	/*
 	 * To get the size of the head, we give a look at the read-only
 	 * mapping of the kernel we created in locore. We're identity mapped,
 	 * so kernpa = kernva.
@@ -324,6 +337,10 @@ mm_map_head(void)
 	size = elf_get_head_size((vaddr_t)kernpa_start);
 	npages = size / PAGE_SIZE;
 
+	/*
+	 * Choose a random range of VAs in the HEAD window, and create the page
+	 * tree for it.
+	 */
 	prng_get_rand(, sizeof(rnd));
 	randva = rounddown(HEAD_WINDOW_BASE + rnd % (HEAD_WINDOW_SIZE - size),
 	PAGE_SIZE);
@@ -355,22 +372,27 @@ mm_map_segment(int segtype, paddr_t pa, 
 		pagesz = NBPD_L2;
 	}
 
+	/* Create the page tree */
 	size = roundup(elfsz, pagesz);
 	randva = mm_randva_kregion(size, pagesz);
 
+	/* Enter the segment */
 	npages = size / PAGE_SIZE;
 	for (i = 0; i < npages; i++) {
 		mm_enter_pa(pa + i * PAGE_SIZE,
 		randva + i * PAGE_SIZE, MM_PROT_READ|MM_PROT_WRITE);
 	}
 
+	/* Shift the segment in memory */
 	offset = mm_shift_segment(randva, pagesz, elfsz, elfalign);
 	ASSERT(offset + elfsz <= size);
 
+	/* Fill the paddings */
 	pad = pads[segtype];
 	memset((void *)randva, pad, offset);
 	memset((void *)(randva + offset + elfsz), pad, size - elfsz - offset);
 
+	/* Register the bootspace information */
 	bootspace_addseg(segtype, randva, pa, size);
 
 	return (randva + offset);
@@ -425,12 +447,31 @@ mm_map_boot(void)
 }
 
 /*
- * There is a variable number of independent regions: one head, several kernel
- * segments, one boot. They are all mapped at random VAs.
+ * The bootloader has set up the following layout of physical memory:
+ * ++-+---+--+---+
+ * | ELF HEADER | SECTION HEADERS | KERN SECTIONS | SYM+REL SECTIONS | EXTRA |
+ * ++-+---+--+---+
+ * Which we abstract into several "regions":
+ * +--+---+--+
+ * | Head region  | Several segs  |   Boot region|
+ * +--+---+--+
+ * See loadfile_elf32.c:loadfile_dynamic() for the details.
+ *
+ * There is a variable number of independent regions we create: one head,
+ * several kernel segments, one boot. They are all mapped at random VAs.
  *
  * Head contains the ELF Header and ELF Section Headers, and we use them to
- * map the rest of the regions. Head must be placed in memory *before* the
- * other regions.
+ * map the rest of the regions. Head must be placed in both virtual memory
+ * and physical memory *before* the rest.
+ *
+ * The Kernel Sections are mapped at random VAs using individual segments
+ * in bootspace.
+ *
+ * Boot contains various information, including the ELF Sym+Rel sections,
+ * plus extra memory the prekern has used so far; it is a region that the
+ * kernel will eventually use for module_map. Boot is placed *after* the
+ * other regions in physical memory. In virtual memory however there is no
+ * constraint, so its VA is randomly selected in the main KASLR window.
  *
  * At the end of this function, the bootspace structure is fully constructed.
  */



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

2020-01-24 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Jan 24 18:58:46 UTC 2020

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

Log Message:
Set AUDIO_BLK_MS=4 - unlikely to cause significant overhead on non-m68k.

Several of us have been setting this in /etc/sysctl.conf for months, to
get better performance from applications that require synced audio, etc.

It's also mentioned as a good value with low overhead on most archs here:
https://mail-index.netbsd.org/tech-kern/2019/12/07/msg025830.html

We could probably go lower, but this is low enough to make most/all
software run well, removing frame drops. It's also low enough to get
emulators/mednafen to stop complaining in the console.


To generate a diff of this commit:
cvs rdiff -u -r1.558 -r1.559 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.558 src/sys/arch/amd64/conf/GENERIC:1.559
--- src/sys/arch/amd64/conf/GENERIC:1.558	Mon Jan 20 18:38:19 2020
+++ src/sys/arch/amd64/conf/GENERIC	Fri Jan 24 18:58:46 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.558 2020/01/20 18:38:19 thorpej Exp $
+# $NetBSD: GENERIC,v 1.559 2020/01/24 18:58:46 nia 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.558 $"
+#ident		"GENERIC-$Revision: 1.559 $"
 
 maxusers	64		# estimated number of users
 
@@ -55,6 +55,9 @@ maxusers	64		# estimated number of users
 
 options 	INSECURE	# disable kernel security levels - X needs this
 
+options		AUDIO_BLK_MS=4	# make software with low latency needs performant
+# no substantial CPU overhead on this platform
+
 options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
 options 	NTP		# NTP phase/frequency locked loop
 



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

2020-01-22 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 22 16:52:46 UTC 2020

Modified Files:
src/sys/arch/amd64/include: param.h vmparam.h

Log Message:
Move the UBC defaults into vmparam.h


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/include/param.h
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/amd64/include/vmparam.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/param.h
diff -u src/sys/arch/amd64/include/param.h:1.34 src/sys/arch/amd64/include/param.h:1.35
--- src/sys/arch/amd64/include/param.h:1.34	Fri Jan 17 21:14:16 2020
+++ src/sys/arch/amd64/include/param.h	Wed Jan 22 16:52:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.34 2020/01/17 21:14:16 ad Exp $	*/
+/*	$NetBSD: param.h,v 1.35 2020/01/22 16:52:46 ad Exp $	*/
 
 #ifdef __x86_64__
 
@@ -113,17 +113,6 @@
 #define	NKMEMPAGES_MAX_UNLIMITED 1
 
 /*
- * Defaults for Unified Buffer Cache parameters.
- */
-
-#ifndef UBC_WINSHIFT
-#define	UBC_WINSHIFT	16	/* 64kB */
-#endif
-#ifndef UBC_NWINS
-#define	UBC_NWINS	4096	/* 256MB */
-#endif
-
-/*
  * XXXfvdl the PD* stuff is different from i386.
  */
 /*

Index: src/sys/arch/amd64/include/vmparam.h
diff -u src/sys/arch/amd64/include/vmparam.h:1.51 src/sys/arch/amd64/include/vmparam.h:1.52
--- src/sys/arch/amd64/include/vmparam.h:1.51	Mon Feb 11 14:59:32 2019
+++ src/sys/arch/amd64/include/vmparam.h	Wed Jan 22 16:52:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.51 2019/02/11 14:59:32 cherry Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.52 2020/01/22 16:52:46 ad Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -63,6 +63,17 @@
 #define	PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024)
 
 /*
+ * Defaults for Unified Buffer Cache parameters.
+ */
+
+#ifndef UBC_WINSHIFT
+#define	UBC_WINSHIFT	16	/* 64kB */
+#endif
+#ifndef UBC_NWINS
+#define	UBC_NWINS	4096	/* 256MB */
+#endif
+
+/*
  * USRSTACK is the top (end) of the user stack. Immediately above the
  * user stack resides the user structure, which is UPAGES long and contains
  * the kernel stack.



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

2020-01-17 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Jan 17 21:14:16 UTC 2020

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

Log Message:
Bump UBC_WINSHIFT & UBC_NWINS to more reasonable values for amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/amd64/include/param.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/param.h
diff -u src/sys/arch/amd64/include/param.h:1.33 src/sys/arch/amd64/include/param.h:1.34
--- src/sys/arch/amd64/include/param.h:1.33	Thu Nov 14 16:23:52 2019
+++ src/sys/arch/amd64/include/param.h	Fri Jan 17 21:14:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.33 2019/11/14 16:23:52 maxv Exp $	*/
+/*	$NetBSD: param.h,v 1.34 2020/01/17 21:14:16 ad Exp $	*/
 
 #ifdef __x86_64__
 
@@ -113,6 +113,17 @@
 #define	NKMEMPAGES_MAX_UNLIMITED 1
 
 /*
+ * Defaults for Unified Buffer Cache parameters.
+ */
+
+#ifndef UBC_WINSHIFT
+#define	UBC_WINSHIFT	16	/* 64kB */
+#endif
+#ifndef UBC_NWINS
+#define	UBC_NWINS	4096	/* 256MB */
+#endif
+
+/*
  * XXXfvdl the PD* stuff is different from i386.
  */
 /*



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

2020-01-13 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Jan 13 11:40:15 UTC 2020

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

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


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 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.198 src/sys/arch/amd64/amd64/locore.S:1.199
--- src/sys/arch/amd64/amd64/locore.S:1.198	Thu Jan  9 00:42:24 2020
+++ src/sys/arch/amd64/amd64/locore.S	Mon Jan 13 11:40:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.198 2020/01/09 00:42:24 manu Exp $	*/
+/*	$NetBSD: locore.S,v 1.199 2020/01/13 11:40:15 ad Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1079,10 +1079,14 @@ ENTRY(cpu_switchto)
 	movq	%rdi,%r13	/* oldlwp */
 	movq	%rsi,%r12	/* newlwp */
 
+	testq	%r13,%r13	/* oldlwp = NULL ? */
+	jz	.Lskip_save
+
 	/* Save old context. */
 	movq	L_PCB(%r13),%rax
 	movq	%rsp,PCB_RSP(%rax)
 	movq	%rbp,PCB_RBP(%rax)
+.Lskip_save:
 
 	/* Switch to newlwp's stack. */
 	movq	L_PCB(%r12),%r14



CVS commit: src/sys/arch/amd64

2020-01-08 Thread Emmanuel Dreyfus
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):
-	.int	MULTIBOOT2_HEADER_MAGIC
-	.int	MULTIBOOT2_ARCHITECTURE_I386
-	.int	Multiboot2_Header_end - Multiboot2_Header
-	.int	-(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \
-		+ (Multiboot2_Header_end - Multiboot2_Header))
-
-	.int	1	/* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */
-	.int	12	/* sizeof(multiboot_header_tag_information_request) */
-			/* + sizeof(uint32_t) * requests */
-	.int	4	/* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */
-	.align	8
-
-	.int	3	/* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS */
-	.int	16	/* sizeof(struct multiboot_tag_efi64) */
-	.quad	(multiboot2_entry - KERNBASE)
-	.align	8
-
-	.int	9	/* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 */
-	.int	16	/* 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.
-	 */
-	.int	7	/* MULTIBOOT_HEADER_TAG_EFI_BS */
-	.int	8	/* sizeof(struct multiboot_tag) */
-	.align	8
-#endif
-
-	.int	0	/* MULTIBOOT_HEADER_TAG_END */
-	.int	8	/* 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
-	call	next
-next:	pop	%r8
-	sub	$(next - start), %r8
-
-	/*
-	 * Save multiboot_info for later. We cannot use	
-	 * temporary stack for that since we are going to
-	 * overwrite it.
-	 */
-	movl	%ebx, (multiboot2_info_ptr - start)(%r8)
-
-	/*
-	 * Get relocated multiboot2_loader entry point in %r9
-	 */
-	mov	$(KERNTEXTOFF - KERNBASE), %r9
-	add	$(multiboot2_loader - kernel_text), %r9
-
-	/* Copy kernel */
-	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? */
-	

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

2019-12-31 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Dec 31 15:07:22 UTC 2019

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

Log Message:
Update to not include COMPAT_90


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/conf/MODULAR

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/MODULAR
diff -u src/sys/arch/amd64/conf/MODULAR:1.12 src/sys/arch/amd64/conf/MODULAR:1.13
--- src/sys/arch/amd64/conf/MODULAR:1.12	Mon Jun 17 03:31:57 2019
+++ src/sys/arch/amd64/conf/MODULAR	Tue Dec 31 15:07:22 2019
@@ -1,4 +1,4 @@
-# $NetBSD: MODULAR,v 1.12 2019/06/17 03:31:57 christos Exp $
+# $NetBSD: MODULAR,v 1.13 2019/12/31 15:07:22 pgoyette Exp $
 #
 # Try to exclude all the drivers in GENERIC that have been modularized
 # XXX: incomplete
@@ -22,8 +22,9 @@ options 	MODULAR_DEFAULT_AUTOLOAD
 -no options 	COMPAT_40	# NetBSD 4.0,
 -no options 	COMPAT_50	# NetBSD 5.0,
 -no options 	COMPAT_60	# NetBSD 6.0,
--no options 	COMPAT_70	# NetBSD 7.0, and
--no options 	COMPAT_80	# NetBSD 8.0 binary compatibility.
+-no options 	COMPAT_70	# NetBSD 7.0,
+-no options 	COMPAT_80	# NetBSD 8.0, and
+-no options 	COMPAT_90	# NetBSD 9.0 binary compatibility.
 -no options 	COMPAT_43	# and 4.3BSD
 #options 	COMPAT_386BSD_MBRPART # recognize old partition ID
 



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

2019-12-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 26 17:52:49 UTC 2019

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

Log Message:
 Add cas(4).


To generate a diff of this commit:
cvs rdiff -u -r1.551 -r1.552 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.551 src/sys/arch/amd64/conf/GENERIC:1.552
--- src/sys/arch/amd64/conf/GENERIC:1.551	Sat Dec 14 07:45:20 2019
+++ src/sys/arch/amd64/conf/GENERIC	Thu Dec 26 17:52:49 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.551 2019/12/14 07:45:20 maxv Exp $
+# $NetBSD: GENERIC,v 1.552 2019/12/26 17:52:49 msaitoh 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.551 $"
+#ident		"GENERIC-$Revision: 1.552 $"
 
 maxusers	64		# estimated number of users
 
@@ -788,6 +788,7 @@ bge*	at pci? dev ? function ?	# Broadcom
 bnx*	at pci? dev ? function ?	# Broadcom NetXtremeII gigabit Ethernet
 bwi*	at pci? dev ? function ?	# Broadcom BCM43xx wireless
 bwfm*	at pci? dev ? function ?	# Broadcom FullMAC
+cas*	at pci? dev ? function ?	# Sun Cassini/Cassini+ Ethernet
 dge*	at pci? dev ? function ?	# Intel 82597 10GbE LR
 ena*	at pci? dev ? function ?	# Amazon.com Elastic Network Adapter
 ep*	at pci? dev ? function ?	# 3Com 3c59x



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

2019-12-14 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sun Dec 15 02:58:22 UTC 2019

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

Log Message:
Fix typo that caused two instructions  to be commented out

Oddly, that did not break booting.


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 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.194 src/sys/arch/amd64/amd64/locore.S:1.195
--- src/sys/arch/amd64/amd64/locore.S:1.194	Sun Dec 15 02:56:40 2019
+++ src/sys/arch/amd64/amd64/locore.S	Sun Dec 15 02:58:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.194 2019/12/15 02:56:40 manu Exp $	*/
+/*	$NetBSD: locore.S,v 1.195 2019/12/15 02:58:21 manu Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -544,7 +544,7 @@ next:	pop	%r8
 	mov	$(KERNTEXTOFF - KERNBASE), %rdi			/* dest */
 	mov	%r8, %rsi		
 	sub	$(start - kernel_text), %rsi			/* src */
-	mov	$(__kernel_end - kernel_text), %rcx		/* size *.
+	mov	$(__kernel_end - kernel_text), %rcx		/* size */
 	mov	%rcx, %r12		
 	movq	%rdi, %r11		/* for misaligned check */
 



CVS commit: src/sys/arch/amd64

2019-12-14 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sun Dec 15 02:56:40 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/amd64/conf: kern.ldscript

Log Message:
Restore multiboot 2 header in amd64 kernel

The header must appear below 32k offset in the kernel file, but we
have to make sure it does not load at low addresses, otherwise we
break BIOS boot.

.text section used to load at 0x20, we just load multiboot section
there, and have .text loaded just after.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.29 -r1.30 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.193 src/sys/arch/amd64/amd64/locore.S:1.194
--- src/sys/arch/amd64/amd64/locore.S:1.193	Tue Dec 10 02:06:07 2019
+++ src/sys/arch/amd64/amd64/locore.S	Sun Dec 15 02:56:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.193 2019/12/10 02:06:07 manu Exp $	*/
+/*	$NetBSD: locore.S,v 1.194 2019/12/15 02:56:40 manu Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -432,7 +432,7 @@ END(farjmp64)
 	.space	512
 tmpstk:
 
-.section multiboot,"ax",@progbits
+.section multiboot,"a"
 #if defined(MULTIBOOT)
 	.align	8
 	.globl	Multiboot2_Header

Index: src/sys/arch/amd64/conf/kern.ldscript
diff -u src/sys/arch/amd64/conf/kern.ldscript:1.29 src/sys/arch/amd64/conf/kern.ldscript:1.30
--- src/sys/arch/amd64/conf/kern.ldscript:1.29	Wed Dec 11 02:31:44 2019
+++ src/sys/arch/amd64/conf/kern.ldscript	Sun Dec 15 02:56:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern.ldscript,v 1.29 2019/12/11 02:31:44 manu Exp $	*/
+/*	$NetBSD: kern.ldscript,v 1.30 2019/12/15 02:56:40 manu Exp $	*/
 
 #include "assym.h"
 
@@ -13,7 +13,17 @@ __LARGE_PAGE_SIZE = 0x20 ;
 ENTRY(_start)
 SECTIONS
 {
-	.text : AT (ADDR(.text) & 0x0fff)
+	/*
+	 * 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)
+	{
+		. = ALIGN(8);
+		KEEP(*(multiboot));
+	}
+	.text : AT (0x20 + SIZEOF(multiboot))
 	{
 		. = ALIGN(__PAGE_SIZE);
 		__text_user_start = . ;



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

2019-12-13 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Dec 14 07:45:20 UTC 2019

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

Log Message:
Disable multiboot for now, too much breakage.


To generate a diff of this commit:
cvs rdiff -u -r1.550 -r1.551 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.550 src/sys/arch/amd64/conf/GENERIC:1.551
--- src/sys/arch/amd64/conf/GENERIC:1.550	Tue Dec 10 12:08:52 2019
+++ src/sys/arch/amd64/conf/GENERIC	Sat Dec 14 07:45:20 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.550 2019/12/10 12:08:52 yamaguchi Exp $
+# $NetBSD: GENERIC,v 1.551 2019/12/14 07:45:20 maxv Exp $
 #
 # GENERIC machine description file
 #
@@ -22,11 +22,11 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.550 $"
+#ident		"GENERIC-$Revision: 1.551 $"
 
 maxusers	64		# estimated number of users
 
-options		MULTIBOOT	# Multiboot support (see multiboot(8)) 
+#options 	MULTIBOOT	# Multiboot support (see multiboot(8)) 
 
 # delay between "rebooting ..." message and hardware reset, in milliseconds
 #options 	CPURESET_DELAY=2000



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

2019-12-13 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Dec 13 20:14:25 UTC 2019

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

Log Message:
Break the global uvm_pageqlock into a per-page identity lock and a private
lock for use of the pagedaemon policy code.  Discussed on tech-kern.

PR kern/54209: NetBSD 8 large memory performance extremely low
PR kern/54210: NetBSD-8 processes presumably not exiting
PR kern/54727: writing a large file causes unreasonable system behaviour


To generate a diff of this commit:
cvs rdiff -u -r1.343 -r1.344 src/sys/arch/amd64/amd64/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/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.343 src/sys/arch/amd64/amd64/machdep.c:1.344
--- src/sys/arch/amd64/amd64/machdep.c:1.343	Tue Dec 10 02:06:07 2019
+++ src/sys/arch/amd64/amd64/machdep.c	Fri Dec 13 20:14:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.343 2019/12/10 02:06:07 manu Exp $	*/
+/*	$NetBSD: machdep.c,v 1.344 2019/12/13 20:14:25 ad Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.343 2019/12/10 02:06:07 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.344 2019/12/13 20:14:25 ad Exp $");
 
 #include "opt_modular.h"
 #include "opt_multiboot.h"
@@ -865,7 +865,7 @@ sparse_dump_mark(void)
 		 pfn++) {
 			pg = PHYS_TO_VM_PAGE(ptoa(pfn));
 
-			if (pg->uanon || (pg->pqflags & PQ_FREE) ||
+			if (pg->uanon || (pg->flags & PG_FREE) ||
 			(pg->uobject && pg->uobject->pgops)) {
 p = VM_PAGE_TO_PHYS(pg) / PAGE_SIZE;
 clrbit(sparse_dump_physmap, p);



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

2019-12-10 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed Dec 11 02:31:45 UTC 2019

Modified Files:
src/sys/arch/amd64/conf: kern.ldscript

Log Message:
Rollback kernel link scrpt change for multiboot

The multiboot section breaks BIOS boot. Rolling back the link script
removes the section, which breaks multiboot but should restore BIOS boot.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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/conf/kern.ldscript
diff -u src/sys/arch/amd64/conf/kern.ldscript:1.28 src/sys/arch/amd64/conf/kern.ldscript:1.29
--- src/sys/arch/amd64/conf/kern.ldscript:1.28	Tue Dec 10 02:06:07 2019
+++ src/sys/arch/amd64/conf/kern.ldscript	Wed Dec 11 02:31:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern.ldscript,v 1.28 2019/12/10 02:06:07 manu Exp $	*/
+/*	$NetBSD: kern.ldscript,v 1.29 2019/12/11 02:31:44 manu Exp $	*/
 
 #include "assym.h"
 
@@ -13,13 +13,9 @@ __LARGE_PAGE_SIZE = 0x20 ;
 ENTRY(_start)
 SECTIONS
 {
-	multiboot 0x4000 :
-	{
-		KEEP(*(multiboot));
-	}
 	.text : AT (ADDR(.text) & 0x0fff)
 	{
-		. = ALIGN(__LARGE_PAGE_SIZE);
+		. = ALIGN(__PAGE_SIZE);
 		__text_user_start = . ;
 		*(.text.user)
 		. = ALIGN(__PAGE_SIZE);



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

2019-12-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Dec  7 10:19:35 UTC 2019

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

Log Message:
Panic instead of printf, same as syscall.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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.50 src/sys/arch/amd64/amd64/amd64_trap.S:1.51
--- src/sys/arch/amd64/amd64/amd64_trap.S:1.50	Thu Nov 14 16:23:52 2019
+++ src/sys/arch/amd64/amd64/amd64_trap.S	Sat Dec  7 10:19:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: amd64_trap.S,v 1.50 2019/11/14 16:23:52 maxv Exp $	*/
+/*	$NetBSD: amd64_trap.S,v 1.51 2019/12/07 10:19:35 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc.
@@ -694,13 +694,8 @@ calltrap:
 	STI(si)
 	movabsq	$4f,%rdi
 	movl	CPUVAR(ILEVEL),%esi
-	movl	%ebx,%edx
-	xorq	%rax,%rax
-	call	_C_LABEL(printf)
-	movl	%ebx,%edi
-	call	_C_LABEL(spllower)
-	jmp	.Lalltraps_checkast
-4:	.asciz	"WARNING: SPL NOT LOWERED ON TRAP EXIT %x %x\n"
+	call	_C_LABEL(panic)
+4:	.asciz	"spl not lowered on trap exit, ilevel=%x"
 #endif
 END(alltraps)
 



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

2019-12-02 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Dec  2 19:17:27 UTC 2019

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

Log Message:
Define PT_GETXMMREGS and PT_SETXMMREGS in PT_MACHDEP_STRINGS/amd64


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/amd64/include/ptrace.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/ptrace.h
diff -u src/sys/arch/amd64/include/ptrace.h:1.19 src/sys/arch/amd64/include/ptrace.h:1.20
--- src/sys/arch/amd64/include/ptrace.h:1.19	Wed Nov 27 09:16:58 2019
+++ src/sys/arch/amd64/include/ptrace.h	Mon Dec  2 19:17:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.19 2019/11/27 09:16:58 rin Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.20 2019/12/02 19:17:27 kamil Exp $	*/
 
 /*
  * Copyright (c) 1993 Christopher G. Demetriou
@@ -69,7 +69,9 @@
 	"PT_SETSTEP", \
 	"PT_CLEARSTEP", \
 	"PT_GETXSTATE", \
-	"PT_SETXSTATE"
+	"PT_SETXSTATE", \
+	"PT_GETXMMREGS", \
+	"PT_SETXMMREGS"
 
 #include 
 #define PTRACE_REG_PC(r)	(r)->regs[_REG_RIP]



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

2019-04-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 25 03:53:11 UTC 2019

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

Log Message:
 Add gem(4).


To generate a diff of this commit:
cvs rdiff -u -r1.524 -r1.525 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.524 src/sys/arch/amd64/conf/GENERIC:1.525
--- src/sys/arch/amd64/conf/GENERIC:1.524	Thu Apr 18 17:13:00 2019
+++ src/sys/arch/amd64/conf/GENERIC	Thu Apr 25 03:53:11 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.524 2019/04/18 17:13:00 maya Exp $
+# $NetBSD: GENERIC,v 1.525 2019/04/25 03:53:11 msaitoh 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.524 $"
+#ident		"GENERIC-$Revision: 1.525 $"
 
 maxusers	64		# estimated number of users
 
@@ -798,6 +798,7 @@ et*	at pci? dev ? function ?	# Agere/LSI
 ex*	at pci? dev ? function ?	# 3Com 90x[BC]
 fpa*	at pci? dev ? function ?	# DEC DEFPA FDDI
 fxp*	at pci? dev ? function ?	# Intel EtherExpress PRO 10+/100B
+gem*	at pci? dev ? function ?	# Apple GMAC and Sun ERI gigabit enet
 gsip*	at pci? dev ? function ?	# NS83820 Gigabit Ethernet
 ipw*	at pci? dev ? function ?	# Intel PRO/Wireless 2100
 iwi*	at pci? dev ? function ?	# Intel PRO/Wireless 2200BG



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

2019-04-18 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Apr 18 17:13:00 UTC 2019

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

Log Message:
Follow arm64 and provide two sizes of fonts, so a larger one is chosen
for larger displays.


To generate a diff of this commit:
cvs rdiff -u -r1.523 -r1.524 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/amd64/conf/INSTALL

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.523 src/sys/arch/amd64/conf/GENERIC:1.524
--- src/sys/arch/amd64/conf/GENERIC:1.523	Thu Apr 18 16:46:11 2019
+++ src/sys/arch/amd64/conf/GENERIC	Thu Apr 18 17:13:00 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.523 2019/04/18 16:46:11 christos Exp $
+# $NetBSD: GENERIC,v 1.524 2019/04/18 17:13:00 maya 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.523 $"
+#ident		"GENERIC-$Revision: 1.524 $"
 
 maxusers	64		# estimated number of users
 
@@ -1185,6 +1185,9 @@ pseudo-device	nsmb			# experimental - SM
 # wscons pseudo-devices
 pseudo-device	wsmux			# mouse & keyboard multiplexor
 pseudo-device	wsfont
+# Give us a choice of fonts based on monitor size
+options 	FONT_BOLD8x16
+options 	FONT_BOLD16x32
 
 # pseudo audio device driver
 pseudo-device	pad

Index: src/sys/arch/amd64/conf/INSTALL
diff -u src/sys/arch/amd64/conf/INSTALL:1.94 src/sys/arch/amd64/conf/INSTALL:1.95
--- src/sys/arch/amd64/conf/INSTALL:1.94	Tue Dec 11 16:52:49 2018
+++ src/sys/arch/amd64/conf/INSTALL	Thu Apr 18 17:13:00 2019
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.94 2018/12/11 16:52:49 maya Exp $
+# $NetBSD: INSTALL,v 1.95 2019/04/18 17:13:00 maya Exp $
 #
 #	INSTALL - Installation kernel.
 #
@@ -8,9 +8,11 @@
 include	"arch/amd64/conf/GENERIC"
 
 options 	CONSDEVNAME="\"com\"",CONADDR=0x2f8,CONSPEED=115200
-#ident 		"INSTALL-$Revision: 1.94 $"
+#ident 		"INSTALL-$Revision: 1.95 $"
 
 no options	MEMORY_DISK_DYNAMIC
+no options	FONT_BOLD16x32
+no options 	FONT_BOLD8x16
 options 	MEMORY_DISK_IS_ROOT	# force root on memory disk
 options 	MEMORY_DISK_SERVER=0	# no userspace memory disk support
 options 	MEMORY_DISK_ROOT_SIZE=1	# size of memory disk, in blocks



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

2019-04-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 18 16:46:11 UTC 2019

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

Log Message:
Yes, we support FFS_EI but not DISKLABEL_EI... How does that make sense?


To generate a diff of this commit:
cvs rdiff -u -r1.522 -r1.523 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.522 src/sys/arch/amd64/conf/GENERIC:1.523
--- src/sys/arch/amd64/conf/GENERIC:1.522	Sat Apr 13 04:41:37 2019
+++ src/sys/arch/amd64/conf/GENERIC	Thu Apr 18 12:46:11 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.522 2019/04/13 08:41:37 maxv Exp $
+# $NetBSD: GENERIC,v 1.523 2019/04/18 16:46:11 christos 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.522 $"
+#ident		"GENERIC-$Revision: 1.523 $"
 
 maxusers	64		# estimated number of users
 
@@ -204,7 +204,7 @@ options 	UFS_EXTATTR	# Extended attribut
 #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



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

2019-04-03 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr  3 19:14:25 UTC 2019

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

Log Message:
When scrolling the screen don't forget to update the last line. Whatever,
there is no case where the screen scrolls actually.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/stand/prekern/console.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/stand/prekern/console.c
diff -u src/sys/arch/amd64/stand/prekern/console.c:1.3 src/sys/arch/amd64/stand/prekern/console.c:1.4
--- src/sys/arch/amd64/stand/prekern/console.c:1.3	Fri Nov 17 07:07:52 2017
+++ src/sys/arch/amd64/stand/prekern/console.c	Wed Apr  3 19:14:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: console.c,v 1.3 2017/11/17 07:07:52 maxv Exp $	*/
+/*	$NetBSD: console.c,v 1.4 2019/04/03 19:14:25 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -61,7 +61,7 @@ static void check_scroll(void)
 	memset(_buffer[0] + (CONS_WID * 2) * (CONS_HEI-1), 0,
 	(CONS_WID * 2));
 	cons_y--;
-	memcpy(cons_start, _buffer[0], (CONS_WID * 2) * (CONS_HEI-1));
+	memcpy(cons_start, _buffer[0], CONS_WID * 2 * CONS_HEI);
 }
 
 void print_ext(int color, char *buf)



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

2019-03-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Mar 19 19:15:57 UTC 2019

Modified Files:
src/sys/arch/amd64/stand/prekern: locore.S prekern.c trap.S

Log Message:
Fix/remove some half-baked stuff I left in the prekern:

 - Page-align the idt store, to be extra sure.
 - Remove unneeded prototypes.
 - Drop the TSS, we don't care and aren't even using it.
 - Initialize %ss with a default value.
 - Fix three exception handlers, no need to push an error code.

No actual impact, because these things are used only when returning from
exceptions received in the prekern; these exceptions are not supposed to
be ever received, never are, and if they were we wouldn't return anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/stand/prekern/locore.S \
src/sys/arch/amd64/stand/prekern/prekern.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/stand/prekern/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/stand/prekern/locore.S
diff -u src/sys/arch/amd64/stand/prekern/locore.S:1.10 src/sys/arch/amd64/stand/prekern/locore.S:1.11
--- src/sys/arch/amd64/stand/prekern/locore.S:1.10	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/amd64/stand/prekern/locore.S	Tue Mar 19 19:15:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.10 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.11 2019/03/19 19:15:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2007, 2008, 2016, 2017 The NetBSD Foundation, Inc.
@@ -193,8 +193,6 @@ LABEL(gdt64_start)
 	.quad 0x	/* always empty */
 	.quad 0x00af9a00	/* kernel CS */
 	.quad 0x00cf9200	/* kernel DS */
-	.quad 0x	/* kernel TSS [1/2] */
-	.quad 0x	/* kernel TSS [2/2] */
 END(gdt64_start)
 gdt64_end:
 
@@ -569,6 +567,9 @@ longmode:
 	movw	%ax,%gs
 	movw	%ax,%fs
 
+	movw	$GSEL(GDATA_SEL, SEL_KPL),%ax
+	movw	%ax,%ss
+
 	/* The first physical page available. */
 	leaq	(TABLESIZE)(%rsi),%rdi
 
Index: src/sys/arch/amd64/stand/prekern/prekern.c
diff -u src/sys/arch/amd64/stand/prekern/prekern.c:1.10 src/sys/arch/amd64/stand/prekern/prekern.c:1.11
--- src/sys/arch/amd64/stand/prekern/prekern.c:1.10	Sun Aug 12 12:42:54 2018
+++ src/sys/arch/amd64/stand/prekern/prekern.c	Tue Mar 19 19:15:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: prekern.c,v 1.10 2018/08/12 12:42:54 maxv Exp $	*/
+/*	$NetBSD: prekern.c,v 1.11 2019/03/19 19:15:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -46,15 +46,7 @@ struct bootinfo bootinfo;
 
 extern paddr_t kernpa_start, kernpa_end;
 
-static uint8_t idtstore[PAGE_SIZE];
-static uint8_t faultstack[PAGE_SIZE];
-static struct x86_64_tss prekern_tss;
-
-/* GDT offsets */
-#define PREKERN_GDT_NUL_OFF	(0 * 8)
-#define PREKERN_GDT_CS_OFF	(1 * 8)
-#define PREKERN_GDT_DS_OFF	(2 * 8)
-#define PREKERN_GDT_TSS_OFF	(3 * 8)
+static uint8_t idtstore[PAGE_SIZE] __aligned(PAGE_SIZE);
 
 #define IDTVEC(name) __CONCAT(X, name)
 typedef void (vector)(void);
@@ -83,14 +75,6 @@ struct smallframe {
 	uint64_t sf_ss;
 };
 
-static void setregion(struct region_descriptor *, void *, uint16_t);
-static void setgate(struct gate_descriptor *, void *, int, int, int, int);
-static void set_sys_segment(struct sys_segment_descriptor *, void *,
-size_t, int, int, int);
-static void set_sys_gdt(int, void *, size_t, int, int, int);
-static void init_tss(void);
-static void init_idt(void);
-
 void trap(struct smallframe *);
 
 static char *trap_type[] = {
@@ -142,6 +126,8 @@ trap(struct smallframe *sf)
 	while (1);
 }
 
+/* -- */
+
 static void
 setregion(struct region_descriptor *rd, void *base, uint16_t limit)
 {
@@ -167,42 +153,6 @@ setgate(struct gate_descriptor *gd, void
 }
 
 static void
-set_sys_segment(struct sys_segment_descriptor *sd, void *base, size_t limit,
-int type, int dpl, int gran)
-{
-	memset(sd, 0, sizeof(*sd));
-	sd->sd_lolimit = (unsigned)limit;
-	sd->sd_lobase = (uint64_t)base;
-	sd->sd_type = type;
-	sd->sd_dpl = dpl;
-	sd->sd_p = 1;
-	sd->sd_hilimit = (unsigned)limit >> 16;
-	sd->sd_gran = gran;
-	sd->sd_hibase = (uint64_t)base >> 24;
-}
-
-static void
-set_sys_gdt(int slotoff, void *base, size_t limit, int type, int dpl, int gran)
-{
-	struct sys_segment_descriptor sd;
-	extern uint64_t *gdt64_start;
-
-	set_sys_segment(, base, limit, type, dpl, gran);
-
-	memcpy(_start + slotoff, , sizeof(sd));
-}
-
-static void
-init_tss(void)
-{
-	memset(_tss, 0, sizeof(prekern_tss));
-	prekern_tss.tss_ist[0] = (uintptr_t)([PAGE_SIZE-1]) & ~0xf;
-
-	set_sys_gdt(PREKERN_GDT_TSS_OFF, _tss,
-	sizeof(struct x86_64_tss) - 1, SDT_SYS386TSS, SEL_KPL, 0);
-}
-
-static void
 init_idt(void)
 {
 	struct region_descriptor region;
@@ -331,10 +281,9 @@ init_prekern(paddr_t pa_start)
 	mm_init(pa_start);
 
 	/*
-	 * Init the TSS and IDT. We mostly don't 

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

2019-03-16 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Mar 16 11:50:48 UTC 2019

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

Log Message:
Bump STACK_ALIGNBYTES to (16 - 1) to satisfy requirement by AMD64
System V ABI in kernel level. This is because

(1) for LLDB, we want to bypass libc/csu (and therefore manual stack
alignment in _start), and

(2) rtld in glibc >= 2.23 for Linux/x86_64 requires it.

Fix SEGV for Linux/x86_64 binaries with glibc >= 2.23, reported as
PR port-amd64/54052.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/amd64/include/param.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/param.h
diff -u src/sys/arch/amd64/include/param.h:1.29 src/sys/arch/amd64/include/param.h:1.30
--- src/sys/arch/amd64/include/param.h:1.29	Mon Feb 11 14:59:32 2019
+++ src/sys/arch/amd64/include/param.h	Sat Mar 16 11:50:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.29 2019/02/11 14:59:32 cherry Exp $	*/
+/*	$NetBSD: param.h,v 1.30 2019/03/16 11:50:48 rin Exp $	*/
 
 #ifdef __x86_64__
 
@@ -23,6 +23,13 @@
 
 #define ALIGNED_POINTER(p,t)	1
 
+/*
+ * Align stack as required by AMD64 System V ABI. This is because
+ * (1) we want to bypass libc/csu in LLDB, and
+ * (2) rtld in glibc >= 2.23 for Linux/x86_64 requires it.
+ */
+#define STACK_ALIGNBYTES	(16 - 1)
+
 #define ALIGNBYTES32		(sizeof(int) - 1)
 #define ALIGN32(p)		(((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
 



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

2019-03-07 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Mar  7 10:16:07 UTC 2019

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

Log Message:
Use IDTVEC instead of NENTRY for handle_hyperv_hypercall.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 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.69 src/sys/arch/amd64/amd64/vector.S:1.70
--- src/sys/arch/amd64/amd64/vector.S:1.69	Fri Feb 15 08:54:01 2019
+++ src/sys/arch/amd64/amd64/vector.S	Thu Mar  7 10:16:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.69 2019/02/15 08:54:01 nonaka Exp $	*/
+/*	$NetBSD: vector.S,v 1.70 2019/03/07 10:16:07 nonaka Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -277,12 +277,12 @@ IDTVEC(recurse_hyperv_hypercall)
 	INTR_RECURSE_ENTRY
 	jmp	1f
 IDTVEC_END(recurse_hyperv_hypercall)
-NENTRY(handle_hyperv_hypercall)
+IDTVEC(handle_hyperv_hypercall)
 	movl	CPUVAR(ILEVEL),%ebx
 	cmpl	$IPL_NET,%ebx
 	jae	2f
 	jmp	1f
-END(handle_hyperv_hypercall)
+IDTVEC_END(handle_hyperv_hypercall)
 IDTVEC(resume_hyperv_hypercall)
 1:
 	incl	CPUVAR(IDEPTH)
@@ -302,7 +302,7 @@ IDTVEC(intr_hyperv_hypercall)
 	pushq	$0
 	pushq	$T_ASTFLT
 	INTRENTRY
-	jmp	_C_LABEL(handle_hyperv_hypercall)
+	jmp	_C_LABEL(Xhandle_hyperv_hypercall)
 IDTVEC_END(intr_hyperv_hypercall)
 	TEXT_USER_END
 #endif	/* NHYPERV > 0 */



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

2019-03-01 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar  1 12:25:09 UTC 2019

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

Log Message:
fix typo. pointed out by pgoyette@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.519 -r1.520 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.519 src/sys/arch/amd64/conf/GENERIC:1.520
--- src/sys/arch/amd64/conf/GENERIC:1.519	Fri Mar  1 11:06:55 2019
+++ src/sys/arch/amd64/conf/GENERIC	Fri Mar  1 12:25:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.519 2019/03/01 11:06:55 pgoyette Exp $
+# $NetBSD: GENERIC,v 1.520 2019/03/01 12:25:09 nonaka 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.519 $"
+#ident		"GENERIC-$Revision: 1.520 $"
 
 maxusers	64		# estimated number of users
 
@@ -1090,7 +1090,7 @@ vmbus*		at acpi?		# Hyper-V VMBus
 hvn*		at vmbus?		# Hyper-V NetVSC
 hvs*		at vmbus?		# Hyper-V StorVSC
 hvheartbeat*	at vmbus?		# Hyper-V Heartbeat Service
-hvshutdown*	at vmbus?		# Hyper-V Geust Shutdown 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
 



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

2019-02-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Feb 24 20:58:55 UTC 2019

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

Log Message:
Enable kUBSan kASan and KCOV in NetBSD/amd64 kernel=ALL

Add disabled KLEAK as it conflicts right now with KCOV, using the same
compiler instrumentation.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 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.115 src/sys/arch/amd64/conf/ALL:1.116
--- src/sys/arch/amd64/conf/ALL:1.115	Wed Feb  6 11:58:30 2019
+++ src/sys/arch/amd64/conf/ALL	Sun Feb 24 20:58:55 2019
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.115 2019/02/06 11:58:30 rin Exp $
+# $NetBSD: ALL,v 1.116 2019/02/24 20:58:55 kamil 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.115 $"
+#ident		"ALL-$Revision: 1.116 $"
 
 maxusers	64		# estimated number of users
 
@@ -120,6 +120,7 @@ options 	KGDB		# remote debugger
 options 	KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600
 makeoptions	COPTS="-O2 -fno-omit-frame-pointer"
 makeoptions	DEBUG="-g"	# compile full symbol table
+options		KUBSAN		# Kernel Undefined Behavior Sanitizer (kUBSan)
 options 	SYSCALL_STATS	# per syscall counts
 options 	SYSCALL_TIMES	# per syscall times
 options 	SYSCALL_TIMES_HASCOUNTER	# use 'broken' rdtsc (soekris)
@@ -127,6 +128,19 @@ options 	KDTRACE_HOOKS	# kernel DTrace h
 options 	UVMHIST		# kernhist for uvm subsystem
 options 	BIOHIST		# kernhist for buff I/O
 
+# Kernel Address Sanitizer (kASan). You need to disable SVS to use it.
+makeoptions	KASAN=1		# Kernel Address Sanitizer
+options		KASAN
+#no options SVS
+
+# Kernel Info Leak Detector.
+#makeoptions	KLEAK=1
+#options		KLEAK
+
+# Kernel Code Coverage Driver.
+makeoptions	KCOV=1
+options		KCOV
+
 # 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/include

2019-02-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Feb  7 00:19:54 UTC 2019

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

Log Message:
Define PTRACE_ILLEGAL_ASM for NetBSD/amd64 in ptrace.h

Use ud2 instruction that is guaranteed to raise an invalid instruction
exception (through SIGILL).

On NetBSD and FreeBSD this instruction raises ILL_PRVOPC, on Linux
ILL_ILLOPN. It's not clear which opion is better "Privileged opcode" vs
"Illegal operand", because ud2 doesn't seem to be a privileged operation
and it doesn't take any operand.

Assume in future changes that this opcode will raise ILL_PRVOPC and keep
it purely for testing purposes of the SIGILL crash type.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/include/ptrace.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/ptrace.h
diff -u src/sys/arch/amd64/include/ptrace.h:1.12 src/sys/arch/amd64/include/ptrace.h:1.13
--- src/sys/arch/amd64/include/ptrace.h:1.12	Wed Apr 12 18:17:59 2017
+++ src/sys/arch/amd64/include/ptrace.h	Thu Feb  7 00:19:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.12 2017/04/12 18:17:59 kamil Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.13 2019/02/07 00:19:54 kamil Exp $	*/
 
 /*
  * Copyright (c) 1993 Christopher G. Demetriou
@@ -63,6 +63,8 @@
 #define PTRACE_REG_SP(r)	(r)->regs[_REG_RSP]
 #define PTRACE_REG_INTRV(r)	(r)->regs[_REG_RAX]
 
+#define PTRACE_ILLEGAL_ASM	__asm __volatile ("ud2" : : : "memory")
+
 #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xcc })
 #define PTRACE_BREAKPOINT_ASM	__asm __volatile ("int3" : : : "memory")
 #define PTRACE_BREAKPOINT_SIZE	1



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

2019-02-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Feb  4 15:07:35 UTC 2019

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

Log Message:
Add more symbols to the unwinder, in case we get a KASAN message inside
an exception handler.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amd64/include/asan.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.1 src/sys/arch/amd64/include/asan.h:1.2
--- src/sys/arch/amd64/include/asan.h:1.1	Wed Oct 31 06:26:26 2018
+++ src/sys/arch/amd64/include/asan.h	Mon Feb  4 15:07:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.1 2018/10/31 06:26:26 maxv Exp $	*/
+/*	$NetBSD: asan.h,v 1.2 2019/02/04 15:07:34 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -165,7 +165,9 @@ static inline bool
 __md_unwind_end(const char *name)
 {
 	if (!strcmp(name, "syscall") ||
+	!strcmp(name, "alltraps") ||
 	!strcmp(name, "handle_syscall") ||
+	!strncmp(name, "Xtrap", 5) ||
 	!strncmp(name, "Xintr", 5) ||
 	!strncmp(name, "Xhandle", 7) ||
 	!strncmp(name, "Xresume", 7) ||



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

2019-02-02 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Feb  2 15:13:54 UTC 2019

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

Log Message:
Re-enable ixg(4) on NetBSD/xen dom0

Namespace conflicts have been resolved.

Note that driver still has an incorrect us of __asm() gnu primitives
via

#if __FreeBSD_version < 80
...
#endif

Since __FreeBSD_version is undefined and thus equates to 0 and thus
satisfies the inequality.

Needs fixing by driver maintainer.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 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.163 src/sys/arch/amd64/conf/XEN3_DOM0:1.164
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.163	Sat Feb  2 12:05:09 2019
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Sat Feb  2 15:13:54 2019
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.163 2019/02/02 12:05:09 cherry Exp $
+# $NetBSD: XEN3_DOM0,v 1.164 2019/02/02 15:13:54 cherry Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -10,7 +10,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOM0-$Revision: 1.163 $"
+#ident		"XEN3_DOM0-$Revision: 1.164 $"
 
 maxusers	32		# estimated number of users
 
@@ -371,7 +371,7 @@ ipw*	at pci? dev ? function ?	# Intel PR
 iwi*	at pci? dev ? function ?	# Intel PRO/Wireless 2200BG
 iwn*	at pci? dev ? function ?	# Intel PRO/Wireless 4965AGN
 iwm*	at pci? dev ? function ?	# Intel Wireless WiFi Link 7xxx
-#ixg*	at pci? dev ? function ?	# Intel 8259x 10 gigabit
+ixg*	at pci? dev ? function ?	# Intel 8259x 10 gigabit
 jme*	at pci? dev ? function ?	# JMicron JMC2[56]0 ethernet
 le*	at pci? dev ? function ?	# PCnet-PCI Ethernet
 lii*	at pci? dev ? function ?	# Atheros L2 Fast-Ethernet



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

2019-02-02 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Feb  2 12:05:09 UTC 2019

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

Log Message:
Summary: Disable ixg(4) until the linuxist mb() API re-definition
within the XEN amd64 dom0 build is resolved.

Detail:
The xen public headers >= 0x00030201 depend on a linuxism - a memory
barrier "API" namely mb(), rmb() and wmb(). These are made accessible
to NetBSD code via the interface
sys/external/bsd/common/include/asm/barrier.h

Currently the ixg(4) driver uses an identical API by defining them
(incorrectly) to inline assembler macro definitions in
sys/dev/pci/ixgbe/ixgbe_osdep.h

This will result in the dom0 builds failing to build due to this
redefinition of the macros. We therefore disable the driver in
NetBSD/amd64 dom0 in order to facilitate smoothly moving the XEN
kernel builds to the new XEN source level API (RELEASE-4.11.1).

The fix for this is trivial, but needs the attention of the driver
maintainer.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 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.162 src/sys/arch/amd64/conf/XEN3_DOM0:1.163
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.162	Tue Dec 25 11:56:14 2018
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Sat Feb  2 12:05:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.162 2018/12/25 11:56:14 mlelstv Exp $
+# $NetBSD: XEN3_DOM0,v 1.163 2019/02/02 12:05:09 cherry Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -10,7 +10,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOM0-$Revision: 1.162 $"
+#ident		"XEN3_DOM0-$Revision: 1.163 $"
 
 maxusers	32		# estimated number of users
 
@@ -371,7 +371,7 @@ ipw*	at pci? dev ? function ?	# Intel PR
 iwi*	at pci? dev ? function ?	# Intel PRO/Wireless 2200BG
 iwn*	at pci? dev ? function ?	# Intel PRO/Wireless 4965AGN
 iwm*	at pci? dev ? function ?	# Intel Wireless WiFi Link 7xxx
-ixg*	at pci? dev ? function ?	# Intel 8259x 10 gigabit
+#ixg*	at pci? dev ? function ?	# Intel 8259x 10 gigabit
 jme*	at pci? dev ? function ?	# JMicron JMC2[56]0 ethernet
 le*	at pci? dev ? function ?	# PCnet-PCI Ethernet
 lii*	at pci? dev ? function ?	# Atheros L2 Fast-Ethernet



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

2019-01-21 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 21 20:22:48 UTC 2019

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

Log Message:
Fix wrong scoping of {U,}LLONG_MAX.
PR 53298 from Roberto E. Vargas Caballero.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/amd64/include/limits.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/limits.h
diff -u src/sys/arch/amd64/include/limits.h:1.14 src/sys/arch/amd64/include/limits.h:1.15
--- src/sys/arch/amd64/include/limits.h:1.14	Mon Apr 21 10:53:47 2014
+++ src/sys/arch/amd64/include/limits.h	Mon Jan 21 20:22:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: limits.h,v 1.14 2014/04/21 10:53:47 matt Exp $	*/
+/*	$NetBSD: limits.h,v 1.15 2019/01/21 20:22:48 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988 The Regents of the University of California.
@@ -56,10 +56,6 @@
 #define	LONG_MAX	0x7fffL	/* max value for a long */
 #define	LONG_MIN	(-0x7fffL-1)	/* min value for a long */
 
-#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
-defined(_NETBSD_SOURCE)
-#define	SSIZE_MAX	LONG_MAX		/* max value for a ssize_t */
-
 #if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
 defined(_NETBSD_SOURCE)
 #define	ULLONG_MAX	0xULL	/* max unsigned long long */
@@ -67,6 +63,10 @@
 #define	LLONG_MIN	(-0x7fffLL-1) /* min signed long long */
 #endif
 
+#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
+defined(_NETBSD_SOURCE)
+#define	SSIZE_MAX	LONG_MAX		/* max value for a ssize_t */
+
 #if defined(_NETBSD_SOURCE)
 #define	SSIZE_MIN	LONG_MIN		/* min value for a ssize_t */
 #define	SIZE_T_MAX	ULONG_MAX	/* max value for a size_t */



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

2019-01-17 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jan 17 19:26:03 UTC 2019

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

Log Message:
Increase VM_PHYSSEG_MAX from 32 to 64. Saw an example on tech-kern@ of a
heavily fragmented memory map.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amd64/include/vmparam.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/vmparam.h
diff -u src/sys/arch/amd64/include/vmparam.h:1.49 src/sys/arch/amd64/include/vmparam.h:1.50
--- src/sys/arch/amd64/include/vmparam.h:1.49	Mon Oct 29 19:43:16 2018
+++ src/sys/arch/amd64/include/vmparam.h	Thu Jan 17 19:26:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.49 2018/10/29 19:43:16 maya Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.50 2019/01/17 19:26:03 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -159,7 +159,7 @@ extern vaddr_t vm_max_kernel_address;
 /* virtual sizes (bytes) for various kernel submaps */
 #define VM_PHYS_SIZE		(USRIOSIZE*PAGE_SIZE)
 
-#define VM_PHYSSEG_MAX		32	/* 1 "hole" + 31 free lists */
+#define VM_PHYSSEG_MAX		64	/* 1 "hole" + 63 free lists */
 #define VM_PHYSSEG_STRAT	VM_PSTRAT_BIGFIRST
 
 #define	VM_NFREELIST		6



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

2019-01-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Jan  5 22:11:07 UTC 2019

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

Log Message:
Apply amd64/kobj_machdep.c::rev1.7 to the prekern too, to fix the
relocation with updated binutils.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/amd64/stand/prekern/elf.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/stand/prekern/elf.c
diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.17 src/sys/arch/amd64/stand/prekern/elf.c:1.18
--- src/sys/arch/amd64/stand/prekern/elf.c:1.17	Tue Nov 21 07:56:05 2017
+++ src/sys/arch/amd64/stand/prekern/elf.c	Sat Jan  5 22:11:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf.c,v 1.17 2017/11/21 07:56:05 maxv Exp $	*/
+/*	$NetBSD: elf.c,v 1.18 2019/01/05 22:11:07 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -196,6 +196,7 @@ elf_apply_reloc(uintptr_t relocbase, con
 		break;
 
 	case R_X86_64_PC32:	/* S + A - P */
+	case R_X86_64_PLT32:
 		addr = elf_sym_lookup(symidx);
 		where32 = (Elf32_Addr *)where;
 		val32 = (Elf32_Addr)(addr + addend - (Elf64_Addr)where);



  1   2   3   4   5   6   7   >