CVS commit: src/usr.bin/patch

2024-07-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Jul 12 15:48:39 UTC 2024

Modified Files:
src/usr.bin/patch: patch.c pch.c pch.h

Log Message:
Let patch(1) handle lines of length beyond INT16_MAX

Borrowed from OpenBSD
https://marc.info/?l=openbsd-bugs&m=168907249732754


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/patch/patch.c
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/patch/pch.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/patch/pch.h

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

Modified files:

Index: src/usr.bin/patch/patch.c
diff -u src/usr.bin/patch/patch.c:1.34 src/usr.bin/patch/patch.c:1.35
--- src/usr.bin/patch/patch.c:1.34	Fri Jun 16 11:27:00 2023
+++ src/usr.bin/patch/patch.c	Fri Jul 12 15:48:39 2024
@@ -1,7 +1,7 @@
 /*
  * $OpenBSD: patch.c,v 1.45 2007/04/18 21:52:24 sobrado Exp $
  * $DragonFly: src/usr.bin/patch/patch.c,v 1.10 2008/08/10 23:39:56 joerg Exp $
- * $NetBSD: patch.c,v 1.34 2023/06/16 11:27:00 wiz Exp $
+ * $NetBSD: patch.c,v 1.35 2024/07/12 15:48:39 manu Exp $
  */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: patch.c,v 1.34 2023/06/16 11:27:00 wiz Exp $");
+__RCSID("$NetBSD: patch.c,v 1.35 2024/07/12 15:48:39 manu Exp $");
 
 #include 
 #include 
@@ -106,7 +106,7 @@ static void	copy_till(LINENUM, bool);
 static bool	spew_output(void);
 static void	dump_line(LINENUM, bool);
 static bool	patch_match(LINENUM, LINENUM, LINENUM);
-static bool	similar(const char *, const char *, int);
+static bool	similar(const char *, const char *, ssize_t);
 __dead static void	usage(void);
 
 /* true if -E was specified on command line.  */
