summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-02-22 19:28:07 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-02-22 19:28:07 +0000
commit5c30cd4260474e303da4723e994e5d93cdcd0483 (patch)
tree61d9e1faf865b66dc174709d28f179d33902c927 /sys
parentf19a9cdec2be86dd535b2a0effa37f4a51e6f4f1 (diff)
enlarge msgbuf, somewhat line netbsd did
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/alpha/machdep.c15
-rw-r--r--sys/arch/alpha/include/param.h4
-rw-r--r--sys/arch/amiga/amiga/machdep.c8
-rw-r--r--sys/arch/amiga/amiga/pmap.c7
-rw-r--r--sys/arch/amiga/include/param.h4
-rw-r--r--sys/arch/hp300/hp300/machdep.c8
-rw-r--r--sys/arch/hp300/hp300/pmap_bootstrap.c7
-rw-r--r--sys/arch/hp300/include/param.h4
-rw-r--r--sys/arch/i386/i386/machdep.c25
-rw-r--r--sys/arch/i386/i386/pmap.c5
-rw-r--r--sys/arch/i386/i386/pmap.old.c5
-rw-r--r--sys/arch/i386/include/param.h6
-rw-r--r--sys/arch/mac68k/include/param.h4
-rw-r--r--sys/arch/mac68k/mac68k/machdep.c8
-rw-r--r--sys/arch/mac68k/mac68k/pmap_bootstrap.c9
-rw-r--r--sys/arch/mvme68k/include/param.h4
-rw-r--r--sys/arch/mvme68k/mvme68k/machdep.c13
-rw-r--r--sys/arch/mvme68k/mvme68k/pmap_bootstrap.c7
-rw-r--r--sys/arch/mvme88k/include/param.h6
-rw-r--r--sys/arch/mvme88k/mvme88k/machdep.c14
-rw-r--r--sys/arch/mvme88k/mvme88k/pmap.c4
-rw-r--r--sys/arch/powerpc/include/param.h4
-rw-r--r--sys/arch/powerpc/powerpc/machdep.c14
-rw-r--r--sys/arch/sparc/include/param.h4
-rw-r--r--sys/arch/sparc/sparc/autoconf.c13
-rw-r--r--sys/arch/sparc/sparc/locore.s6
-rw-r--r--sys/arch/sparc/sparc/machdep.c23
-rw-r--r--sys/kern/kern_sysctl.c11
-rw-r--r--sys/kern/subr_log.c61
-rw-r--r--sys/kern/subr_prf.c12
-rw-r--r--sys/miscfs/kernfs/kernfs_vnops.c26
-rw-r--r--sys/sys/msgbuf.h8
-rw-r--r--sys/sys/sysctl.h6
33 files changed, 201 insertions, 154 deletions
diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c
index 2512dfe1f4f..e80f92db679 100644
--- a/sys/arch/alpha/alpha/machdep.c
+++ b/sys/arch/alpha/alpha/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.30 2000/02/09 06:01:15 itojun Exp $ */
+/* $OpenBSD: machdep.c,v 1.31 2000/02/22 19:27:40 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.61 1996/12/07 01:54:49 cgd Exp $ */
/*
@@ -134,7 +134,6 @@ int bufpages = BUFPAGES;
#else
int bufpages = 0;
#endif
-int msgbufmapped = 0; /* set when safe to use msgbuf */
int maxmem; /* max memory per process */
int totalphysmem; /* total amount of physical memory in system */
@@ -433,10 +432,13 @@ unknown_cputype:
/*
* Initialize error message buffer (at end of core).
*/
- lastusablepage -= btoc(sizeof (struct msgbuf));
- msgbufp =
- (struct msgbuf *)ALPHA_PHYS_TO_K0SEG(ctob(lastusablepage + 1));
- msgbufmapped = 1;
+ lastusablepage -= btoc(MSGBUFSIZE);
+ printf("%lx %d\n", (caddr_t)ALPHA_PHYS_TO_K0SEG(ctob(lastusablepage + 1)),
+ MSGBUFSIZE);
+ initmsgbuf((caddr_t)ALPHA_PHYS_TO_K0SEG(ctob(lastusablepage + 1)),
+ MSGBUFSIZE);
+ printf("%lx %d\n", (caddr_t)ALPHA_PHYS_TO_K0SEG(ctob(lastusablepage + 1)),
+ MSGBUFSIZE);
/*
* Allocate space for system data structures.
@@ -944,6 +946,7 @@ dumpsys()
daddr_t blkno;
int (*dump) __P((dev_t, daddr_t, caddr_t, size_t));
int error;
+ extern int msgbufmapped;
/* Save registers. */
savectx(&dumppcb);
diff --git a/sys/arch/alpha/include/param.h b/sys/arch/alpha/include/param.h
index 0350a8ded4d..0926d360936 100644
--- a/sys/arch/alpha/include/param.h
+++ b/sys/arch/alpha/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.10 1997/09/17 17:44:04 downsj Exp $ */
+/* $OpenBSD: param.h,v 1.11 2000/02/22 19:27:40 deraadt Exp $ */
/* $NetBSD: param.h,v 1.15 1996/11/13 21:13:19 cgd Exp $ */
/*
@@ -109,6 +109,8 @@
#endif
#endif
+#define MSGBUFSIZE 8192
+
/*
* Size of kernel malloc arena in CLBYTES-sized logical pages
*/
diff --git a/sys/arch/amiga/amiga/machdep.c b/sys/arch/amiga/amiga/machdep.c
index 458526fb3e6..7aabe71fc55 100644
--- a/sys/arch/amiga/amiga/machdep.c
+++ b/sys/arch/amiga/amiga/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.35 1999/12/08 06:50:14 itojun Exp $ */
+/* $OpenBSD: machdep.c,v 1.36 2000/02/22 19:27:42 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.95 1997/08/27 18:31:17 is Exp $ */
/*
@@ -151,7 +151,6 @@ int bufpages = BUFPAGES;
#else
int bufpages = 0;
#endif
-int msgbufmapped; /* set when safe to use msgbuf */
int maxmem; /* max memory per process */
int physmem = MAXMEM; /* max supported memory, changes to actual */
/*
@@ -326,11 +325,11 @@ cpu_startup()
pmapdebug = 0;
#endif
/* avail_end was pre-decremented in pmap_bootstrap to compensate */
- for (i = 0; i < btoc(sizeof (struct msgbuf)); i++)
+ for (i = 0; i < btoc(MSGBUFSIZE); i++)
pmap_enter(pmap_kernel(), (vm_offset_t)msgbufp,
avail_end + i * NBPG, VM_PROT_READ|VM_PROT_WRITE, TRUE,
VM_PROT_READ|VM_PROT_WRITE);
- msgbufmapped = 1;
+ initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE));
/*
* Good {morning,afternoon,evening,night}.
@@ -873,6 +872,7 @@ dumpsys()
kcore_seg_t *kseg_p;
cpu_kcore_hdr_t *chdr_p;
char dump_hdr[dbtob(1)]; /* XXX assume hdr fits in 1 block */
+ extern int msgbufmapped;
msgbufmapped = 0;
if (dumpdev == NODEV)
diff --git a/sys/arch/amiga/amiga/pmap.c b/sys/arch/amiga/amiga/pmap.c
index baf16996364..120e274e6c5 100644
--- a/sys/arch/amiga/amiga/pmap.c
+++ b/sys/arch/amiga/amiga/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.16 1999/09/03 18:00:29 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.17 2000/02/22 19:27:42 deraadt Exp $ */
/* $NetBSD: pmap.c,v 1.39 1997/06/10 18:26:41 veego Exp $ */
/*
@@ -295,7 +295,6 @@ void pmap_pvdump __P((vm_offset_t));
*/
caddr_t CADDR1, CADDR2, vmmap;
u_int *CMAP1, *CMAP2, *vmpte, *msgbufmap;
-struct msgbuf *msgbufp;
/*
* Bootstrap the system enough to run with virtual memory.
@@ -324,7 +323,7 @@ pmap_bootstrap(firstaddr, loadaddr)
avail_end = maxmem << PGSHIFT;
/* XXX: allow for msgbuf */
- avail_end -= m68k_round_page(sizeof(struct msgbuf));
+ avail_end -= m68k_round_page(MSGBUFSIZE);
#ifdef MACHINE_NONCONTIG
/*
* first segment of memory is always the one loadbsd found
@@ -423,7 +422,7 @@ pmap_bootstrap(firstaddr, loadaddr)
SYSMAP(caddr_t ,CMAP1 ,CADDR1 ,1 )
SYSMAP(caddr_t ,CMAP2 ,CADDR2 ,1 )
SYSMAP(caddr_t ,vmpte ,vmmap ,1 )
- SYSMAP(struct msgbuf * ,msgbufmap ,msgbufp ,1 )
+ SYSMAP(struct msgbuf * ,msgbufmap ,msgbufp ,btoc(MSGBUFSIZE))
virtual_avail = reserve_dumppages(va);
}
diff --git a/sys/arch/amiga/include/param.h b/sys/arch/amiga/include/param.h
index 5b04b0daf87..12da70cf30b 100644
--- a/sys/arch/amiga/include/param.h
+++ b/sys/arch/amiga/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.10 1997/09/18 13:40:02 niklas Exp $ */
+/* $OpenBSD: param.h,v 1.11 2000/02/22 19:27:43 deraadt Exp $ */
/* $NetBSD: param.h,v 1.35 1997/07/10 08:22:36 veego Exp $ */
/*
@@ -75,6 +75,8 @@
#define NKMEMCLUSTERS (3072 * 1024 / CLBYTES)
#endif
+#define MSGBUFSIZE 8192
+
/*
* spl functions; all are normally done in-line
*/
diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c
index 323c8fd9cab..170b07c5137 100644
--- a/sys/arch/hp300/hp300/machdep.c
+++ b/sys/arch/hp300/hp300/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.38 1999/09/03 18:00:41 art Exp $ */
+/* $OpenBSD: machdep.c,v 1.39 2000/02/22 19:27:46 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.94 1997/06/12 15:46:29 mrg Exp $ */
/*
@@ -133,7 +133,6 @@ int bufpages = BUFPAGES;
#else
int bufpages = 0;
#endif
-int msgbufmapped; /* set when safe to use msgbuf */
int maxmem; /* max memory per process */
int physmem = MAXMEM; /* max supported memory, changes to actual */
/*
@@ -247,11 +246,11 @@ cpu_startup()
* Initialize error message buffer (at end of core).
* avail_end was pre-decremented in pmap_bootstrap to compensate.
*/
- for (i = 0; i < btoc(sizeof (struct msgbuf)); i++)
+ for (i = 0; i < btoc(MSGBUFSIZE); i++)
pmap_enter(pmap_kernel(), (vm_offset_t)msgbufp,
avail_end + i * NBPG, VM_PROT_READ|VM_PROT_WRITE, TRUE,
VM_PROT_READ|VM_PROT_WRITE);
- msgbufmapped = 1;
+ initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE));
/*
* Good {morning,afternoon,evening,night}.
@@ -889,6 +888,7 @@ dumpsys()
cpu_kcore_hdr_t *chdr_p;
char dump_hdr[dbtob(1)]; /* XXX assume hdr fits in 1 block */
#endif /* HP300_NEWKVM */
+ extern int msgbufmapped;
/* XXX initialized here because of gcc lossage */
maddr = lowram;
diff --git a/sys/arch/hp300/hp300/pmap_bootstrap.c b/sys/arch/hp300/hp300/pmap_bootstrap.c
index 26227b80ae9..5d06ae30f1b 100644
--- a/sys/arch/hp300/hp300/pmap_bootstrap.c
+++ b/sys/arch/hp300/hp300/pmap_bootstrap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_bootstrap.c,v 1.6 1998/03/07 12:41:33 deraadt Exp $ */
+/* $OpenBSD: pmap_bootstrap.c,v 1.7 2000/02/22 19:27:46 deraadt Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.13 1997/06/10 18:56:50 veego Exp $ */
/*
@@ -85,7 +85,6 @@ void pmap_bootstrap __P((vm_offset_t, vm_offset_t));
* msgbufp: kernel message buffer
*/
caddr_t CADDR1, CADDR2, vmmap, ledbase;
-struct msgbuf *msgbufp;
/*
* Bootstrap the VM system.
@@ -438,7 +437,7 @@ pmap_bootstrap(nextpa, firstpa)
*/
RELOC(avail_start, vm_offset_t) = nextpa;
RELOC(avail_end, vm_offset_t) = m68k_ptob(RELOC(maxmem, int)) -
- (m68k_round_page(sizeof(struct msgbuf)) + m68k_ptob(1));
+ (m68k_round_page(MSGBUFSIZE) + m68k_ptob(1));
RELOC(mem_size, vm_size_t) = m68k_ptob(RELOC(physmem, int));
RELOC(virtual_avail, vm_offset_t) =
VM_MIN_KERNEL_ADDRESS + (nextpa - firstpa);
@@ -525,7 +524,7 @@ pmap_bootstrap(nextpa, firstpa)
RELOC(ledbase, caddr_t) = (caddr_t)va;
va += NBPG;
RELOC(msgbufp, struct msgbuf *) = (struct msgbuf *)va;
- va += NBPG;
+ va += MSGBUFSIZE;
RELOC(virtual_avail, vm_offset_t) = va;
}
}
diff --git a/sys/arch/hp300/include/param.h b/sys/arch/hp300/include/param.h
index a81227f6093..69eaaed41a8 100644
--- a/sys/arch/hp300/include/param.h
+++ b/sys/arch/hp300/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.9 1997/07/13 09:48:02 downsj Exp $ */
+/* $OpenBSD: param.h,v 1.10 2000/02/22 19:27:46 deraadt Exp $ */
/* $NetBSD: param.h,v 1.35 1997/07/10 08:22:38 veego Exp $ */
/*
@@ -77,6 +77,8 @@
# define NKMEMCLUSTERS (2048 * 1024 / CLBYTES)
#endif
+#define MSGBUFSIZE 4096
+
#if defined(_KERNEL) && !defined(_LOCORE)
#define delay(us) _delay((us) << 8)
#define DELAY(us) delay(us)
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 58bcba53120..4aaee78bf0a 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.124 2000/02/08 00:14:12 niklas Exp $ */
+/* $OpenBSD: machdep.c,v 1.125 2000/02/22 19:27:48 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -226,9 +226,6 @@ long dumplo = 0; /* blocks */
int cpu_class;
-struct msgbuf *msgbufp;
-int msgbufmapped;
-
bootarg_t *bootargp;
vm_offset_t avail_end;
@@ -319,19 +316,18 @@ cpu_startup()
* (space reserved in /boot)
*/
pa = avail_end;
- for (i = 0; i < btoc(sizeof(struct msgbuf)); i++, pa += NBPG)
+ for (i = 0; i < btoc(MSGBUFSIZE); i++, pa += NBPG)
pmap_enter(pmap_kernel(),
(vm_offset_t)((caddr_t)msgbufp + i * NBPG), pa,
VM_PROT_READ|VM_PROT_WRITE, TRUE,
VM_PROT_READ|VM_PROT_WRITE);
-
- msgbufmapped = 1;
+ initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE));
printf(version);
startrtclock();
identifycpu();
- printf("real mem = %d\n", ctob(physmem));
+ printf("real mem = %u (%uK)\n", ctob(physmem), ctob(physmem)/1024);
/*
* Find out how much space we need, allocate it,
@@ -399,12 +395,14 @@ cpu_startup()
callout[i-1].c_next = &callout[i];
#if defined(UVM)
- printf("avail mem = %ld\n", ptoa(uvmexp.free));
+ printf("avail mem = %lu (%uK)\n", ptoa(uvmexp.free),
+ ptoa(uvmexp.free)/1024);
#else
- printf("avail mem = %ld\n", ptoa(cnt.v_free_count));
+ printf("avail mem = %lu (%uK)\n", ptoa(cnt.v_free_count),
+ ptoa(cnt.v_free_count)/1024);
#endif
- printf("using %d buffers containing %d bytes of memory\n",
- nbuf, bufpages * CLBYTES);
+ printf("using %d buffers containing %u bytes (%uK) of memory\n",
+ nbuf, bufpages * CLBYTES, bufpages * CLBYTES / 1024);
/*
* Set up buffers, so they can be used to read disk labels.
@@ -1636,6 +1634,7 @@ dumpsys()
int (*dump) __P((dev_t, daddr_t, caddr_t, size_t));
int error;
register char *str;
+ extern int msgbufmapped;
/* Save registers. */
savectx(&dumppcb);
@@ -2049,7 +2048,7 @@ init386(first_avail)
}
ndumpmem = i;
- avail_end -= i386_round_page(sizeof(struct msgbuf));
+ avail_end -= i386_round_page(MSGBUFSIZE);
#ifdef DEBUG
printf(": %lx\n", avail_end);
diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c
index ec96fd20324..2371786f1e8 100644
--- a/sys/arch/i386/i386/pmap.c
+++ b/sys/arch/i386/i386/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.34 2000/01/29 21:41:51 mickey Exp $ */
+/* $OpenBSD: pmap.c,v 1.35 2000/02/22 19:27:48 deraadt Exp $ */
/* $NetBSD: pmap.c,v 1.36 1996/05/03 19:42:22 christos Exp $ */
/*
@@ -280,8 +280,7 @@ pmap_bootstrap(virtual_start)
SYSMAP(caddr_t ,CMAP1 ,CADDR1 ,1 )
SYSMAP(caddr_t ,CMAP2 ,CADDR2 ,1 )
SYSMAP(caddr_t ,XXX_mmap ,vmmap ,1 )
- SYSMAP(struct msgbuf * ,msgbufmap ,msgbufp ,
- btoc(sizeof(struct msgbuf)) )
+ SYSMAP(struct msgbuf * ,msgbufmap ,msgbufp ,btoc(MSGBUFSIZE))
SYSMAP(bootarg_t * ,bootargmap ,bootargp ,btoc(bootargc))
virtual_avail = va;
#endif
diff --git a/sys/arch/i386/i386/pmap.old.c b/sys/arch/i386/i386/pmap.old.c
index 3c896a9a72f..809e80b7131 100644
--- a/sys/arch/i386/i386/pmap.old.c
+++ b/sys/arch/i386/i386/pmap.old.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.old.c,v 1.34 2000/01/29 21:41:51 mickey Exp $ */
+/* $OpenBSD: pmap.old.c,v 1.35 2000/02/22 19:27:48 deraadt Exp $ */
/* $NetBSD: pmap.c,v 1.36 1996/05/03 19:42:22 christos Exp $ */
/*
@@ -280,8 +280,7 @@ pmap_bootstrap(virtual_start)
SYSMAP(caddr_t ,CMAP1 ,CADDR1 ,1 )
SYSMAP(caddr_t ,CMAP2 ,CADDR2 ,1 )
SYSMAP(caddr_t ,XXX_mmap ,vmmap ,1 )
- SYSMAP(struct msgbuf * ,msgbufmap ,msgbufp ,
- btoc(sizeof(struct msgbuf)) )
+ SYSMAP(struct msgbuf * ,msgbufmap ,msgbufp ,btoc(MSGBUFSIZE))
SYSMAP(bootarg_t * ,bootargmap ,bootargp ,btoc(bootargc))
virtual_avail = va;
#endif
diff --git a/sys/arch/i386/include/param.h b/sys/arch/i386/include/param.h
index eedfe26d667..ed1128db081 100644
--- a/sys/arch/i386/include/param.h
+++ b/sys/arch/i386/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.9 1999/11/27 16:25:32 deraadt Exp $ */
+/* $OpenBSD: param.h,v 1.10 2000/02/22 19:27:48 deraadt Exp $ */
/* $NetBSD: param.h,v 1.29 1996/03/04 05:04:26 cgd Exp $ */
/*-
@@ -93,6 +93,10 @@
#define UPAGES 2 /* pages of u-area */
#define USPACE (UPAGES * NBPG) /* total size of u-area */
+#ifndef MSGBUFSIZE
+#define MSGBUFSIZE 2*NBPG /* default message buffer size */
+#endif
+
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than CLBYTES (the software page size), and,
diff --git a/sys/arch/mac68k/include/param.h b/sys/arch/mac68k/include/param.h
index eff676c12d0..c73f5ac21b3 100644
--- a/sys/arch/mac68k/include/param.h
+++ b/sys/arch/mac68k/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.9 1999/04/24 06:39:40 downsj Exp $ */
+/* $OpenBSD: param.h,v 1.10 2000/02/22 19:27:51 deraadt Exp $ */
/* $NetBSD: param.h,v 1.28 1997/03/01 06:57:45 scottr Exp $ */
/*
@@ -110,6 +110,8 @@
#define NKMEMCLUSTERS (2048 * 1024 / CLBYTES)
#endif
+#define MSGBUFSIZE 4096
+
#if defined(_KERNEL) && !defined(_LOCORE)
void delay __P((unsigned));
#define DELAY(ms) delay(ms)
diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c
index d27edd00388..88f09533e26 100644
--- a/sys/arch/mac68k/mac68k/machdep.c
+++ b/sys/arch/mac68k/mac68k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.64 1999/12/08 06:50:16 itojun Exp $ */
+/* $OpenBSD: machdep.c,v 1.65 2000/02/22 19:27:52 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.134 1997/02/14 06:15:30 scottr Exp $ */
/*
@@ -201,7 +201,6 @@ int bufpages = BUFPAGES;
int bufpages = 0;
#endif
-int msgbufmapped; /* set when safe to use msgbuf */
int maxmem; /* max memory per process */
int physmem = MAXMEM; /* max supported memory, changes to actual */
@@ -310,12 +309,12 @@ cpu_startup(void)
* Initialize error message buffer (at end of core).
* high[numranges-1] was decremented in pmap_bootstrap.
*/
- for (i = 0; i < btoc(sizeof(struct msgbuf)); i++)
+ for (i = 0; i < btoc(MSGBUFSIZE); i++)
pmap_enter(pmap_kernel(), (vm_offset_t) msgbufp,
high[numranges - 1] + i * NBPG,
VM_PROT_READ|VM_PROT_WRITE, TRUE,
VM_PROT_READ|VM_PROT_WRITE);
- msgbufmapped = 1;
+ initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE));
/*
* Good {morning,afternoon,evening,night}.
@@ -792,6 +791,7 @@ dumpsys()
vm_offset_t maddr; /* PA being dumped */
int seg; /* RAM segment being dumped */
int error; /* error code from (*dump)() */
+ extern int msgbufmapped;
/* XXX initialized here because of gcc lossage */
seg = 0;
diff --git a/sys/arch/mac68k/mac68k/pmap_bootstrap.c b/sys/arch/mac68k/mac68k/pmap_bootstrap.c
index 1e15d469b2c..0697dc91b18 100644
--- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c
+++ b/sys/arch/mac68k/mac68k/pmap_bootstrap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_bootstrap.c,v 1.12 1999/04/24 06:39:41 downsj Exp $ */
+/* $OpenBSD: pmap_bootstrap.c,v 1.13 2000/02/22 19:27:52 deraadt Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.30 1997/01/07 07:44:01 scottr Exp $ */
/*
@@ -103,7 +103,6 @@ extern caddr_t ROMBase;
* msgbufp: kernel message buffer
*/
caddr_t CADDR1, CADDR2, vmmap;
-struct msgbuf *msgbufp;
/*
* Bootstrap the VM system.
@@ -462,8 +461,8 @@ pmap_bootstrap(nextpa, firstpa)
}
}
physmem = m68k_btop(avail_remaining + nextpa - firstpa);
- avail_remaining -= m68k_round_page(sizeof(struct msgbuf));
- high[numranges - 1] -= m68k_round_page(sizeof(struct msgbuf));
+ avail_remaining -= m68k_round_page(MSGBUFSIZE);
+ high[numranges - 1] -= m68k_round_page(MSGBUFSIZE);
/* XXX -- this doesn't look correct to me. */
while (high[numranges - 1] < low[numranges - 1]) {
@@ -549,7 +548,7 @@ pmap_bootstrap(nextpa, firstpa)
tmp_vpages[0] = va;
va += NBPG;
msgbufp = (struct msgbuf *)va;
- va += NBPG;
+ va += MSGBUFSIZE;
virtual_avail = va;
}
}
diff --git a/sys/arch/mvme68k/include/param.h b/sys/arch/mvme68k/include/param.h
index 0b4dc1204cf..6146d846670 100644
--- a/sys/arch/mvme68k/include/param.h
+++ b/sys/arch/mvme68k/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.7 2000/01/06 03:21:43 smurph Exp $ */
+/* $OpenBSD: param.h,v 1.8 2000/02/22 19:27:53 deraadt Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -106,6 +106,8 @@
#endif
#endif
+#define MSGBUFSIZE 4096
+
/*
* Size of kernel malloc arena in CLBYTES-sized logical pages
*/
diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c
index 6cde1e3e49e..101d54be691 100644
--- a/sys/arch/mvme68k/mvme68k/machdep.c
+++ b/sys/arch/mvme68k/mvme68k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.31 2000/01/06 03:21:43 smurph Exp $ */
+/* $OpenBSD: machdep.c,v 1.32 2000/02/22 19:27:54 deraadt Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -137,7 +137,6 @@ int bufpages = BUFPAGES;
#else
int bufpages = 0;
#endif
-int msgbufmapped; /* set when safe to use msgbuf */
int maxmem; /* max memory per process */
int physmem = MAXMEM; /* max supported memory, changes to actual */
/*
@@ -258,12 +257,11 @@ cpu_startup()
* Initialize error message buffer (at end of core).
* avail_end was pre-decremented in pmap_bootstrap to compensate.
*/
- for (i = 0; i < btoc(sizeof (struct msgbuf)); i++)
+ for (i = 0; i < btoc(MSGBUFSIZE); i++)
pmap_enter(pmap_kernel(), (vm_offset_t)msgbufp,
- avail_end + i * NBPG, VM_PROT_READ|VM_PROT_WRITE,
- TRUE, VM_PROT_READ|VM_PROT_WRITE);
-
- msgbufmapped = 1;
+ avail_end + i * NBPG, VM_PROT_READ|VM_PROT_WRITE,
+ TRUE, VM_PROT_READ|VM_PROT_WRITE);
+ initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE));
/*
* Good {morning,afternoon,evening,night}.
@@ -802,6 +800,7 @@ dumpconf()
*/
dumpsys()
{
+ extern int msgbufmapped;
msgbufmapped = 0;
if (dumpdev == NODEV)
diff --git a/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c b/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c
index 9383afedf7b..fc09967e427 100644
--- a/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c
+++ b/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_bootstrap.c,v 1.4 2000/01/06 03:21:43 smurph Exp $ */
+/* $OpenBSD: pmap_bootstrap.c,v 1.5 2000/02/22 19:27:54 deraadt Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -103,7 +103,6 @@ extern int protection_codes[];
* msgbufp: kernel message buffer
*/
caddr_t CADDR1, CADDR2, vmmap, ledbase;
-struct msgbuf *msgbufp;
#define ETHERPAGES 16
void *etherbuf;
int etherlen;
@@ -400,7 +399,7 @@ register vm_offset_t firstpa;
RELOC(avail_start, vm_offset_t) = nextpa;
RELOC(avail_end, vm_offset_t) = m68k_ptob(RELOC(maxmem, int))
/* XXX allow for msgbuf */
- - m68k_round_page(sizeof(struct msgbuf));
+ - m68k_round_page(MSGBUFSIZE);
RELOC(mem_size, vm_size_t) = m68k_ptob(RELOC(physmem, int));
RELOC(virtual_avail, vm_offset_t) =
VM_MIN_KERNEL_ADDRESS + (nextpa - firstpa);
@@ -475,7 +474,7 @@ register vm_offset_t firstpa;
RELOC(ledbase, caddr_t) = (caddr_t)va;
va += NBPG;
RELOC(msgbufp, struct msgbuf *) = (struct msgbuf *)va;
- va += NBPG;
+ va += MSGBUFSIZE;
RELOC(virtual_avail, vm_offset_t) = va;
}
}
diff --git a/sys/arch/mvme88k/include/param.h b/sys/arch/mvme88k/include/param.h
index aab7bff3cc4..20de45cd71c 100644
--- a/sys/arch/mvme88k/include/param.h
+++ b/sys/arch/mvme88k/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.10 1999/09/27 20:46:18 smurph Exp $ */
+/* $OpenBSD: param.h,v 1.11 2000/02/22 19:27:55 deraadt Exp $ */
/*
* Copyright (c) 1999 Steve Murphree, Jr.
* Copyright (c) 1988 University of Utah.
@@ -40,7 +40,7 @@
* from: Utah $Hdr: machparam.h 1.11 89/08/14$
*
* @(#)param.h 7.8 (Berkeley) 6/28/91
- * $Id: param.h,v 1.10 1999/09/27 20:46:18 smurph Exp $
+ * $Id: param.h,v 1.11 2000/02/22 19:27:55 deraadt Exp $
*/
#ifndef _MACHINE_PARAM_H_
#define _MACHINE_PARAM_H_
@@ -133,6 +133,8 @@
#define NKMEMCLUSTERS (4096*1024/CLBYTES)
#endif
+#define MSGBUFSIZE 4096
+
/* pages ("clicks") to disk blocks */
#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT))
#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT))
diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c
index 50cf804b303..700140a76ba 100644
--- a/sys/arch/mvme88k/mvme88k/machdep.c
+++ b/sys/arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.18 1999/12/08 06:50:16 itojun Exp $ */
+/* $OpenBSD: machdep.c,v 1.19 2000/02/22 19:27:55 deraadt Exp $ */
/*
* Copyright (c) 1998, 1999 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -157,7 +157,6 @@ volatile vm_offset_t extiova;
int physmem; /* available physical memory, in pages */
int cold; /* boot process flag */
vm_offset_t avail_end, avail_start, avail_next;
-int msgbufmapped = 0;
int foodebug = 0; /* for size_memory() */
int longformat = 1; /* for regdump() */
int BugWorks = 0;
@@ -461,12 +460,11 @@ cpu_startup()
* avail_end was pre-decremented in mvme_bootstrap().
*/
- for (i = 0; i < btoc(sizeof(struct msgbuf)); i++)
+ for (i = 0; i < btoc(MSGBUFSIZE); i++)
pmap_enter(kernel_pmap, (vm_offset_t)msgbufp,
- avail_end + i * NBPG, VM_PROT_READ|VM_PROT_WRITE,
- VM_PROT_READ|VM_PROT_WRITE, TRUE);
-
- msgbufmapped = 1;
+ avail_end + i * NBPG, VM_PROT_READ|VM_PROT_WRITE,
+ VM_PROT_READ|VM_PROT_WRITE, TRUE);
+ initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE));
printf("real mem = %d\n", ctob(physmem));
@@ -1160,6 +1158,8 @@ dumpconf()
*/
dumpsys()
{
+ extern int msgbufmapped;
+
msgbufmapped = 0;
if (dumpdev == NODEV)
return;
diff --git a/sys/arch/mvme88k/mvme88k/pmap.c b/sys/arch/mvme88k/mvme88k/pmap.c
index 08c1fb8991b..cc715bbd65e 100644
--- a/sys/arch/mvme88k/mvme88k/pmap.c
+++ b/sys/arch/mvme88k/mvme88k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.12 1999/09/27 19:13:23 smurph Exp $ */
+/* $OpenBSD: pmap.c,v 1.13 2000/02/22 19:27:56 deraadt Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* All rights reserved.
@@ -1344,7 +1344,7 @@ pmap_bootstrap(vm_offset_t load_start, /* IN */
virt = *virt_start;
SYSMAP(caddr_t, vmpte , vmmap, 1);
- SYSMAP(struct msgbuf *, msgbufmap ,msgbufp, 1);
+ SYSMAP(struct msgbuf *, msgbufmap ,msgbufp, btoc(MSGBUFSIZE));
vmpte->pfn = -1;
vmpte->dtype = DT_INVALID;
diff --git a/sys/arch/powerpc/include/param.h b/sys/arch/powerpc/include/param.h
index a243b1cbac7..429833a3db0 100644
--- a/sys/arch/powerpc/include/param.h
+++ b/sys/arch/powerpc/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.8 1999/11/28 23:20:23 rahnds Exp $ */
+/* $OpenBSD: param.h,v 1.9 2000/02/22 19:27:57 deraadt Exp $ */
/* $NetBSD: param.h,v 1.1 1996/09/30 16:34:28 ws Exp $ */
/*-
@@ -88,6 +88,8 @@
#endif
#endif
+#define MSGBUFSIZE NBPG
+
/*
* Size of kernel malloc arena in CLBYTES-sized logical pages.
*/
diff --git a/sys/arch/powerpc/powerpc/machdep.c b/sys/arch/powerpc/powerpc/machdep.c
index 482c40c6265..0f134422d85 100644
--- a/sys/arch/powerpc/powerpc/machdep.c
+++ b/sys/arch/powerpc/powerpc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.32 2000/01/22 03:51:56 rahnds Exp $ */
+/* $OpenBSD: machdep.c,v 1.33 2000/02/22 19:27:58 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -125,12 +125,6 @@ struct firmware *fw = NULL;
void ofw_dbg(char *str);
-/*
- * We use the page just above the interrupt vector as message buffer
- */
-struct msgbuf *msgbufp = (struct msgbuf *)0x3000;
-int msgbufmapped = 1; /* message buffer is always mapped */
-
caddr_t allocsys __P((caddr_t));
int power4e_get_eth_addr __P((void));
@@ -173,6 +167,12 @@ initppc(startkernel, endkernel, args)
proc0.p_addr = proc0paddr;
bzero(proc0.p_addr, sizeof *proc0.p_addr);
+ /*
+ * XXX We use the page just above the interrupt vector as
+ * message buffer
+ */
+ initmsgbuf(0x3000, MSGBUFSIZE);
+
where = 3;
curpcb = &proc0paddr->u_pcb;
diff --git a/sys/arch/sparc/include/param.h b/sys/arch/sparc/include/param.h
index d0480956b16..1fe8ded1d35 100644
--- a/sys/arch/sparc/include/param.h
+++ b/sys/arch/sparc/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.13 2000/02/15 16:32:41 art Exp $ */
+/* $OpenBSD: param.h,v 1.14 2000/02/22 19:27:59 deraadt Exp $ */
/* $NetBSD: param.h,v 1.29 1997/03/10 22:50:37 pk Exp $ */
/*
@@ -124,6 +124,8 @@ extern int nbpg, pgofset, pgshift;
#endif
#endif
+#define MSGBUFSIZE 4096 /* cannot be changed without great pain */
+
/*
* Size of kernel malloc arena in CLBYTES-sized logical pages.
*/
diff --git a/sys/arch/sparc/sparc/autoconf.c b/sys/arch/sparc/sparc/autoconf.c
index 304b8a1d539..1a6a0c4b740 100644
--- a/sys/arch/sparc/sparc/autoconf.c
+++ b/sys/arch/sparc/sparc/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.33 1999/12/08 23:49:07 deraadt Exp $ */
+/* $OpenBSD: autoconf.c,v 1.34 2000/02/22 19:27:59 deraadt Exp $ */
/* $NetBSD: autoconf.c,v 1.73 1997/07/29 09:41:53 fair Exp $ */
/*
@@ -200,19 +200,9 @@ struct om_vector *oldpvec = (struct om_vector *)PROM_BASE;
void
bootstrap()
{
- extern int msgbufmapped;
-
#if defined(SUN4)
if (CPU_ISSUN4) {
extern void oldmon_w_cmd __P((u_long, char *));
- extern struct msgbuf *msgbufp;
- /*
- * XXX
- * Some boot programs mess up physical page 0, which
- * is where we want to put the msgbuf. There's some
- * room, so shift it over half a page.
- */
- msgbufp = (struct msgbuf *)((caddr_t) msgbufp + 4096);
/*
* XXX:
@@ -251,7 +241,6 @@ bootstrap()
pmap_bootstrap(cpuinfo.mmu_ncontext,
cpuinfo.mmu_nregion,
cpuinfo.mmu_nsegment);
- msgbufmapped = 1; /* enable message buffer */
#ifdef KGDB
zs_kgdb_init(); /* XXX */
#endif
diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s
index 21bce05f5e9..6c153ab457d 100644
--- a/sys/arch/sparc/sparc/locore.s
+++ b/sys/arch/sparc/sparc/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.34 2000/02/21 17:08:36 art Exp $ */
+/* $OpenBSD: locore.s,v 1.35 2000/02/22 19:28:00 deraadt Exp $ */
/* $NetBSD: locore.s,v 1.73 1997/09/13 20:36:48 pk Exp $ */
/*
@@ -269,8 +269,6 @@ sun4_notsup:
* kernel space we remap it in configure() to another location and
* invalidate the mapping at KERNBASE.
*/
- .globl _msgbuf
-_msgbuf = KERNBASE
/*
* Each trap has room for four instructions, of which one perforce must
@@ -4674,7 +4672,7 @@ Lsw_havectx:
#endif
1:
#if defined(SUN4M)
- /*
+ /*
* Flush caches that need to be flushed on context switch.
* We know this is currently only necessary on the sun4m hypersparc.
*/
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c
index 781314d5afe..cf7a130a73c 100644
--- a/sys/arch/sparc/sparc/machdep.c
+++ b/sys/arch/sparc/sparc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.45 2000/02/21 21:05:59 art Exp $ */
+/* $OpenBSD: machdep.c,v 1.46 2000/02/22 19:28:01 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */
/*
@@ -139,10 +139,6 @@ int bufpages = 0;
int physmem;
-extern struct msgbuf msgbuf;
-struct msgbuf *msgbufp = &msgbuf;
-int msgbufmapped = 0; /* not mapped until pmap_bootstrap */
-
/* sysctl settable */
int sparc_led_blink = 0;
@@ -185,6 +181,13 @@ cpu_startup()
pmapdebug = 0;
#endif
+ /*
+ * fix message buffer mapping, note phys addr of msgbuf is 0
+ */
+ pmap_enter(pmap_kernel(), MSGBUF_VA, 0x0, VM_PROT_READ|VM_PROT_WRITE,
+ TRUE, VM_PROT_READ | VM_PROT_WRITE);
+ initmsgbuf((caddr_t)(MSGBUF_VA + (CPU_ISSUN4 ? 4096 : 0)), MSGBUFSIZE);
+
proc0.p_addr = proc0paddr;
/*
@@ -386,16 +389,6 @@ cpu_startup()
*/
bzero(proc0paddr, sizeof(struct user));
- /*
- * fix message buffer mapping, note phys addr of msgbuf is 0
- */
-
- pmap_enter(pmap_kernel(), MSGBUF_VA, 0x0, VM_PROT_READ|VM_PROT_WRITE,
- TRUE, VM_PROT_READ | VM_PROT_WRITE);
- if (CPU_ISSUN4)
- msgbufp = (struct msgbuf *)(MSGBUF_VA + 4096);
- else
- msgbufp = (struct msgbuf *)MSGBUF_VA;
pmap_redzone();
}
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 14f3da7c1ff..6afca527cb8 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.29 1999/06/29 23:51:59 provos Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.30 2000/02/22 19:28:03 deraadt Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -58,6 +58,7 @@
#include <sys/disklabel.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
+#include <sys/msgbuf.h>
#if defined(UVM)
#include <uvm/uvm_extern.h>
@@ -349,6 +350,14 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
#else
return (sysctl_rdint(oldp, oldlenp, newp, 0));
#endif
+ case KERN_MSGBUFSIZE:
+ /*
+ * deal with cases where the message buffer has
+ * become corrupted.
+ */
+ if (!msgbufp || msgbufp->msg_magic != MSG_MAGIC)
+ return (ENXIO);
+ return (sysctl_rdint(oldp, oldlenp, newp, msgbufp->msg_bufs));
default:
return (EOPNOTSUPP);
}
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c
index 5d247ead19f..00eb5a93bc9 100644
--- a/sys/kern/subr_log.c
+++ b/sys/kern/subr_log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_log.c,v 1.5 1997/09/18 13:23:26 deraadt Exp $ */
+/* $OpenBSD: subr_log.c,v 1.6 2000/02/22 19:28:03 deraadt Exp $ */
/* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */
/*
@@ -65,6 +65,44 @@ struct logsoftc {
} logsoftc;
int log_open; /* also used in log() */
+int msgbufmapped; /* is the message buffer mapped */
+int msgbufenabled; /* is logging to the buffer enabled */
+struct msgbuf *msgbufp; /* the mapped buffer, itself. */
+
+#define offsetof(type, member) ((size_t)(&((type *)0)->member))
+
+void
+initmsgbuf(buf, bufsize)
+ caddr_t buf;
+ size_t bufsize;
+{
+ register struct msgbuf *mbp;
+ long new_bufs;
+
+ /* Sanity-check the given size. */
+ if (bufsize < sizeof(struct msgbuf))
+ return;
+
+ mbp = msgbufp = (struct msgbuf *)buf;
+
+ new_bufs = bufsize - offsetof(struct msgbuf, msg_bufc);
+ if ((mbp->msg_magic != MSG_MAGIC) || (mbp->msg_bufs != new_bufs) ||
+ (mbp->msg_bufr < 0) || (mbp->msg_bufr >= mbp->msg_bufs) ||
+ (mbp->msg_bufx < 0) || (mbp->msg_bufx >= mbp->msg_bufs)) {
+ /*
+ * If the buffer magic number is wrong, has changed
+ * size (which shouldn't happen often), or is
+ * internally inconsistent, initialize it.
+ */
+
+ bzero(buf, bufsize);
+ mbp->msg_magic = MSG_MAGIC;
+ mbp->msg_bufs = new_bufs;
+ }
+
+ /* mark it as ready for use. */
+ msgbufmapped = msgbufenabled = 1;
+}
/*ARGSUSED*/
int
@@ -73,24 +111,9 @@ logopen(dev, flags, mode, p)
int flags, mode;
struct proc *p;
{
- register struct msgbuf *mbp = msgbufp;
-
if (log_open)
return (EBUSY);
log_open = 1;
- /*
- * Potential race here with putchar() but since putchar should be
- * called by autoconf, msg_magic should be initialized by the time
- * we get here.
- */
- if (mbp->msg_magic != MSG_MAGIC) {
- register int i;
-
- mbp->msg_magic = MSG_MAGIC;
- mbp->msg_bufx = mbp->msg_bufr = 0;
- for (i=0; i < MSG_BSIZE; i++)
- mbp->msg_bufc[i] = 0;
- }
return (0);
}
@@ -139,7 +162,7 @@ logread(dev, uio, flag)
while (uio->uio_resid > 0) {
l = mbp->msg_bufx - mbp->msg_bufr;
if (l < 0)
- l = MSG_BSIZE - mbp->msg_bufr;
+ l = mbp->msg_bufs - mbp->msg_bufr;
l = min(l, uio->uio_resid);
if (l == 0)
break;
@@ -148,7 +171,7 @@ logread(dev, uio, flag)
if (error)
break;
mbp->msg_bufr += l;
- if (mbp->msg_bufr < 0 || mbp->msg_bufr >= MSG_BSIZE)
+ if (mbp->msg_bufr < 0 || mbp->msg_bufr >= mbp->msg_bufs)
mbp->msg_bufr = 0;
}
return (error);
@@ -212,7 +235,7 @@ logioctl(dev, com, data, flag, p)
l = msgbufp->msg_bufx - msgbufp->msg_bufr;
splx(s);
if (l < 0)
- l += MSG_BSIZE;
+ l += msgbufp->msg_bufs;
*(int *)data = l;
break;
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 5b6eb3fd762..0ec990f67a9 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_prf.c,v 1.26 1999/12/02 00:23:35 deraadt Exp $ */
+/* $OpenBSD: subr_prf.c,v 1.27 2000/02/22 19:28:04 deraadt Exp $ */
/* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */
/*-
@@ -317,12 +317,16 @@ putchar(c, flags, tp)
c != '\0' && c != '\r' && c != 0177 && msgbufmapped) {
mbp = msgbufp;
if (mbp->msg_magic != MSG_MAGIC) {
- bzero((caddr_t) mbp, sizeof(*mbp));
- mbp->msg_magic = MSG_MAGIC;
+ /* Nothing we can do */
}
mbp->msg_bufc[mbp->msg_bufx++] = c;
- if (mbp->msg_bufx < 0 || mbp->msg_bufx >= MSG_BSIZE)
+ if (mbp->msg_bufx < 0 || mbp->msg_bufx >= mbp->msg_bufs)
mbp->msg_bufx = 0;
+ /* If the buffer is full, keep the most recent data. */
+ if (mbp->msg_bufr == mbp->msg_bufx) {
+ if (++mbp->msg_bufr >= mbp->msg_bufs)
+ mbp->msg_bufr = 0;
+ }
}
if ((flags & TOCONS) && constty == NULL && c != '\0')
(*v_putc)(c);
diff --git a/sys/miscfs/kernfs/kernfs_vnops.c b/sys/miscfs/kernfs/kernfs_vnops.c
index 7af09c11138..23922ae3343 100644
--- a/sys/miscfs/kernfs/kernfs_vnops.c
+++ b/sys/miscfs/kernfs/kernfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kernfs_vnops.c,v 1.17 1999/11/10 23:17:39 csapuntz Exp $ */
+/* $OpenBSD: kernfs_vnops.c,v 1.18 2000/02/22 19:28:06 deraadt Exp $ */
/* $NetBSD: kernfs_vnops.c,v 1.43 1996/03/16 23:52:47 christos Exp $ */
/*
@@ -257,12 +257,24 @@ kernfs_xread(kt, off, bufp, len)
extern struct msgbuf *msgbufp;
long n;
- if (off >= MSG_BSIZE)
+ if (msgbufp == NULL || msgbufp->msg_magic != MSG_MAGIC)
+ return (ENXIO);
+
+ /*
+ * Note that reads of /kern/msgbuf won't necessarily yield
+ * consistent results, if the message buffer is modified
+ * while the read is in progress. The worst that can happen
+ * is that incorrect data will be read. There's no way
+ * that this can crash the system unless the values in the
+ * message buffer header are corrupted, but that'll cause
+ * the system to die anyway.
+ */
+ if (off >= msgbufp->msg_bufs)
return (0);
n = msgbufp->msg_bufx + off;
- if (n >= MSG_BSIZE)
- n -= MSG_BSIZE;
- len = min(MSG_BSIZE - n, MSG_BSIZE - off);
+ if (n >= msgbufp->msg_bufs)
+ n -= msgbufp->msg_bufs;
+ len = min(msgbufp->msg_bufs - n, msgbufp->msg_bufs - off);
*bufp = msgbufp->msg_bufc + n;
return (len);
}
@@ -308,8 +320,8 @@ kernfs_xread(kt, off, bufp, len)
#endif
break;
#ifdef IPSEC
- case KTT_IPSECSPI:
- return(ipsp_kern(off, bufp, len));
+ case KTT_IPSECSPI:
+ return(ipsp_kern(off, bufp, len));
#endif
default:
return (0);
diff --git a/sys/sys/msgbuf.h b/sys/sys/msgbuf.h
index 728a768b605..1214c4cbc8d 100644
--- a/sys/sys/msgbuf.h
+++ b/sys/sys/msgbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: msgbuf.h,v 1.2 1996/03/03 12:12:03 niklas Exp $ */
+/* $OpenBSD: msgbuf.h,v 1.3 2000/02/22 19:28:05 deraadt Exp $ */
/* $NetBSD: msgbuf.h,v 1.8 1995/03/26 20:24:27 jtc Exp $ */
/*
@@ -36,14 +36,16 @@
* @(#)msgbuf.h 8.1 (Berkeley) 6/2/93
*/
-#define MSG_BSIZE (4096 - 3 * sizeof(long))
struct msgbuf {
#define MSG_MAGIC 0x063061
long msg_magic;
long msg_bufx; /* write pointer */
long msg_bufr; /* read pointer */
- char msg_bufc[MSG_BSIZE]; /* buffer */
+ long msg_bufs; /* real msg_bufc size (bytes) */
+ char msg_bufc[1]; /* buffer */
};
#ifdef _KERNEL
struct msgbuf *msgbufp;
+
+void initmsgbuf __P((caddr_t buf, size_t bufsize));
#endif
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 54634643e11..4f170c19ba0 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.28 1999/06/29 23:52:00 provos Exp $ */
+/* $OpenBSD: sysctl.h,v 1.29 2000/02/22 19:28:05 deraadt Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -151,7 +151,8 @@ struct ctlname {
#define KERN_SYSVSEM 35 /* int: SysV semaphore support */
#define KERN_SYSVSHM 36 /* int: SysV shared memory support */
#define KERN_ARND 37 /* int: random integer from arc4rnd */
-#define KERN_MAXID 38 /* number of valid kern ids */
+#define KERN_MSGBUFSIZE 38 /* int: size of message buffer */
+#define KERN_MAXID 39 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
{ 0, 0 }, \
@@ -192,6 +193,7 @@ struct ctlname {
{ "sysvsem", CTLTYPE_INT }, \
{ "sysvshm", CTLTYPE_INT }, \
{ "arandom", CTLTYPE_INT }, \
+ { "msgbufsize", CTLTYPE_INT }, \
}
/*