CVS commit: src/distrib/common/bootimage

2023-12-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Dec  3 07:20:23 UTC 2023

Modified Files:
src/distrib/common/bootimage: Makefile.bootimage

Log Message:
Use defined ${GPTSECTORS} rather than hardcoded 2048.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/distrib/common/bootimage/Makefile.bootimage

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

Modified files:

Index: src/distrib/common/bootimage/Makefile.bootimage
diff -u src/distrib/common/bootimage/Makefile.bootimage:1.31 src/distrib/common/bootimage/Makefile.bootimage:1.32
--- src/distrib/common/bootimage/Makefile.bootimage:1.31	Sun Dec  3 07:17:11 2023
+++ src/distrib/common/bootimage/Makefile.bootimage	Sun Dec  3 07:20:23 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.bootimage,v 1.31 2023/12/03 07:17:11 tsutsui Exp $
+#	$NetBSD: Makefile.bootimage,v 1.32 2023/12/03 07:20:23 tsutsui Exp $
 #
 # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
 #
@@ -573,8 +573,8 @@ ${WORKMBR}:
 
 ${WORKGPT}: ${WORKMBR}
 	@echo create GPT image...
-	${DD} if=${WORKMBR} of=${WORKGPT} skip=$$((${IMAGESECTORS} - 2048)) \
-	count=2048
+	${DD} if=${WORKMBR} of=${WORKGPT} \
+	skip=$$((${IMAGESECTORS} - ${GPTSECTORS})) count=${GPTSECTORS}
 
 .if ${USE_GPT} == "no"
 ${IMGBASE}.img:	${WORKLABEL}



CVS commit: src/distrib/common/bootimage

2023-12-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Dec  3 07:20:23 UTC 2023

Modified Files:
src/distrib/common/bootimage: Makefile.bootimage

Log Message:
Use defined ${GPTSECTORS} rather than hardcoded 2048.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/distrib/common/bootimage/Makefile.bootimage

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



CVS commit: src/distrib/common/bootimage

2023-12-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Dec  3 07:17:11 UTC 2023

Modified Files:
src/distrib/common/bootimage: Makefile.bootimage

Log Message:
Document USE_GPTMBR and GPTSECTORS.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/distrib/common/bootimage/Makefile.bootimage

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

Modified files:

Index: src/distrib/common/bootimage/Makefile.bootimage
diff -u src/distrib/common/bootimage/Makefile.bootimage:1.30 src/distrib/common/bootimage/Makefile.bootimage:1.31
--- src/distrib/common/bootimage/Makefile.bootimage:1.30	Sun May 15 00:05:24 2022
+++ src/distrib/common/bootimage/Makefile.bootimage	Sun Dec  3 07:17:11 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.bootimage,v 1.30 2022/05/15 00:05:24 mrg Exp $
+#	$NetBSD: Makefile.bootimage,v 1.31 2023/12/03 07:17:11 tsutsui Exp $
 #
 # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
 #
@@ -40,6 +40,10 @@
 #	USE_GPT
 #		set yes if target disk image requires GPT partition
 #		(default: no)
+#	USE_GPTMBR
+#		set yes if target disk image requires GPT partition
+#		with hybrid MBR boot code
+#		(default: no; valid only if USE_GPT=yes)
 #	MBR_BOOTCODE
 #		optional MBR bootcode which should be installed by fdisk(8)
 #		(default: empty)
@@ -66,6 +70,10 @@
 #	FATMB
 #		FAT partition size in target image in MB
 #		(default: 0)
+#	GPTSECTORS
+#		Size of a region reserved for the secondary GPT table/entry
+#		at the end of the target image in sectors
+#		(default: 2048 if USE_GPT=yes, otherwise 0)
 #	KERN_SET
 #		kernel set name which should be extracted into image
 #		(default: kern-GENERIC)



CVS commit: src/distrib/common/bootimage

2023-12-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Dec  3 07:17:11 UTC 2023

Modified Files:
src/distrib/common/bootimage: Makefile.bootimage

Log Message:
Document USE_GPTMBR and GPTSECTORS.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/distrib/common/bootimage/Makefile.bootimage

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



CVS commit: src/sys/kern

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:50:09 UTC 2023

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

Log Message:
Assert that the vmem_btag_pool has been initialized before we attempt
to allocate from it.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/kern/subr_vmem.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

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:50:09 UTC 2023

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

Log Message:
Assert that the vmem_btag_pool has been initialized before we attempt
to allocate from it.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/kern/subr_vmem.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/subr_vmem.c
diff -u src/sys/kern/subr_vmem.c:1.111 src/sys/kern/subr_vmem.c:1.112
--- src/sys/kern/subr_vmem.c:1.111	Sat Dec  2 21:02:12 2023
+++ src/sys/kern/subr_vmem.c	Sun Dec  3 02:50:09 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_vmem.c,v 1.111 2023/12/02 21:02:12 thorpej Exp $	*/
+/*	$NetBSD: subr_vmem.c,v 1.112 2023/12/03 02:50:09 thorpej Exp $	*/
 
 /*-
  * Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.111 2023/12/02 21:02:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.112 2023/12/03 02:50:09 thorpej Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -205,6 +205,7 @@ static kmutex_t vmem_btag_lock;
 static LIST_HEAD(, vmem_btag) vmem_btag_freelist;
 static size_t vmem_btag_freelist_count = 0;
 static struct pool vmem_btag_pool;
+static bool vmem_btag_pool_initialized __read_mostly;
 
 /*  boundary tag */
 
@@ -263,6 +264,7 @@ bt_refill_locked(vmem_t *vm)
 
 	while (vm->vm_nfreetags <= BT_MINRESERVE) {
 		VMEM_UNLOCK(vm);
+		KASSERT(vmem_btag_pool_initialized);
 		mutex_enter(&vmem_btag_refill_lock);
 		bt = pool_get(&vmem_btag_pool, PR_NOWAIT);
 		mutex_exit(&vmem_btag_refill_lock);
@@ -697,6 +699,7 @@ vmem_subsystem_init(vmem_t *vm)
 
 	pool_init(&vmem_btag_pool, sizeof(bt_t), coherency_unit, 0,
 	PR_PHINPAGE, "vmembt", &pool_allocator_vmem_meta, IPL_VM);
+	vmem_btag_pool_initialized = true;
 }
 #endif /* defined(_KERNEL) */
 



CVS commit: src/sys/arch/hppa/dev

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:17:06 UTC 2023

Modified Files:
src/sys/arch/hppa/dev: uturn.c

Log Message:
Use vmem(9) rather than extent(9) to manage IOMMU mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/dev/uturn.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/hppa/dev/uturn.c
diff -u src/sys/arch/hppa/dev/uturn.c:1.6 src/sys/arch/hppa/dev/uturn.c:1.7
--- src/sys/arch/hppa/dev/uturn.c:1.6	Thu Sep 29 06:42:14 2022
+++ src/sys/arch/hppa/dev/uturn.c	Sun Dec  3 02:17:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: uturn.c,v 1.6 2022/09/29 06:42:14 skrll Exp $	*/
+/*	$NetBSD: uturn.c,v 1.7 2023/12/03 02:17:06 thorpej Exp $	*/
 
 /*	$OpenBSD: uturn.c,v 1.6 2007/12/29 01:26:14 kettenis Exp $	*/
 
@@ -85,7 +85,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -178,7 +178,7 @@ struct uturn_softc {
 	uint32_t sc_chainid_shift;
 
 	char sc_mapname[20];
-	struct extent *sc_map;
+	vmem_t *sc_map;
 
 	struct hppa_bus_dma_tag sc_dmatag;
 };