@@ -1027,7 +1027,7 @@ patch_match(LINENUM base, LINENUM offset
 	LINENUM		pat_lines = pch_ptrn_lines() - fuzz;
 	const char	*ilineptr;
 	const char	*plineptr;
-	short		plinelen;
+	ssize_t		plinelen;
 
 	for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) {
 		ilineptr = ifetch(iline, offset >= 0);
@@ -1063,7 +1063,7 @@ patch_match(LINENUM base, LINENUM offset
  * Do two lines match with canonicalized white space?
  */
 static bool
-similar(const char *a, const char *b, int len)
+similar(const char *a, const char *b, ssize_t len)
 {
 	while (len) {
 		if (isspace((unsigned char)*b)) {	/* whitespace (or \n) to match? */

Index: src/usr.bin/patch/pch.c
diff -u src/usr.bin/patch/pch.c:1.33 src/usr.bin/patch/pch.c:1.34
--- src/usr.bin/patch/pch.c:1.33	Fri Jun 16 23:31:53 2023
+++ src/usr.bin/patch/pch.c	Fri Jul 12 15:48:39 2024
@@ -1,7 +1,7 @@
 /*
  * $OpenBSD: pch.c,v 1.37 2007/09/02 15:19:33 deraadt Exp $
  * $DragonFly: src/usr.bin/patch/pch.c,v 1.6 2008/08/10 23:35:40 joerg Exp $
- * $NetBSD: pch.c,v 1.33 2023/06/16 23:31:53 wiz Exp $
+ * $NetBSD: pch.c,v 1.34 2024/07/12 15:48:39 manu Exp $
  */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pch.c,v 1.33 2023/06/16 23:31:53 wiz Exp $");
+__RCSID("$NetBSD: pch.c,v 1.34 2024/07/12 15:48:39 manu Exp $");
 
 #include 
 #include 
@@ -61,7 +61,7 @@ static LINENUM	p_max;		/* max allowed va
 static LINENUM	p_context = 3;	/* # of context lines */
 static LINENUM	p_input_line = 0;	/* current line # from patch file */
 static char	**p_line = NULL;/* the text of the hunk */
-static short	*p_len = NULL;	/* length of each line */
+static ssize_t	*p_len = NULL;	/* length of each line */
 static char	*p_char = NULL;	/* +, -, and ! */
 static int	hunkmax = INITHUNKMAX;	/* size of above arrays to begin with */
 static int	p_indent;	/* indent to patch */
@@ -135,7 +135,7 @@ set_hunkmax(void)
 	if (p_line == NULL)
 		p_line = calloc((size_t) hunkmax, sizeof(char *));
 	if (p_len == NULL)
-		p_len = calloc((size_t) hunkmax, sizeof(short));
+		p_len = calloc((size_t) hunkmax, sizeof(ssize_t));
 	if (p_char == NULL)
 		p_char = calloc((size_t) hunkmax, sizeof(char));
 }
@@ -148,7 +148,7 @@ grow_hunkmax(void)
 {
 	int		new_hunkmax;
 	char		**new_p_line;
-	short		*new_p_len;
+	ssize_t		*new_p_len;
 	char		*new_p_char;
 
 	new_hunkmax = hunkmax * 2;
@@ -160,7 +160,7 @@ grow_hunkmax(void)
 	if (new_p_line == NULL)
 		free(p_line);
 
-	new_p_len = pch_realloc(p_len, new_hunkmax, sizeof(short));
+	new_p_len = pch_realloc(p_len, new_hunkmax, sizeof(ssize_t));
 	if (new_p_len == NULL)
 		free(p_len);
 
@@ -1207,7 +1207,7 @@ bool
 pch_swap(void)
 {
 	char	**tp_line;	/* the text of the hunk */
-	short	*tp_len;	/* length of each line */
+	ssize_t	*tp_len;	/* length of each line */
 	char	*tp_char;	/* +, -, and ! */
 	LINENUM	i;
 	LINENUM	n;
@@ -1364,7 +1364,7 @@ pch_context(void)
 /*
  * Return the length of a particular patch line.
  */
-short
+ssize_t
 pch_line_len(LINENUM line)
 {
 	return p_len[line];

Index: src/usr.bin/patch/pch.h
diff -u src/usr.bin/patch/pch.h:1.10 src/usr.bin/patch/pch.h:1.11
--- src/usr.bin/patch/pch.h:1.10	Fri Sep 19 18:33:34 2008
+++ src/usr.bin/patch/pch.h	Fri Jul 12 15:48:39 2024
@@ -1,7 +1,7 @@
 /*
  * $OpenBSD: pch.h,v 1.9 2003/10/31 20:20:45 millert Exp $

CVS commit: src/usr.bin/patch

2024-07-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Jul 12 15:48:39 UTC 2024

Modified Files:
src/usr.bin/patch: patch.c pch.c pch.h

Log Message:
Let patch(1) handle lines of length beyond INT16_MAX

Borrowed from OpenBSD
https://marc.info/?l=openbsd-bugs&m=168907249732754


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/patch/patch.c
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/patch/pch.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/patch/pch.h

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



CVS commit: src/sys/arch/x86/x86

2024-05-16 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri May 17 00:37:14 UTC 2024

Modified Files:
src/sys/arch/x86/x86: fpu.c

Log Message:
iWorkaround panic: fpudna from userland

i386 Xen PV domU get spurious fpudna traps from userland. Older eager FPU
contact switching code took care of ignoring them. When transitioning
from eager switching to awlays switching, this special handling was
removed, causing "fpudna from userland" panics.

This change restores the previosu behavior where fpudna traps from
userland are ignored on Xen PV domU.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/x86/x86/fpu.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/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.87 src/sys/arch/x86/x86/fpu.c:1.88
--- src/sys/arch/x86/x86/fpu.c:1.87	Tue Jul 18 12:34:25 2023
+++ src/sys/arch/x86/x86/fpu.c	Fri May 17 00:37:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.87 2023/07/18 12:34:25 riastradh Exp $	*/
+/*	$NetBSD: fpu.c,v 1.88 2024/05/17 00:37:14 manu Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.87 2023/07/18 12:34:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.88 2024/05/17 00:37:14 manu Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -617,6 +617,15 @@ fputrap(struct trapframe *frame)
 void
 fpudna(struct trapframe *frame)
 {
+#ifdef XENPV
+	/*
+	 * Xen produes spurious fpudna traps, just do nothing.
+	 */
+	if (USERMODE(frame->tf_cs)) {
+		clts();
+		return;
+	} 
+#endif
 	panic("fpudna from %s, ip %p, trapframe %p",
 	USERMODE(frame->tf_cs) ? "userland" : "kernel",
 	(void *)X86_TF_RIP(frame), frame);



CVS commit: src/sys/arch/x86/x86

2024-05-16 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri May 17 00:37:14 UTC 2024

Modified Files:
src/sys/arch/x86/x86: fpu.c

Log Message:
iWorkaround panic: fpudna from userland

i386 Xen PV domU get spurious fpudna traps from userland. Older eager FPU
contact switching code took care of ignoring them. When transitioning
from eager switching to awlays switching, this special handling was
removed, causing "fpudna from userland" panics.

This change restores the previosu behavior where fpudna traps from
userland are ignored on Xen PV domU.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/x86/x86/fpu.c

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



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

2023-10-01 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Oct  2 00:02:34 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Fix build with -DNO_GPT


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/i386/stand/lib/biosdisk.c

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



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

2023-10-01 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Oct  2 00:02:34 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Fix build with -DNO_GPT


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/i386/stand/lib/biosdisk.c

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

Modified files:

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.59 src/sys/arch/i386/stand/lib/biosdisk.c:1.60
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.59	Thu Sep 28 15:46:55 2023
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Mon Oct  2 00:02:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.59 2023/09/28 15:46:55 manu Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.60 2023/10/02 00:02:33 manu Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -328,7 +328,6 @@ guid_is_equal(const struct uuid *a, cons
 	return (memcmp(a, b, sizeof(*a)) == 0 ? true : false);
 }
 
-#ifndef NO_GPT
 static void
 part_name_utf8(const uint16_t *utf16_src, size_t utf16_srclen,
 	   char *utf8_dst, size_t utf8_dstlen)
@@ -351,7 +350,6 @@ part_name_utf8(const uint16_t *utf16_src
 
 	return;
 }
-#endif
 
 static int
 check_gpt(struct biosdisk *d, daddr_t rf_offset, daddr_t sector)
@@ -1562,14 +1560,17 @@ next_disk:
 			if (d->part[part].fstype == FS_UNUSED)
 continue;
 
+#ifndef NO_GPT
 			if (first_bootme == -1 &&
 			d->part[part].attr & GPT_ENT_ATTR_BOOTME)
 first_bootme = part;
+#endif
 
 			if (first_ffs == -1 &&
 			(d->part[part].fstype == FS_BSDFFS ||
 			 d->part[part].fstype == FS_BSDLFS))
 first_ffs = part;
+
 			if (part == target_part) {
 *biosdev = raidframe[i].biosdev;
 *offset = raidframe[i].offset



CVS commit: src/sys

2023-09-28 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Sep 28 15:50:24 UTC 2023

Modified Files:
src/sys/dev/raidframe: rf_netbsdkintf.c
src/sys/rump/librump/rumpkern: emul.c

Log Message:
Fix root search in RAID 1 sets

We use the wedge information given by bootstrap, where the kernel was
found. This requires src/sys/arch/i386/stand/i386/lib/biosdisk.c 1.59
to work in all cases.


To generate a diff of this commit:
cvs rdiff -u -r1.415 -r1.416 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.199 -r1.200 src/sys/rump/librump/rumpkern/emul.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/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.415 src/sys/dev/raidframe/rf_netbsdkintf.c:1.416
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.415	Mon Sep 25 21:59:38 2023
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Thu Sep 28 15:50:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.415 2023/09/25 21:59:38 oster Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.416 2023/09/28 15:50:23 manu Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.415 2023/09/25 21:59:38 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.416 2023/09/28 15:50:23 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_raid_autoconfig.h"
@@ -157,6 +157,8 @@ int rf_kdebug_level = 0;
 #define db1_printf(a) { }
 #endif/* DEBUG */
 
+#define DEVICE_XNAME(dev) dev ? device_xname(dev) : "null"
+
 #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0)
 static rf_declare_mutex2(rf_sparet_wait_mutex);
 static rf_declare_cond2(rf_sparet_wait_cv);
@@ -522,6 +524,134 @@ rf_rescan(void)
 	return 0;
 }
 
+/*
+ * Example setup:
+ * dk1 at wd0: "raid@wd0", 171965 blocks at 32802, type: raidframe
+ * dk3 at wd1: "raid@wd1", 171965 blocks at 32802, type: raidframz
+ * raid1: Components: /dev/dk1 /dev/dk3
+ * dk4 at raid1: "empty@raid1", 8192 blocks at 34, type: msdos
+ * dk5 at raid1: "root@raid1", 163517 blocks at 8226, type: ffs
+ * 
+ * If booted from wd0, booted_device will be 
+ * disk wd0, startblk = 41092, nblks = 163517
+ *
+ * That is, dk5 with startblk computed from the beginning of wd0
+ * instead of beginning of raid1:
+ * 32802 + 64 (RF_PROTECTED_SECTORS) + 8226 = 41092
+ * 
+ * In order to find the boot wedge, we must iterate on each component, 
+ * find its offset from disk beginning, abd look for the boot wedge with 
+ * startblck adjusted.
+ */
+static device_t
+rf_find_bootwedge(struct raid_softc *rsc)
+{
+	RF_Raid_t *r = &rsc->sc_r;
+	const char *bootname;
+	size_t len;
+	device_t rdev = NULL;
+
+	if (booted_device == NULL)
+		goto out;
+		
+	bootname = device_xname(booted_device);
+	len = strlen(bootname);
+
+	aprint_debug("%s: booted_device %s, startblk = %"PRId64", "
+		 "nblks = %"PRId64"\n", __func__,
+		 bootname, booted_startblk, booted_nblks);
+
+	for (int col = 0; col < r->numCol; col++) {
+		const char *devname = r->Disks[col].devname;
+		const char *parent;
+		struct disk *dk;
+		u_int nwedges;
+		struct dkwedge_info *dkwi;
+		struct dkwedge_list dkwl;
+		size_t dkwi_len;
+		int i;
+
+		devname += sizeof("/dev/") - 1;
+		if (strncmp(devname, "dk", 2) != 0) 
+			continue;
+
+		parent = dkwedge_get_parent_name(r->Disks[col].dev);
+		if (parent == NULL) {
+			aprint_debug("%s: cannot find parent for "
+ "component /dev/%s", __func__, devname); 
+			continue;
+		}
+
+		if (strncmp(parent, bootname, len) != 0)
+			continue;
+
+		aprint_debug("%s: looking up wedge %s in device %s\n",
+			 __func__, devname, parent);
+
+		dk = disk_find(parent);
+		nwedges = dk->dk_nwedges;
+		dkwi_len = sizeof(*dkwi) * nwedges;
+		dkwi = RF_Malloc(dkwi_len);
+
+		dkwl.dkwl_buf = dkwi;
+		dkwl.dkwl_bufsize = dkwi_len;
+		dkwl.dkwl_nwedges = 0;
+		dkwl.dkwl_ncopied = 0;
+
+		if (dkwedge_list(dk, &dkwl, curlwp) == 0) {
+			daddr_t startblk;
+
+			for (i = 0; i < dkwl.dkwl_ncopied; i++) {
+if (strcmp(dkwi[i].dkw_devname, devname) == 0)
+	break;
+			}
+
+			KASSERT(i < dkwl.dkwl_ncopied);
+
+			aprint_debug("%s: wedge %s, "
+ "startblk = %"PRId64", "
+ "nblks = %"PRId64"\n",
+ __func__,
+ dkwi[i].dkw_devname,
+ dkwi[i].dkw_offset,
+ dkwi[i].dkw_size);
+
+			startblk = booted_startblk
+ - dkwi[i].dkw_offset
+ - RF_PROTECTED_SECTORS;
+			
+			aprint_debug("%s: looking for wedge in %s, "
+ "startblk = %"PRId64", "
+ "nblks = %"PRId64"\n",
+ __func__,
+ DEVICE_XNAME(rsc->sc_dksc.sc_dev),
+ startblk, booted_nblks);
+
+			rdev = dkwedge_find_partition(rsc->sc_dksc.sc_dev,
+		  startblk,
+		  booted_nblks);
+			if (rdev) {
+aprint_debug("%s: root candidate wedge %s "
+	 "shifted from

CVS commit: src/sys

2023-09-28 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Sep 28 15:50:24 UTC 2023

Modified Files:
src/sys/dev/raidframe: rf_netbsdkintf.c
src/sys/rump/librump/rumpkern: emul.c

Log Message:
Fix root search in RAID 1 sets

We use the wedge information given by bootstrap, where the kernel was
found. This requires src/sys/arch/i386/stand/i386/lib/biosdisk.c 1.59
to work in all cases.


To generate a diff of this commit:
cvs rdiff -u -r1.415 -r1.416 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.199 -r1.200 src/sys/rump/librump/rumpkern/emul.c

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



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

2023-09-28 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Sep 28 15:46:55 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Align the behavior of different boot methods in RAIDframe

We enforce the documented and paritally implemented behavior when
looking for the kernel in RAID 1 sets without a partition name given.
We search for:
- A GPT partition with bootme attribute set
- A FFS or LFS patititon
- The first partition


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/i386/stand/lib/biosdisk.c

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

Modified files:

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.58 src/sys/arch/i386/stand/lib/biosdisk.c:1.59
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.58	Tue May  3 10:09:40 2022
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Thu Sep 28 15:46:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.58 2022/05/03 10:09:40 jmcneill Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.59 2023/09/28 15:46:55 manu Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -105,6 +105,7 @@
 struct biosdisk {
 	struct biosdisk_ll ll;
 	daddr_t boff;
+	daddr_t size;
 	charbuf[BIOSDISK_BUFSIZE];
 #if !defined(NO_DISKLABEL) || !defined(NO_GPT)
 	struct biosdisk_partition part[BIOSDISKNPART];
@@ -666,6 +667,7 @@ read_label(struct biosdisk *d, daddr_t o
 	dflt_lbl.d_npartitions = 8;
 
 	d->boff = 0;
+	d->size = 0;
 
 	if (d->ll.type != BIOSDISK_TYPE_HD)
 		/* No label on floppy and CD */
@@ -1208,7 +1210,7 @@ add_biosdisk_bootinfo(void)
 #endif
 
 #ifndef NO_GPT
-static daddr_t
+static void
 raidframe_part_offset(struct biosdisk *d, int part)
 {
 	struct biosdisk raidframe;
@@ -1221,8 +1223,10 @@ raidframe_part_offset(struct biosdisk *d
 
 	rf_offset = d->part[part].offset + RF_PROTECTED_SECTORS;
 	rf_size = d->part[part].size;
-	if (read_gpt(&raidframe, rf_offset, rf_size) != 0)
-		return RF_PROTECTED_SECTORS;
+	if (read_gpt(&raidframe, rf_offset, rf_size) != 0) {
+		d->boff += RF_PROTECTED_SECTORS;
+		return;
+	}
 
 	candidate = 0;
 	for (i = 0; i < BIOSDISKNPART; i++) {
@@ -1231,12 +1235,20 @@ raidframe_part_offset(struct biosdisk *d
 		if (raidframe.part[i].fstype == FS_UNUSED)
 			continue;
 #ifndef NO_GPT
-		if (raidframe.part[i].attr & GPT_ENT_ATTR_BOOTME)
+		if (raidframe.part[i].attr & GPT_ENT_ATTR_BOOTME) {
 			candidate = i;
+			break;
+		}
 #endif
+		if (raidframe.part[i].fstype == FS_BSDFFS ||
+		raidframe.part[i].fstype == FS_BSDLFS) {
+			if (candidate == 0)
+candidate = i;
+		}
 	}
 
-	return RF_PROTECTED_SECTORS + raidframe.part[candidate].offset;
+	d->boff += RF_PROTECTED_SECTORS + raidframe.part[candidate].offset;
+	d->size = raidframe.part[candidate].size;
 }
 #endif
 
@@ -1285,17 +1297,18 @@ biosdisk_open(struct open_file *f, ...)
 	}
 
 	d->boff = d->part[partition].offset;
+	d->size = d->part[partition].size;
 
 	if (d->part[partition].fstype == FS_RAID)
 #ifndef NO_GPT
-		d->boff += raidframe_part_offset(d, partition);
+		raidframe_part_offset(d, partition);
 #else
 		d->boff += RF_PROTECTED_SECTORS;
 #endif
 
 #ifdef _STANDALONE
-	bi_wedge.startblk = d->part[partition].offset;
-	bi_wedge.nblks = d->part[partition].size;
+	bi_wedge.startblk = d->boff;
+	bi_wedge.nblks = d->size;
 #endif
 
 nolabel:
@@ -1389,6 +1402,8 @@ next_disk:
 
 #ifndef NO_RAIDFRAME
 	for (i = 0; i < raidframe_count; i++) {
+		int first_bootme = -1;
+		int first_ffs = -1;
 		int candidate = -1;
 
 		if ((d = alloc_biosdisk(raidframe[i].biosdev)) == NULL) {
@@ -1402,12 +1417,20 @@ next_disk:
 			goto next_raidframe;
 
 		for (part = 0; part < BIOSDISKNPART; part++) {
-			bool bootme = d->part[part].attr & GPT_ENT_ATTR_BOOTME;
 			if (d->part[part].size == 0)
 continue;
 			if (d->part[part].fstype == FS_UNUSED)
 continue;
 
+			if (first_bootme == -1 && 
+			d->part[part].attr & GPT_ENT_ATTR_BOOTME)
+first_bootme = part;
+
+			if (first_ffs == -1 && 
+			(d->part[part].fstype == FS_BSDFFS ||
+			 d->part[part].fstype == FS_BSDLFS))
+first_ffs = part;
+
 			if (d->part[part].part_name != NULL &&
 			strcmp(d->part[part].part_name, name) == 0) {
 *biosdev = raidframe[i].biosdev;
@@ -1418,11 +1441,13 @@ next_disk:
 ret = 0;
 goto out;
 			}
-			if (strcmp(raidframe[i].parent_name, name) == 0) {
-if (candidate == -1 || bootme)
-	candidate = part;
-continue;
-			}
+		}
+
+		if (strcmp(raidframe[i].parent_name, name) == 0) {
+			if (first_bootme != -1)
+candidate = first_bootme;
+			else if (first_ffs != -1)
+candidate = first_ffs;
 		}
 
 		if (candidate != -1) {
@@ -1514,6 +1539,10 @@ next_disk:
 	}
 
 	for (i = 0; i < raidframe_count; i++) {
+		int first_bootme = -1;
+		int first_ffs = -1;
+		int candidate = -1;
+
 		if (raidframe[i].last_unit != target_unit)
 			continue;
 
@@ -1532,6 +1561,15 @@ next_disk:
 continue;
 			if (d->part[part]

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

2023-09-28 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Sep 28 15:46:55 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Align the behavior of different boot methods in RAIDframe

We enforce the documented and paritally implemented behavior when
looking for the kernel in RAID 1 sets without a partition name given.
We search for:
- A GPT partition with bootme attribute set
- A FFS or LFS patititon
- The first partition


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/i386/stand/lib/biosdisk.c

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



CVS commit: src/sys/dev/usb

2023-08-04 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Aug  4 13:25:18 UTC 2023

Modified Files:
src/sys/dev/usb: umodeswitch.c

Log Message:
Add support for D-Link DWM-222 4G LTS USB adapter

Oddly, the fake umass device does not detach after umodeswitch does
its duty, but functionality is there, thanks to five u3g devices that
attach. u3g devices 0, 3 and 4 does not seem to accept AT commands.
u3g devices 1 and 2 are fine to be used as modems.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/umodeswitch.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/dev/usb/umodeswitch.c
diff -u src/sys/dev/usb/umodeswitch.c:1.5 src/sys/dev/usb/umodeswitch.c:1.6
--- src/sys/dev/usb/umodeswitch.c:1.5	Sat Feb 15 02:14:02 2020
+++ src/sys/dev/usb/umodeswitch.c	Fri Aug  4 13:25:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: umodeswitch.c,v 1.5 2020/02/15 02:14:02 manu Exp $	*/
+/*	$NetBSD: umodeswitch.c,v 1.6 2023/08/04 13:25:17 manu Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umodeswitch.c,v 1.5 2020/02/15 02:14:02 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umodeswitch.c,v 1.6 2023/08/04 13:25:17 manu Exp $");
 
 #include 
 #include 
@@ -440,6 +440,7 @@ umodeswitch_match(device_t parent, cfdat
 		switch (uaa->uaa_product) {
 		case USB_PRODUCT_DLINK_DWM157E_CD:
 		case USB_PRODUCT_DLINK_DWM157_CD:
+		case USB_PRODUCT_DLINK_DWM222_CD:
 			(void)u3g_bulk_ata_eject(uaa->uaa_device);
 			(void)u3g_bulk_scsi_eject(uaa->uaa_device);
 			return UMATCH_HIGHEST;



CVS commit: src/sys/dev/usb

2023-08-04 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Aug  4 13:25:18 UTC 2023

Modified Files:
src/sys/dev/usb: umodeswitch.c

Log Message:
Add support for D-Link DWM-222 4G LTS USB adapter

Oddly, the fake umass device does not detach after umodeswitch does
its duty, but functionality is there, thanks to five u3g devices that
attach. u3g devices 0, 3 and 4 does not seem to accept AT commands.
u3g devices 1 and 2 are fine to be used as modems.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/umodeswitch.c

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



Re: CVS commit: src/sys/arch/i386/stand/bootxx

2023-06-29 Thread Emmanuel Dreyfus
On Thu, Jun 29, 2023 at 08:43:36PM -0400, Greg Troxel wrote:
> > Primary bootstrap is now able to read a GPT inside RAIDframe.
> did you also update documentation?

We do not have any documentation specific to primary bootstrap. 
x86/boot(8) domuent the behavior with no detail about primary
and secondary bootstrap distinct roles.

The change makes primary bootstrap behavior in line with secondary
bootstrap and with what is already documented in x86/boot(8). Hence
there is no documentation update, we could consider it as a bug fix, 
since the previosu behavior did not match x86/boot(8) documentation.

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


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

2023-06-29 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Jun 29 14:18:58 UTC 2023

Modified Files:
src/sys/arch/i386/stand/bootxx: boot1.c

Log Message:
Primary bootstrap is now able to read a GPT inside RAIDframe.

Previously, primary bootstrap was able to boot on RAID-1 RAIDframe set
with the limitation that the FFS filesystem had to start at bloc 0 in the
RAID. That allowed inner RAID partitionning with a disklabel, but not with
a GPT.

When booting on a RAID-1 RAIDframe, primary bootstrap now first try a
filesystem at bloc 0 of the RAID as before. On failure, it tries to
read a GPT and load secondary bootstrap from, by priority;
1) the first partition with the bootme attribute set
2) the first partition of type FFS, LFS, CCD or CGD
3) the first partition present in the GPT


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/bootxx/boot1.c

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

Modified files:

Index: src/sys/arch/i386/stand/bootxx/boot1.c
diff -u src/sys/arch/i386/stand/bootxx/boot1.c:1.21 src/sys/arch/i386/stand/bootxx/boot1.c:1.22
--- src/sys/arch/i386/stand/bootxx/boot1.c:1.21	Thu Jun 24 01:23:16 2021
+++ src/sys/arch/i386/stand/bootxx/boot1.c	Thu Jun 29 14:18:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot1.c,v 1.21 2021/06/24 01:23:16 gutteridge Exp $	*/
+/*	$NetBSD: boot1.c,v 1.22 2023/06/29 14:18:58 manu Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -30,15 +30,17 @@
  */
 
 #include 
-__RCSID("$NetBSD: boot1.c,v 1.21 2021/06/24 01:23:16 gutteridge Exp $");
+__RCSID("$NetBSD: boot1.c,v 1.22 2023/06/29 14:18:58 manu Exp $");
 
 #include 
 #include 
 #include 
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 	/* For RF_PROTECTED_SECTORS */
 
 #define XSTR(x) #x
@@ -49,6 +51,9 @@ static daddr_t bios_sector;
 static struct biosdisk_ll d;
 
 const char *boot1(uint32_t, uint64_t *);
+#ifndef NO_GPT
+static daddr_t gpt_lookup(daddr_t);
+#endif
 extern void putstr(const char *);
 
 extern struct disklabel ptn_disklabel;
@@ -90,6 +95,17 @@ boot1(uint32_t biosdev, uint64_t *sector
 	fd = ob();
 	if (fd != -1)
 		goto done;
+
+#ifndef NO_GPT
+	/*
+	 * Test for a GPT inside the RAID
+	 */
+	bios_sector += gpt_lookup(bios_sector);
+	fd = ob();
+	if (fd != -1)
+		goto done;
+#endif
+
 	/*
 	 * Nothing at the start of the MBR partition, fallback on
 	 * partition 'a' from the disklabel in this MBR partition.
@@ -144,3 +160,146 @@ blkdevstrategy(void *devdata, int flag, 
 
 	return 0;
 }
+
+#ifndef NO_GPT
+static int
+is_unused(struct gpt_ent *ent)
+{
+	const struct uuid unused = GPT_ENT_TYPE_UNUSED;
+
+	return (memcmp(ent->ent_type, &unused, sizeof(unused)) == 0);
+}
+
+static int
+is_bootable(struct gpt_ent *ent)
+{
+	/* GPT_ENT_TYPE_NETBSD_RAID omitted as we are already in a RAID */
+	const struct uuid bootable[] = {
+		GPT_ENT_TYPE_NETBSD_FFS,
+		GPT_ENT_TYPE_NETBSD_LFS,
+		GPT_ENT_TYPE_NETBSD_CCD,
+		GPT_ENT_TYPE_NETBSD_CGD,
+	};
+	int i;
+
+	for (i = 0; i < sizeof(bootable) / sizeof(*bootable); i++) {
+		if (memcmp(ent->ent_type, &bootable[i],
+		sizeof(struct uuid)) == 0)
+			return 1;
+	}
+
+	return 0;
+}
+
+static daddr_t
+gpt_lookup(daddr_t sector)
+{
+	char buf[BIOSDISK_DEFAULT_SECSIZE];
+	struct mbr_sector *pmbr;	
+	const char gpt_hdr_sig[] = GPT_HDR_SIG;
+	struct gpt_hdr *hdr;
+	struct gpt_ent *ent;
+	uint32_t nents;
+	uint32_t entsz;
+	uint32_t entries_per_sector;
+	uint32_t sectors_per_entry;
+	uint64_t firstpart_lba = 0;
+	uint64_t bootable_lba = 0;
+	uint64_t bootme_lba = 0;
+	int i, j;
+
+	/*
+	 * Look for a PMBR
+	 */
+	if (readsects(&d, sector, 1, buf, 1) != 0)
+		return 0;
+
+	pmbr = (struct mbr_sector *)buf;
+
+	if (pmbr->mbr_magic != htole16(MBR_MAGIC))
+		return 0;
+
+	if (pmbr->mbr_parts[0].mbrp_type != MBR_PTYPE_PMBR)
+		return 0;
+
+	sector++; /* skip PMBR */
+
+	/*
+	 * Look for a GPT header
+	 * Space is scarce, we do not check CRC.
+	 */
+	if (readsects(&d, sector, 1, buf, 1) != 0)
+		return 0;
+
+	hdr = (struct gpt_hdr *)buf;
+
+	if (memcmp(gpt_hdr_sig, hdr->hdr_sig, sizeof(hdr->hdr_sig)) != 0)
+		return 0;
+
+	if (hdr->hdr_revision != htole32(GPT_HDR_REVISION))
+		return 0;
+
+	if (le32toh(hdr->hdr_size) > BIOSDISK_DEFAULT_SECSIZE)
+		return 0;
+
+	nents = le32toh(hdr->hdr_entries);
+	entsz = le32toh(hdr->hdr_entsz);
+
+	sector++; /* skip GPT header */
+
+	/*
+	 * Read partition table
+	 *
+	 * According to UEFI specification section 5.3.2, entries
+	 * are 128 * (2^n) bytes long. The most common scenario is
+	 * 128 bytes (n = 0) where there are 4 entries per sector.
+	 * If n > 2, then entries spans multiple sectors, but they
+	 * remain sector-aligned.
+	 */
+	entries_per_sector = BIOSDISK_DEFAULT_SECSIZE / entsz;
+	if (entries_per_sector == 0)
+		entries_per_sector = 1;
+
+	sectors_per_entry = entsz / BIOSDISK_DEFAULT_SECSIZE;
+	if (sectors_per_entry == 0)
+		sectors_per_entry = 1;
+
+	for (i = 0; i < nents; i += entr

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

2023-06-29 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Jun 29 14:18:58 UTC 2023

Modified Files:
src/sys/arch/i386/stand/bootxx: boot1.c

Log Message:
Primary bootstrap is now able to read a GPT inside RAIDframe.

Previously, primary bootstrap was able to boot on RAID-1 RAIDframe set
with the limitation that the FFS filesystem had to start at bloc 0 in the
RAID. That allowed inner RAID partitionning with a disklabel, but not with
a GPT.

When booting on a RAID-1 RAIDframe, primary bootstrap now first try a
filesystem at bloc 0 of the RAID as before. On failure, it tries to
read a GPT and load secondary bootstrap from, by priority;
1) the first partition with the bootme attribute set
2) the first partition of type FFS, LFS, CCD or CGD
3) the first partition present in the GPT


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/bootxx/boot1.c

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



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

2023-05-09 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed May 10 00:49:17 UTC 2023

Modified Files:
src/sys/arch/i386/stand/efiboot: version

Log Message:
Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/version

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/version
diff -u src/sys/arch/i386/stand/efiboot/version:1.2 src/sys/arch/i386/stand/efiboot/version:1.3
--- src/sys/arch/i386/stand/efiboot/version:1.2	Sat Aug  3 08:13:36 2019
+++ src/sys/arch/i386/stand/efiboot/version	Wed May 10 00:49:17 2023
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.2 2019/08/03 08:13:36 nonaka Exp $
+$NetBSD: version,v 1.3 2023/05/10 00:49:17 manu Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -6,3 +6,4 @@ is taken as the current.
 
 1.0:	Initial version.
 1.1:	Add CD/DVD-ROM, serial, PXE boot and UEFI memory map compaction support.
+1.2:	Add reloc command



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

2023-05-09 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed May 10 00:49:17 UTC 2023

Modified Files:
src/sys/arch/i386/stand/efiboot: version

Log Message:
Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/version

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



CVS commit: src/share/man/man8/man8.x86

2023-05-07 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon May  8 00:40:50 UTC 2023

Modified Files:
src/share/man/man8/man8.x86: boot.8

Log Message:
Remove XXX todo marker left by mistake


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/share/man/man8/man8.x86/boot.8

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

Modified files:

Index: src/share/man/man8/man8.x86/boot.8
diff -u src/share/man/man8/man8.x86/boot.8:1.28 src/share/man/man8/man8.x86/boot.8:1.29
--- src/share/man/man8/man8.x86/boot.8:1.28	Fri May  5 00:34:40 2023
+++ src/share/man/man8/man8.x86/boot.8	Mon May  8 00:40:50 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: boot.8,v 1.28 2023/05/05 00:34:40 manu Exp $
+.\"	$NetBSD: boot.8,v 1.29 2023/05/08 00:40:50 manu Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -701,7 +701,7 @@ and may impact system security.
 Pass an explicit root specification to the kernel.
 See BTINFO_ROOTDEVICE for details.
 .It Ic splash Ar file
-[Only available for BIOS and UEFI boot] XXX document
+[Only available for BIOS and UEFI boot]
 Load a graphical image from the specified
 .Ar file
 and request the kernel to use it as a splash screen.



CVS commit: src/share/man/man8/man8.x86

2023-05-07 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon May  8 00:40:50 UTC 2023

Modified Files:
src/share/man/man8/man8.x86: boot.8

Log Message:
Remove XXX todo marker left by mistake


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/share/man/man8/man8.x86/boot.8

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



CVS commit: src

2023-05-04 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri May  5 00:34:41 UTC 2023

Modified Files:
src/share/man/man4: options.4
src/share/man/man8/man8.x86: boot.8
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/amd64/conf: files.amd64 std.amd64

Log Message:
Add a SELFRELOC kernel option for the sake of documentation clarity.

Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.


To generate a diff of this commit:
cvs rdiff -u -r1.523 -r1.524 src/share/man/man4/options.4
cvs rdiff -u -r1.27 -r1.28 src/share/man/man8/man8.x86/boot.8
cvs rdiff -u -r1.219 -r1.220 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/amd64/conf/files.amd64
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/conf/std.amd64

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



CVS commit: src

2023-05-04 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri May  5 00:34:41 UTC 2023

Modified Files:
src/share/man/man4: options.4
src/share/man/man8/man8.x86: boot.8
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/amd64/conf: files.amd64 std.amd64

Log Message:
Add a SELFRELOC kernel option for the sake of documentation clarity.

Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.


To generate a diff of this commit:
cvs rdiff -u -r1.523 -r1.524 src/share/man/man4/options.4
cvs rdiff -u -r1.27 -r1.28 src/share/man/man8/man8.x86/boot.8
cvs rdiff -u -r1.219 -r1.220 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/amd64/conf/files.amd64
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/conf/std.amd64

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

Modified files:

Index: src/share/man/man4/options.4
diff -u src/share/man/man4/options.4:1.523 src/share/man/man4/options.4:1.524
--- src/share/man/man4/options.4:1.523	Sun Aug 28 14:29:05 2022
+++ src/share/man/man4/options.4	Fri May  5 00:34:41 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: options.4,v 1.523 2022/08/28 14:29:05 riastradh Exp $
+.\"	$NetBSD: options.4,v 1.524 2023/05/05 00:34:41 manu Exp $
 .\"
 .\" Copyright (c) 1996
 .\" 	Perry E. Metzger.  All rights reserved.
@@ -1307,6 +1307,14 @@ See
 and
 .Xr vnconfig 8
 for more information.
+.It Cd options SELFRELOC
+Make the kernel able to self relocate at bootstrap, so that it can
+run whatever its load address is. 
+This is intented to be used withe the 
+.Ic reloc
+boostrap command documented in
+.Xr x86/boot 8 ,
+to workaround UEFI bugs, and is only available on amd64.
 .It Cd options SPLDEBUG
 Help the kernel programmer find bugs related to the interrupt priority
 level.

Index: src/share/man/man8/man8.x86/boot.8
diff -u src/share/man/man8/man8.x86/boot.8:1.27 src/share/man/man8/man8.x86/boot.8:1.28
--- src/share/man/man8/man8.x86/boot.8:1.27	Mon Apr 24 13:55:45 2023
+++ src/share/man/man8/man8.x86/boot.8	Fri May  5 00:34:40 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: boot.8,v 1.27 2023/04/24 13:55:45 manu Exp $
+.\"	$NetBSD: boot.8,v 1.28 2023/05/05 00:34:40 manu Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -655,8 +655,10 @@ Reboot the system.
 .It Ic reloc Op Va default No \(or Va none No \(or Va address
 [Only UEFI boot] Sets where the kernel is copied by bootstrap
 before it is started. Values other than default require a kernel
-that can relocate itself at the right address, otherwise a crash
-occurs at boot time.
+built with the
+.Cd SELFRELOC
+option, so that can relocate itself at the right address,
+otherwise a crash occurs at boot time.
 .Bl -tag -width default
 .It Va default
 Copy the kernel at ELF header load address, this is the historical

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.219 src/sys/arch/amd64/amd64/locore.S:1.220
--- src/sys/arch/amd64/amd64/locore.S:1.219	Thu Apr 20 00:42:23 2023
+++ src/sys/arch/amd64/amd64/locore.S	Fri May  5 00:34:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.219 2023/04/20 00:42:23 manu Exp $	*/
+/*	$NetBSD: locore.S,v 1.220 2023/05/05 00:34:41 manu Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -156,6 +156,7 @@
 #include "opt_ddbparam.h"
 #include "opt_modular.h"
 #include "opt_realmem.h"
+#include "opt_selfreloc.h"
 
 #include "opt_compat_netbsd.h"
 #include "opt_compat_netbsd32.h"
@@ -456,6 +457,7 @@ ENTRY(start)
 #ifndef XENPV
 	.code32
 
+#ifdef SELFRELOC
 	call	next
 next:	pop	%edi
 	sub $(next - kernel_text), %edi 
@@ -463,6 +465,7 @@ next:	pop	%edi
 	/* If not KERNBASE, reloc ourselves to KERNBASE */
 	cmpl	$(KERNTEXTOFF_LO - KERNBASE_LO), %edi
 	jne	selfreloc_start
+#endif /* SELFRELOC */
 
 	/* Warm boot */
 	movw	$0x1234,0x472
@@ -1766,6 +1769,7 @@ LABEL(nomds_leave)
 	NOMDS_LEAVE
 LABEL(nomds_leave_end)
 
+#ifdef SELFRELOC
 /*
  * selfreloc(loadddr edi)
  * This is adapted from sys/arch/i386/i386/locore.S
@@ -1900,3 +1904,4 @@ gdtr:
 gdtrr:
 	.quad
 END(selfreloc_start)
+#endif /* SELFRELOC */

Index: src/sys/arch/amd64/conf/files.amd64
diff -u src/sys/arch/amd64/conf/files.amd64:1.120 src/sys/arch/amd64/conf/files.amd64:1.121
--- src/sys/arch/amd64/conf/files.amd64:1.120	Wed Oct 21 13:31:51 2020
+++ src/sys/arch/amd64/conf/files.amd64	Fri May  5 00:34:41 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: files.amd64,v 1.120 2020/10/21 13:31:51 christos Exp $
+#	$NetBSD: files.amd64,v 1.121 2023/05/05 00:34:41 manu Exp $
 #
 # new style config file for amd64 architecture
 #
@@ -20,6 +20,9 @@ defparam opt_physmem.h	PHYSMEM_MAX_ADDR 
 # Enable GCC spectre V2 mitigation options
 defflag opt_spectre.h	SPECTRE_V2_GCC_MITIGATION
 
+# Enable kernel self-relocation at boot

CVS commit: src/share/man/man8/man8.x86

2023-04-24 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Apr 24 13:55:45 UTC 2023

Modified Files:
src/share/man/man8/man8.x86: boot.8 dosboot.8 pxeboot.8

Log Message:
Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/share/man/man8/man8.x86/boot.8
cvs rdiff -u -r1.3 -r1.4 src/share/man/man8/man8.x86/dosboot.8
cvs rdiff -u -r1.5 -r1.6 src/share/man/man8/man8.x86/pxeboot.8

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

Modified files:

Index: src/share/man/man8/man8.x86/boot.8
diff -u src/share/man/man8/man8.x86/boot.8:1.26 src/share/man/man8/man8.x86/boot.8:1.27
--- src/share/man/man8/man8.x86/boot.8:1.26	Tue Jun 22 03:39:21 2021
+++ src/share/man/man8/man8.x86/boot.8	Mon Apr 24 13:55:45 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: boot.8,v 1.26 2021/06/22 03:39:21 gutteridge Exp $
+.\"	$NetBSD: boot.8,v 1.27 2023/04/24 13:55:45 manu Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -364,6 +364,8 @@ flag in
 Boot the system in silent mode.
 .El
 .It Ic consdev Ar dev\| Ns Oo Ns Ic \&, Ns Ar speed Oc
+[Not available for 
+.Xr x86/dosboot 8 ]
 Immediately switch the console to the specified device
 .Ar dev
 and reprint the banner.
@@ -397,16 +399,26 @@ Without an argument, print the current s
 .Ar device
 is of the form specified in
 .Ic boot .
+.It Ic devpath
+[Only available for UEFI boot] Dump UEFI device paths.
+.It Ic efivar
+[Only available for UEFI boot] Dump UEFI environment variables from NVRAM.
 .It Ic fs Ar file
+[Only available for BIOS and UEFI boot]
 Load a file system image from the specified
 .Ar file ,
 and request the kernel to use it as the root file system.
 The
 .Xr makefs 8
 utility may be used to create suitable file system images.
+.It Ic gop Op Va mode_index
+[Only available for UEFI boot] Without argument, list the available
+video modes. If an argument is given, select a video mode.
 .It Ic help
 Print an overview about commands and arguments.
 .It Ic load Ar module Op Ar arguments
+[Not available for 
+.Xr x86/dosboot 8 ]
 Load the specified kernel
 .Ar module ,
 and pass it the specified
@@ -520,12 +532,17 @@ See
 .Xr pciback 4 .
 .El
 .It Ic ls Op Ar path
+[Not available for
+.Xr x86/pxeboot 8 ]
 Print a directory listing of
 .Ar path ,
 containing inode number, filename, and file type.
 .Ar path
 can contain a device specification.
+.It Ic memmap
+[Only available for UEFI boot] Dump UEFI memory map.
 .It Ic menu
+[Only available for BIOS and UEFI boot]
 Display the boot menu and initiate a countdown,
 similarly to what would have happened if interactive mode
 had not been entered.
@@ -534,6 +551,8 @@ had not been entered.
No \(or Li enabled \
No \(or Li disabled\^ \
Brc
+[Not available for
+.Xr x86/dosboot 8 ]
 The values
 .Ql enabled ,
 .Ql on
@@ -545,7 +564,18 @@ whereas
 .Ql disabled ,
 .Ql off
 will turn off the feature.
+.It Ic mode Va fstype
+[Only available for
+.Xr x86/dosboot 8 ]
+Switch file system type;
+.Va fstype
+should be one of
+.Ar dos
+or
+.Ar ufs .
 .It Ic multiboot Ar kernel Op Ar arguments
+[Not available for
+.Xr x86/dosboot 8 ]
 Boot the specified
 .Ar kernel ,
 using the
@@ -615,12 +645,30 @@ command.
 See the foreign operating system's documentation for the available
 .Ar arguments .
 .El
+.It Ic pkboot
+[Only available for BIOS and UEFI boot] Boot a kernel that has
+the
+.Cd KASLR
+option set, for Kernel Address Space Layout Randomizaton.
 .It Ic quit
 Reboot the system.
-.It Ic root Ar spec
-Pass an explicit root specification to the kernel.
-See BTINFO_ROOTDEVICE for details.
+.It Ic reloc Op Va default No \(or Va none No \(or Va address
+[Only UEFI boot] Sets where the kernel is copied by bootstrap
+before it is started. Values other than default require a kernel
+that can relocate itself at the right address, otherwise a crash
+occurs at boot time.
+.Bl -tag -width default
+.It Va default
+Copy the kernel at ELF header load address, this is the historical
+behavior.
+.It Va none
+Leave the kernel where it was loaded and start it as is. 
+.It Va address
+Copy the kernel at given
+.Va address .
+.El
 .It Ic rndseed Ar file
+[Only available for BIOS and UEFI boot]
 Load the specified
 .Ar file
 and request the kernel to use it as a seed for the
@@ -646,16 +694,12 @@ Using the same seed file on more then on
 or for more than one boot on the same host,
 will reduce the quality of random numbers
 and may impact system security.
-.It Ic userconf Ar command
-Pass command
-.Ar command
-to
-.Xr userconf 4
-at boot time.
-These commands are processed before the interactive
-.Xr

CVS commit: src/share/man/man8/man8.x86

2023-04-24 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Apr 24 13:55:45 UTC 2023

Modified Files:
src/share/man/man8/man8.x86: boot.8 dosboot.8 pxeboot.8

Log Message:
Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/share/man/man8/man8.x86/boot.8
cvs rdiff -u -r1.3 -r1.4 src/share/man/man8/man8.x86/dosboot.8
cvs rdiff -u -r1.5 -r1.6 src/share/man/man8/man8.x86/pxeboot.8

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



CVS commit: src/sys/arch

2023-04-19 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Apr 20 00:42:24 UTC 2023

Modified Files:
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/i386/stand/efiboot: boot.c efiboot.c efiboot.h
src/sys/arch/i386/stand/efiboot/bootia32: efibootia32.c startprog32.S
src/sys/arch/i386/stand/efiboot/bootx64: efibootx64.c startprog64.S
src/sys/arch/i386/stand/lib: exec.c

Log Message:
Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x20), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x20.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x20, hhe the kernel relocates
itself and start over at the right address.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.5 -r1.6 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/i386/stand/lib/exec.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/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.218 src/sys/arch/amd64/amd64/locore.S:1.219
--- src/sys/arch/amd64/amd64/locore.S:1.218	Fri Mar  3 14:32:48 2023
+++ src/sys/arch/amd64/amd64/locore.S	Thu Apr 20 00:42:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.218 2023/03/03 14:32:48 riastradh Exp $	*/
+/*	$NetBSD: locore.S,v 1.219 2023/04/20 00:42:23 manu Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -456,6 +456,14 @@ ENTRY(start)
 #ifndef XENPV
 	.code32
 
+	call	next
+next:	pop	%edi
+	sub $(next - kernel_text), %edi 
+
+	/* If not KERNBASE, reloc ourselves to KERNBASE */
+	cmpl	$(KERNTEXTOFF_LO - KERNBASE_LO), %edi
+	jne	selfreloc_start
+
 	/* Warm boot */
 	movw	$0x1234,0x472
 
@@ -1757,3 +1765,138 @@ LABEL(mds_leave_end)
 LABEL(nomds_leave)
 	NOMDS_LEAVE
 LABEL(nomds_leave_end)
+
+/*
+ * selfreloc(loadddr edi)
+ * This is adapted from sys/arch/i386/i386/locore.S
+ */
+	.code32
+ENTRY(selfreloc_start)
+	movl	%edi, %ebx		/* loadaddr saved in ebx */
+	movl	%edi, %esi/* src */
+	movl	$_RELOC(kernel_text), %edi		/* dest */
+	movl	16(%esp),%ecx/* esym */
+	subl	$_RELOC(kernel_text), %ecx		/* size */
+
+#if defined(NO_OVERLAP)
+movl%ecx, %eax
+#else 
+movl%edi, %eax
+subl%esi, %eax
+cmpl%ecx, %eax  /* overlapping? */
+movl%ecx, %eax
+jb  .Lbackwards
+#endif
+/* nope, copy forwards. */
+shrl$2, %ecx/* copy by words */
+rep
+movsl
+and $3, %eax/* any bytes left? */
+jnz .Ltrailing
+jmp .Lcopy_done
+
+.Ltrailing:
+cmp $2, %eax
+jb  11f
+movw(%esi), %ax
+movw%ax, (%edi)
+je  .Lcopy_done
+movb2(%esi), %al
+movb%al, 2(%edi)
+jmp .Lcopy_done
+11: movb(%esi), %al
+movb%al, (%edi)
+jmp .Lcopy_done
+
+#if !defined(NO_OVERLAP)
+.Lbackwards:
+addl%ecx, %edi  /* copy backwards. */
+addl%ecx, %esi
+and $3, %eax/* any fractional bytes? */
+jnz .Lback_align
+.Lback_aligned:
+shrl$2, %ecx
+subl$4, %esi
+subl$4, %edi
+std
+rep
+movsl
+cld
+jmp .Lcopy_done
+
+.Lback_align:
+sub %eax, %esi
+sub %eax, %edi
+cmp $2, %eax
+jb  11f
+je  12f
+movb2(%esi), %al
+movb%al, 2(%edi)
+12: movw(%esi), %ax
+movw%ax, (%edi)
+jmp .Lback_aligned
+11: movb(%esi), %al
+movb%al, (%edi)
+jmp .Lback_aligned
+#endif
+/* End of copy kernel */
+.Lcopy_done:
+	cld			/* LynxOS depends on it */
+
+	/* load current selfreloc_start a

CVS commit: src/sys/arch

2023-04-19 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Apr 20 00:42:24 UTC 2023

Modified Files:
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/i386/stand/efiboot: boot.c efiboot.c efiboot.h
src/sys/arch/i386/stand/efiboot/bootia32: efibootia32.c startprog32.S
src/sys/arch/i386/stand/efiboot/bootx64: efibootx64.c startprog64.S
src/sys/arch/i386/stand/lib: exec.c

Log Message:
Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x20), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x20.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x20, hhe the kernel relocates
itself and start over at the right address.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.5 -r1.6 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/i386/stand/lib/exec.c

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



CVS commit: src/sys/dev/usb

2023-02-13 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Feb 13 14:05:26 UTC 2023

Modified Files:
src/sys/dev/usb: u3g.c

Log Message:
Add support for ZTE MF112 and D-Link DWM222 3G USB modems


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/u3g.c

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



CVS commit: src/sys/dev/usb

2023-02-13 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Feb 13 14:05:26 UTC 2023

Modified Files:
src/sys/dev/usb: u3g.c

Log Message:
Add support for ZTE MF112 and D-Link DWM222 3G USB modems


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/u3g.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/dev/usb/u3g.c
diff -u src/sys/dev/usb/u3g.c:1.43 src/sys/dev/usb/u3g.c:1.44
--- src/sys/dev/usb/u3g.c:1.43	Sat Aug  7 16:19:17 2021
+++ src/sys/dev/usb/u3g.c	Mon Feb 13 14:05:26 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: u3g.c,v 1.43 2021/08/07 16:19:17 thorpej Exp $	*/
+/*	$NetBSD: u3g.c,v 1.44 2023/02/13 14:05:26 manu Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.43 2021/08/07 16:19:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.44 2023/02/13 14:05:26 manu Exp $");
 
 #include 
 #include 
@@ -252,6 +252,7 @@ static const struct usb_devno u3g_devs[]
 	{ USB_VENDOR_ZTE, USB_PRODUCT_ZTE_MF626 },
 	{ USB_VENDOR_ZTE, USB_PRODUCT_ZTE_MF628 },
 	{ USB_VENDOR_ZTE, USB_PRODUCT_ZTE_MF820D },
+	{ USB_VENDOR_ZTE, USB_PRODUCT_ZTE_MF112 },
 
 	/* 4G Systems */
 	{ USB_VENDOR_LONGCHEER, USB_PRODUCT_LONGCHEER_XSSTICK_P14 },
@@ -260,6 +261,7 @@ static const struct usb_devno u3g_devs[]
 	/* DLink */
 	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157 },
 	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157E },
+	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM222 },
 };
 
 /*



CVS commit: src/sys/external/bsd/drm2

2022-05-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat May 28 01:07:47 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_bios.c radeon_drv.h
src/sys/external/bsd/drm2/include/linux: acpi.h

Log Message:
Let radeon DRM driver build on ports that lack ACPI


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/include/linux/acpi.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/external/bsd/drm2/dist/drm/radeon/radeon_bios.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.11 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.12
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.11	Mon Feb 28 17:15:29 2022
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c	Sat May 28 01:07:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_bios.c,v 1.11 2022/02/28 17:15:29 riastradh Exp $	*/
+/*	$NetBSD: radeon_bios.c,v 1.12 2022/05/28 01:07:47 manu Exp $	*/
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.11 2022/02/28 17:15:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.12 2022/05/28 01:07:47 manu Exp $");
 
 #include 
 #include 
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_bios.
 #include "radeon.h"
 #include "radeon_reg.h"
 
-#ifdef __NetBSD__
+#if defined(__NetBSD__) && NACPICA > 0
 #include 
 #define	_COMPONENT	ACPI_DISPLAY_COMPONENT
 ACPI_MODULE_NAME("radeon_acpi")

Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h:1.3 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h:1.4
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h:1.3	Sat Dec 18 23:45:43 2021
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h	Sat May 28 01:07:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_drv.h,v 1.3 2021/12/18 23:45:43 riastradh Exp $	*/
+/*	$NetBSD: radeon_drv.h,v 1.4 2022/05/28 01:07:47 manu Exp $	*/
 
 /* radeon_drv.h -- Private header for radeon driver -*- linux-c -*-
  *
@@ -33,6 +33,15 @@
 #ifndef __RADEON_DRV_H__
 #define __RADEON_DRV_H__
 
+#if defined(__NetBSD__)
+#ifdef _KERNEL_OPT
+#include "acpica.h"
+#endif  /* _KERNEL_OPT */
+#if (NACPICA > 0)
+#define CONFIG_ACPI
+#endif  /* NACPICA > 0 */
+#endif  /* __NetBSD__ */
+
 #include 
 #include 
 #include 

Index: src/sys/external/bsd/drm2/include/linux/acpi.h
diff -u src/sys/external/bsd/drm2/include/linux/acpi.h:1.9 src/sys/external/bsd/drm2/include/linux/acpi.h:1.10
--- src/sys/external/bsd/drm2/include/linux/acpi.h:1.9	Sun Feb 27 14:22:50 2022
+++ src/sys/external/bsd/drm2/include/linux/acpi.h	Sat May 28 01:07:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi.h,v 1.9 2022/02/27 14:22:50 riastradh Exp $	*/
+/*	$NetBSD: acpi.h,v 1.10 2022/05/28 01:07:47 manu Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,6 @@
 
 #if NACPICA > 0
 #include 
-#endif
 
 #include 
 #include 
@@ -58,4 +57,5 @@ union acpi_object *acpi_evaluate_dsm_typ
 uint64_t, uint64_t, union acpi_object *, acpi_object_type);
 bool acpi_check_dsm(acpi_handle, const guid_t *, uint64_t, uint64_t);
 
+#endif	/* NACPICA > 0 */
 #endif  /* _LINUX_ACPI_H_ */



CVS commit: src/sys/external/bsd/drm2

2022-05-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat May 28 01:07:47 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_bios.c radeon_drv.h
src/sys/external/bsd/drm2/include/linux: acpi.h

Log Message:
Let radeon DRM driver build on ports that lack ACPI


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/include/linux/acpi.h

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



CVS commit: src/share/man/man4

2022-05-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat May 28 00:53:41 UTC 2022

Modified Files:
src/share/man/man4: wm.4

Log Message:
Document hw.wmX.txex_workqueue sysctl


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/share/man/man4/wm.4

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

Modified files:

Index: src/share/man/man4/wm.4
diff -u src/share/man/man4/wm.4:1.42 src/share/man/man4/wm.4:1.43
--- src/share/man/man4/wm.4:1.42	Wed Feb 17 08:15:43 2021
+++ src/share/man/man4/wm.4	Sat May 28 00:53:41 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: wm.4,v 1.42 2021/02/17 08:15:43 knakahara Exp $
+.\"	$NetBSD: wm.4,v 1.43 2022/05/28 00:53:41 manu Exp $
 .\"
 .\" Copyright 2002, 2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -184,6 +184,16 @@ utility configures the adapter to receiv
 .\" .Sh DIAGNOSTICS
 .\" XXX to be done.
 .Sh OPTIONS
+The driver default behavior is to handle packets in interrupt context,
+which reduces the CPU time available to user processes when under 
+heavy nerwork load. The 
+.Em hw.wmX.txrx_workqueue
+.Xr sysctl 8
+alters this behavior so that packets are handled by a kernel thread, 
+which executes at a lower priority. This gives user processes more
+opportunity to be executed, at the exepense of network throughput.
+.Pp
+The following options can be set at build time:
 .Bl -tag -width WM_RX_INTR_PROCESS_LIMIT_DEFAULT -offset 3n
 .It Dv WM_RX_PROCESS_LIMIT_DEFAULT
 The maximum number of received packets processed in each
@@ -247,7 +257,8 @@ to
 .Xr mii 4 ,
 .Xr netintro 4 ,
 .Xr pci 4 ,
-.Xr ifconfig 8
+.Xr ifconfig 8 ,
+.Xr sysctl 8
 .Sh HISTORY
 The
 .Nm



CVS commit: src/share/man/man4

2022-05-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat May 28 00:53:41 UTC 2022

Modified Files:
src/share/man/man4: wm.4

Log Message:
Document hw.wmX.txex_workqueue sysctl


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/share/man/man4/wm.4

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



CVS commit: src/sys/dev/adb

2022-05-13 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat May 14 01:16:55 UTC 2022

Modified Files:
src/sys/dev/adb: adb_kbd.c adb_keymap.h adb_usb_map.c

Log Message:
Add ISO and JIS keyboard layouts for ADB to USB emulation

The layout is configurable using sysctl machdep.adbkbdX.emulate_usb:
0 = no emulation
1 = ANSI
2 = ISO (new with this change)
3 = JIS (new with this change)

Default value is detected using the ADB keyboard handler id. JIS
default is disabled until it is tested.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/adb/adb_kbd.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/adb/adb_keymap.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/adb/adb_usb_map.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/dev/adb/adb_kbd.c
diff -u src/sys/dev/adb/adb_kbd.c:1.32 src/sys/dev/adb/adb_kbd.c:1.33
--- src/sys/dev/adb/adb_kbd.c:1.32	Sat Aug  7 16:19:09 2021
+++ src/sys/dev/adb/adb_kbd.c	Sat May 14 01:16:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: adb_kbd.c,v 1.32 2021/08/07 16:19:09 thorpej Exp $	*/
+/*	$NetBSD: adb_kbd.c,v 1.33 2022/05/14 01:16:55 manu Exp $	*/
 
 /*
  * Copyright (C) 1998	Colin Wood
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.32 2021/08/07 16:19:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.33 2022/05/14 01:16:55 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -93,7 +93,7 @@ struct adbkbd_softc {
 #ifdef WSDISPLAY_COMPAT_RAWKBD
 	int sc_rawkbd;
 #endif
-	bool sc_emul_usb;
+	int sc_emul_usb;
 	bool sc_power_dbg;
 
 	uint32_t sc_power;
@@ -235,7 +235,7 @@ adbkbd_attach(device_t parent, device_t 
 	 */
 	sc->sc_power = 0x;
 	sc->sc_timestamp = 0;
-	sc->sc_emul_usb = FALSE;
+	sc->sc_emul_usb = ADB_EMUL_USB_NONE;
 #ifdef ADBKBD_POWER_DDB
 	sc->sc_power_dbg = TRUE;
 #else
@@ -386,8 +386,56 @@ adbkbd_attach(device_t parent, device_t 
 	sc->sc_wskbddev = config_found(self, &a, wskbddevprint,
 	CFARGS(.iattr = "wskbddev"));
 #ifdef ADBKBD_EMUL_USB
-	sc->sc_emul_usb = TRUE;
-	wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb, 128);
+	/* Values from Linux's drivers/macintosh/adbhud.c */
+switch (sc->sc_adbdev->handler_id) {
+	case ADB_ISOKBD:	/* FALLTHROUGH */
+	case ADB_EXTISOKBD:	/* FALLTHROUGH */
+	case 0x07:		/* FALLTHROUGH */
+	case ADB_ISOKBDII:	/* FALLTHROUGH */
+	case ADB_PBISOKBD:	/* FALLTHROUGH */
+	case ADB_ADJISOKBD:	/* FALLTHROUGH */
+	case ADB_PBEXTISOKBD:	/* FALLTHROUGH */
+	case 0x19:		/* FALLTHROUGH */
+	case 0x1d:		/* FALLTHROUGH */
+	case 0xc1:		/* FALLTHROUGH */
+	case ADB_IBOOKKBD:	/* FALLTHROUGH */
+	case 0xc7:
+		sc->sc_emul_usb = ADB_EMUL_USB_ISO;
+		wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_iso, 128);
+		break;
+#ifdef notyet
+	case ADB_ADJJAPKBD:	/* FALLTHROUGH */
+	case ADB_PBEXTJAPKBD:	/* FALLTHROUGH */
+	case ADB_JPKBDII:	/* FALLTHROUGH */
+	case 0x17:		/* FALLTHROUGH */
+	case 0x1a:		/* FALLTHROUGH */
+	case ADB_PBJPKBD:	/* FALLTHROUGH */
+	case 0xc2:		/* FALLTHROUGH */
+	case 0xc5:		/* FALLTHROUGH */
+	case 0xc8:		/* FALLTHROUGH */
+	case 0xc9:
+		sc->sc_emul_usb = ADB_EMUL_USB_JIS;
+		wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_jis, 128);
+		break;
+#endif
+	case ADB_STDKBD:	/* FALLTHROUGH */
+	case ADB_EXTKBD:	/* FALLTHROUGH */
+	case 0x03:		/* FALLTHROUGH */
+	case 0x06:		/* FALLTHROUGH */
+	case ADB_KBDII:		/* FALLTHROUGH */
+	case ADB_PBKBD:		/* FALLTHROUGH */
+	case ADB_ADJKBD:	/* FALLTHROUGH */
+	case ADB_PBEXTKBD:	/* FALLTHROUGH */
+	case ADB_DESIGNKBD:	/* FALLTHROUGH */
+	case 0x1c:		/* FALLTHROUGH */
+	case 0xc0:		/* FALLTHROUGH */
+	case ADB_PBG3KBD:	/* FALLTHROUGH */
+	case 0xc6:		/* FALLTHROUGH */
+	default:	/* default to ANSI for unknown values */
+		sc->sc_emul_usb = ADB_EMUL_USB_ANSI;
+		wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_ansi, 128);
+		break;
+	}
 #endif /* ADBKBD_EMUL_USB */
 
 #if NWSMOUSE > 0
@@ -633,7 +681,7 @@ adbkbd_ioctl(void *v, u_long cmd, void *
 	switch (cmd) {
 
 	case WSKBDIO_GTYPE:
-		if (sc->sc_emul_usb) {
+		if (sc->sc_emul_usb != ADB_EMUL_USB_NONE) {
 			*(int *)data = WSKBD_TYPE_USB;
 		} else {
 			*(int *)data = WSKBD_TYPE_ADB;
@@ -798,7 +846,7 @@ adbkbd_sysctl_usb(SYSCTLFN_ARGS)
 	struct sysctlnode node = *rnode;
 	struct adbkbd_softc *sc=(struct adbkbd_softc *)node.sysctl_data;
 	const int *np = newp;
-	bool reg;
+	int reg;
 
 	DPRINTF("%s\n", __func__);
 	reg = sc->sc_emul_usb;
@@ -807,12 +855,26 @@ adbkbd_sysctl_usb(SYSCTLFN_ARGS)
 		node.sysctl_data = ®
 		if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) {
 			
-			sc->sc_emul_usb = *(bool *)node.sysctl_data;
-			if (sc->sc_emul_usb) {
-wskbd_set_evtrans(sc->sc_wskbddev,
-adb_to_usb, 128);
-			} else {
+			sc->sc_emul_usb = *(int *)node.sysctl_data;
+			switch (sc->sc_emul_usb) {
+			case ADB_EMUL_USB_NONE:
 wskbd_set_evtrans(sc->sc_wskbddev, NULL, 0);
+break;
+			case ADB_EMUL_USB_ANSI:
+wskbd_set_evtrans(sc->sc_wskbddev,
+adb_to_usb_ansi, 

CVS commit: src/sys/dev/adb

2022-05-13 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat May 14 01:16:55 UTC 2022

Modified Files:
src/sys/dev/adb: adb_kbd.c adb_keymap.h adb_usb_map.c

Log Message:
Add ISO and JIS keyboard layouts for ADB to USB emulation

The layout is configurable using sysctl machdep.adbkbdX.emulate_usb:
0 = no emulation
1 = ANSI
2 = ISO (new with this change)
3 = JIS (new with this change)

Default value is detected using the ADB keyboard handler id. JIS
default is disabled until it is tested.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/adb/adb_kbd.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/adb/adb_keymap.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/adb/adb_usb_map.c

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



CVS commit: src/distrib/sets/lists/man

2022-03-24 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Mar 24 14:04:28 UTC 2022

Modified Files:
src/distrib/sets/lists/man: mi

Log Message:
Add man page for Intel GPIO igpio.4


To generate a diff of this commit:
cvs rdiff -u -r1.1735 -r1.1736 src/distrib/sets/lists/man/mi

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



CVS commit: src/distrib/sets/lists/man

2022-03-24 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Mar 24 14:04:28 UTC 2022

Modified Files:
src/distrib/sets/lists/man: mi

Log Message:
Add man page for Intel GPIO igpio.4


To generate a diff of this commit:
cvs rdiff -u -r1.1735 -r1.1736 src/distrib/sets/lists/man/mi

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

Modified files:

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1735 src/distrib/sets/lists/man/mi:1.1736
--- src/distrib/sets/lists/man/mi:1.1735	Thu Feb 24 03:35:33 2022
+++ src/distrib/sets/lists/man/mi	Thu Mar 24 14:04:28 2022
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1735 2022/02/24 03:35:33 mrg Exp $
+# $NetBSD: mi,v 1.1736 2022/03/24 14:04:28 manu Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7621,6 +7621,7 @@
 ./usr/share/man/man4/ifpci.4			man-obsolete		obsolete
 ./usr/share/man/man4/igmafb.4			man-sys-man		.man
 ./usr/share/man/man4/igphy.4			man-sys-man		.man
+./usr/share/man/man4/igpio.4			man-sys-man		.man
 ./usr/share/man/man4/igsfb.4			man-sys-man		.man
 ./usr/share/man/man4/iha.4			man-sys-man		.man
 ./usr/share/man/man4/ihidev.4			man-sys-man		.man



CVS commit: src/share/man/man4

2022-03-24 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Mar 24 14:00:19 UTC 2022

Modified Files:
src/share/man/man4: Makefile
Added Files:
src/share/man/man4: igpio.4

Log Message:
Add documentatiion for Intel GPIO driver igpio(4)


To generate a diff of this commit:
cvs rdiff -u -r1.722 -r1.723 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/igpio.4

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

Modified files:

Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.722 src/share/man/man4/Makefile:1.723
--- src/share/man/man4/Makefile:1.722	Mon Jan 17 16:31:23 2022
+++ src/share/man/man4/Makefile	Thu Mar 24 14:00:19 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.722 2022/01/17 16:31:23 thorpej Exp $
+#	$NetBSD: Makefile,v 1.723 2022/03/24 14:00:19 manu Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/18/93
 
 MAN=	aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -30,7 +30,7 @@ MAN=	aac.4 ac97.4 acardide.4 aceride.4 a
 	gpiosim.4 gre.4 gphyter.4 gsip.4 \
 	hdaudio.4 hifn.4 hme.4 hpacel.4 hpqlb.4 hptide.4 hvn.4 hythygtemp.4 \
 	iavf.4 ibmcd.4 ibmhawk.4 ichsmb.4 icmp.4 icp.4 icsphy.4 iee.4 \
-	ieee80211.4 ifmedia.4 igmafb.4 igphy.4 igsfb.4 iha.4 ihidev.4 \
+	ieee80211.4 ifmedia.4 igmafb.4 igphy.4 igpio.4 igsfb.4 iha.4 ihidev.4 \
 	ihphy.4 iic.4 ims.4 inet.4 ikphy.4 inphy.4 intersil7170.4 intro.4 \
 	ioasic.4 ioat.4 iop.4 iophy.4 iopsp.4 ip.4 ipgphy.4 ipmi.4 ipw.4 \
 	irmce.4 isp.4 ismt.4 isv.4 itesio.4 iteide.4 iwi.4 iwm.4 iwn.4 ixg.4 \

Added files:

Index: src/share/man/man4/igpio.4
diff -u /dev/null src/share/man/man4/igpio.4:1.1
--- /dev/null	Thu Mar 24 14:00:19 2022
+++ src/share/man/man4/igpio.4	Thu Mar 24 14:00:19 2022
@@ -0,0 +1,91 @@
+.\" $NetBSD: igpio.4,v 1.1 2022/03/24 14:00:19 manu Exp $
+.\"
+.\" Copyright (c) 2022 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Emmanuel Dreyfus.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd Mars 24, 2022
+.Dt IGPIO 4
+.Os
+.Sh NAME
+.Nm igpio
+.Nd Intel GPIO Controller
+.Sh SYNOPSIS
+.Cd "igpio* at acpi?"
+.Cd "gpio* at gpiobus?"
+.Sh DESCRIPTION
+.Nm
+provides a
+.Xr gpio 4
+interface for the following Intel chipsets:
+.Bl -tag -width autoselect -compact
+.It Alderlake
+.It Baytrail
+.It Cannonlake-H
+.It Cannonlake-LP
+.It Cedarfork
+.It Denverton
+.It Emmitsburg
+.It Geminilake
+.It Icelake
+.It Jasperlake
+.It Lakefield
+.It Lewisburg
+.It Lynxpoint
+.It Sunrisepoint-H
+.It Sunrisepoint-LP
+.It Tigerlake-H
+.It Tigerlake-LP
+.El
+Support for Broxton and Cherryview is not enabled yet.
+.Pp
+The driver supports
+.Dv GPIO_PIN_INPUT ,
+.Dv GPIO_PIN_OUTPUT ,
+.Dv GPIO_PIN_INOUT ,
+.Dv GPIO_PIN_ININ ,
+.Dv GPIO_PIN_PULLUP ,
+.Dv GPIO_PIN_PULLDOWN ,
+and interrupt capabilies
+.Dv GPIO_INTR_POS_EDGE ,
+.Dv GPIO_INTR_NEG_EDGE ,
+.Dv GPIO_INTR_DOUBLE_EDGE ,
+.Dv GPIO_INTR_HIGH_LEVEL ,
+.Dv GPIO_INTR_LOW_LEVEL .
+.Sh SEE ALSO
+.Xr gpio 4
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Nx 10.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver and man page was written by
+.An Emmanuel Dreyfus
+.Aq Mt m...@netbsd.org .



CVS commit: src/share/man/man4

2022-03-24 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Mar 24 14:00:19 UTC 2022

Modified Files:
src/share/man/man4: Makefile
Added Files:
src/share/man/man4: igpio.4

Log Message:
Add documentatiion for Intel GPIO driver igpio(4)


To generate a diff of this commit:
cvs rdiff -u -r1.722 -r1.723 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/igpio.4

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



CVS commit: src/sys

2022-03-23 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Mar 24 02:24:25 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: GENERIC
src/sys/conf: files
src/sys/dev/acpi: files.acpi
Added Files:
src/sys/dev/acpi: igpio_acpi.c
src/sys/dev/ic: igpio.c igpioreg.h igpiovar.h

Log Message:
Add initial support for Intel GPIO chips


To generate a diff of this commit:
cvs rdiff -u -r1.593 -r1.594 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.1295 -r1.1296 src/sys/conf/files
cvs rdiff -u -r1.124 -r1.125 src/sys/dev/acpi/files.acpi
cvs rdiff -u -r0 -r1.1 src/sys/dev/acpi/igpio_acpi.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/igpio.c src/sys/dev/ic/igpioreg.h \
src/sys/dev/ic/igpiovar.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/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.593 src/sys/arch/amd64/conf/GENERIC:1.594
--- src/sys/arch/amd64/conf/GENERIC:1.593	Sun Oct 31 00:31:48 2021
+++ src/sys/arch/amd64/conf/GENERIC	Thu Mar 24 02:24:24 2022
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.593 2021/10/31 00:31:48 simonb Exp $
+# $NetBSD: GENERIC,v 1.594 2022/03/24 02:24:24 manu 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.593 $"
+#ident		"GENERIC-$Revision: 1.594 $"
 
 maxusers	64		# estimated number of users
 
@@ -596,6 +596,9 @@ iic*		at dwiic?
 #sdtemp* at iic? addr 0x1e
 #sdtemp* at iic? addr 0x1f
 
+# Intel GPIO
+igpio* at acpi? 
+
 # I2C HID devices
 ihidev* at iic?
 

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1295 src/sys/conf/files:1.1296
--- src/sys/conf/files:1.1295	Wed Feb 16 20:14:30 2022
+++ src/sys/conf/files	Thu Mar 24 02:24:24 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1295 2022/02/16 20:14:30 riastradh Exp $
+#	$NetBSD: files,v 1.1296 2022/03/24 02:24:24 manu Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20171118
@@ -1357,6 +1357,10 @@ file	dev/ic/pl061.c			plgpio
 device	plmmc: sdmmcbus
 file	dev/ic/pl181.c			plmmc
 
+# Intel GPIO
+device	igpio: gpiobus
+file	dev/ic/igpio.c			igpio
+
 # Myson MTD803 3-in-1 Fast Ethernet Controller
 device	mtd: arp, ether, ifnet, mii
 file	dev/ic/mtd803.c			mtd

Index: src/sys/dev/acpi/files.acpi
diff -u src/sys/dev/acpi/files.acpi:1.124 src/sys/dev/acpi/files.acpi:1.125
--- src/sys/dev/acpi/files.acpi:1.124	Wed Feb 16 20:14:30 2022
+++ src/sys/dev/acpi/files.acpi	Thu Mar 24 02:24:25 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.acpi,v 1.124 2022/02/16 20:14:30 riastradh Exp $
+#	$NetBSD: files.acpi,v 1.125 2022/03/24 02:24:25 manu Exp $
 
 defflag	opt_acpi.h	ACPIVERBOSE ACPI_DEBUG ACPI_ACTIVATE_DEV
 			ACPI_DSDT_OVERRIDE ACPI_SCANPCI ACPI_BREAKPOINT
@@ -300,6 +300,10 @@ file	dev/acpi/genet_acpi.c		genet_acpi
 attach	eqos at acpinodebus with eqos_acpi
 file	dev/acpi/eqos_acpi.c		eqos_acpi
 
+# Intel GPIO
+attach	igpio at acpinodebus with igpio_acpi
+file	dev/acpi/igpio_acpi.c		igpio_acpi
+
 # DesignWare Mobile Storage Host Controller
 attach	dwcmmc at acpinodebus with dwcmmc_acpi
 file	dev/acpi/dwcmmc_acpi.c		dwcmmc_acpi

Added files:

Index: src/sys/dev/acpi/igpio_acpi.c
diff -u /dev/null src/sys/dev/acpi/igpio_acpi.c:1.1
--- /dev/null	Thu Mar 24 02:24:25 2022
+++ src/sys/dev/acpi/igpio_acpi.c	Thu Mar 24 02:24:25 2022
@@ -0,0 +1,237 @@
+/* $NetBSD: igpio_acpi.c,v 1.1 2022/03/24 02:24:25 manu Exp $ */
+
+/*-
+ * Copyright (c) 2021,2022 Emmanuel Dreyfus
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAM

CVS commit: src/sys

2022-03-23 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Mar 24 02:24:25 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: GENERIC
src/sys/conf: files
src/sys/dev/acpi: files.acpi
Added Files:
src/sys/dev/acpi: igpio_acpi.c
src/sys/dev/ic: igpio.c igpioreg.h igpiovar.h

Log Message:
Add initial support for Intel GPIO chips


To generate a diff of this commit:
cvs rdiff -u -r1.593 -r1.594 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.1295 -r1.1296 src/sys/conf/files
cvs rdiff -u -r1.124 -r1.125 src/sys/dev/acpi/files.acpi
cvs rdiff -u -r0 -r1.1 src/sys/dev/acpi/igpio_acpi.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/igpio.c src/sys/dev/ic/igpioreg.h \
src/sys/dev/ic/igpiovar.h

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



Re: CVS commit: src/sys/arch/i386/stand/efiboot

2021-12-27 Thread Emmanuel Dreyfus
On Mon, Dec 27, 2021 at 10:54:13PM +1100, Simon Burge wrote:
> If you have a way of preproducing this, I'm happy to have a look.

I recall it now.
In src/sys/arch/i386/stand/efiboot/devopen.c
bios2dev(boot_biosdev, boot_biossector, &devname, &unit,
   &partition, NULL);

In the same file, bios2dev() passes NULL part_name to biosdisk_findpartition()
void
bios2dev(int biosdev, daddr_t sector, char **devname, int *unit,
 int *partition, const char **part_name) 
{
(...)
(void)biosdisk_findpartition(biosdev, sector, partition, part_name);

In src/sys/arch/i386/stand/lib/biosdisk.c
int
biosdisk_findpartition(int biosdev, daddr_t sector,
   int *partition, const char **part_name)
{
(...)
/* default ot first partition */
*partition = 0;
*part_name = NULL;

part_name is NULL, *part_name crashes. How do you avoid that?

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


Re: CVS commit: src/sys/arch/i386/stand/efiboot

2021-12-26 Thread Emmanuel Dreyfus
On Mon, Dec 27, 2021 at 01:08:15PM +1100, Simon Burge wrote:
> What crash did this fix?  All the use of part_name by the
> called functions should check if it is NULL before trying
> to assign anything to *part_name.

I do not recall the details now, but I had a crash because
of this. Please revert my change, I will get back to it when
I find some time.

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


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

2021-11-18 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Nov 18 16:18:13 UTC 2021

Modified Files:
src/sys/arch/i386/stand/efiboot: devopen.c

Log Message:
Fix crash because of NULL pointer reference


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/devopen.c

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/devopen.c
diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.11 src/sys/arch/i386/stand/efiboot/devopen.c:1.12
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.11	Sat Jan 18 19:25:58 2020
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Thu Nov 18 16:18:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.11 2020/01/18 19:25:58 nonaka Exp $	 */
+/*	$NetBSD: devopen.c,v 1.12 2021/11/18 16:18:13 manu Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -288,8 +288,9 @@ neterr:
 	 * biosdisk
 	 */
 	if (strcmp(devname, "esp") == 0) {
+		const char *part_name = NULL;
 		bios2dev(boot_biosdev, boot_biossector, &devname, &unit,
-		&partition, NULL);
+		&partition, &part_name);
 		if (efidisk_get_efi_system_partition(boot_biosdev, &partition))
 			return ENXIO;
 	}



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

2021-11-18 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Nov 18 16:18:13 UTC 2021

Modified Files:
src/sys/arch/i386/stand/efiboot: devopen.c

Log Message:
Fix crash because of NULL pointer reference


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/devopen.c

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



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

2021-11-18 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Nov 18 16:17:41 UTC 2021

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot

Log Message:
Do not pass BIOS geometry when booting using EFI

Recent Mac return garbage data that will crash the code handling it,
and EFI boot does not need it anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/stand/efiboot/Makefile.efiboot

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



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

2021-11-18 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Nov 18 16:17:41 UTC 2021

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot

Log Message:
Do not pass BIOS geometry when booting using EFI

Recent Mac return garbage data that will crash the code handling it,
and EFI boot does not need it anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/stand/efiboot/Makefile.efiboot

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.18 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.18	Sun Sep  6 07:20:29 2020
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Thu Nov 18 16:17:40 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.18 2020/09/06 07:20:29 mrg Exp $
+# $NetBSD: Makefile.efiboot,v 1.19 2021/11/18 16:17:40 manu Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -66,7 +66,8 @@ CPPFLAGS+= -DSUPPORT_BOOTP
 CPPFLAGS+= -DSUPPORT_DHCP
 CPPFLAGS+= -DSUPPORT_NFS
 CPPFLAGS+= -DSUPPORT_TFTP
-CPPFLAGS+= -DPASS_BIOSGEOM
+# Recent macs report garbage geometry
+#CPPFLAGS+= -DPASS_BIOSGEOM
 CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048	# for bootinfo_biosgeom.c
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 



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

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

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

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


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

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

Modified files:

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

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

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

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

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


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

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



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

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

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

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

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


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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

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


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

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

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

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


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


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

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

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

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

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

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

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

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


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

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

What are the actual drawbacks? 

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

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


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

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

Please try the attached patch.

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

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

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

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

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

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

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

What is the backtace? Does it goes through svs_init?

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


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

2019-12-25 Thread Emmanuel Dreyfus
On Wed, Dec 25, 2019 at 07:42:47PM +0900, Ryo ONODERA wrote:
> The attached patch works for me.
> However I have no idea about the meaning.

It changes the multiboot section from DATA to CODE, which is
odd but perfectly fine. I cannot understand how it can change
the situation, though. Did it really fix the problem? Your 
next message about reverted kern.ldscript  confuses me.

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


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

2019-12-24 Thread Emmanuel Dreyfus
On Tue, Dec 24, 2019 at 05:50:00PM +0900, Ryo ONODERA wrote:
> After this change, amd64 kernel does not boot on my HP Spectre x360
> 13-inch ae019TU laptop with pure UEFI boot mode.

Hello

Does the attached patch (crafted for port-amd64/54775) fix the
problem?

-- 
Emmanuel Dreyfus
m...@netbsd.org
Index: sys/arch/amd64/amd64/locore.S
===
RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v
retrieving revision 1.195
diff -U4 -r1.195 locore.S
--- sys/arch/amd64/amd64/locore.S   15 Dec 2019 02:58:21 -  1.195
+++ sys/arch/amd64/amd64/locore.S   22 Dec 2019 02:23:11 -
@@ -432,10 +432,10 @@
.space  512
 tmpstk:
 
 .section multiboot,"a"
-#if defined(MULTIBOOT)
.align  8
+#if defined(MULTIBOOT)
.globl  Multiboot2_Header
 _C_LABEL(Multiboot2_Header):
.intMULTIBOOT2_HEADER_MAGIC
.intMULTIBOOT2_ARCHITECTURE_I386
@@ -473,8 +473,11 @@
.int8   /* sizeof(struct multiboot_tag) */
.align  8
.globl  Multiboot2_Header_end
 _C_LABEL(Multiboot2_Header_end):
+#else /* MULTIBOOT */
+   .int0xdeadbeef  /* have some non empty content */
+   .align  8
 #endif /* MULTIBOOT */
 
 /*
  * Some hackage to deal with 64bit symbols in 32 bit mode.


Re: CVS commit: src/sys/arch (multiboot2 support)

2019-12-10 Thread Emmanuel Dreyfus
Paul Goyette  wrote:

> This commit seems to have broken amd64 booting!  When booting into
> a qemu environment (as set up by misc/py-anita), it just hangs while
> printing the "progress numbers with the spinny cursor".  Others on
> irc/icb have indicated an immediate crash.

I rolled back the change to sys/arch/amd64/conf/kern.ldscript, this
should fix BIOS boot. 

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


Re: CVS commit: src/sys/arch (multiboot2 support)

2019-12-10 Thread Emmanuel Dreyfus
Paul Goyette  wrote:

> This commit seems to have broken amd64 booting!  When booting into
> a qemu environment (as set up by misc/py-anita), it just hangs while
> printing the "progress numbers with the spinny cursor".  Others on
> irc/icb have indicated an immediate crash.
> 
> Seems like non-efi booting is borked.

This is caused by sys/arch/amd64/conf/kern.ldscript  1.27-1.28
I will fix that within a few hours.

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


CVS commit: src/sys/arch

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

Modified Files:
src/sys/arch/i386/conf: files.i386
src/sys/arch/i386/i386: locore.S machdep.c multiboot.c
src/sys/arch/i386/include: multiboot.h
Added Files:
src/sys/arch/x86/x86: multiboot2.c

Log Message:
Multiboot2 kernel support for i386

That implementation works either with BIOS or UEFI bootstrap

This requires the following kernel changes:

Add UEFI boot services and I/O method protoypes
src/sys/arch/x86/include/efi.h 1.8 - 1.9

Fix EFI system table mapping in virtual space
src/sys/arch/x86/x86/efi.c 1.19 - 1.20

Make sure no bioscall is issued when booting off UEFI system
src/sys/arch/i386/i386/machdep.c 1.821 - 1.822
src/sys/arch/i386/pci/piixpcib.c 1.22 - 1.23

And the following bootstrap changes:

Add kernel symbols for multiboot1
src/sys/arch/i386/stand/lib/exec_multiboot1.c 1.2 - 1.3
src/sys/arch/i386/stand/lib/libi386.h 1.45 - 1.47

Fix kernel symbols for multiboot2
src/sys/arch/i386/stand/lib/exec_multiboot2.c 1.2 - 1.3


To generate a diff of this commit:
cvs rdiff -u -r1.400 -r1.401 src/sys/arch/i386/conf/files.i386
cvs rdiff -u -r1.172 -r1.173 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.822 -r1.823 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/i386/multiboot.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/include/multiboot.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/x86/multiboot2.c

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



CVS commit: src/sys/arch

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

Modified Files:
src/sys/arch/i386/conf: files.i386
src/sys/arch/i386/i386: locore.S machdep.c multiboot.c
src/sys/arch/i386/include: multiboot.h
Added Files:
src/sys/arch/x86/x86: multiboot2.c

Log Message:
Multiboot2 kernel support for i386

That implementation works either with BIOS or UEFI bootstrap

This requires the following kernel changes:

Add UEFI boot services and I/O method protoypes
src/sys/arch/x86/include/efi.h 1.8 - 1.9

Fix EFI system table mapping in virtual space
src/sys/arch/x86/x86/efi.c 1.19 - 1.20

Make sure no bioscall is issued when booting off UEFI system
src/sys/arch/i386/i386/machdep.c 1.821 - 1.822
src/sys/arch/i386/pci/piixpcib.c 1.22 - 1.23

And the following bootstrap changes:

Add kernel symbols for multiboot1
src/sys/arch/i386/stand/lib/exec_multiboot1.c 1.2 - 1.3
src/sys/arch/i386/stand/lib/libi386.h 1.45 - 1.47

Fix kernel symbols for multiboot2
src/sys/arch/i386/stand/lib/exec_multiboot2.c 1.2 - 1.3


To generate a diff of this commit:
cvs rdiff -u -r1.400 -r1.401 src/sys/arch/i386/conf/files.i386
cvs rdiff -u -r1.172 -r1.173 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.822 -r1.823 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/i386/multiboot.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/include/multiboot.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/x86/multiboot2.c

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

Modified files:

Index: src/sys/arch/i386/conf/files.i386
diff -u src/sys/arch/i386/conf/files.i386:1.400 src/sys/arch/i386/conf/files.i386:1.401
--- src/sys/arch/i386/conf/files.i386:1.400	Fri Feb 15 08:54:01 2019
+++ src/sys/arch/i386/conf/files.i386	Fri Oct 18 01:38:28 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i386,v 1.400 2019/02/15 08:54:01 nonaka Exp $
+#	$NetBSD: files.i386,v 1.401 2019/10/18 01:38:28 manu Exp $
 #
 # new style config file for i386 architecture
 #
@@ -51,6 +51,7 @@ defparam 	opt_beep.h		BEEP_ONHALT_PERIOD
 defflag 	opt_multiboot.h		MULTIBOOT
 obsolete 	defparam		MULTIBOOT_SYMTAB_SPACE
 file 	arch/i386/i386/multiboot.c	multiboot
+file 	arch/x86/x86/multiboot2.c	multiboot
 
 file	arch/i386/i386/autoconf.c
 file	arch/i386/i386/aout_machdep.c	exec_aout

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.172 src/sys/arch/i386/i386/locore.S:1.173
--- src/sys/arch/i386/i386/locore.S:1.172	Sat Oct 12 06:31:03 2019
+++ src/sys/arch/i386/i386/locore.S	Fri Oct 18 01:38:28 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.172 2019/10/12 06:31:03 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.173 2019/10/18 01:38:28 manu Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.172 2019/10/12 06:31:03 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.173 2019/10/18 01:38:28 manu Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -346,12 +346,52 @@ _C_LABEL(Multiboot_Header):
 	.long	MULTIBOOT_HEADER_FLAGS
 	.long	-(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
 
+	.align	8
+	.globl	Multiboot2_Header
+_C_LABEL(Multiboot2_Header):
+	.long	MULTIBOOT2_HEADER_MAGIC
+	.long	MULTIBOOT2_ARCHITECTURE_I386
+	.long	Multiboot2_Header_end - Multiboot2_Header
+	.long	-(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \
+		+ (Multiboot2_Header_end - Multiboot2_Header))
+
+	.long	1	/* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */
+	.long	12	/* sizeof(multiboot_header_tag_information_request) */
+			/* + sizeof(uint32_t) * requests */
+	.long	4	/* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */
+	.long	0	/* pad for 8 bytes alignment */
+
+	.long	8	/* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 */
+	.long	12	/* sizeof(struct multiboot_tag_efi32) */
+	.long	efi_multiboot2_loader - KERNBASE
+	.long   0	/* pad for 8 bytes alignment */
+
+#if notyet 
+	/* 
+	 * Could be used to get an early console for debug,
+	 * but this is broken.
+	 */
+	.long	7	/* MULTIBOOT_HEADER_TAG_EFI_BS */
+	.long	8	/* sizeof(struct multiboot_tag) */
+#endif
+
+	.long	0	/* MULTIBOOT_HEADER_TAG_END */
+	.long	8	/* sizeof(struct multiboot_tag) */
+	.globl	Multiboot2_Header_end
+_C_LABEL(Multiboot2_Header_end):
+
 1:
 	/* Check if we are being executed by a Multiboot-compliant boot
 	 * loader. */
 	cmpl	$MULTIBOOT_INFO_MAGIC,%eax
-	jne	1f
+	je	multiboot1_loader
+
+	cmpl	$MULTIBOOT2_BOOTLOADER_MAGIC,%eax
+	je	multiboot2_loader
 
+	jmp	1f
+
+multiboot1_loader:
 	/*
 	 * Indeed, a multiboot-compliant boot loader executed us. We switch
 	 * to the temporary stack, and copy the received Multiboot information
@@ -361,10 +401,187 @@ _C_LABEL(Multiboot_Header):
 	 */
 	movl	$_RELOC(tmpstk),%esp
 	pushl	%ebx		/* Address of Multiboot information */
-	call	_C_LABEL(multiboot_pre_reloc)
+	call	_C_LABEL(multiboot1_pre_reloc)
 	addl	$4,%esp
 	jmp	2f
+
+efi_multiboot2_loader:
+	/*
+	 * EFI32 multiboot2 entry poin

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

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

Modified Files:
src/sys/arch/i386/stand/lib: libi386.h

Log Message:
Remove prototype added twice by mistake


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/i386/stand/lib/libi386.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/i386/stand/lib/libi386.h
diff -u src/sys/arch/i386/stand/lib/libi386.h:1.46 src/sys/arch/i386/stand/lib/libi386.h:1.47
--- src/sys/arch/i386/stand/lib/libi386.h:1.46	Fri Oct 18 01:09:46 2019
+++ src/sys/arch/i386/stand/lib/libi386.h	Fri Oct 18 01:24:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: libi386.h,v 1.46 2019/10/18 01:09:46 manu Exp $	*/
+/*	$NetBSD: libi386.h,v 1.47 2019/10/18 01:24:51 manu Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -173,6 +173,4 @@ void framebuffer_configure(struct btinfo
 
 void ksyms_addr_set(void *, void *, void *);
 
-void ksyms_addr_set(void *, void *, void *);
-
 #endif	/* __I386_STAND_LIBI386_H__ */



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

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

Modified Files:
src/sys/arch/i386/stand/lib: libi386.h

Log Message:
Remove prototype added twice by mistake


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/i386/stand/lib/libi386.h

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



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

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

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

Log Message:
Fix multiboot1 kernel symbol load

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


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

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

Modified files:

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



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

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

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

Log Message:
Fix multiboot1 kernel symbol load

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


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

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



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

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

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot2.c

Log Message:
Fix kernel symbols for multiboot2

Previous version just provided the ELF section table, which is correct
as far as the multiboot 2 specification is concerned.

But in order to retreive kernel symboles, the NetBSD kernelneeds symbol
table and string table sections to be loaded in memory, and have an
address set in the section table.

Requires change: Add kernel symbols for multiboot1
src/sys/arch/i386/stand/lib/exec_multiboot1.c 1.2 - 1.3
src/sys/arch/i386/stand/lib/libi386.h 1.45 - 1.46


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/lib/exec_multiboot2.c

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



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

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

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot2.c

Log Message:
Fix kernel symbols for multiboot2

Previous version just provided the ELF section table, which is correct
as far as the multiboot 2 specification is concerned.

But in order to retreive kernel symboles, the NetBSD kernelneeds symbol
table and string table sections to be loaded in memory, and have an
address set in the section table.

Requires change: Add kernel symbols for multiboot1
src/sys/arch/i386/stand/lib/exec_multiboot1.c 1.2 - 1.3
src/sys/arch/i386/stand/lib/libi386.h 1.45 - 1.46


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/lib/exec_multiboot2.c

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

Modified files:

Index: src/sys/arch/i386/stand/lib/exec_multiboot2.c
diff -u src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.2 src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.3
--- src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.2	Sun Sep 15 23:55:26 2019
+++ src/sys/arch/i386/stand/lib/exec_multiboot2.c	Fri Oct 18 01:15:54 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_multiboot2.c,v 1.2 2019/09/15 23:55:26 manu Exp $ */
+/* $NetBSD: exec_multiboot2.c,v 1.3 2019/10/18 01:15:54 manu Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -976,9 +976,10 @@ mbi_elf_sections(struct multiboot_packag
 	size_t len = 0;
 	struct multiboot_tag_elf_sections *mbt = buf;
 	Elf_Ehdr ehdr;
+	int class;
 	Elf32_Ehdr *ehdr32 = NULL;
 	Elf64_Ehdr *ehdr64 = NULL;
-	uint32_t shnum, shentsize, shstrndx, shoff;
+	uint64_t shnum, shentsize, shstrndx, shoff;
 	size_t shdr_len;
 
 	if (mbp->mbp_marks[MARK_SYM] == 0)
@@ -992,7 +993,9 @@ mbi_elf_sections(struct multiboot_packag
 	if (memcmp(&ehdr.e_ident, ELFMAG, SELFMAG) != 0)
 		goto out;
 
-	switch (ehdr.e_ident[EI_CLASS]) {
+	class = ehdr.e_ident[EI_CLASS];
+
+	switch (class) {
 	case ELFCLASS32:
 		ehdr32 = (Elf32_Ehdr *)&ehdr;
 		shnum = ehdr32->e_shnum;
@@ -1017,8 +1020,7 @@ mbi_elf_sections(struct multiboot_packag
 
 	len = sizeof(*mbt) + shdr_len;
 	if (mbt) {
-		int fd = -1;
-		int ret = -1;
+		char *shdr = (char *)mbp->mbp_marks[MARK_SYM] + shoff;
 
 		mbt->type = MULTIBOOT_TAG_TYPE_ELF_SECTIONS;
 		mbt->size = len;
@@ -1026,26 +1028,16 @@ mbi_elf_sections(struct multiboot_packag
 		mbt->entsize = shentsize;
 		mbt->shndx = shstrndx;
 		
-		if ((fd = open(mbp->mbp_file, 0)) == -1)
-			goto out_read;
-
-		if (lseek(fd, shoff, SEEK_SET) != shoff)
-			goto out_read;
- 
-		if (read(fd, mbt + 1,  shdr_len) != shdr_len)
-			goto out_read;
+		pvbcopy((void *)shdr, mbt + 1, shdr_len);
 
-		ret = 0;
-out_read:
-		if (fd != -1)
-			close(fd);
-
-		if (ret != 0) {
-			printf("Error reading ELF sections from %s\n",
-			mbp->mbp_file);
-			len = 0;
-		}
+		/*
+		 * Adjust sh_addr for symtab and strtab
+		 * section that have been loaded.
+		 */
+		ksyms_addr_set(&ehdr, mbt + 1,
+		(void *)mbp->mbp_marks[MARK_SYM]);
 	}
+
 out:
 	return roundup(len, MULTIBOOT_TAG_ALIGN);
 }



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

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

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot1.c libi386.h

Log Message:
Add kernel symbols for multiboot1


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/lib/exec_multiboot1.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/i386/stand/lib/libi386.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/i386/stand/lib/exec_multiboot1.c
diff -u src/sys/arch/i386/stand/lib/exec_multiboot1.c:1.2 src/sys/arch/i386/stand/lib/exec_multiboot1.c:1.3
--- src/sys/arch/i386/stand/lib/exec_multiboot1.c:1.2	Fri Oct 18 01:04:24 2019
+++ src/sys/arch/i386/stand/lib/exec_multiboot1.c	Fri Oct 18 01:09:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_multiboot1.c,v 1.2 2019/10/18 01:04:24 manu Exp $ */
+/* $NetBSD: exec_multiboot1.c,v 1.3 2019/10/18 01:09:46 manu Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -42,6 +42,80 @@
 
 extern struct btinfo_modulelist *btinfo_modulelist;
 
+void
+ksyms_addr_set(void *ehdr, void *shdr, void *symbase)
+{
+	int class;
+	Elf32_Ehdr *ehdr32 = NULL;
+	Elf64_Ehdr *ehdr64 = NULL;
+	uint64_t shnum;
+	int i;
+
+	class = ((Elf_Ehdr *)ehdr)->e_ident[EI_CLASS];
+
+switch (class) {
+case ELFCLASS32: 
+ehdr32 = (Elf32_Ehdr *)ehdr;
+shnum = ehdr32->e_shnum;
+break;
+case ELFCLASS64:
+ehdr64 = (Elf64_Ehdr *)ehdr;
+shnum = ehdr64->e_shnum;
+break;
+default:
+		panic("Unexpected ELF class");
+		break;
+}
+
+	for (i = 0; i < shnum; i++) {
+		Elf64_Shdr *shdrp64 = NULL;
+		Elf32_Shdr *shdrp32 = NULL;
+		uint64_t shtype, shaddr, shsize, shoffset;
+
+		switch(class) {
+		case ELFCLASS64:
+			shdrp64 = &((Elf64_Shdr *)shdr)[i];	
+			shtype = shdrp64->sh_type;
+			shaddr = shdrp64->sh_addr;
+			shsize = shdrp64->sh_size;
+			shoffset = shdrp64->sh_offset;
+			break;
+		case ELFCLASS32:
+			shdrp32 = &((Elf32_Shdr *)shdr)[i];	
+			shtype = shdrp32->sh_type;
+			shaddr = shdrp32->sh_addr;
+			shsize = shdrp32->sh_size;
+			shoffset = shdrp32->sh_offset;
+			break;
+		default:
+			panic("Unexpected ELF class");
+			break;
+		}
+
+		if (shtype != SHT_SYMTAB && shtype != SHT_STRTAB)
+			continue;
+
+		if (shaddr != 0 || shsize == 0)
+			continue;
+
+		shaddr = (uint64_t)(uintptr_t)(symbase + shoffset);
+
+		switch(class) {
+		case ELFCLASS64:
+			shdrp64->sh_addr = shaddr;
+			break;
+		case ELFCLASS32:
+			shdrp32->sh_addr = shaddr;
+			break;
+		default:
+			panic("Unexpected ELF class");
+			break;
+		}
+	}
+
+	return;
+}
+
 static int
 exec_multiboot1(struct multiboot_package *mbp)
 {
@@ -85,6 +159,38 @@ exec_multiboot1(struct multiboot_package
 		mbi->mi_mods_addr = vtophys(mbm);
 	}
 
+	if (mbp->mbp_marks[MARK_SYM] != 0) {
+		Elf32_Ehdr ehdr;
+		void *shbuf;
+		size_t shlen;
+		u_long shaddr;
+
+		pvbcopy((void *)mbp->mbp_marks[MARK_SYM], &ehdr, sizeof(ehdr));
+
+		if (memcmp(&ehdr.e_ident, ELFMAG, SELFMAG) != 0)
+			goto skip_ksyms;
+
+		shaddr = mbp->mbp_marks[MARK_SYM] + ehdr.e_shoff;
+
+		shlen = ehdr.e_shnum * ehdr.e_shentsize;
+		shbuf = alloc(shlen);
+
+		pvbcopy((void *)shaddr, shbuf, shlen);
+		ksyms_addr_set(&ehdr, shbuf,
+		(void *)(KERNBASE + mbp->mbp_marks[MARK_SYM]));
+		vpbcopy(shbuf, (void *)shaddr, shlen);
+
+		dealloc(shbuf, shlen);
+
+		mbi->mi_elfshdr_num = ehdr.e_shnum;
+		mbi->mi_elfshdr_size = ehdr.e_shentsize;
+		mbi->mi_elfshdr_addr = shaddr;
+		mbi->mi_elfshdr_shndx = ehdr.e_shstrndx;
+
+		mbi->mi_flags |= MULTIBOOT_INFO_HAS_ELF_SYMS;
+	}
+skip_ksyms:
+
 #ifdef DEBUG
 	printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n",
 	mbp->mbp_marks[MARK_ENTRY],

Index: src/sys/arch/i386/stand/lib/libi386.h
diff -u src/sys/arch/i386/stand/lib/libi386.h:1.45 src/sys/arch/i386/stand/lib/libi386.h:1.46
--- src/sys/arch/i386/stand/lib/libi386.h:1.45	Fri Sep 13 02:19:46 2019
+++ src/sys/arch/i386/stand/lib/libi386.h	Fri Oct 18 01:09:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: libi386.h,v 1.45 2019/09/13 02:19:46 manu Exp $	*/
+/*	$NetBSD: libi386.h,v 1.46 2019/10/18 01:09:46 manu Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -171,4 +171,8 @@ void module_add_split(const char *, uint
 struct btinfo_framebuffer;
 void framebuffer_configure(struct btinfo_framebuffer *);
 
+void ksyms_addr_set(void *, void *, void *);
+
+void ksyms_addr_set(void *, void *, void *);
+
 #endif	/* __I386_STAND_LIBI386_H__ */



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

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

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot1.c libi386.h

Log Message:
Add kernel symbols for multiboot1


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/lib/exec_multiboot1.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/i386/stand/lib/libi386.h

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



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

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

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot1.c

Log Message:
Fix multiboot1 header detection

Specification states it must be must be longword (32-bit) aligned


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/lib/exec_multiboot1.c

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

Modified files:

Index: src/sys/arch/i386/stand/lib/exec_multiboot1.c
diff -u src/sys/arch/i386/stand/lib/exec_multiboot1.c:1.1 src/sys/arch/i386/stand/lib/exec_multiboot1.c:1.2
--- src/sys/arch/i386/stand/lib/exec_multiboot1.c:1.1	Fri Sep 13 02:19:46 2019
+++ src/sys/arch/i386/stand/lib/exec_multiboot1.c	Fri Oct 18 01:04:24 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_multiboot1.c,v 1.1 2019/09/13 02:19:46 manu Exp $ */
+/* $NetBSD: exec_multiboot1.c,v 1.2 2019/10/18 01:04:24 manu Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -126,7 +126,7 @@ probe_multiboot1(const char *path)
 	if (readen < sizeof(struct multiboot_header))
 		goto out;
 
-	for (i = 0; i < readen; i += 8) {
+	for (i = 0; i < readen; i += 4) {
 		struct multiboot_header *mbh;
 
 		mbh = (struct multiboot_header *)(buf + i);



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

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

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot1.c

Log Message:
Fix multiboot1 header detection

Specification states it must be must be longword (32-bit) aligned


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/lib/exec_multiboot1.c

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



CVS commit: src/sys/arch/i386

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

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

Log Message:
Make sure no bioscall is issued when booting off UEFI system


To generate a diff of this commit:
cvs rdiff -u -r1.821 -r1.822 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/i386/pci/piixpcib.c

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



CVS commit: src/sys/arch/i386

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

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

Log Message:
Make sure no bioscall is issued when booting off UEFI system


To generate a diff of this commit:
cvs rdiff -u -r1.821 -r1.822 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/i386/pci/piixpcib.c

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

Modified files:

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.821 src/sys/arch/i386/i386/machdep.c:1.822
--- src/sys/arch/i386/i386/machdep.c:1.821	Sat Oct 12 06:31:03 2019
+++ src/sys/arch/i386/i386/machdep.c	Fri Oct 18 01:00:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.821 2019/10/12 06:31:03 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.822 2019/10/18 01:00:24 manu Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.821 2019/10/12 06:31:03 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.822 2019/10/18 01:00:24 manu Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -119,6 +119,8 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -1368,10 +1370,15 @@ init386(paddr_t first_avail)
 	init386_ksyms();
 
 #if NMCA > 0
-	/* check for MCA bus, needed to be done before ISA stuff - if
+	/* 
+	 * check for MCA bus, needed to be done before ISA stuff - if
 	 * MCA is detected, ISA needs to use level triggered interrupts
-	 * by default */
-	mca_busprobe();
+	 * by default
+	 * And we do not search for MCA using bioscall() on EFI systems
+	 * that lacks it (they lack MCA too, anyway).
+	 */
+	if (lookup_bootinfo(BTINFO_EFI) == NULL)
+		mca_busprobe();
 #endif
 
 #ifdef XENPV

Index: src/sys/arch/i386/pci/piixpcib.c
diff -u src/sys/arch/i386/pci/piixpcib.c:1.22 src/sys/arch/i386/pci/piixpcib.c:1.23
--- src/sys/arch/i386/pci/piixpcib.c:1.22	Mon Jul 11 11:31:49 2016
+++ src/sys/arch/i386/pci/piixpcib.c	Fri Oct 18 01:00:25 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpcib.c,v 1.22 2016/07/11 11:31:49 msaitoh Exp $ */
+/* $NetBSD: piixpcib.c,v 1.23 2019/10/18 01:00:25 manu Exp $ */
 
 /*-
  * Copyright (c) 2004, 2006 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: piixpcib.c,v 1.22 2016/07/11 11:31:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpcib.c,v 1.23 2019/10/18 01:00:25 manu Exp $");
 
 #include 
 #include 
@@ -195,6 +195,12 @@ piixpcib_int15_gsic_call(int *sig, int *
 {
 	struct bioscallregs regs;
 
+	/* No bioscall with EFI */
+	if (lookup_bootinfo(BTINFO_EFI) != NULL) {
+		*sig = *smicmd = *cmd = *smidata = *flags = -1;
+		return;
+	}
+		
 	memset(®s, 0, sizeof(struct bioscallregs));
 	regs.EAX = 0xe980;	/* IST support */
 	regs.EDX = PIIXPCIB_GSIC;



CVS commit: src/sys/arch/x86/x86

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

Modified Files:
src/sys/arch/x86/x86: efi.c

Log Message:
Fix EFI system table mapping in virtual space

Previous version was annoted as untested, and indeed it did not work.
New version uses the same approach as for ACPI table mapping.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/x86/efi.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/x86/x86/efi.c
diff -u src/sys/arch/x86/x86/efi.c:1.19 src/sys/arch/x86/x86/efi.c:1.20
--- src/sys/arch/x86/x86/efi.c:1.19	Mon Dec  3 19:46:43 2018
+++ src/sys/arch/x86/x86/efi.c	Fri Oct 18 00:56:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efi.c,v 1.19 2018/12/03 19:46:43 cherry Exp $	*/
+/*	$NetBSD: efi.c,v 1.20 2019/10/18 00:56:25 manu Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.19 2018/12/03 19:46:43 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.20 2019/10/18 00:56:25 manu Exp $");
 
 #include 
 #include 
@@ -37,6 +37,8 @@ __KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.19
 #include 
 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -73,21 +75,19 @@ static vaddr_t
 efi_getva(paddr_t pa)
 {
 	vaddr_t va;
+	int rv;
 
 #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
 	if (mm_md_direct_mapped_phys(pa, &va))
 		return va;
 #endif
 
-	/* XXX This code path is not tested. */
-	va = uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
-	UVM_KMF_VAONLY | UVM_KMF_WAITVA);
-	if (va == 0) {
+	rv = _x86_memio_map(x86_bus_space_mem, pa, 
+	PAGE_SIZE, 0, (bus_space_handle_t *)&va);   
+	if (rv != 0) {
 		aprint_debug("efi: unable to allocate va\n");
 		return 0;
 	}
-	pmap_kenter_pa(va, pa, VM_PROT_READ, 0);
-	pmap_update(pmap_kernel());
 
 	return va;
 }
@@ -107,10 +107,8 @@ efi_relva(paddr_t pa, vaddr_t va)
 	}
 #endif
 
-	/* XXX This code path is not tested. */
-	pmap_kremove(va, PAGE_SIZE);
-	pmap_update(pmap_kernel());
-	uvm_km_free(kernel_map, va, PAGE_SIZE, UVM_KMF_VAONLY);
+	(void)_x86_memio_unmap(x86_bus_space_mem, (bus_space_handle_t)va,
+	PAGE_SIZE, NULL);
 }
 
 /*



CVS commit: src/sys/arch/x86/x86

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

Modified Files:
src/sys/arch/x86/x86: efi.c

Log Message:
Fix EFI system table mapping in virtual space

Previous version was annoted as untested, and indeed it did not work.
New version uses the same approach as for ACPI table mapping.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/x86/efi.c

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



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

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

Modified Files:
src/sys/arch/x86/include: efi.h

Log Message:
Add UEFI boot services and I/O method protoypes


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/include/efi.h

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



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

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

Modified Files:
src/sys/arch/x86/include: efi.h

Log Message:
Add UEFI boot services and I/O method protoypes


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/include/efi.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/x86/include/efi.h
diff -u src/sys/arch/x86/include/efi.h:1.8 src/sys/arch/x86/include/efi.h:1.9
--- src/sys/arch/x86/include/efi.h:1.8	Sun Oct 22 00:59:28 2017
+++ src/sys/arch/x86/include/efi.h	Fri Oct 18 00:54:48 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: efi.h,v 1.8 2017/10/22 00:59:28 maya Exp $   */
+/* $NetBSD: efi.h,v 1.9 2019/10/18 00:54:48 manu Exp $   */
 
 /*-
  * Copyright (c) 2004 Marcel Moolenaar
@@ -63,6 +63,12 @@ enum efi_reset {
 typedef uint16_t   efi_char;
 typedef unsigned long efi_status;
 
+#if defined(__amd64__)
+typedef uint64_t uintn;
+#elif defined(__i386__)
+typedef uint32_t uintn;
+#endif
+
 struct efi_cfgtbl {
struct uuid ct_uuid;
void   *ct_data;
@@ -149,6 +155,133 @@ struct efi_rt {
efi_char *);
 };
 
+typedef uintn efi_tpl;
+typedef void *efi_event;
+typedef void (*efi_event_notify)(efi_event, void *);
+typedef void *efi_handle;
+typedef struct {
+	uint8_t type;
+	uint8_t subtype;
+	uint8_t ldnegth[2];
+} efi_device_path;
+
+struct efi_bs {
+   struct efi_tblhdr bs_hdr;
+#define		EFI_BS_SIG  0x56524553544f4f42UL
+   efi_tpl (*bs_raisetpl)(efi_tpl);
+   void(*bs_restoretpl)(efi_tpl);
+   efi_status  (*bs_allocatepages)(uint32_t, uint32_t,
+	   uintn, paddr_t *);
+   efi_status  (*bs_freepages)(paddr_t, uintn);
+   efi_status  (*bs_getmemorymap)(uintn *, struct efi_md *,
+	   uintn *, uintn *, uint32_t *);
+   efi_status  (*bs_allocatepool)(uint32_t, uintn, void **);
+   efi_status  (*bs_freepool)(void *);
+   efi_status  (*bs_createevent)(uint32_t, efi_tpl, efi_event_notify,
+	   void *, efi_event *);
+   efi_status  (*bs_settimer)(efi_event, uint32_t, uint64_t);
+   efi_status  (*bs_waitforevent)(uintn, efi_event *, uintn *);
+   efi_status  (*bs_signalevent)(efi_event);
+   efi_status  (*bs_closeevent)(efi_event);
+   efi_status  (*bs_checkevent)(efi_event);
+   efi_status  (*bs_installprotocolinterface)(efi_handle *,
+	   struct uuid *, uint32_t, void *);
+   efi_status  (*bs_reinstallprotocolinterface)(efi_handle *,
+	   struct uuid *, void *, void *);
+   efi_status  (*bs_uninstallprotocolinterface)(efi_handle *,
+	   struct uuid *, void *);
+   efi_status  (*bs_handleprotocol)(efi_handle,
+	   struct uuid *, void **);
+   efi_status  (*bs_pchandleprotocol)(efi_handle,
+	   struct uuid *, void **);
+   efi_status  (*bs_registerprotocolnotify)(struct uuid *, efi_event,
+	   void **);
+   efi_status  (*bs_locatehandle)(uint32_t, struct uuid *, void *,
+	   uintn *, efi_handle *);
+   efi_status  (*bs_locatedevicepath)(struct uuid *, efi_device_path **,
+	   efi_handle *);
+   efi_status  (*bs_installconfigurationtable)(struct uuid *, void *);
+   efi_status  (*bs_loadimage)(uint8_t, efi_handle, efi_device_path *,
+	   void *, uintn, efi_handle *);
+   efi_status  (*bs_startimage)(efi_handle, uintn *, efi_char **);
+   efi_status  (*bs_exit)(efi_handle, efi_status, uintn, efi_char *);
+   efi_status  (*bs_unloadimage)(efi_handle);
+   efi_status  (*bs_exitbootservices)(efi_handle, uintn);
+   efi_status  (*bs_getnextmonotoniccount)(uint64_t *);
+   efi_status  (*bs_stall)(uintn);
+   efi_status  (*bs_setwatchdogtimer)(uintn, uint64_t,
+	   uintn, efi_char *);
+   efi_status  (*bs_connectcontroller)(efi_handle, efi_handle *,
+	efi_device_path *, uint8_t);
+   efi_status  (*bs_disconnectcontroller)(efi_handle, efi_handle,
+	efi_handle);
+   efi_status  (*bs_openprotocol)(efi_handle, struct uuid *, void **,
+	efi_handle, efi_handle, uint32_t);
+   efi_status  (*bs_closeprotocol)(efi_handle, struct uuid *,
+	efi_handle, efi_handle);
+   efi_status  (*bs_openprotocolinformation)(efi_handle, efi_handle,
+	uint32_t, uint32_t);
+   efi_status  (*bs_protocolsperhandle)(efi_handle,
+	struct uuid ***, uintn *);
+   efi_status  (*bs_locatehandlebuffer)(uint32_t, struct uuid *,
+	void *, uintn *, efi_handle **);
+   efi_status  (*bs_locateprotocol)(struct uuid *, void *, void **);
+   efi_status  (*bs_installmultipleprotocolinterfaces)(efi_handle *,
+	...);
+   efi_status  (*bs_uninstallmultipleprotocolinterfaces)(efi_handle,
+	...);
+   efi_status  (*bs_calculatecrc32)(void *, uintn, uint32_t *);
+   efi_status  (*bs_copyme

CVS commit: src/sys/arch/i386/stand/efiboot/bootia32

2019-09-23 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Tue Sep 24 00:47:46 UTC 2019

Modified Files:
src/sys/arch/i386/stand/efiboot/bootia32: multiboot32.S

Log Message:
Fix multiboot32 argument usage


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S
diff -u src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S:1.1 src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S:1.2
--- src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S:1.1	Fri Sep 13 02:19:45 2019
+++ src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S	Tue Sep 24 00:47:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: multiboot32.S,v 1.1 2019/09/13 02:19:45 manu Exp $ */
+/*	$NetBSD: multiboot32.S,v 1.2 2019/09/24 00:47:46 manu Exp $ */
 
 #include 
 #include 
@@ -16,12 +16,12 @@ _C_LABEL(multiboot32_size):
 	.p2align 4,,15
 
 /*
- * multiboot32(entry 8(%esp), multiboot2_info 12(%esp), magic 16(%esp))
+ * multiboot32(entry 4(%esp), multiboot2_info 8(%esp), magic 12(%esp))
  */
 ENTRY(multiboot32_start)
 start:
-movl16(%esp),%eax
-movl12(%esp),%ebx
-movl8(%esp),%edx
+movl12(%esp),%eax
+movl8(%esp),%ebx
+movl4(%esp),%edx
 jmp*%edx
 multiboot32_end:



CVS commit: src/sys/arch/i386/stand/efiboot/bootia32

2019-09-23 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Tue Sep 24 00:47:46 UTC 2019

Modified Files:
src/sys/arch/i386/stand/efiboot/bootia32: multiboot32.S

Log Message:
Fix multiboot32 argument usage


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S

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



CVS commit: src/share/man/man8/man8.x86

2019-09-15 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Sep 16 01:57:58 UTC 2019

Modified Files:
src/share/man/man8/man8.x86: boot.8

Log Message:
Remove obsoeolete BUGS note that UEFI bootloader does not support multiboot


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/share/man/man8/man8.x86/boot.8

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

Modified files:

Index: src/share/man/man8/man8.x86/boot.8
diff -u src/share/man/man8/man8.x86/boot.8:1.19 src/share/man/man8/man8.x86/boot.8:1.20
--- src/share/man/man8/man8.x86/boot.8:1.19	Fri Sep 13 07:11:04 2019
+++ src/share/man/man8/man8.x86/boot.8	Mon Sep 16 01:57:58 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: boot.8,v 1.19 2019/09/13 07:11:04 wiz Exp $
+.\"	$NetBSD: boot.8,v 1.20 2019/09/16 01:57:58 manu Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -826,11 +826,6 @@ field of the
 .Nx
 disklabel (if it is a hard disk).
 .Pp
-.Ic multiboot
-is not supported by
-.Tn UEFI
-bootstrap code.
-.Pp
 .Tn UEFI
 implementation are supposed to support either
 .Xr mbr 8



CVS commit: src/share/man/man8/man8.x86

2019-09-15 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Sep 16 01:57:58 UTC 2019

Modified Files:
src/share/man/man8/man8.x86: boot.8

Log Message:
Remove obsoeolete BUGS note that UEFI bootloader does not support multiboot


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/share/man/man8/man8.x86/boot.8

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



CVS commit: src/sys/kern

2019-09-15 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Sep 16 00:01:17 UTC 2019

Modified Files:
src/sys/kern: kern_subr.c

Log Message:
Accept root device specification as NAME=label


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/kern/kern_subr.c

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



CVS commit: src/sys/kern

2019-09-15 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Sep 16 00:01:17 UTC 2019

Modified Files:
src/sys/kern: kern_subr.c

Log Message:
Accept root device specification as NAME=label


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/kern/kern_subr.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/kern/kern_subr.c
diff -u src/sys/kern/kern_subr.c:1.226 src/sys/kern/kern_subr.c:1.227
--- src/sys/kern/kern_subr.c:1.226	Sun Sep 15 23:59:33 2019
+++ src/sys/kern/kern_subr.c	Mon Sep 16 00:01:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_subr.c,v 1.226 2019/09/15 23:59:33 manu Exp $	*/
+/*	$NetBSD: kern_subr.c,v 1.227 2019/09/16 00:01:16 manu Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.226 2019/09/15 23:59:33 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.227 2019/09/16 00:01:16 manu Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -691,13 +691,18 @@ getdisk(const char *str, int len, int de
 static const char *
 getwedgename(const char *name, int namelen)
 {
-	const char *wpfx = "wedge:";
-	const int wpfxlen = strlen(wpfx);
+	const char *wpfx1 = "wedge:";
+	const char *wpfx2 = "NAME=";
+	const int wpfx1len = strlen(wpfx1);
+	const int wpfx2len = strlen(wpfx2);
 
-	if (namelen < wpfxlen || strncmp(name, wpfx, wpfxlen) != 0)
-		return NULL;
+	if (namelen > wpfx1len && strncmp(name, wpfx1, wpfx1len) == 0)
+		return name + wpfx1len;
+
+	if (namelen > wpfx2len && strncasecmp(name, wpfx2, wpfx2len) == 0)
+		return name + wpfx2len;
 
-	return name + wpfxlen;
+	return NULL;
 }
 
 static device_t



CVS commit: src/sys/kern

2019-09-15 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sun Sep 15 23:59:33 UTC 2019

Modified Files:
src/sys/kern: kern_subr.c

Log Message:
Rollback change to accept NAME=label root device specification

As suggested by Michael van Elst, the operation should be done
int getwedgename()


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/sys/kern/kern_subr.c

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



CVS commit: src/sys/kern

2019-09-15 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sun Sep 15 23:59:33 UTC 2019

Modified Files:
src/sys/kern: kern_subr.c

Log Message:
Rollback change to accept NAME=label root device specification

As suggested by Michael van Elst, the operation should be done
int getwedgename()


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/sys/kern/kern_subr.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/kern/kern_subr.c
diff -u src/sys/kern/kern_subr.c:1.225 src/sys/kern/kern_subr.c:1.226
--- src/sys/kern/kern_subr.c:1.225	Fri Sep 13 01:33:20 2019
+++ src/sys/kern/kern_subr.c	Sun Sep 15 23:59:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_subr.c,v 1.225 2019/09/13 01:33:20 manu Exp $	*/
+/*	$NetBSD: kern_subr.c,v 1.226 2019/09/15 23:59:33 manu Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.225 2019/09/13 01:33:20 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.226 2019/09/15 23:59:33 manu Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -229,16 +229,6 @@ setroot(device_t bootdv, int bootpartiti
 	 */
 	setroot_nfs(bootdv);
 
-
-	/*
-	 * Try to lookup by wedge label name
-	 */
-	if (bootdv == NULL && rootspec != NULL &&
-	strncmp(rootspec, "NAME=", 5) == 0) {
-		if ((bootdv = dkwedge_find_by_wname(rootspec + 5)) != NULL)
-			rootspec = bootdv->dv_xname;
-	}
-
 	/*
 	 * If no bootdv was found by MD code and no
 	 * root specified ask the user.



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

2019-09-15 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sun Sep 15 23:55:26 UTC 2019

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot2.c

Log Message:
Remove debug define.

It remained there unseen because it was misspelled!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/lib/exec_multiboot2.c

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

Modified files:

Index: src/sys/arch/i386/stand/lib/exec_multiboot2.c
diff -u src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.1 src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.2
--- src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.1	Fri Sep 13 02:19:46 2019
+++ src/sys/arch/i386/stand/lib/exec_multiboot2.c	Sun Sep 15 23:55:26 2019
@@ -1,5 +1,4 @@
-/* $NetBSD: exec_multiboot2.c,v 1.1 2019/09/13 02:19:46 manu Exp $ */
-#define MULTIBBOT2_DEBUG
+/* $NetBSD: exec_multiboot2.c,v 1.2 2019/09/15 23:55:26 manu Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.



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

2019-09-15 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sun Sep 15 23:55:26 UTC 2019

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot2.c

Log Message:
Remove debug define.

It remained there unseen because it was misspelled!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/lib/exec_multiboot2.c

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



CVS commit: src/doc

2019-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 13 02:23:31 UTC 2019

Modified Files:
src/doc: CHANGES

Log Message:
boot(8): multiboot 2 support, Xen can now boot from EFI


To generate a diff of this commit:
cvs rdiff -u -r1.2580 -r1.2581 src/doc/CHANGES

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



CVS commit: src/doc

2019-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 13 02:23:31 UTC 2019

Modified Files:
src/doc: CHANGES

Log Message:
boot(8): multiboot 2 support, Xen can now boot from EFI


To generate a diff of this commit:
cvs rdiff -u -r1.2580 -r1.2581 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2580 src/doc/CHANGES:1.2581
--- src/doc/CHANGES:1.2580	Sun Sep  8 20:57:16 2019
+++ src/doc/CHANGES	Fri Sep 13 02:23:31 2019
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2580 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2581 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -39,3 +39,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	dhcpcd(8): Import dhcpcd-8.0.4 [roy 20190904]
 	bind: Import version 9.14.5. [christos 20190905]
 	resolvconf(8): Import openresolv-3.9.2 [roy 20190908]
+	boot(8): multiboot 2 support, Xen can now boot from EFI [manu 20190913]



CVS commit: src/sys/arch/i386

2019-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 13 02:19:46 UTC 2019

Modified Files:
src/sys/arch/i386/include: Makefile
src/sys/arch/i386/stand/boot: Makefile.boot
src/sys/arch/i386/stand/dosboot: Makefile
src/sys/arch/i386/stand/efiboot: Makefile.efiboot boot.c efiboot.c
efiboot.h eficons.c efimemory.c
src/sys/arch/i386/stand/efiboot/bootia32: Makefile efibootia32.c
src/sys/arch/i386/stand/efiboot/bootx64: Makefile efibootx64.c
src/sys/arch/i386/stand/lib: Makefile biosdisk.c biosdisk.h
bootinfo_memmap.c exec.c libi386.h multiboot.S pread.c
src/sys/arch/i386/stand/netboot: Makefile.netboot
src/sys/arch/i386/stand/pxeboot: Makefile
Added Files:
src/sys/arch/i386/include: multiboot2.h
src/sys/arch/i386/stand/efiboot/bootia32: multiboot32.S
src/sys/arch/i386/stand/efiboot/bootx64: multiboot64.S
src/sys/arch/i386/stand/lib: exec_multiboot1.c exec_multiboot2.c

Log Message:
Add multiboot 2 support to x86 bootloaders

multiboot 2 is required to boot Xen on an EFI system.
This also require a kernel patch for properly discovering
the ACPI RSDP, which is available after 20190912, in
src/sys/arch/x86/acpi/acpi_machdep.c 1.26-1.28

There are a few missing bit in this multiboot 2 implementation
(which are unused by Xen):
- Header tags Address, Freambuffer, and Relocatable are ignored
- Tags APM and Network are not provided
- Tags ACPI old and ACP new are only provided for ACPI boot
- Tag boot device does not provides the subpart (BSD disklabel partition)

Notes:
- multiboot2 is disabled in dosboot, otherwise the binary
  gets too big and build fails.
- in src/sys/arch/i386/stand/efiboot, consinit() is renamed
  as efi_consinit() to avoid prototype conflicts in src/sys/sys/systm.h


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/i386/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/include/multiboot2.h
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/i386/stand/boot/Makefile.boot
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/i386/stand/dosboot/Makefile
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/i386/stand/efiboot/Makefile.efiboot \
src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/eficons.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/efimemory.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/bootia32/Makefile
cvs rdiff -u -r1.4 -r1.5 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/bootx64/Makefile
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/bootx64/multiboot64.S
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/i386/stand/lib/Makefile
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/lib/biosdisk.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/bootinfo_memmap.c
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/lib/exec_multiboot1.c \
src/sys/arch/i386/stand/lib/exec_multiboot2.c
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/i386/stand/lib/libi386.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/lib/multiboot.S
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/lib/pread.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/netboot/Makefile.netboot
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/stand/pxeboot/Makefile

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



CVS commit: src/sys/arch/i386

2019-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 13 02:19:46 UTC 2019

Modified Files:
src/sys/arch/i386/include: Makefile
src/sys/arch/i386/stand/boot: Makefile.boot
src/sys/arch/i386/stand/dosboot: Makefile
src/sys/arch/i386/stand/efiboot: Makefile.efiboot boot.c efiboot.c
efiboot.h eficons.c efimemory.c
src/sys/arch/i386/stand/efiboot/bootia32: Makefile efibootia32.c
src/sys/arch/i386/stand/efiboot/bootx64: Makefile efibootx64.c
src/sys/arch/i386/stand/lib: Makefile biosdisk.c biosdisk.h
bootinfo_memmap.c exec.c libi386.h multiboot.S pread.c
src/sys/arch/i386/stand/netboot: Makefile.netboot
src/sys/arch/i386/stand/pxeboot: Makefile
Added Files:
src/sys/arch/i386/include: multiboot2.h
src/sys/arch/i386/stand/efiboot/bootia32: multiboot32.S
src/sys/arch/i386/stand/efiboot/bootx64: multiboot64.S
src/sys/arch/i386/stand/lib: exec_multiboot1.c exec_multiboot2.c

Log Message:
Add multiboot 2 support to x86 bootloaders

multiboot 2 is required to boot Xen on an EFI system.
This also require a kernel patch for properly discovering
the ACPI RSDP, which is available after 20190912, in
src/sys/arch/x86/acpi/acpi_machdep.c 1.26-1.28

There are a few missing bit in this multiboot 2 implementation
(which are unused by Xen):
- Header tags Address, Freambuffer, and Relocatable are ignored
- Tags APM and Network are not provided
- Tags ACPI old and ACP new are only provided for ACPI boot
- Tag boot device does not provides the subpart (BSD disklabel partition)

Notes:
- multiboot2 is disabled in dosboot, otherwise the binary
  gets too big and build fails.
- in src/sys/arch/i386/stand/efiboot, consinit() is renamed
  as efi_consinit() to avoid prototype conflicts in src/sys/sys/systm.h


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/i386/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/include/multiboot2.h
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/i386/stand/boot/Makefile.boot
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/i386/stand/dosboot/Makefile
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/i386/stand/efiboot/Makefile.efiboot \
src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/eficons.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/efimemory.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/bootia32/Makefile
cvs rdiff -u -r1.4 -r1.5 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/bootia32/multiboot32.S
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/bootx64/Makefile
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/bootx64/multiboot64.S
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/i386/stand/lib/Makefile
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/lib/biosdisk.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/bootinfo_memmap.c
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/lib/exec_multiboot1.c \
src/sys/arch/i386/stand/lib/exec_multiboot2.c
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/i386/stand/lib/libi386.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/lib/multiboot.S
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/lib/pread.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/netboot/Makefile.netboot
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/stand/pxeboot/Makefile

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

Modified files:

Index: src/sys/arch/i386/include/Makefile
diff -u src/sys/arch/i386/include/Makefile:1.49 src/sys/arch/i386/include/Makefile:1.50
--- src/sys/arch/i386/include/Makefile:1.49	Thu Jul 12 10:46:44 2018
+++ src/sys/arch/i386/include/Makefile	Fri Sep 13 02:19:45 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.49 2018/07/12 10:46:44 maxv Exp $
+#	$NetBSD: Makefile,v 1.50 2019/09/13 02:19:45 manu Exp $
 
 INCSDIR= /usr/include/i386
 
@@ -15,7 +15,7 @@ INCS=	ansi.h aout_machdep.h apmvar.h asm
 	joystick.h \
 	kcore.h \
 	limits.h lock.h \
-	math.h mcontext.h mutex.h mtrr.h multiboot.h \
+	math.h mcontext.h mutex.h mtrr.h multiboot.h multiboot2.h \
 	param.h pcb.h pio.h pmap.h proc.h profile.h psl.h \
 	pte.h ptrace.h \
 	reg.h rwlock.h \

Index: src/sys/arch/i386/stand/boot/Makefile.boot
diff -u src/sys/arch/i386/stand/boot/Makefile.boot:1.72 src/sys/arch/i386/stand/boot/Makefile.boot:1.73
--- src/sys/arch/i386/stand/boot/Makefile.boot:1.72	Wed Jul 25 23:45:32 2018
+++ src/sys/arch/i386/stand/boot/Makefile.boot	Fri Sep 13 02:19:45 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile

CVS commit: src/share/man/man8/man8.x86

2019-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 13 01:34:19 UTC 2019

Modified Files:
src/share/man/man8/man8.x86: boot.8

Log Message:
Document that bootdev option accepts device specification as NAME=label


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/share/man/man8/man8.x86/boot.8

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

Modified files:

Index: src/share/man/man8/man8.x86/boot.8
diff -u src/share/man/man8/man8.x86/boot.8:1.17 src/share/man/man8/man8.x86/boot.8:1.18
--- src/share/man/man8/man8.x86/boot.8:1.17	Sun Aug 18 08:12:36 2019
+++ src/share/man/man8/man8.x86/boot.8	Fri Sep 13 01:34:19 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: boot.8,v 1.17 2019/08/18 08:12:36 wiz Exp $
+.\"	$NetBSD: boot.8,v 1.18 2019/09/13 01:34:19 manu Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -436,7 +436,11 @@ being separated with spaces
 .It Ic bootdev Ns = Ns Ar dev Po or Ic root Ns = Ns Ar dev Pc
 Override the default boot device.
 .Ar dev
-can be a unit name
+is of the form
+.Va NAME=partition_label
+for
+.Xr gpt 8
+partitionned disks. It can also be a unit name
 .Po Dq wd0
 .Pc ,
 or an interface name



CVS commit: src/share/man/man8/man8.x86

2019-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 13 01:34:19 UTC 2019

Modified Files:
src/share/man/man8/man8.x86: boot.8

Log Message:
Document that bootdev option accepts device specification as NAME=label


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/share/man/man8/man8.x86/boot.8

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



CVS commit: src/sys/kern

2019-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 13 01:33:20 UTC 2019

Modified Files:
src/sys/kern: kern_subr.c

Log Message:
Accept root device specification as NAME=label


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/kern/kern_subr.c

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



CVS commit: src/sys/kern

2019-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Sep 13 01:33:20 UTC 2019

Modified Files:
src/sys/kern: kern_subr.c

Log Message:
Accept root device specification as NAME=label


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/kern/kern_subr.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/kern/kern_subr.c
diff -u src/sys/kern/kern_subr.c:1.224 src/sys/kern/kern_subr.c:1.225
--- src/sys/kern/kern_subr.c:1.224	Sun Aug 18 06:28:42 2019
+++ src/sys/kern/kern_subr.c	Fri Sep 13 01:33:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_subr.c,v 1.224 2019/08/18 06:28:42 mlelstv Exp $	*/
+/*	$NetBSD: kern_subr.c,v 1.225 2019/09/13 01:33:20 manu Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.224 2019/08/18 06:28:42 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.225 2019/09/13 01:33:20 manu Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -229,6 +229,16 @@ setroot(device_t bootdv, int bootpartiti
 	 */
 	setroot_nfs(bootdv);
 
+
+	/*
+	 * Try to lookup by wedge label name
+	 */
+	if (bootdv == NULL && rootspec != NULL &&
+	strncmp(rootspec, "NAME=", 5) == 0) {
+		if ((bootdv = dkwedge_find_by_wname(rootspec + 5)) != NULL)
+			rootspec = bootdv->dv_xname;
+	}
+
 	/*
 	 * If no bootdv was found by MD code and no
 	 * root specified ask the user.



CVS commit: src/sys/arch/x86/acpi

2019-09-11 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Sep 12 00:52:22 UTC 2019

Modified Files:
src/sys/arch/x86/acpi: acpi_machdep.c

Log Message:
Attempt to obtain ACPI RSDP from the hypervisor for Xen PV

There are three possible way of obtaining the ACPI RSDP
- From Extended BIOS Data Area (EBDA) when kernel or Xen was booted from
  BIOS bootstrap
- From EFI SystemTable when kernel is booted from EFI bootstrap
- When Xen is booted from EFI bootstrap, EBDA is not mapped, and EFI
  SystemTable is not passed to the kernel. The only way to go is to
  obtain ACPI RSDP trhough an hypercall.

Note: EFI bootstrap support for booting Xen has not yet been committed.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/acpi/acpi_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/x86/acpi/acpi_machdep.c
diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.26 src/sys/arch/x86/acpi/acpi_machdep.c:1.27
--- src/sys/arch/x86/acpi/acpi_machdep.c:1.26	Wed May  1 07:26:28 2019
+++ src/sys/arch/x86/acpi/acpi_machdep.c	Thu Sep 12 00:52:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.27 2019/09/12 00:52:22 manu Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.27 2019/09/12 00:52:22 manu Exp $");
 
 #include 
 #include 
@@ -100,8 +100,61 @@ acpi_md_OsGetRootPointer(void)
 	ACPI_PHYSICAL_ADDRESS PhysicalAddress;
 	ACPI_STATUS Status;
 
-#ifndef XENPV
-	/* If EFI is available, attempt to use it to locate the ACPI table. */
+#ifdef XENPV
+	/*
+	 * Obtain the ACPI RSDP from the hypervisor. 
+	 * This is the only way to go if Xen booted from EFI: the 
+	 * Extended BIOS Data Area (EBDA) is not mapped, and Xen 
+	 * does not pass an EFI SystemTable to the kernel.
+	 */
+struct xen_platform_op op = {
+.cmd = XENPF_firmware_info,
+.u.firmware_info = {
+.type = XEN_FW_EFI_INFO,  
+.index = XEN_FW_EFI_CONFIG_TABLE
+}
+};
+union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
+if (HYPERVISOR_platform_op(&op) == 0) {
+		struct efi_cfgtbl *ct;
+		int i;
+
+		ct = AcpiOsMapMemory(info->cfg.addr, 
+		sizeof(*ct) * info->cfg.nent);
+
+		for (i = 0; i < info->cfg.nent; i++) {
+	if (memcmp(&ct[i].ct_uuid,
+			&EFI_UUID_ACPI20, sizeof(EFI_UUID_ACPI20)) == 0) {
+PhysicalAddress =
+(ACPI_PHYSICAL_ADDRESS)ct[i].ct_data;
+if (PhysicalAddress)
+	goto out;
+	
+			}
+		}
+
+		for (i = 0; i < info->cfg.nent; i++) {
+	if (memcmp(&ct[i].ct_uuid,
+			&EFI_UUID_ACPI10, sizeof(EFI_UUID_ACPI10)) == 0) {
+PhysicalAddress =
+(ACPI_PHYSICAL_ADDRESS)ct[i].ct_data;
+if (PhysicalAddress)
+	goto out;
+	
+			}
+		}
+out:
+		AcpiOsUnmapMemory(ct, sizeof(*ct) * info->cfg.nent);
+
+		if (PhysicalAddress)
+			return PhysicalAddress;
+	}
+#else
+	/* 
+	 * Get the ACPI RSDP from EFI SystemTable. This works when the 
+	 * kernel was loaded from EFI bootloader.
+	 */
 	if (efi_probe()) {
 		PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI20);
 		if (!PhysicalAddress)
@@ -111,6 +164,11 @@ acpi_md_OsGetRootPointer(void)
 	}
 
 #endif
+	/*
+	 * Find ACPI RSDP from Extended BIOS Data Area (EBDA). This
+	 * works when the kernel was started from BIOS bootloader,
+	 * or for Xen PV when Xen was started from BIOS bootloader.
+	 */
 	Status = AcpiFindRootPointer(&PhysicalAddress);
 	if (ACPI_FAILURE(Status))
 		PhysicalAddress = 0;



CVS commit: src/sys/arch/x86/acpi

2019-09-11 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Sep 12 00:52:22 UTC 2019

Modified Files:
src/sys/arch/x86/acpi: acpi_machdep.c

Log Message:
Attempt to obtain ACPI RSDP from the hypervisor for Xen PV

There are three possible way of obtaining the ACPI RSDP
- From Extended BIOS Data Area (EBDA) when kernel or Xen was booted from
  BIOS bootstrap
- From EFI SystemTable when kernel is booted from EFI bootstrap
- When Xen is booted from EFI bootstrap, EBDA is not mapped, and EFI
  SystemTable is not passed to the kernel. The only way to go is to
  obtain ACPI RSDP trhough an hypercall.

Note: EFI bootstrap support for booting Xen has not yet been committed.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/acpi/acpi_machdep.c

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



  1   2   >