@@ -357,8 +357,17 @@ uturnattach(device_t parent, device_t se
 
 	snprintf(sc->sc_mapname, sizeof(sc->sc_mapname), "%s_map",
 	device_xname(sc->sc_dv));
-	sc->sc_map = extent_create(sc->sc_mapname, 0, (1 << iova_bits),
-	0, 0, EX_WAITOK);
+	sc->sc_map = vmem_create(sc->sc_mapname,
+ 0,			/* base */
+ (1 << iova_bits),	/* size */
+ PAGE_SIZE,		/* quantum */
+ NULL,			/* allocfn */
+ NULL,			/* freefn */
+ NULL,			/* source */
+ 0,			/* qcache_max */
+ VM_SLEEP,
+ IPL_VM);
+	KASSERT(sc->sc_map != NULL);
 
 	sc->sc_dmatag = uturn_dmat;
 	sc->sc_dmatag._cookie = sc;
@@ -539,18 +548,18 @@ uturn_iomap_load_map(struct uturn_softc 
 	struct uturn_map_state *ums = map->_dm_cookie;
 	struct uturn_page_map *upm = &ums->ums_map;
 	struct uturn_page_entry *e;
-	int err, seg, s;
+	int err, seg;
 	paddr_t pa, paend;
 	vaddr_t va;
 	bus_size_t sgsize;
 	bus_size_t align, boundary;
-	u_long iovaddr;
+	vmem_addr_t iovaddr;
 	bus_addr_t iova;
 	int i;
 
 	/* XXX */
 	boundary = map->_dm_boundary;
-	align = PAGE_SIZE;
+	align = 0;	/* align to quantum */
 
 	uturn_iomap_clear_pages(ums);
 
@@ -570,12 +579,18 @@ uturn_iomap_load_map(struct uturn_softc 
 		}
 	}
 
+	const vm_flag_t vmflags = VM_BESTFIT |
+	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
 	sgsize = ums->ums_map.upm_pagecnt * PAGE_SIZE;
-	/* XXXNH */
-	s = splhigh();
-	err = extent_alloc(sc->sc_map, sgsize, align, boundary,
-	EX_NOWAIT | EX_BOUNDZERO, &iovaddr);
-	splx(s);
+	err = vmem_xalloc(sc->sc_map, sgsize,
+			  align,		/* align */
+			  0,			/* phase */
+			  boundary,		/* nocross */
+			  VMEM_ADDR_MIN,	/* minaddr */
+			  VMEM_ADDR_MAX,	/* maxaddr */
+			  vmflags,
+			  &iovaddr);
 	if (err)
 		return (err);
 
@@ -653,7 +668,7 @@ uturn_dmamap_unload(void *v, bus_dmamap_
 	struct uturn_map_state *ums = map->_dm_cookie;
 	struct uturn_page_map *upm = &ums->ums_map;
 	struct uturn_page_entry *e;
-	int err, i, s;
+	int i;
 
 	/* Remove the IOMMU entries. */
 	for (i = 0, e = upm->upm_map; i < upm->upm_pagecnt; ++i, ++e)
@@ -664,14 +679,9 @@ uturn_dmamap_unload(void *v, bus_dmamap_
 
 	bus_dmamap_unload(sc->sc_dmat, map);
 
-	s = splhigh();
-	err = extent_free(sc->sc_map, ums->ums_iovastart,
-	ums->ums_iovasize, EX_NOWAIT);
+	vmem_xfree(sc->sc_map, ums->ums_iovastart, ums->ums_iovasize);
 	ums->ums_iovastart = 0;
 	ums->ums_iovasize = 0;
-	splx(s);
-	if (err)
-		printf("warning: %ld of IOVA space lost\n", ums->ums_iovasize);
 }
 
 void



CVS commit: src/sys/arch/hppa/dev

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:17:06 UTC 2023

Modified Files:
src/sys/arch/hppa/dev: uturn.c

Log Message:
Use vmem(9) rather than extent(9) to manage IOMMU mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/dev/uturn.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/hppa/dev

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:03:18 UTC 2023

Modified Files:
src/sys/arch/hppa/dev: astro.c

Log Message:
Use vmem(9) rather than extent(9) to manage IOMMU mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/astro.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/hppa/dev/astro.c
diff -u src/sys/arch/hppa/dev/astro.c:1.5 src/sys/arch/hppa/dev/astro.c:1.6
--- src/sys/arch/hppa/dev/astro.c:1.5	Thu Sep 29 06:42:14 2022
+++ src/sys/arch/hppa/dev/astro.c	Sun Dec  3 02:03:18 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: astro.c,v 1.5 2022/09/29 06:42:14 skrll Exp $	*/
+/*	$NetBSD: astro.c,v 1.6 2023/12/03 02:03:18 thorpej Exp $	*/
 
 /*	$OpenBSD: astro.c,v 1.8 2007/10/06 23:50:54 krw Exp $	*/
 
@@ -22,7 +22,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -124,7 +124,7 @@ struct astro_softc {
 	uint64_t *sc_pdir;
 
 	char sc_dvmamapname[20];
-	struct extent *sc_dvmamap;
+	vmem_t *sc_dvmamap;
 	struct hppa_bus_dma_tag sc_dmatag;
 };
 
@@ -328,8 +328,17 @@ astro_attach(device_t parent, device_t s
 	 */
 	snprintf(sc->sc_dvmamapname, sizeof(sc->sc_dvmamapname),
 	"%s_dvma", device_xname(sc->sc_dv));
-	sc->sc_dvmamap = extent_create(sc->sc_dvmamapname, 0, (1 << iova_bits),
-	0, 0, EX_WAITOK);
+	sc->sc_dvmamap = vmem_create(sc->sc_dvmamapname,
+ 0,			/* base */
+ (1 << iova_bits),	/* size */
+ PAGE_SIZE,		/* quantum */
+ NULL,		/* allocfn */
+ NULL,		/* freefn */
+ NULL,		/* source */
+ 0,			/* qcache_max */
+ VM_SLEEP,
+ IPL_VM);
+	KASSERT(sc->sc_dvmamap != NULL);
 
 	sc->sc_dmatag = astro_dmat;
 	sc->sc_dmatag._cookie = sc;
@@ -401,18 +410,18 @@ iommu_iomap_load_map(struct astro_softc 
 	struct iommu_map_state *ims = map->_dm_cookie;
 	struct iommu_page_map *ipm = &ims->ims_map;
 	struct iommu_page_entry *e;
-	int err, seg, s;
+	int err, seg;
 	paddr_t pa, paend;
 	vaddr_t va;
 	bus_size_t sgsize;
 	bus_size_t align, boundary;
-	u_long dvmaddr;
+	vmem_addr_t dvmaddr;
 	bus_addr_t dva;
 	int i;
 
 	/* XXX */
 	boundary = map->_dm_boundary;
-	align = PAGE_SIZE;
+	align = 0;	/* align to quantum */
 
 	iommu_iomap_clear_pages(ims);
 
@@ -432,12 +441,18 @@ iommu_iomap_load_map(struct astro_softc 
 		}
 	}
 
+	const vm_flag_t vmflags = VM_BESTFIT |
+	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
 	sgsize = ims->ims_map.ipm_pagecnt * PAGE_SIZE;
-	/* XXXNH */
-	s = splhigh();
-	err = extent_alloc(sc->sc_dvmamap, sgsize, align, boundary,
-	EX_NOWAIT | EX_BOUNDZERO, &dvmaddr);
-	splx(s);
+	err = vmem_xalloc(sc->sc_dvmamap, sgsize,
+			  align,		/* align */
+			  0,			/* phase */
+			  boundary,		/* nocross */
+			  VMEM_ADDR_MIN,	/* minaddr */
+			  VMEM_ADDR_MAX,	/* maxaddr */
+			  vmflags,
+			  &dvmaddr);
 	if (err)
 		return (err);
 
@@ -514,7 +529,7 @@ iommu_dvmamap_unload(void *v, bus_dmamap
 	struct iommu_map_state *ims = map->_dm_cookie;
 	struct iommu_page_map *ipm = &ims->ims_map;
 	struct iommu_page_entry *e;
-	int err, i, s;
+	int i;
 
 	/* Remove the IOMMU entries. */
 	for (i = 0, e = ipm->ipm_map; i < ipm->ipm_pagecnt; ++i, ++e)
@@ -525,14 +540,9 @@ iommu_dvmamap_unload(void *v, bus_dmamap
 
 	bus_dmamap_unload(sc->sc_dmat, map);
 
-	s = splhigh();
-	err = extent_free(sc->sc_dvmamap, ims->ims_dvmastart,
-	ims->ims_dvmasize, EX_NOWAIT);
+	vmem_xfree(sc->sc_dvmamap, ims->ims_dvmastart, ims->ims_dvmasize);
 	ims->ims_dvmastart = 0;
 	ims->ims_dvmasize = 0;
-	splx(s);
-	if (err)
-		printf("warning: %ld of DVMA space lost\n", ims->ims_dvmasize);
 }
 
 void
@@ -736,7 +746,7 @@ iommu_enter(struct astro_softc *sc, bus_
 	if (tte & IOTTE_V) {
 		printf("Overwriting valid tte entry (dva %lx pa %lx "
 		"&tte %p tte %llx)\n", dva, pa, tte_ptr, tte);
-		extent_print(sc->sc_dvmamap);
+		/* vmem_print(sc->sc_dvmamap);		XXX */
 		panic("IOMMU overwrite");
 	}
 #endif
@@ -773,7 +783,7 @@ iommu_remove(struct astro_softc *sc, bus
 	if ((tte & IOTTE_V) == 0) {
 		printf("Removing invalid tte entry (dva %lx &tte %p "
 		"tte %llx)\n", dva, tte_ptr, tte);
-		extent_print(sc->sc_dvmamap);
+		/* vmem_print(sc->sc_dvmamap);		XXX */
 		panic("IOMMU remove overwrite");
 	}
 #endif



CVS commit: src/sys/arch/hppa/dev

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:03:18 UTC 2023

Modified Files:
src/sys/arch/hppa/dev: astro.c

Log Message:
Use vmem(9) rather than extent(9) to manage IOMMU mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/astro.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/vax

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 00:49:46 UTC 2023

Modified Files:
src/sys/arch/vax/include: sgmap.h
src/sys/arch/vax/vax: sgmap.c

Log Message:
Use vmem(9) rather than extent(9) to manage SGMAP space.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/vax/include/sgmap.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/vax/vax/sgmap.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/vax/include/sgmap.h
diff -u src/sys/arch/vax/include/sgmap.h:1.7 src/sys/arch/vax/include/sgmap.h:1.8
--- src/sys/arch/vax/include/sgmap.h:1.7	Sun Jul  5 02:03:36 2015
+++ src/sys/arch/vax/include/sgmap.h	Sun Dec  3 00:49:46 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap.h,v 1.7 2015/07/05 02:03:36 matt Exp $ */
+/* $NetBSD: sgmap.h,v 1.8 2023/12/03 00:49:46 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -33,21 +33,21 @@
 #ifndef	_VAX_SGMAP_H
 #define	_VAX_SGMAP_H
 
-#include 
+#include 
 #include 
 #include 
 
 /*
  * A VAX SGMAP's state information.  Nothing in the sgmap requires
- * locking[*], with the exception of the extent map.  Locking of the
- * extent map is handled within the extent manager itself.
+ * locking[*], with the exception of the vmem arena, which takes care
+ * of it on its own.
  *
  * [*] While the page table is a `global' resource, access to it is
- * controlled by the extent map; once a region has been allocated from
- * the map, that region is effectively `locked'.
+ * controlled by the arena; once a region has been allocated from
+ * the arena, that region is effectively `locked'.
  */
 struct vax_sgmap {
-	struct extent *aps_ex;		/* extent map to manage sgva space */
+	vmem_t *aps_arena;		/* arena to manage sgva space */
 	struct pte *aps_pt;		/* page table */
 	bus_addr_t aps_sgvabase;	/* base of the sgva space */
 	bus_size_t aps_sgvasize;	/* size of the sgva space */

Index: src/sys/arch/vax/vax/sgmap.c
diff -u src/sys/arch/vax/vax/sgmap.c:1.19 src/sys/arch/vax/vax/sgmap.c:1.20
--- src/sys/arch/vax/vax/sgmap.c:1.19	Thu Jul  7 06:55:39 2016
+++ src/sys/arch/vax/vax/sgmap.c	Sun Dec  3 00:49:46 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap.c,v 1.19 2016/07/07 06:55:39 msaitoh Exp $ */
+/* $NetBSD: sgmap.c,v 1.20 2023/12/03 00:49:46 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sgmap.c,v 1.19 2016/07/07 06:55:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgmap.c,v 1.20 2023/12/03 00:49:46 thorpej Exp $");
 
 #include 
 #include 
@@ -89,16 +89,18 @@ vax_sgmap_init(bus_dma_tag_t t, struct v
 	}
 
 	/*
-	 * Create the extent map used to manage the virtual address
+	 * Create the arena used to manage the virtual address
 	 * space.
 	 */
-	sgmap->aps_ex = extent_create(name, sgvabase, sgvasize - 1,
-	NULL, 0, EX_NOWAIT|EX_NOCOALESCE);
-	if (sgmap->aps_ex == NULL) {
-		printf("unable to create extent map for sgmap `%s'\n", name);
-		goto die;
-	}
-
+	sgmap->aps_arena = vmem_create(name, sgvabase, sgvasize,
+   VAX_NBPG,	/* quantum */
+   NULL,		/* importfn */
+   NULL,		/* releasefn */
+   NULL,		/* source */
+   0,		/* qcache_max */
+   VM_SLEEP,
+   IPL_VM);
+	KASSERT(sgmap->aps_arena != NULL);
 	return;
  die:
 	panic("vax_sgmap_init");
@@ -131,9 +133,18 @@ vax_sgmap_alloc(bus_dmamap_t map, bus_si
 	(unsigned int)origlen, (unsigned int)len, (unsigned int)map->_dm_sgvalen, (unsigned int)map->_dm_boundary, 1);
 #endif
 
-	error = extent_alloc(sgmap->aps_ex, map->_dm_sgvalen, VAX_NBPG,
-	0, (flags & BUS_DMA_NOWAIT) ? EX_NOWAIT : EX_WAITOK,
-	&map->_dm_sgva);
+	const vm_flag_t vmflags = VM_BESTFIT |
+	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
+	error = vmem_xalloc(sgmap->aps_arena, map->_dm_sgvalen,
+			0,			/* alignment */
+			0,			/* phase */
+			map->_dm_boundary,	/* nocross */
+			VMEM_ADDR_MIN,	/* minaddr */
+			VMEM_ADDR_MAX,	/* maxaddr */
+			vmflags,
+			&map->_dm_sgva);
+
 #if DEBUG_SGMAP
 	printf("error %d _dm_sgva %lx\n", error, map->_dm_sgva);
 #endif
@@ -155,9 +166,7 @@ vax_sgmap_free(bus_dmamap_t map, struct 
 		panic("vax_sgmap_free: no sgva space to free");
 #endif
 
-	if (extent_free(sgmap->aps_ex, map->_dm_sgva, map->_dm_sgvalen,
-	EX_NOWAIT))
-		panic("vax_sgmap_free");
+	vmem_xfree(sgmap->aps_arena, map->_dm_sgva, map->_dm_sgvalen);
 
 	map->_dm_flags &= ~DMAMAP_HAS_SGMAP;
 }
@@ -165,7 +174,7 @@ vax_sgmap_free(bus_dmamap_t map, struct 
 int
 vax_sgmap_reserve(bus_addr_t ba, bus_size_t len, struct vax_sgmap *sgmap)
 {
-	return extent_alloc_region(sgmap->aps_ex, ba, len, EX_NOWAIT);
+	return vmem_xalloc_addr(sgmap->aps_arena, ba, len, VM_NOSLEEP);
 }
 
 int



CVS commit: src/sys/arch/vax

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 00:49:46 UTC 2023

Modified Files:
src/sys/arch/vax/include: sgmap.h
src/sys/arch/vax/vax: sgmap.c

Log Message:
Use vmem(9) rather than extent(9) to manage SGMAP space.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/vax/include/sgmap.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/vax/vax/sgmap.c

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



CVS commit: src/tests/usr.bin/xlint/lint1

2023-12-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec  2 23:54:49 UTC 2023

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_schar.c platform_uchar.c

Log Message:
tests/lint: add more test cases for nonportable character comparison


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_schar.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_uchar.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/platform_schar.c
diff -u src/tests/usr.bin/xlint/lint1/platform_schar.c:1.4 src/tests/usr.bin/xlint/lint1/platform_schar.c:1.5
--- src/tests/usr.bin/xlint/lint1/platform_schar.c:1.4	Wed Feb 22 22:30:40 2023
+++ src/tests/usr.bin/xlint/lint1/platform_schar.c	Sat Dec  2 23:54:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_schar.c,v 1.4 2023/02/22 22:30:40 rillig Exp $	*/
+/*	$NetBSD: platform_schar.c,v 1.5 2023/12/02 23:54:49 rillig Exp $	*/
 # 3 "platform_schar.c"
 
 /*
@@ -6,9 +6,14 @@
  * representation as signed char.
  */
 
-/* lint1-extra-flags: -c -h -a -p -b -r -z */
+/* lint1-extra-flags: -c -h -a -p -b -r -z -X 161 */
 /* lint1-only-if: schar */
 
-/* CONSTCOND */
 /* expect+1: warning: nonportable character comparison '-128 < ?' [230] */
-typedef int is_signed[(char)'\200' < (char)'\177' ? 1 : -1];
+typedef int char_char[(char)'\200' < (char)'\177' ? 1 : -1];
+/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */
+typedef int char_int[(char)'\200' < (char)127 ? 1 : -1];
+/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */
+typedef int int_char[(char)-128 < (char)'\177' ? 1 : -1];
+/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */
+typedef int int_int[(char)-128 < (char)127 ? 1 : -1];

Index: src/tests/usr.bin/xlint/lint1/platform_uchar.c
diff -u src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.3 src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.4
--- src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.3	Wed Feb 22 22:12:35 2023
+++ src/tests/usr.bin/xlint/lint1/platform_uchar.c	Sat Dec  2 23:54:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_uchar.c,v 1.3 2023/02/22 22:12:35 rillig Exp $	*/
+/*	$NetBSD: platform_uchar.c,v 1.4 2023/12/02 23:54:49 rillig Exp $	*/
 # 3 "platform_uchar.c"
 
 /*
@@ -6,9 +6,14 @@
  * representation as unsigned char.
  */
 
-/* lint1-extra-flags: -c -h -a -p -b -r -z */
+/* lint1-extra-flags: -c -h -a -p -b -r -z -X 161 */
 /* lint1-only-if: uchar */
 
-/* CONSTCOND */
 /* expect+1: warning: nonportable character comparison '< 128' [230] */
-typedef int is_unsigned[(char)'\177' < (char)'\200' ? 1 : -1];
+typedef int char_char[(char)'\177' < (char)'\200' ? 1 : -1];
+/* expect+1: warning: nonportable character comparison '< 128' [230] */
+typedef int int_char[(char)127 < (char)'\200' ? 1 : -1];
+/* expect+1: warning: nonportable character comparison '< 128' [230] */
+typedef int char_int[(char)'\177' < (char)128 ? 1 : -1];
+/* expect+1: warning: nonportable character comparison '< 128' [230] */
+typedef int int_int[(char)127 < (char)128 ? 1 : -1];



CVS commit: src/tests/usr.bin/xlint/lint1

2023-12-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec  2 23:54:49 UTC 2023

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_schar.c platform_uchar.c

Log Message:
tests/lint: add more test cases for nonportable character comparison


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_schar.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_uchar.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/dreamcast/dev/g2

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 22:42:02 UTC 2023

Modified Files:
src/sys/arch/dreamcast/dev/g2: gapspci_dma.c gapspcivar.h

Log Message:
Use vmem(9) rather than extent(9) to manage the GAPS PCI DMA buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/dreamcast/dev/g2/gapspci_dma.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/dreamcast/dev/g2/gapspcivar.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/dreamcast/dev/g2/gapspci_dma.c
diff -u src/sys/arch/dreamcast/dev/g2/gapspci_dma.c:1.20 src/sys/arch/dreamcast/dev/g2/gapspci_dma.c:1.21
--- src/sys/arch/dreamcast/dev/g2/gapspci_dma.c:1.20	Fri Jan 27 18:52:53 2012
+++ src/sys/arch/dreamcast/dev/g2/gapspci_dma.c	Sat Dec  2 22:42:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: gapspci_dma.c,v 1.20 2012/01/27 18:52:53 para Exp $	*/
+/*	$NetBSD: gapspci_dma.c,v 1.21 2023/12/02 22:42:02 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -32,20 +32,20 @@
 /*
  * Bus DMA implementation for the SEGA GAPS PCI bridge.
  *
- * NOTE: We only implement a small subset of what the bus_space(9)
+ * NOTE: We only implement a small subset of what the bus_dma(9)
  * API specifies.  Right now, the GAPS PCI bridge is only used for
  * the Dreamcast Broadband Adatper, so we only provide what the
  * pci(4) and rtk(4) drivers need.
  */
 
 #include 			/* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: gapspci_dma.c,v 1.20 2012/01/27 18:52:53 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gapspci_dma.c,v 1.21 2023/12/02 22:42:02 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -105,11 +105,18 @@ gaps_dma_init(struct gaps_softc *sc)
 
 	/*
 	 * The GAPS PCI bridge has 32k of DMA memory.  We manage it
-	 * with an extent map.
+	 * with a vmem arena.
 	 */
-	sc->sc_dma_ex = extent_create("gaps dma",
-	sc->sc_dmabase, sc->sc_dmabase + (sc->sc_dmasize - 1),
-	NULL, 0, EX_WAITOK | EXF_NOCOALESCE);
+	sc->sc_dma_arena = vmem_create("gaps dma",
+   sc->sc_dmabase,
+   sc->sc_dmasize,
+   1024 /* XXX */,	/* quantum */
+   NULL,		/* allocfn */
+   NULL,		/* freefn */
+   NULL,		/* arg */
+   0,		/* qcache_max */
+   VM_SLEEP,
+   IPL_VM);
 
 	if (bus_space_map(sc->sc_memt, sc->sc_dmabase, sc->sc_dmasize,
 	0, &sc->sc_dma_memh) != 0)
@@ -169,12 +176,20 @@ gaps_dmamap_create(bus_dma_tag_t t, bus_
 	map->dm_maxsegsz = maxsegsz;
 
 	if (flags & BUS_DMA_ALLOCNOW) {
-		u_long res;
+		vmem_addr_t res;
 		int error;
 
-		error = extent_alloc(sc->sc_dma_ex, size, 1024 /* XXX */,
-		map->_dm_boundary,
-		(flags & BUS_DMA_NOWAIT) ? EX_NOWAIT : EX_WAITOK, &res);
+		const vm_flag_t vmflags = VM_BESTFIT |
+		((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
+		error = vmem_xalloc(sc->sc_dma_arena, size,
+0,			/* alignment */
+0,			/* phase */
+0,			/* nocross */
+VMEM_ADDR_MIN,	/* minaddr */
+VMEM_ADDR_MAX,	/* maxaddr */
+vmflags,
+&res);
 		if (error) {
 			free(gmap, M_DEVBUF);
 			return error;
@@ -201,9 +216,8 @@ gaps_dmamap_destroy(bus_dma_tag_t t, bus
 	struct gaps_softc *sc = t->_cookie;
 
 	if (map->_dm_flags & BUS_DMA_ALLOCNOW) {
-		(void) extent_free(sc->sc_dma_ex,
-		map->dm_segs[0].ds_addr,
-		map->dm_mapsize, EX_NOWAIT);
+		vmem_xfree(sc->sc_dma_arena, map->dm_segs[0].ds_addr,
+		map->dm_mapsize);
 	}
 	free(map, M_DMAMAP);
 }
@@ -214,7 +228,7 @@ gaps_dmamap_load(bus_dma_tag_t t, bus_dm
 {
 	struct gaps_softc *sc = t->_cookie;
 	struct gaps_dmamap *gmap = (void *) map;
-	u_long res;
+	vmem_addr_t res;
 	int error;
 
 	if ((map->_dm_flags & BUS_DMA_ALLOCNOW) == 0) {
@@ -234,9 +248,17 @@ gaps_dmamap_load(bus_dma_tag_t t, bus_dm
 	if (size > map->_dm_size)
 		return EINVAL;
 
-	error = extent_alloc(sc->sc_dma_ex, size, 1024 /* XXX */,
-	map->_dm_boundary,
-	(flags & BUS_DMA_NOWAIT) ? EX_NOWAIT : EX_WAITOK, &res);
+	const vm_flag_t vmflags = VM_BESTFIT |
+	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
+	error = vmem_xalloc(sc->sc_dma_arena, size,
+			0,			/* alignment */
+			0,			/* phase */
+			map->_dm_boundary,	/* nocross */
+			VMEM_ADDR_MIN,	/* minaddr */
+			VMEM_ADDR_MAX,	/* maxaddr */
+			vmflags,
+			&res);
 	if (error)
 		return error;
 
@@ -258,7 +280,7 @@ gaps_dmamap_load_mbuf(bus_dma_tag_t t, b
 {
 	struct gaps_softc *sc = t->_cookie;
 	struct gaps_dmamap *gmap = (void *) map;
-	u_long res;
+	vmem_addr_t res;
 	int error;
 
 	if ((map->_dm_flags & BUS_DMA_ALLOCNOW) == 0) {
@@ -279,9 +301,17 @@ gaps_dmamap_load_mbuf(bus_dma_tag_t t, b
 	if (m0->m_pkthdr.len > map->_dm_size)
 		return EINVAL;
 
-	error = extent_alloc(sc->sc_dma_ex, m0->m_pkthdr.len, 1024 /* XXX */,
-	map->_dm_boundary,
-	(flags & BUS_DMA_N

CVS commit: src/sys/arch/dreamcast/dev/g2

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 22:42:02 UTC 2023

Modified Files:
src/sys/arch/dreamcast/dev/g2: gapspci_dma.c gapspcivar.h

Log Message:
Use vmem(9) rather than extent(9) to manage the GAPS PCI DMA buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/dreamcast/dev/g2/gapspci_dma.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/dreamcast/dev/g2/gapspcivar.h

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



CVS commit: src/usr.bin/xlint/lint1

2023-12-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec  2 21:53:15 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: extract nonportable char comparison to separate function

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.582 -r1.583 src/usr.bin/xlint/lint1/tree.c

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/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.582 src/usr.bin/xlint/lint1/tree.c:1.583
--- src/usr.bin/xlint/lint1/tree.c:1.582	Sat Dec  2 21:47:05 2023
+++ src/usr.bin/xlint/lint1/tree.c	Sat Dec  2 21:53:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.582 2023/12/02 21:47:05 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.583 2023/12/02 21:53:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.582 2023/12/02 21:47:05 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.583 2023/12/02 21:53:15 rillig Exp $");
 #endif
 
 #include 
@@ -576,6 +576,33 @@ is_out_of_char_range(const tnode_t *tn)
 		 tn->tn_val.u.integer < 1 << (CHAR_SIZE - 1));
 }
 
+static bool
+check_nonportable_char_comparison(op_t op,
+  const tnode_t *ln, tspec_t lt,
+  const tnode_t *rn, tspec_t rt)
+{
+	if (!(hflag || pflag))
+		return true;
+
+	if (lt == CHAR && is_out_of_char_range(rn)) {
+		char buf[128];
+		(void)snprintf(buf, sizeof(buf), "%s %d",
+		op_name(op), (int)rn->tn_val.u.integer);
+		/* nonportable character comparison '%s' */
+		warning(230, buf);
+		return false;
+	}
+	if (rt == CHAR && is_out_of_char_range(ln)) {
+		char buf[128];
+		(void)snprintf(buf, sizeof(buf), "%d %s ?",
+		(int)ln->tn_val.u.integer, op_name(op));
+		/* nonportable character comparison '%s' */
+		warning(230, buf);
+		return false;
+	}
+	return true;
+}
+
 static void
 check_integer_comparison(op_t op, tnode_t *ln, tnode_t *rn)
 {
@@ -604,24 +631,8 @@ check_integer_comparison(op_t op, tnode_
 		}
 	}
 
-	if (hflag || pflag) {
-		if (lt == CHAR && is_out_of_char_range(rn)) {
-			char buf[128];
-			(void)snprintf(buf, sizeof(buf), "%s %d",
-			op_name(op), (int)rn->tn_val.u.integer);
-			/* nonportable character comparison '%s' */
-			warning(230, buf);
-			return;
-		}
-		if (rt == CHAR && is_out_of_char_range(ln)) {
-			char buf[128];
-			(void)snprintf(buf, sizeof(buf), "%d %s ?",
-			(int)ln->tn_val.u.integer, op_name(op));
-			/* nonportable character comparison '%s' */
-			warning(230, buf);
-			return;
-		}
-	}
+	if (!check_nonportable_char_comparison(op, ln, lt, rn, rt))
+		return;
 
 	if (is_uinteger(lt) && !is_uinteger(rt) &&
 	rn->tn_op == CON && rn->tn_val.u.integer <= 0) {



CVS commit: src/usr.bin/xlint/lint1

2023-12-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec  2 21:53:15 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: extract nonportable char comparison to separate function

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.582 -r1.583 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src/usr.bin/xlint

2023-12-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec  2 21:50:21 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: emit1.c func.c init.c
src/usr.bin/xlint/lint2: chk.c

Log Message:
lint: remove redundant empty lines

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.bin/xlint/lint1/emit1.c
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint2/chk.c

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/xlint/lint1/emit1.c
diff -u src/usr.bin/xlint/lint1/emit1.c:1.77 src/usr.bin/xlint/lint1/emit1.c:1.78
--- src/usr.bin/xlint/lint1/emit1.c:1.77	Wed Sep 13 20:31:58 2023
+++ src/usr.bin/xlint/lint1/emit1.c	Sat Dec  2 21:50:20 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.77 2023/09/13 20:31:58 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.78 2023/12/02 21:50:20 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: emit1.c,v 1.77 2023/09/13 20:31:58 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.78 2023/12/02 21:50:20 rillig Exp $");
 #endif
 
 #include "lint1.h"
@@ -374,7 +374,6 @@ outcall(const tnode_t *tn, bool retval_u
 			outint(n);
 			outfstrg(arg->tn_left->tn_string);
 		}
-
 	}
 	outchar((char)(retval_discarded ? 'd' : retval_used ? 'u' : 'i'));
 
@@ -539,7 +538,6 @@ outfstrg(strg_t *strg)
 }
 			}
 		}
-
 	}
 
 	outchar('"');

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.174 src/usr.bin/xlint/lint1/func.c:1.175
--- src/usr.bin/xlint/lint1/func.c:1.174	Sun Aug  6 19:44:50 2023
+++ src/usr.bin/xlint/lint1/func.c	Sat Dec  2 21:50:20 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.174 2023/08/06 19:44:50 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.175 2023/12/02 21:50:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.174 2023/08/06 19:44:50 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.175 2023/12/02 21:50:20 rillig Exp $");
 #endif
 
 #include 
@@ -318,12 +318,10 @@ begin_function(sym_t *fsym)
 
 			if (rdsym->s_inline)
 fsym->s_inline = true;
-
 		}
 
 		/* remove the old symbol from the symbol table */
 		rmsym(rdsym);
-
 	}
 
 	if (fsym->s_osdef && !fsym->s_type->t_proto) {

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.250 src/usr.bin/xlint/lint1/init.c:1.251
--- src/usr.bin/xlint/lint1/init.c:1.250	Sun Jul 30 22:27:21 2023
+++ src/usr.bin/xlint/lint1/init.c	Sat Dec  2 21:50:20 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.250 2023/07/30 22:27:21 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.251 2023/12/02 21:50:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: init.c,v 1.250 2023/07/30 22:27:21 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.251 2023/12/02 21:50:20 rillig Exp $");
 #endif
 
 #include 
@@ -598,7 +598,6 @@ warn_too_many_initializers(designator_ki
 		/* too many initializers */
 		error(174);
 	}
-
 }
 
 static bool

Index: src/usr.bin/xlint/lint2/chk.c
diff -u src/usr.bin/xlint/lint2/chk.c:1.61 src/usr.bin/xlint/lint2/chk.c:1.62
--- src/usr.bin/xlint/lint2/chk.c:1.61	Sat Aug 26 10:43:53 2023
+++ src/usr.bin/xlint/lint2/chk.c	Sat Dec  2 21:50:21 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.61 2023/08/26 10:43:53 rillig Exp $ */
+/* $NetBSD: chk.c,v 1.62 2023/12/02 21:50:21 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: chk.c,v 1.61 2023/08/26 10:43:53 rillig Exp $");
+__RCSID("$NetBSD: chk.c,v 1.62 2023/12/02 21:50:21 rillig Exp $");
 #endif
 
 #include 
@@ -1302,7 +1302,6 @@ types_compatible(type_t *tp1, type_t *tp
 		ignqual = promot = false;
 		to = t;
 		indir++;
-
 	}
 
 	return tp1 == tp2;
@@ -1329,7 +1328,6 @@ prototypes_compatible(type_t *tp1, type_
 
 		a1++;
 		a2++;
-
 	}
 
 	return *a1 == *a2;



CVS commit: src/usr.bin/xlint

2023-12-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec  2 21:50:21 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: emit1.c func.c init.c
src/usr.bin/xlint/lint2: chk.c

Log Message:
lint: remove redundant empty lines

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.bin/xlint/lint1/emit1.c
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint2/chk.c

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



CVS commit: src/usr.bin/xlint/lint1

2023-12-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec  2 21:47:05 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: debug.c decl.c lex.c lint1.h tree.c

Log Message:
lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC.  No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.379 -r1.380 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.192 -r1.193 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.202 -r1.203 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.581 -r1.582 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src/usr.bin/xlint/lint1

2023-12-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec  2 21:47:05 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: debug.c decl.c lex.c lint1.h tree.c

Log Message:
lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC.  No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.379 -r1.380 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.192 -r1.193 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.202 -r1.203 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.581 -r1.582 src/usr.bin/xlint/lint1/tree.c

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/xlint/lint1/debug.c
diff -u src/usr.bin/xlint/lint1/debug.c:1.63 src/usr.bin/xlint/lint1/debug.c:1.64
--- src/usr.bin/xlint/lint1/debug.c:1.63	Tue Oct 17 19:29:09 2023
+++ src/usr.bin/xlint/lint1/debug.c	Sat Dec  2 21:47:05 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.63 2023/10/17 19:29:09 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.64 2023/12/02 21:47:05 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.63 2023/10/17 19:29:09 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.64 2023/12/02 21:47:05 rillig Exp $");
 #endif
 
 #include 
@@ -385,7 +385,7 @@ debug_sym(const char *prefix, const sym_
 	debug_word(sym->s_osdef, "old-style");
 	debug_word(sym->s_inline, "inline");
 	debug_word(sym->s_ext_sym != NULL, "has-external");
-	debug_word(sym->s_scl != NOSCL, scl_name(sym->s_scl));
+	debug_word(sym->s_scl != NO_SCL, scl_name(sym->s_scl));
 	debug_word(sym->s_keyword == NULL, def_name(sym->s_def));
 
 	if (sym->s_def_pos.p_file != NULL)
@@ -441,7 +441,7 @@ debug_decl_level(const decl_level *dl)
 {
 
 	debug_printf("kind=%s", decl_level_kind_name(dl->d_kind));
-	if (dl->d_scl != NOSCL)
+	if (dl->d_scl != NO_SCL)
 		debug_printf(" %s", scl_name(dl->d_scl));
 	if (dl->d_type != NULL)
 		debug_printf(" '%s'", type_name(dl->d_type));

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.379 src/usr.bin/xlint/lint1/decl.c:1.380
--- src/usr.bin/xlint/lint1/decl.c:1.379	Thu Sep 14 21:53:02 2023
+++ src/usr.bin/xlint/lint1/decl.c	Sat Dec  2 21:47:05 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.379 2023/09/14 21:53:02 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.380 2023/12/02 21:47:05 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.379 2023/09/14 21:53:02 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.380 2023/12/02 21:47:05 rillig Exp $");
 #endif
 
 #include 
@@ -206,7 +206,7 @@ dcs_add_storage_class(scl_t sc)
 		warning(83);
 	}
 
-	if (dcs->d_scl == NOSCL)
+	if (dcs->d_scl == NO_SCL)
 		dcs->d_scl = sc;
 	else if ((dcs->d_scl == EXTERN && sc == THREAD_LOCAL)
 	|| (dcs->d_scl == THREAD_LOCAL && sc == EXTERN))
@@ -607,7 +607,7 @@ dcs_begin_type(void)
 	dcs->d_complex_mod = NO_TSPEC;
 	dcs->d_sign_mod = NO_TSPEC;
 	dcs->d_rank_mod = NO_TSPEC;
-	dcs->d_scl = NOSCL;
+	dcs->d_scl = NO_SCL;
 	dcs->d_type = NULL;
 	dcs->d_redeclared_symbol = NULL;
 	dcs->d_qual = (type_qualifiers) { .tq_const = false };
@@ -630,14 +630,14 @@ dcs_adjust_storage_class(void)
 		if (dcs->d_scl == REG || dcs->d_scl == AUTO) {
 			/* illegal storage class */
 			error(8);
-			dcs->d_scl = NOSCL;
+			dcs->d_scl = NO_SCL;
 		}
 	} else if (dcs->d_kind == DLK_OLD_STYLE_PARAMS ||
 		   dcs->d_kind == DLK_PROTO_PARAMS) {
-		if (dcs->d_scl != NOSCL && dcs->d_scl != REG) {
+		if (dcs->d_scl != NO_SCL && dcs->d_scl != REG) {
 			/* only 'register' is valid as storage class ... */
 			error(9);
-			dcs->d_scl = NOSCL;
+			dcs->d_scl = NO_SCL;
 		}
 	}
 }
@@ -1431,9 +1431,9 @@ check_function_definition(sym_t *sym, bo
 sym_t *
 declarator_name(sym_t *sym)
 {
-	scl_t sc = NOSCL;
+	scl_t sc = NO_SCL;
 
-	if (sym->s_scl == NOSCL)
+	if (sym->s_scl == NO_SCL)
 		dcs->d_redeclared_symbol = NULL;
 	else if (sym->s_defparam) {
 		sym->s_defparam = false;
@@ -1458,7 +1458,7 @@ declarator_name(sym_t *sym)
 		 * or this is a function definition.
 		 */
 		sc = dcs->d_scl;
-		if (sc == NOSCL || sc == THREAD_LOCAL) {
+		if (sc == NO_SCL || sc == THREAD_LOCAL) {
 			sc = EXTERN;
 			sym->s_def = TDEF;
 		} else if (sc == STATIC)
@@ -1474,13 +1474,13 @@ declarator_name(sym_t *sym)
 		sym->s_param = true;
 		/* FALLTHROUGH */
 	case DLK_OLD_STYLE_PARAMS:
-		lint_assert(dcs->d_scl == NOSCL || dcs->d_scl == REG);
+		lint_assert(dcs->d_scl == NO_SCL || dcs->d_scl == REG);
 		sym->s_register = dcs->d_scl == REG;
 		sc = AUTO;
 		sym->s_def = DEF;
 		break;
 	case DLK_AUTO:
-		if ((sc = dcs->d_scl) == NOSCL) {
+		if ((sc = dcs->d_scl) == NO_SCL) {
 			/*
 			 * XXX somewhat ugly because we don't know whether this
 			 * is AUTO or EXTERN (functions). If we are wrong, it
@@ -1504,7 +1

CVS commit: src/sys/arch/sparc64/dev

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 21:02:53 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: sbus.c

Log Message:
Use vmem_xalloc_addr() to reserve the first Sbus DVMA page.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/sparc64/dev/sbus.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/sparc64/dev/sbus.c
diff -u src/sys/arch/sparc64/dev/sbus.c:1.105 src/sys/arch/sparc64/dev/sbus.c:1.106
--- src/sys/arch/sparc64/dev/sbus.c:1.105	Fri Dec  1 06:47:59 2023
+++ src/sys/arch/sparc64/dev/sbus.c	Sat Dec  2 21:02:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbus.c,v 1.105 2023/12/01 06:47:59 thorpej Exp $ */
+/*	$NetBSD: sbus.c,v 1.106 2023/12/02 21:02:53 thorpej Exp $ */
 
 /*
  * Copyright (c) 1999-2002 Eduardo Horvath
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.105 2023/12/01 06:47:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.106 2023/12/02 21:02:53 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -268,19 +268,9 @@ sbus_attach(device_t parent, device_t se
 	 * NULL DMA pointer will be translated by the first page of the IOTSB.
 	 * To avoid bugs we'll alloc and ignore the first entry in the IOTSB.
 	 */
-	{
-		vmem_addr_t dummy;
-
-		if (vmem_xalloc(sc->sc_is.is_dvmamap, PAGE_SIZE,
-0,		/* alignment */
-0,		/* phase */
-0,		/* nocross */
-sc->sc_is.is_dvmabase,
-sc->sc_is.is_dvmabase + PAGE_SIZE - 1,
-VM_BESTFIT | VM_NOSLEEP,
-&dummy) != 0) {
-			panic("sbus iommu: can't toss first dvma page");
-		}
+	if (vmem_xalloc_addr(sc->sc_is.is_dvmamap, sc->sc_is.is_dvmabase,
+			PAGE_SIZE, VM_NOSLEEP) != 0) {
+		panic("sbus iommu: can't toss first dvma page");
 	}
 
 	/*



CVS commit: src/sys/arch/sparc64/dev

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 21:02:53 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: sbus.c

Log Message:
Use vmem_xalloc_addr() to reserve the first Sbus DVMA page.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/sparc64/dev/sbus.c

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



CVS commit: src

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 21:02:13 UTC 2023

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile vmem.9
src/sys/kern: subr_vmem.c
src/sys/sys: vmem.h

Log Message:
Add a vmem_xalloc_addr() function, which allocates a specific address
from an arena.  This is just a convenience wrapper around vmem_xalloc(),
that's just a bit more obvious how to use and performs some additional
sanity checks.


To generate a diff of this commit:
cvs rdiff -u -r1.2450 -r1.2451 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.467 -r1.468 src/share/man/man9/Makefile
cvs rdiff -u -r1.21 -r1.22 src/share/man/man9/vmem.9
cvs rdiff -u -r1.110 -r1.111 src/sys/kern/subr_vmem.c
cvs rdiff -u -r1.23 -r1.24 src/sys/sys/vmem.h

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2450 src/distrib/sets/lists/comp/mi:1.2451
--- src/distrib/sets/lists/comp/mi:1.2450	Sun Oct 15 13:04:15 2023
+++ src/distrib/sets/lists/comp/mi	Sat Dec  2 21:02:12 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2450 2023/10/15 13:04:15 riastradh Exp $
+#	$NetBSD: mi,v 1.2451 2023/12/02 21:02:12 thorpej Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -13097,6 +13097,7 @@
 ./usr/share/man/cat9/vmem_destroy.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/vmem_free.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/vmem_xalloc.0		comp-sys-catman		.cat
+./usr/share/man/cat9/vmem_xalloc_addr.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/vmem_xfree.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/vmem_xfreeall.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/vn_bwrite.0		comp-sys-catman		.cat
@@ -21435,6 +21436,7 @@
 ./usr/share/man/html9/vmem_destroy.html		comp-sys-htmlman	html
 ./usr/share/man/html9/vmem_free.html		comp-sys-htmlman	html
 ./usr/share/man/html9/vmem_xalloc.html		comp-sys-htmlman	html
+./usr/share/man/html9/vmem_xalloc_addr.html	comp-sys-htmlman	html
 ./usr/share/man/html9/vmem_xfree.html		comp-sys-htmlman	html
 ./usr/share/man/html9/vmem_xfreeall.html	comp-sys-htmlman	html
 ./usr/share/man/html9/vn_bwrite.html		comp-sys-htmlman	html
@@ -30012,6 +30014,7 @@
 ./usr/share/man/man9/vmem_destroy.9		comp-sys-man		.man
 ./usr/share/man/man9/vmem_free.9		comp-sys-man		.man
 ./usr/share/man/man9/vmem_xalloc.9		comp-sys-man		.man
+./usr/share/man/man9/vmem_xalloc_addr.9		comp-sys-man		.man
 ./usr/share/man/man9/vmem_xfree.9		comp-sys-man		.man
 ./usr/share/man/man9/vmem_xfreeall.9		comp-sys-man		.man
 ./usr/share/man/man9/vn_bwrite.9		comp-sys-man		.man

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.467 src/share/man/man9/Makefile:1.468
--- src/share/man/man9/Makefile:1.467	Sat Jul  8 16:14:11 2023
+++ src/share/man/man9/Makefile	Sat Dec  2 21:02:12 2023
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.467 2023/07/08 16:14:11 christos Exp $
+#   $NetBSD: Makefile,v 1.468 2023/12/02 21:02:12 thorpej Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -1071,6 +1071,7 @@ MLINKS+=vmem.9 vmem_alloc.9 \
 	vmem.9 vmem_destroy.9 \
 	vmem.9 vmem_free.9 \
 	vmem.9 vmem_xalloc.9 \
+	vmem.9 vmem_xalloc_addr.9 \
 	vmem.9 vmem_xfree.9 \
 	vmem.9 vmem_xfreeall.9
 MLINKS+=vnode.9 vref.9 \

Index: src/share/man/man9/vmem.9
diff -u src/share/man/man9/vmem.9:1.21 src/share/man/man9/vmem.9:1.22
--- src/share/man/man9/vmem.9:1.21	Sat Oct 15 14:54:21 2022
+++ src/share/man/man9/vmem.9	Sat Dec  2 21:02:12 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vmem.9,v 1.21 2022/10/15 14:54:21 riastradh Exp $
+.\"	$NetBSD: vmem.9,v 1.22 2023/12/02 21:02:12 thorpej Exp $
 .\"
 .\" Copyright (c)2006 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" 
-.Dd June 15, 2020
+.Dd December 2, 2023
 .Dt VMEM 9
 .Os
 .\" 
@@ -60,6 +60,10 @@
 "vmem_size_t phase" "vmem_size_t nocross" "vmem_addr_t minaddr" \
 "vmem_addr_t maxaddr" "vm_flag_t flags" "vmem_addr_t *addrp"
 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+.Ft int
+.Fn vmem_xalloc_addr \
+"vmem_t *vm" "vmem_addr_t addr" "vmem_size_t size" "vm_flag_t flags"
+.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 .Ft void
 .Fn vmem_xfree "vmem_t *vm" "vmem_addr_t addr" "vmem_size_t size"
 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -387,9 +391,40 @@ overwrites it with the start address of 
 .El
 .Pp
 .\" 
+.Fn vmem_xalloc_addr
+allocates a specific address from the arena.
+The requested address must be aligned with the arena's quantum.
+.Bl -tag -offset indent -width flags
+.It Fa vm
+The arena which we allocate from.
+.It 

CVS commit: src

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 21:02:13 UTC 2023

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile vmem.9
src/sys/kern: subr_vmem.c
src/sys/sys: vmem.h

Log Message:
Add a vmem_xalloc_addr() function, which allocates a specific address
from an arena.  This is just a convenience wrapper around vmem_xalloc(),
that's just a bit more obvious how to use and performs some additional
sanity checks.


To generate a diff of this commit:
cvs rdiff -u -r1.2450 -r1.2451 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.467 -r1.468 src/share/man/man9/Makefile
cvs rdiff -u -r1.21 -r1.22 src/share/man/man9/vmem.9
cvs rdiff -u -r1.110 -r1.111 src/sys/kern/subr_vmem.c
cvs rdiff -u -r1.23 -r1.24 src/sys/sys/vmem.h

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



CVS commit: src/sys/sys

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 19:11:52 UTC 2023

Modified Files:
src/sys/sys: vmem.h vmem_impl.h

Log Message:
vmem_init() requires the caller to include  in order
to know the storage size of "struct vmem", so put the prototype for
vmem_init() there as well.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/sys/vmem.h
cvs rdiff -u -r1.5 -r1.6 src/sys/sys/vmem_impl.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/sys/vmem.h
diff -u src/sys/sys/vmem.h:1.22 src/sys/sys/vmem.h:1.23
--- src/sys/sys/vmem.h:1.22	Tue Jun 16 06:42:36 2020
+++ src/sys/sys/vmem.h	Sat Dec  2 19:11:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmem.h,v 1.22 2020/06/16 06:42:36 thorpej Exp $	*/
+/*	$NetBSD: vmem.h,v 1.23 2023/12/02 19:11:52 thorpej Exp $	*/
 
 /*-
  * Copyright (c)2006 YAMAMOTO Takashi,
@@ -64,9 +64,6 @@ vmem_t *	vmem_create(const char *, vmem_
 vmem_t *	vmem_xcreate(const char *, vmem_addr_t, vmem_size_t,
 		vmem_size_t, vmem_ximport_t *, vmem_release_t *, vmem_t *,
 		vmem_size_t, vm_flag_t, int);
-vmem_t *	vmem_init(vmem_t *, const char *, vmem_addr_t, vmem_size_t,
-		vmem_size_t, vmem_import_t *, vmem_release_t *, vmem_t *,
-		vmem_size_t, vm_flag_t, int);
 void		vmem_destroy(vmem_t *);
 int		vmem_alloc(vmem_t *, vmem_size_t, vm_flag_t, vmem_addr_t *);
 void		vmem_free(vmem_t *, vmem_addr_t, vmem_size_t);

Index: src/sys/sys/vmem_impl.h
diff -u src/sys/sys/vmem_impl.h:1.5 src/sys/sys/vmem_impl.h:1.6
--- src/sys/sys/vmem_impl.h:1.5	Tue Jul  7 03:23:33 2020
+++ src/sys/sys/vmem_impl.h	Sat Dec  2 19:11:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmem_impl.h,v 1.5 2020/07/07 03:23:33 thorpej Exp $	*/
+/*	$NetBSD: vmem_impl.h,v 1.6 2023/12/02 19:11:52 thorpej Exp $	*/
 
 /*-
  * Copyright (c)2006 YAMAMOTO Takashi,
@@ -139,4 +139,8 @@ struct vmem_btag {
 
 #define	BT_END(bt)	((bt)->bt_start + (bt)->bt_size - 1)
 
+vmem_t *	vmem_init(vmem_t *, const char *, vmem_addr_t, vmem_size_t,
+		vmem_size_t, vmem_import_t *, vmem_release_t *, vmem_t *,
+		vmem_size_t, vm_flag_t, int);
+
 #endif /* !_SYS_VMEM_IMPL_H_ */



CVS commit: src/sys/sys

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 19:11:52 UTC 2023

Modified Files:
src/sys/sys: vmem.h vmem_impl.h

Log Message:
vmem_init() requires the caller to include  in order
to know the storage size of "struct vmem", so put the prototype for
vmem_init() there as well.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/sys/vmem.h
cvs rdiff -u -r1.5 -r1.6 src/sys/sys/vmem_impl.h

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



CVS commit: src/sys/kern

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 19:06:17 UTC 2023

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

Log Message:
Minor changes to let this build as the "subr_vmem" test program again.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/subr_vmem.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/subr_vmem.c
diff -u src/sys/kern/subr_vmem.c:1.109 src/sys/kern/subr_vmem.c:1.110
--- src/sys/kern/subr_vmem.c:1.109	Sun Apr  9 09:18:09 2023
+++ src/sys/kern/subr_vmem.c	Sat Dec  2 19:06:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_vmem.c,v 1.109 2023/04/09 09:18:09 riastradh Exp $	*/
+/*	$NetBSD: subr_vmem.c,v 1.110 2023/12/02 19:06:17 thorpej Exp $	*/
 
 /*-
  * Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.109 2023/04/09 09:18:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.110 2023/12/02 19:06:17 thorpej Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -112,12 +112,13 @@ VMEM_EVCNT_DEFINE(static_bt_inuse)
 
 #define	UNITTEST
 #define	KASSERT(a)		assert(a)
+#define	KASSERTMSG(a, m, ...)	assert(a)
 #define	mutex_init(a, b, c)	/* nothing */
 #define	mutex_destroy(a)	/* nothing */
 #define	mutex_enter(a)		/* nothing */
 #define	mutex_tryenter(a)	true
 #define	mutex_exit(a)		/* nothing */
-#define	mutex_owned(a)		/* nothing */
+#define	mutex_owned(a)		true
 #define	ASSERT_SLEEPABLE()	/* nothing */
 #define	panic(...)		printf(__VA_ARGS__); abort()
 #endif /* defined(_KERNEL) */
@@ -142,12 +143,12 @@ static LIST_HEAD(, vmem) vmem_list = LIS
 
 /*  misc */
 
-#define	VMEM_LOCK(vm)		mutex_enter(&vm->vm_lock)
-#define	VMEM_TRYLOCK(vm)	mutex_tryenter(&vm->vm_lock)
-#define	VMEM_UNLOCK(vm)		mutex_exit(&vm->vm_lock)
-#define	VMEM_LOCK_INIT(vm, ipl)	mutex_init(&vm->vm_lock, MUTEX_DEFAULT, ipl)
-#define	VMEM_LOCK_DESTROY(vm)	mutex_destroy(&vm->vm_lock)
-#define	VMEM_ASSERT_LOCKED(vm)	KASSERT(mutex_owned(&vm->vm_lock))
+#define	VMEM_LOCK(vm)		mutex_enter(&(vm)->vm_lock)
+#define	VMEM_TRYLOCK(vm)	mutex_tryenter(&(vm)->vm_lock)
+#define	VMEM_UNLOCK(vm)		mutex_exit(&(vm)->vm_lock)
+#define	VMEM_LOCK_INIT(vm, ipl)	mutex_init(&(vm)->vm_lock, MUTEX_DEFAULT, (ipl))
+#define	VMEM_LOCK_DESTROY(vm)	mutex_destroy(&(vm)->vm_lock)
+#define	VMEM_ASSERT_LOCKED(vm)	KASSERT(mutex_owned(&(vm)->vm_lock))
 
 #define	VMEM_ALIGNUP(addr, align) \
 	(-(-(addr) & -(align)))
@@ -158,11 +159,22 @@ static LIST_HEAD(, vmem) vmem_list = LIS
 #define	ORDER2SIZE(order)	((vmem_size_t)1 << (order))
 #define	SIZE2ORDER(size)	((int)ilog2(size))
 
+static void
+vmem_kick_pdaemon(void)
+{
+#if defined(_KERNEL)
+	uvm_kick_pdaemon();
+#endif
+}
+
+static void vmem_xfree_bt(vmem_t *, bt_t *);
+
 #if !defined(_KERNEL)
 #define	xmalloc(sz, flags)	malloc(sz)
 #define	xfree(p, sz)		free(p)
 #define	bt_alloc(vm, flags)	malloc(sizeof(bt_t))
 #define	bt_free(vm, bt)		free(bt)
+#define	bt_freetrim(vm, l)	/* nothing */
 #else /* defined(_KERNEL) */
 
 #define	xmalloc(sz, flags) \
@@ -194,16 +206,6 @@ static LIST_HEAD(, vmem_btag) vmem_btag_
 static size_t vmem_btag_freelist_count = 0;
 static struct pool vmem_btag_pool;
 
-static void vmem_xfree_bt(vmem_t *, bt_t *);
-
-static void
-vmem_kick_pdaemon(void)
-{
-#if defined(_KERNEL)
-	uvm_kick_pdaemon();
-#endif
-}
-
 /*  boundary tag */
 
 static int bt_refill(vmem_t *vm);
@@ -807,6 +809,7 @@ vmem_import(vmem_t *vm, vmem_size_t size
 	return 0;
 }
 
+#if defined(_KERNEL)
 static int
 vmem_rehash(vmem_t *vm, size_t newhashsize, vm_flag_t flags)
 {
@@ -864,6 +867,7 @@ vmem_rehash(vmem_t *vm, size_t newhashsi
 
 	return 0;
 }
+#endif /* _KERNEL */
 
 /*
  * vmem_fit: check if a bt can satisfy the given restrictions.
@@ -1096,7 +1100,9 @@ vmem_alloc(vmem_t *vm, vmem_size_t size,
 
 	error = vmem_xalloc(vm, size, 0, 0, 0, VMEM_ADDR_MIN, VMEM_ADDR_MAX,
 	flags, addrp);
-out:
+#if defined(QCACHE)
+ out:
+#endif /* defined(QCACHE) */
 	KASSERTMSG(error || addrp == NULL ||
 	(*addrp & vm->vm_quantum_mask) == 0,
 	"vmem %s mask=0x%jx addr=0x%jx",
@@ -1353,8 +1359,10 @@ vmem_xfreeall(vmem_t *vm)
 {
 	bt_t *bt;
 
+#if defined(QCACHE)
 	/* This can't be used if the arena has a quantum cache. */
 	KASSERT(vm->vm_qcache_max == 0);
+#endif /* defined(QCACHE) */
 
 	for (;;) {
 		VMEM_LOCK(vm);



CVS commit: src/sys/kern

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 19:06:17 UTC 2023

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

Log Message:
Minor changes to let this build as the "subr_vmem" test program again.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/subr_vmem.c

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



CVS commit: src/tests/usr.sbin/mtree

2023-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  2 16:18:17 UTC 2023

Modified Files:
src/tests/usr.sbin/mtree: t_mtree.sh

Log Message:
remove dup copy.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.sbin/mtree/t_mtree.sh

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

Modified files:

Index: src/tests/usr.sbin/mtree/t_mtree.sh
diff -u src/tests/usr.sbin/mtree/t_mtree.sh:1.9 src/tests/usr.sbin/mtree/t_mtree.sh:1.10
--- src/tests/usr.sbin/mtree/t_mtree.sh:1.9	Sat Dec  2 08:23:59 2023
+++ src/tests/usr.sbin/mtree/t_mtree.sh	Sat Dec  2 11:18:17 2023
@@ -1,4 +1,4 @@
-# $NetBSD: t_mtree.sh,v 1.9 2023/12/02 13:23:59 christos Exp $
+# $NetBSD: t_mtree.sh,v 1.10 2023/12/02 16:18:17 christos Exp $
 #
 # Copyright (c) 2009, 2012 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -447,42 +447,6 @@ mtree_specspec_type_body()
 	fi
 }
 
-atf_test_case mtree_specspec_type
-mtree_specspec_type_head()
-{
-	atf_set "descr" "Test that spec comparisons detect type changes"
-}
-
-mtree_specspec_type_body()
-{
-	mkdir testdir
-
-	touch testdir/bar
-	mtree -c -p testdir > mtree1.spec
-
-	if [ ! -f mtree1.spec ]; then
-		atf_fail "mtree failed"
-	fi
-
-	rm -f testdir/bar
-	ln -s foo testdir/bar
-	# uid change is expected to be ignored as done in -C
-	chown -h operator testdir/bar
-	mtree -c -p testdir > mtree2.spec
-
-	if [ ! -f mtree2.spec ]; then
-		atf_fail "mtree failed"
-	fi
-
-	atf_check -s ignore -o save:output \
-	-x "mtree -f mtree1.spec -f mtree2.spec"
-
-	if ! cut -f 3 output | egrep -q "bar file" || \
-	! cut -f 3 output | egrep -q "bar link"; then
-		atf_fail "mtree did not detect type change"
-	fi
-}
-
 atf_test_case mtree_onlyfile
 atf_test_case netbsd6_onlyfile
 onlyfile_head()



CVS commit: src/tests/usr.sbin/mtree

2023-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  2 16:18:17 UTC 2023

Modified Files:
src/tests/usr.sbin/mtree: t_mtree.sh

Log Message:
remove dup copy.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.sbin/mtree/t_mtree.sh

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



CVS commit: src/sys/arch/sun2/sun2

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 15:50:57 UTC 2023

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

Log Message:
Use vmem(9) rather than extent(9) to manage DVMA mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/sun2/sun2/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/sun2/sun2/machdep.c
diff -u src/sys/arch/sun2/sun2/machdep.c:1.84 src/sys/arch/sun2/sun2/machdep.c:1.85
--- src/sys/arch/sun2/sun2/machdep.c:1.84	Tue Aug 17 22:00:31 2021
+++ src/sys/arch/sun2/sun2/machdep.c	Sat Dec  2 15:50:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.84 2021/08/17 22:00:31 andvar Exp $	*/
+/*	$NetBSD: machdep.c,v 1.85 2023/12/02 15:50:57 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -149,7 +149,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.84 2021/08/17 22:00:31 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.85 2023/12/02 15:50:57 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_fpu_emulate.h"
@@ -164,7 +164,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #include 
 #include 		/* for MID_* */
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -253,7 +253,7 @@ label_t *nofault;
 /*
  * dvmamap is used to manage DVMA memory.
  */
-static struct extent *dvmamap;
+vmem_t *dvma_arena;
 
 /* Our private scratch page for dumping the MMU. */
 static vaddr_t dumppage;
@@ -351,10 +351,15 @@ cpu_startup(void)
 	/*
 	 * Allocate DMA map for devices on the bus.
 	 */
-	dvmamap = extent_create("dvmamap",
-	DVMA_MAP_BASE, DVMA_MAP_BASE + DVMA_MAP_AVAIL,
-	0, 0, EX_NOWAIT);
-	if (dvmamap == NULL)
+	dvma_arena = vmem_create("dvmamap", DVMA_MAP_BASE, DVMA_MAP_AVAIL,
+ PAGE_SIZE,		/* quantum */
+ NULL,			/* importfn */
+ NULL,			/* releasefn */
+ NULL,			/* source */
+ 0,			/* qcache_max */
+ VM_SLEEP,
+ IPL_VM);
+	if (dvma_arena == NULL)
 		panic("unable to allocate DVMA map");
 
 	/*
@@ -801,7 +806,7 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bu
 {
 	struct vm_page *m;
 	paddr_t pa;
-	bus_addr_t dva;
+	vmem_addr_t dva;
 	bus_size_t sgsize;
 	struct pglist *mlist;
 	int pagesz = PAGE_SIZE;
@@ -831,11 +836,17 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bu
 	 * Otherwise, we need virtual addresses in DVMA space.
 	 */
 	else {
-		error = extent_alloc(dvmamap, sgsize, pagesz,
-	map->_dm_boundary,
-	(flags & BUS_DMA_NOWAIT) == 0
-		? EX_WAITOK : EX_NOWAIT,
-	(u_long *)&dva);
+		const vm_flag_t vmflags = VM_BESTFIT |
+		((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
+		error = vmem_xalloc(dvma_arena, sgsize,
+0,			/* alignment */
+0,			/* phase */
+map->_dm_boundary,	/* nocross */
+VMEM_ADDR_MIN,	/* minaddr */
+VMEM_ADDR_MAX,	/* maxaddr */
+vmflags,
+&dva);
 		if (error)
 			return (error);
 	}
@@ -878,7 +889,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dm
 	bus_size_t sgsize;
 	vaddr_t va = (vaddr_t)buf;
 	int pagesz = PAGE_SIZE;
-	bus_addr_t dva;
+	vmem_addr_t dva;
 	pmap_t pmap;
 	int rv __diagused;
 
@@ -915,9 +926,17 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dm
 	 */
 	sgsize = m68k_round_page(buflen + (va & (pagesz - 1)));
 
-	if (extent_alloc(dvmamap, sgsize, pagesz, map->_dm_boundary,
-			 (flags & BUS_DMA_NOWAIT) == 0 ? EX_WAITOK : EX_NOWAIT,
-			 (u_long *)&dva) != 0) {
+	const vm_flag_t vmflags = VM_BESTFIT |
+	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
+	if (vmem_xalloc(dvma_arena, sgsize,
+			0,			/* alignment */
+			0,			/* phase */
+			map->_dm_boundary,	/* nocross */
+			VMEM_ADDR_MIN,		/* minaddr */
+			VMEM_ADDR_MAX,		/* maxaddr */
+			vmflags,
+			&dva) != 0) {
 		return (ENOMEM);
 	}
 
@@ -982,7 +1001,6 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_
 	int flags = map->_dm_flags;
 	bus_addr_t dva;
 	bus_size_t len;
-	int s, error;
 
 	if (nsegs != 1)
 		panic("_bus_dmamem_unload: nsegs = %d", nsegs);
@@ -1024,11 +1042,7 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_
 			 * This map was loaded using _bus_dmamap_load or
 			 * _bus_dmamap_load_raw for a non-24-bit device.
 			 */
-			s = splhigh();
-			error = extent_free(dvmamap, dva, len, EX_NOWAIT);
-			splx(s);
-			if (error != 0)
-printf("warning: %ld of DVMA space lost\n", len);
+			vmem_xfree(dvma_arena, dva, len);
 		}
 	}
 



CVS commit: src/sys/arch/sun2/sun2

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 15:50:57 UTC 2023

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

Log Message:
Use vmem(9) rather than extent(9) to manage DVMA mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/sun2/sun2/machdep.c

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



CVS commit: src/usr.sbin/mtree

2023-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  2 13:34:48 UTC 2023

Modified Files:
src/usr.sbin/mtree: create.c verify.c

Log Message:
PR/57735: Jose Louis Duran: check if fts_read(3) had an error.
(FreeBSD commit https://github.com/freebsd/freebsd-src/commit/\
2dfa4b66b3d0ce6ce2df476b5615f8415a19)


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/mtree/verify.c

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

Modified files:

Index: src/usr.sbin/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.76 src/usr.sbin/mtree/create.c:1.77
--- src/usr.sbin/mtree/create.c:1.76	Sun Nov 18 18:03:36 2018
+++ src/usr.sbin/mtree/create.c	Sat Dec  2 08:34:48 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.76 2018/11/18 23:03:36 sevan Exp $	*/
+/*	$NetBSD: create.c,v 1.77 2023/12/02 13:34:48 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)create.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: create.c,v 1.76 2018/11/18 23:03:36 sevan Exp $");
+__RCSID("$NetBSD: create.c,v 1.77 2023/12/02 13:34:48 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -173,6 +173,8 @@ cwalk(FILE *fp)
 
 		}
 	}
+	if (errno != 0)
+		mtree_err("fts_read: %s", strerror(errno));
 	fts_close(t);
 	if (sflag && keys & F_CKSUM)
 		mtree_err("%s checksum: %u", fullpath, crc_total);

Index: src/usr.sbin/mtree/verify.c
diff -u src/usr.sbin/mtree/verify.c:1.47 src/usr.sbin/mtree/verify.c:1.48
--- src/usr.sbin/mtree/verify.c:1.47	Thu Mar 18 16:02:18 2021
+++ src/usr.sbin/mtree/verify.c	Sat Dec  2 08:34:48 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: verify.c,v 1.47 2021/03/18 20:02:18 cheusov Exp $	*/
+/*	$NetBSD: verify.c,v 1.48 2023/12/02 13:34:48 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)verify.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: verify.c,v 1.47 2021/03/18 20:02:18 cheusov Exp $");
+__RCSID("$NetBSD: verify.c,v 1.48 2023/12/02 13:34:48 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -166,6 +166,8 @@ vwalk(void)
 		}
 		fts_set(t, p, FTS_SKIP);
 	}
+	if (errno != 0)
+		mtree_err("fts_read: %s", strerror(errno));
 	fts_close(t);
 	if (sflag)
 		warnx("%s checksum: %u", fullpath, crc_total);



CVS commit: src/usr.sbin/mtree

2023-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  2 13:34:48 UTC 2023

Modified Files:
src/usr.sbin/mtree: create.c verify.c

Log Message:
PR/57735: Jose Louis Duran: check if fts_read(3) had an error.
(FreeBSD commit https://github.com/freebsd/freebsd-src/commit/\
2dfa4b66b3d0ce6ce2df476b5615f8415a19)


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/mtree/verify.c

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



CVS commit: src/usr.sbin/mtree

2023-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  2 13:26:09 UTC 2023

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
PR/57735: Jose Louis Duran: Add missing xref to mtree.5
(FreeBSD commit https://github.com/freebsd/freebsd-src/commit/\
da232c04ab9eba3d3a7fc73881daff847071e9fd)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.sbin/mtree/mtree.8

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

Modified files:

Index: src/usr.sbin/mtree/mtree.8
diff -u src/usr.sbin/mtree/mtree.8:1.77 src/usr.sbin/mtree/mtree.8:1.78
--- src/usr.sbin/mtree/mtree.8:1.77	Thu Jun  1 09:04:47 2023
+++ src/usr.sbin/mtree/mtree.8	Sat Dec  2 08:26:09 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mtree.8,v 1.77 2023/06/01 13:04:47 uwe Exp $
+.\"	$NetBSD: mtree.8,v 1.78 2023/12/02 13:26:09 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -56,7 +56,7 @@
 .\"
 .\" @(#)mtree.8	8.2 (Berkeley) 12/11/93
 .\"
-.Dd June 16, 2020
+.Dd December 2, 2023
 .Dt MTREE 8
 .Os
 .Sh NAME
@@ -825,6 +825,7 @@ seconds.nanoseconds without zero padding
 .Xr fnmatch 3 ,
 .Xr fts 3 ,
 .Xr strsvis 3 ,
+.Xr mtree 5 ,
 .Xr chown 8 ,
 .Xr mknod 8
 .Sh HISTORY



CVS commit: src/usr.sbin/mtree

2023-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  2 13:26:09 UTC 2023

Modified Files:
src/usr.sbin/mtree: mtree.8

Log Message:
PR/57735: Jose Louis Duran: Add missing xref to mtree.5
(FreeBSD commit https://github.com/freebsd/freebsd-src/commit/\
da232c04ab9eba3d3a7fc73881daff847071e9fd)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.sbin/mtree/mtree.8

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



CVS commit: src

2023-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  2 13:24:00 UTC 2023

Modified Files:
src/tests/usr.sbin/mtree: t_mtree.sh
src/usr.sbin/mtree: specspec.c

Log Message:
PR/57735: Jose Louis Duran: mtree -f file1 -f file2 does not consider type
changes.
(FreeBSD https://github.com/freebsd/freebsd-src/commit/\
4f4b548b1d21ae16955b09f9b717524167a7d97e)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.sbin/mtree/t_mtree.sh
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/mtree/specspec.c

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



CVS commit: src

2023-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  2 13:24:00 UTC 2023

Modified Files:
src/tests/usr.sbin/mtree: t_mtree.sh
src/usr.sbin/mtree: specspec.c

Log Message:
PR/57735: Jose Louis Duran: mtree -f file1 -f file2 does not consider type
changes.
(FreeBSD https://github.com/freebsd/freebsd-src/commit/\
4f4b548b1d21ae16955b09f9b717524167a7d97e)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.sbin/mtree/t_mtree.sh
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/mtree/specspec.c

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

Modified files:

Index: src/tests/usr.sbin/mtree/t_mtree.sh
diff -u src/tests/usr.sbin/mtree/t_mtree.sh:1.8 src/tests/usr.sbin/mtree/t_mtree.sh:1.9
--- src/tests/usr.sbin/mtree/t_mtree.sh:1.8	Thu Sep  7 00:05:21 2017
+++ src/tests/usr.sbin/mtree/t_mtree.sh	Sat Dec  2 08:23:59 2023
@@ -1,4 +1,4 @@
-# $NetBSD: t_mtree.sh,v 1.8 2017/09/07 04:05:21 nakayama Exp $
+# $NetBSD: t_mtree.sh,v 1.9 2023/12/02 13:23:59 christos Exp $
 #
 # Copyright (c) 2009, 2012 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -411,6 +411,77 @@ netbsd6_nonemptydir_body() 
 	FLAVOR=netbsd6 nonemptydir_body
 }
 
+atf_test_case mtree_specspec_type
+mtree_specspec_type_head()
+{
+	atf_set "descr" "Test that spec comparisons detect type changes"
+}
+
+mtree_specspec_type_body()
+{
+	mkdir testdir
+
+	touch testdir/bar
+	mtree -c -p testdir > mtree1.spec
+
+	if [ ! -f mtree1.spec ]; then
+		atf_fail "mtree failed"
+	fi
+
+	rm -f testdir/bar
+	ln -s foo testdir/bar
+	# uid change is expected to be ignored as done in -C
+	chown -h operator testdir/bar
+	mtree -c -p testdir > mtree2.spec
+
+	if [ ! -f mtree2.spec ]; then
+		atf_fail "mtree failed"
+	fi
+
+	atf_check -s ignore -o save:output \
+	-x "mtree -f mtree1.spec -f mtree2.spec"
+
+	if ! cut -f 3 output | egrep -q "bar file" || \
+	! cut -f 3 output | egrep -q "bar link"; then
+		atf_fail "mtree did not detect type change"
+	fi
+}
+
+atf_test_case mtree_specspec_type
+mtree_specspec_type_head()
+{
+	atf_set "descr" "Test that spec comparisons detect type changes"
+}
+
+mtree_specspec_type_body()
+{
+	mkdir testdir
+
+	touch testdir/bar
+	mtree -c -p testdir > mtree1.spec
+
+	if [ ! -f mtree1.spec ]; then
+		atf_fail "mtree failed"
+	fi
+
+	rm -f testdir/bar
+	ln -s foo testdir/bar
+	# uid change is expected to be ignored as done in -C
+	chown -h operator testdir/bar
+	mtree -c -p testdir > mtree2.spec
+
+	if [ ! -f mtree2.spec ]; then
+		atf_fail "mtree failed"
+	fi
+
+	atf_check -s ignore -o save:output \
+	-x "mtree -f mtree1.spec -f mtree2.spec"
+
+	if ! cut -f 3 output | egrep -q "bar file" || \
+	! cut -f 3 output | egrep -q "bar link"; then
+		atf_fail "mtree did not detect type change"
+	fi
+}
 
 atf_test_case mtree_onlyfile
 atf_test_case netbsd6_onlyfile
@@ -459,6 +530,7 @@ atf_init_test_cases()
 	atf_add_test_case mtree_ignore
 	atf_add_test_case mtree_merge
 	atf_add_test_case mtree_nonemptydir
+	atf_add_test_case mtree_specspec_type
 	atf_add_test_case mtree_onlyfile
 
 	atf_add_test_case netbsd6_create

Index: src/usr.sbin/mtree/specspec.c
diff -u src/usr.sbin/mtree/specspec.c:1.4 src/usr.sbin/mtree/specspec.c:1.5
--- src/usr.sbin/mtree/specspec.c:1.4	Thu Dec 14 13:34:41 2017
+++ src/usr.sbin/mtree/specspec.c	Sat Dec  2 08:24:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: specspec.c,v 1.4 2017/12/14 18:34:41 christos Exp $	*/
+/*	$NetBSD: specspec.c,v 1.5 2023/12/02 13:24:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003 Poul-Henning Kamp
@@ -31,7 +31,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: specspec.c,v 1.4 2017/12/14 18:34:41 christos Exp $");
+__RCSID("$NetBSD: specspec.c,v 1.5 2023/12/02 13:24:00 christos Exp $");
 
 #include 
 #include 
@@ -145,7 +145,7 @@ compare_nodes(NODE *n1, NODE *n2, char c
 		return (1);
 	}
 	if (n1->type != n2->type) {
-		differs = 0;
+		differs = F_TYPE;
 		mismatch(n1, n2, differs, path);
 		return (1);
 	}