Remove DM* modem control commands

2018-02-13 Thread Tobias Ulmer
Remove the ancient tty.h DMSET etc. modem control commands. They're confusing
to someone without the historical background. No documentation doesn't help
either.

TIOCM* serve the same purpose, are documented in tty(4) and the various *ctl()
functions use the TTYCM_ register definitions, making this mix particularly odd
looking.

I've modified the *ctl() functions to use the same type and name as ioctl for
clarity and correctness. Not strictly necessary, but makes me sleep better :)

Tested lightly on sparc64. sab still works. No luna88k, sorry.


## Background blah blah, skip if you just don't care :)

I've noticed these odd DM{SET,GET,BIC,BIS} constants in serial drivers all
over the place and got curious. What do they mean?

Turns out, "DM" is a bolt-in add-on modem by DEC you would connect to
your DH-11, apparently a 16 port serial port multiplexer for your VAX or
PDP-11. As far as I can tell, the drivers were last included in 4.3BSD.
You grey beards correct me on this.

The DM constants and the dmctl() function to manipulate the modem
control register were added to dh in 1980 in order to support this fancy
new modem.

Since then, just about every BSD serial driver has copied the basic structure,
spreading DM* absolutely everywhere.

In 1982, Bill Shannon wanted to play with this control register in userspace
(tip) and the ioctl interface was expanded by TIOCM{SET,GET,BIS,BIC}, hard
coding the interface and register layout of that modem family for decades to 
come.

dh gains dm support:
https://github.com/weiss/original-bsd/commit/b47c3865305da4a404343aeedf0e3561071aae10

TIOCM modem control register bits show up:
https://github.com/weiss/original-bsd/commit/d9d9928137170ec2f49e62509b12d012cac154de
https://github.com/weiss/original-bsd/commit/c849aa74bd3aaa1d644d74d9628ba0e1be028e1a

http://gunkies.org/wiki/DH11_asynchronous_serial_line_interface
http://bitsavers.trailing-edge.com/pdf/dec/unibus/ datasheets..

Who needs TV when you can dig up amusing trivia about early BSD development!

Index: sys/tty.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/sys/tty.h,v
retrieving revision 1.37
diff -u -p -r1.37 tty.h
--- sys/tty.h   24 May 2016 16:09:07 -  1.37
+++ sys/tty.h   13 Feb 2018 20:39:54 -
@@ -215,12 +215,6 @@ struct speedtab {
int sp_code;/* Code. */
 };
 
-/* Modem control commands (driver). */
-#defineDMSET   0
-#defineDMBIS   1
-#defineDMBIC   2
-#defineDMGET   3
-
 /* Flags on a character passed to ttyinput. */
 #defineTTY_CHARMASK0x00ff  /* Character mask */
 #defineTTY_QUOTE   0x0100  /* Character quoted */
 
Index: arch/armv7/exynos/exuart.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/armv7/exynos/exuart.c,v
retrieving revision 1.13
diff -u -p -r1.13 exuart.c
--- arch/armv7/exynos/exuart.c  27 Oct 2017 11:23:28 -  1.13
+++ arch/armv7/exynos/exuart.c  13 Feb 2018 20:38:56 -
@@ -784,37 +784,37 @@ exuartioctl( dev_t dev, u_long cmd, cadd
 
case TIOCSDTR:
 #if 0
-   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIS);
+   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, TIOCMBIS);
 #endif
break;
 
case TIOCCDTR:
 #if 0
-   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIC);
+   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, TIOCMBIC);
 #endif
break;
 
case TIOCMSET:
 #if 0
-   (void) clmctl(dev, *(int *) data, DMSET);
+   (void) clmctl(dev, *(int *) data, TIOCMSET);
 #endif
break;
 
case TIOCMBIS:
 #if 0
-   (void) clmctl(dev, *(int *) data, DMBIS);
+   (void) clmctl(dev, *(int *) data, TIOCMBIS);
 #endif
break;
 
case TIOCMBIC:
 #if 0
-   (void) clmctl(dev, *(int *) data, DMBIC);
+   (void) clmctl(dev, *(int *) data, TIOCMBIC);
 #endif
break;
 
 case TIOCMGET:
 #if 0
-   *(int *)data = clmctl(dev, 0, DMGET);
+   *(int *)data = clmctl(dev, 0, TIOCMGET);
 #endif
break;
 
Index: arch/armv7/imx/imxuart.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/armv7/imx/imxuart.c,v
retrieving revision 1.17
diff -u -p -r1.17 imxuart.c
--- arch/armv7/imx/imxuart.c30 Dec 2017 13:34:56 -  1.17
+++ arch/armv7/imx/imxuart.c13 Feb 2018 20:38:56 -
@@ -701,37 +701,37 @@ imxuartioctl( dev_t dev, u_long cmd, cad
 
case TIOCSDTR:
 #if 0
-   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIS);
+   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, TIOCMBIS);
 #endif
break;
 
case TIOCCDTR:
 #if 0
-   (void) clmctl(dev, TIOCM_DTR | 

ps.1: command keyword width

2017-12-16 Thread Tobias Ulmer
Hi Ingo,

the "command" keyword is restricted in width even if termwidth is
unlimited. See print.c, command():
...
if (ve->next != NULL || termwidth != UNLIMITED) {

It would be nice if this could be documented. Maybe something like this:

Index: ps.1
===
RCS file: /home/vcs/cvs/openbsd/src/bin/ps/ps.1,v
retrieving revision 1.111
diff -u -p -r1.111 ps.1
--- ps.126 Oct 2016 01:20:39 -  1.111
+++ ps.116 Dec 2017 16:40:04 -
@@ -201,6 +201,7 @@ Accounting flag.
 Alias:
 .Cm args .
 Command and arguments.
+Must appear last for unlimited width.
 .It Cm cpu
 Short-term CPU usage factor (for scheduling).
 .It Cm cpuid



Fix NFS hanging on shutdown/reboot

2016-09-10 Thread Tobias Ulmer
Pending NFS requests loop forever, blocking umount and not even allowing
for clean shutdown/reboot.

If you ever played with NFS for more than 30 seconds, you have run into
this and had to press the reset button, followed by suffering through
fsck...

Pending requests occur because the NFS server is gone (duh), network
problems (duh) or the server is sending replies faster than the client
can receive/reassemble packets (sneaky).

The least invasive fix is marking all pending requests "soft". Timeouts
apply and the blocking request gets discarded.

Index: nfs/nfs_vfsops.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/nfs/nfs_vfsops.c,v
retrieving revision 1.110
diff -u -p -r1.110 nfs_vfsops.c
--- nfs/nfs_vfsops.c13 Aug 2016 20:53:17 -  1.110
+++ nfs/nfs_vfsops.c10 Sep 2016 08:12:27 -
@@ -689,13 +689,18 @@ int
 nfs_unmount(struct mount *mp, int mntflags, struct proc *p)
 {
struct nfsmount *nmp;
+   struct nfsreq *rep;
int error, flags;
 
nmp = VFSTONFS(mp);
flags = 0;
 
-   if (mntflags & MNT_FORCE)
+   if (mntflags & MNT_FORCE) {
flags |= FORCECLOSE;
+   TAILQ_FOREACH(rep, >nm_reqsq, r_chain) {
+   rep->r_flags |= R_SOFTTERM;
+   }
+   }
 
error = vflush(mp, NULL, flags);
if (error)



Re: hang with processes in fltamap: how can I identify running out of RAM?

2016-03-15 Thread Tobias Ulmer
Just wanted to note this diff in combination with your other uvm diff
does really well on sparc, building ports. Cuts down amap "INUSE" by
about a factor of 20.
Will report if anything bad happens.



arm: dmamap_destroy: remove explicit unload of map

2016-03-06 Thread Tobias Ulmer
map is passed straight into free where it gets overwritten with junk.
No other arch makes map invalid before free, and my N2100 didn't
suddenly misbehave either.

ok?

Index: arch/arm/arm/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/arm/arm/bus_dma.c,v
retrieving revision 1.28
diff -u -p -r1.28 bus_dma.c
--- arch/arm/arm/bus_dma.c  16 Nov 2014 12:30:56 -  1.28
+++ arch/arm/arm/bus_dma.c  6 Mar 2016 11:34:35 -
@@ -164,15 +164,6 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus
printf("dmamap_destroy: t=%p map=%p\n", t, map);
 #endif /* DEBUG_DMA */
 
-   /*
-* Explicit unload.
-*/
-   map->dm_mapsize = 0;
-   map->dm_nsegs = 0;
-   map->_dm_origbuf = NULL;
-   map->_dm_buftype = ARM32_BUFTYPE_INVALID;
-   map->_dm_proc = NULL;
-
free(map, M_DEVBUF, 0);
 }
 



Re: landisk: invalidate the entire cache on EMODE CPUs

2016-03-05 Thread Tobias Ulmer
On Fri, Mar 04, 2016 at 10:32:01PM +, Miod Vallat wrote:
> 
> > SH4 CPUs with EMODE bit set have a cache twice as big.  Fix the obvious
> > copy mistake.
> 
> There is nothing to fix in these routines.
> 
> When EMODE is enabled, the cache becomes two way, instead of one way,
> which is why it becomes twice as big.
> 
> sh4_emode_icache_sync_all() and sh4_emode_dcache_wbinv_all() wrap
> cache_sh4_emode_op_8lines_32(), which will operate on both ways.
> 

Ouch, that's a pretty mean trap :/ Sorry for the noise



landisk: invalidate the entire cache on EMODE CPUs

2016-03-04 Thread Tobias Ulmer
SH4 CPUs with EMODE bit set have a cache twice as big.  Fix the obvious
copy mistake.

Didn't fix the problem I was looking at, but may help with general
stability (I think all landisks use the EMODE capable SH7751R)
My "good" landisk is happy with this.

diff --git a/sys/arch/sh/sh/cache_sh4.c b/sys/arch/sh/sh/cache_sh4.c
index 8c736a1..ea70312 100644
--- a/sys/arch/sh/sh/cache_sh4.c
+++ b/sys/arch/sh/sh/cache_sh4.c
@@ -403,7 +403,7 @@ void
 sh4_emode_icache_sync_all(void)
 {
vaddr_t va = 0;
-   vaddr_t eva = SH4_ICACHE_SIZE;
+   vaddr_t eva = SH4_EMODE_ICACHE_SIZE;
 
sh4_emode_dcache_wbinv_all();
 
@@ -443,7 +443,7 @@ void
 sh4_emode_dcache_wbinv_all(void)
 {
vaddr_t va = 0;
-   vaddr_t eva = SH4_DCACHE_SIZE;
+   vaddr_t eva = SH4_EMODE_DCACHE_SIZE;
 
while (va < eva) {
cache_sh4_emode_op_8lines_32(va, SH4_CCDA, CCDA_ENTRY_MASK,



landisk: match function declaration

2016-03-04 Thread Tobias Ulmer
Match function declaration, use void

--- a/sys/arch/sh/sh/mmu_sh3.c
+++ b/sys/arch/sh/sh/mmu_sh3.c
@@ -38,7 +38,7 @@
 #include 
 
 void
-sh3_mmu_start()
+sh3_mmu_start(void)
 {
/* Zero clear all TLB entry */
sh3_tlb_invalidate_all();
@@ -89,7 +89,7 @@ sh3_tlb_invalidate_asid(int asid)
 }
 
 void
-sh3_tlb_invalidate_all()
+sh3_tlb_invalidate_all(void)
 {
uint32_t aw, a;
int e, w;
diff --git a/sys/arch/sh/sh/mmu_sh4.c b/sys/arch/sh/sh/mmu_sh4.c
index 4870d79..63a8cf4 100644
--- a/sys/arch/sh/sh/mmu_sh4.c
+++ b/sys/arch/sh/sh/mmu_sh4.c
@@ -42,7 +42,7 @@
 static inline void __sh4_itlb_invalidate_all(void);
 
 static inline void
-__sh4_itlb_invalidate_all()
+__sh4_itlb_invalidate_all(void)
 {
_reg_write_4(SH4_ITLB_AA, 0);
_reg_write_4(SH4_ITLB_AA | (1 << SH4_ITLB_E_SHIFT), 0);
@@ -51,7 +51,7 @@ __sh4_itlb_invalidate_all()
 }
 
 void
-sh4_mmu_start()
+sh4_mmu_start(void)
 {
/* Zero clear all TLB entry */
_reg_write_4(SH4_MMUCR, 0); /* zero wired entry */
@@ -115,7 +115,7 @@ sh4_tlb_invalidate_asid(int asid)
 }
 
 void
-sh4_tlb_invalidate_all()
+sh4_tlb_invalidate_all(void)
 {
uint32_t a;
int e, eend, s;



landisk: bus_dma.c cleanup

2016-03-04 Thread Tobias Ulmer
Found while debugging cache problems on landisk

Remove mapstore and error, remnants of code logic long gone.
DMAMAP_RESET is only used on landisk, disrupts readability and the one
line saved per use doesn't really justify its existence to me

--- a/sys/arch/landisk/landisk/bus_dma.c
+++ b/sys/arch/landisk/landisk/bus_dma.c
@@ -67,11 +67,6 @@ struct _bus_dma_tag landisk_bus_dma = {
._dmamem_mmap = _bus_dmamem_mmap,
 };
 
-#define DMAMAP_RESET(_m) do { \
-   (_m)->dm_mapsize = 0; \
-   (_m)->dm_nsegs = 0; \
-} while (0)
-
 int_bus_dmamap_load_vaddr(bus_dma_tag_t, bus_dmamap_t,
void *, bus_size_t, pmap_t);
 int_bus_dmamap_load_paddr(bus_dma_tag_t, bus_dmamap_t,
@@ -85,9 +80,7 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int 
nsegments,
 bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
 {
bus_dmamap_t map;
-   void *mapstore;
size_t mapsize;
-   int error;
 
DPRINTF(("bus_dmamap_create: t = %p, size = %ld, nsegments = %d, 
maxsegsz = %ld, boundary = %ld, flags = %x\n", t, size, nsegments, maxsegsz, 
boundary, flags));
 
@@ -103,23 +96,21 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int 
nsegments,
 * The bus_dmamap_t includes one bus_dma_segment_t, hence
 * the (nsegments - 1).
 */
-   error = 0;
mapsize = sizeof(struct _bus_dmamap) +
(sizeof(bus_dma_segment_t) * (nsegments - 1));
-   if ((mapstore = malloc(mapsize, M_DEVBUF, (flags & BUS_DMA_NOWAIT) ?
+   if ((map = malloc(mapsize, M_DEVBUF, (flags & BUS_DMA_NOWAIT) ?
(M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO))) == NULL)
return (ENOMEM);
 
-   DPRINTF(("bus_dmamap_create: dmamp = %p\n", mapstore));
+   DPRINTF(("bus_dmamap_create: dmamp = %p\n", map));
 
-   map = (bus_dmamap_t)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
-
-   DMAMAP_RESET(map); /* no valid mappings */
+   map->dm_mapsize = 0;/* no valid mappings */
+   map->dm_nsegs = 0;
 
*dmamp = map;
 
@@ -245,7 +236,8 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void 
*buf,
 
DPRINTF(("bus_dmamap_load: t = %p, map = %p, buf = %p, buflen = %ld, p 
= %p, flags = %x\n", t, map, buf, buflen, p, flags));
 
-   DMAMAP_RESET(map);
+   map->dm_mapsize = 0;
+   map->dm_nsegs = 0;
 
if (buflen > map->_dm_size)
return (EINVAL);
@@ -253,7 +245,8 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void 
*buf,
error = _bus_dmamap_load_vaddr(t, map, buf, buflen,
p == NULL ? pmap_kernel() : p->p_vmspace->vm_map.pmap);
if (error != 0) {
-   DMAMAP_RESET(map); /* no valid mappings */
+   map->dm_mapsize = 0; /* no valid mappings */
+   map->dm_nsegs = 0;
return (error);
}
 
@@ -272,7 +265,8 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, 
struct mbuf *m0,
struct mbuf *m;
int error;
 
-   DMAMAP_RESET(map);
+   map->dm_mapsize = 0;
+   map->dm_nsegs = 0;
 
 #ifdef DIAGNOSTIC
if ((m0->m_flags & M_PKTHDR) == 0)
@@ -289,7 +283,8 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, 
struct mbuf *m0,
error = _bus_dmamap_load_vaddr(t, map, m->m_data, m->m_len,
pmap_kernel());
if (error != 0) {
-   DMAMAP_RESET(map);
+   map->dm_mapsize = 0;
+   map->dm_nsegs = 0;
return (error);
}
}



ARM as: add .inst support

2015-12-02 Thread Tobias Ulmer
Add support for .inst 0xdeadbeef. Required to move forward with gcc 4.9

No GPLv3 license was violated during writing this trivial diff

ok?

Index: gnu/usr.bin/binutils-2.17/gas/config/tc-arm.c
===
RCS file: 
/home/vcs/cvs/openbsd/src/gnu/usr.bin/binutils-2.17/gas/config/tc-arm.c,v
retrieving revision 1.4
diff -u -p -r1.4 tc-arm.c
--- gnu/usr.bin/binutils-2.17/gas/config/tc-arm.c   13 Jun 2015 09:37:13 
-  1.4
+++ gnu/usr.bin/binutils-2.17/gas/config/tc-arm.c   2 Dec 2015 14:31:20 
-
@@ -1730,6 +1730,37 @@ s_syntax (int unused ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
 }
 
+static void
+s_inst(int unused ATTRIBUTE_UNUSED)
+{
+   expressionS exp;
+
+   if (thumb_mode) {
+   as_bad(".inst not implemented for Thumb mode");
+   ignore_rest_of_line();
+   return;
+   }
+
+   if (is_it_end_of_statement()) {
+   demand_empty_rest_of_line();
+   return;
+   }
+
+   do {
+   expression();
+
+   if (exp.X_op != O_constant)
+   as_bad("constant expression required");
+   else
+   emit_expr(, 4);
+
+   } while (*input_line_pointer++ == ',');
+
+   /* Put terminator back into stream. */
+   input_line_pointer--;
+   demand_empty_rest_of_line();
+}
+
 /* Directives: sectioning and alignment.  */
 
 /* Same as s_align_ptwo but align 0 => align 2. */
@@ -2985,6 +3016,7 @@ const pseudo_typeS md_pseudo_table[] =
   { "ltorg",  s_ltorg,   0 },
   { "pool",   s_ltorg,   0 },
   { "syntax", s_syntax,  0 },
+  { "inst",s_inst,0 },
 #ifdef OBJ_ELF
   { "word",   s_arm_elf_cons, 4 },
   { "long",   s_arm_elf_cons, 4 },



sparc: increase MAXTSIZ for running bloatware

2015-09-20 Thread Tobias Ulmer
Required for building gcc/gnat [and firefox, soon... ;p]

ok?

Index: arch/sparc/include/vmparam.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/sparc/include/vmparam.h,v
retrieving revision 1.47
diff -u -p -r1.47 vmparam.h
--- arch/sparc/include/vmparam.h18 Sep 2015 12:50:27 -  1.47
+++ arch/sparc/include/vmparam.h20 Sep 2015 18:45:35 -
@@ -52,7 +52,7 @@
  * Virtual memory related constants, all in bytes
  */
 #ifndef MAXTSIZ
-#defineMAXTSIZ (32*1024*1024)  /* max text size */
+#defineMAXTSIZ (64*1024*1024)  /* max text size */
 #endif
 #ifndef DFLDSIZ
 #defineDFLDSIZ (64*1024*1024)  /* initial data size 
limit */



Re: Thinkpad active cooling

2015-07-19 Thread Tobias Ulmer
On Fri, Jul 17, 2015 at 08:54:26PM +0200, Mark Kettenis wrote:
 Tobias Ulmer schreef op 2015-07-15 02:33:
 As we all know, some Thinkpads have problems with their EC fan control.
 EC is not spinning up the fans to maximum speed, let alone blast mode.
 They also do not offer ACPI methods to spin the fan up.
 
 Previous diffs doing manual fan control were always rejected because
 hooking into the sensors framework with fixed temp limits is crude and
 there are concerns with slowing the fan down and frying the hardware.
 
 This is an attempt to solve the problem slightly differently.
 - Hook into acpitz and only speed the fan up when it is requesting active
   cooling
 - Never set the fan to a mode that would endanger the hardware should we
   crash
 
 PS: It would be nice if there was a function to add cooling methods to
 acpitz eg: acpitz_add(void (*fn)(struct acpitz_softc *, void *), void
 *arg)
 I tried but getting struct acpitz_softc into a header is a bit messy.
 
 Does the AML define any active cooling trip points (_AC0, _AC1, etc)?

No, not in my machines.

Aside from not checking for interference with ACPI, this diff can't
handle multiple thermal zones in a sensible manner.

There's also the problem of not throttling the CPU fast enough for the
little thermal mass in some machines. And I suspect acpitz_refresh()
is not running frequent enough to regulate properly.

I need to play with this some more, not feeling good about it just yet..

 
 Index: acpithinkpad.c
 ===
 RCS file: /home/vcs/cvs/openbsd/src/sys/dev/acpi/acpithinkpad.c,v
 retrieving revision 1.44
 diff -u -p -r1.44 acpithinkpad.c
 --- acpithinkpad.c   24 Apr 2015 14:44:17 -  1.44
 +++ acpithinkpad.c   14 Jul 2015 23:52:14 -
 @@ -104,6 +104,11 @@
  #define THINKPAD_ECOFFSET_FANLO 0x84
  #define THINKPAD_ECOFFSET_FANHI 0x85
 
 +#define THINKPAD_ECOFFSET_FANLEVEL  0x2f
 +#define THINKPAD_ECFANLEVEL_MAX 7
 +#define THINKPAD_ECFANLEVEL_BLAST   (16)
 +#define THINKPAD_ECFANLEVEL_AUTO(17)
 +
  #define THINKPAD_ADAPTIVE_MODE_HOME 1
  #define THINKPAD_ADAPTIVE_MODE_FUNCTION 3
 
 @@ -119,6 +124,7 @@ struct acpithinkpad_softc {
  };
 
  extern void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t
 *);
 +extern void (*acpitz_activecool)(int, int);
 
  int thinkpad_match(struct device *, void *, void *);
  voidthinkpad_attach(struct device *, struct device *, void *);
 @@ -134,6 +140,7 @@ int  thinkpad_brightness_up(struct acpith
  int thinkpad_brightness_down(struct acpithinkpad_softc *);
  int thinkpad_adaptive_change(struct acpithinkpad_softc *);
  int thinkpad_activate(struct device *, int);
 +voidthinkpad_activecool(int, int);
 
  voidthinkpad_sensor_attach(struct acpithinkpad_softc *sc);
  voidthinkpad_sensor_refresh(void *);
 @@ -228,6 +235,7 @@ thinkpad_attach(struct device *parent, s
  {
  struct acpithinkpad_softc *sc = (struct acpithinkpad_softc *)self;
  struct acpi_attach_args *aa = aux;
 +u_int8_t level;
 
  sc-sc_acpi = (struct acpi_softc *)parent;
  sc-sc_devnode = aa-aaa_node;
 @@ -241,6 +249,11 @@ thinkpad_attach(struct device *parent, s
  /* Run thinkpad_hotkey on button presses */
  aml_register_notify(sc-sc_devnode, aa-aaa_dev,
  thinkpad_hotkey, sc, ACPIDEV_POLL);
 +
 +/* Make sure fan is in auto mode, otherwise we're not sure of support */
 +acpiec_read(acpi_softc-sc_ec, THINKPAD_ECOFFSET_FANLEVEL, 1, level);
 +if (level == THINKPAD_ECFANLEVEL_AUTO)
 +acpitz_activecool = thinkpad_activecool;
  }
 
  int
 @@ -546,4 +559,30 @@ thinkpad_activate(struct device *self, i
  break;
  }
  return (0);
 +}
 +
 +void
 +thinkpad_activecool(int tmp, int psv)
 +{
 +static uint8_t level = THINKPAD_ECFANLEVEL_AUTO;
 +uint8_t nlevel;
 +
 +if (tmp  0 || psv  0)
 +return;
 +
 +if (tmp  psv)
 +nlevel = THINKPAD_ECFANLEVEL_BLAST;
 +else if (tmp  psv-50)
 +/* EC firmware fan control is too slow in some models. When
 + * we're getting within 5C of active cooling mode, turn the
 + * fan to MAX. Helps with oscillation between blast and auto */
 +nlevel = THINKPAD_ECFANLEVEL_MAX;
 +else
 +nlevel = THINKPAD_ECFANLEVEL_AUTO;
 +
 +if (nlevel != level) {
 +acpiec_write(acpi_softc-sc_ec, THINKPAD_ECOFFSET_FANLEVEL, 1,
 +nlevel);
 +level = nlevel;
 +}
  }
 Index: acpitz.c
 ===
 RCS file: /home/vcs/cvs/openbsd/src/sys/dev/acpi/acpitz.c,v
 retrieving revision 1.49
 diff -u -p -r1.49 acpitz.c
 --- acpitz.c 6 May 2015 01:41:55 -   1.49
 +++ acpitz.c 14 Jul 2015 23:52:14 -
 @@ -86,6 +86,7 @@ intacpitz_setfan(struct acpitz_softc *,
  voidacpitz_init(struct acpitz_softc *, int

Thinkpad active cooling

2015-07-14 Thread Tobias Ulmer
As we all know, some Thinkpads have problems with their EC fan control.
EC is not spinning up the fans to maximum speed, let alone blast mode.
They also do not offer ACPI methods to spin the fan up.

Previous diffs doing manual fan control were always rejected because
hooking into the sensors framework with fixed temp limits is crude and
there are concerns with slowing the fan down and frying the hardware.

This is an attempt to solve the problem slightly differently.
- Hook into acpitz and only speed the fan up when it is requesting active
  cooling
- Never set the fan to a mode that would endanger the hardware should we
  crash

PS: It would be nice if there was a function to add cooling methods to
acpitz eg: acpitz_add(void (*fn)(struct acpitz_softc *, void *), void *arg)
I tried but getting struct acpitz_softc into a header is a bit messy.

Index: acpithinkpad.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/acpi/acpithinkpad.c,v
retrieving revision 1.44
diff -u -p -r1.44 acpithinkpad.c
--- acpithinkpad.c  24 Apr 2015 14:44:17 -  1.44
+++ acpithinkpad.c  14 Jul 2015 23:52:14 -
@@ -104,6 +104,11 @@
 #define THINKPAD_ECOFFSET_FANLO0x84
 #define THINKPAD_ECOFFSET_FANHI0x85
 
+#define THINKPAD_ECOFFSET_FANLEVEL 0x2f
+#define THINKPAD_ECFANLEVEL_MAX7
+#define THINKPAD_ECFANLEVEL_BLAST  (16)
+#define THINKPAD_ECFANLEVEL_AUTO   (17)
+
 #defineTHINKPAD_ADAPTIVE_MODE_HOME 1
 #defineTHINKPAD_ADAPTIVE_MODE_FUNCTION 3
 
@@ -119,6 +124,7 @@ struct acpithinkpad_softc {
 };
 
 extern void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t *);
+extern void (*acpitz_activecool)(int, int);
 
 intthinkpad_match(struct device *, void *, void *);
 void   thinkpad_attach(struct device *, struct device *, void *);
@@ -134,6 +140,7 @@ int thinkpad_brightness_up(struct acpith
 intthinkpad_brightness_down(struct acpithinkpad_softc *);
 intthinkpad_adaptive_change(struct acpithinkpad_softc *);
 intthinkpad_activate(struct device *, int);
+voidthinkpad_activecool(int, int);
 
 voidthinkpad_sensor_attach(struct acpithinkpad_softc *sc);
 voidthinkpad_sensor_refresh(void *);
@@ -228,6 +235,7 @@ thinkpad_attach(struct device *parent, s
 {
struct acpithinkpad_softc *sc = (struct acpithinkpad_softc *)self;
struct acpi_attach_args *aa = aux;
+   u_int8_t level;
 
sc-sc_acpi = (struct acpi_softc *)parent;
sc-sc_devnode = aa-aaa_node;
@@ -241,6 +249,11 @@ thinkpad_attach(struct device *parent, s
/* Run thinkpad_hotkey on button presses */
aml_register_notify(sc-sc_devnode, aa-aaa_dev,
thinkpad_hotkey, sc, ACPIDEV_POLL);
+
+   /* Make sure fan is in auto mode, otherwise we're not sure of support */
+   acpiec_read(acpi_softc-sc_ec, THINKPAD_ECOFFSET_FANLEVEL, 1, level);
+   if (level == THINKPAD_ECFANLEVEL_AUTO)
+   acpitz_activecool = thinkpad_activecool;
 }
 
 int
@@ -546,4 +559,30 @@ thinkpad_activate(struct device *self, i
break;
}
return (0);
+}
+
+void
+thinkpad_activecool(int tmp, int psv)
+{
+   static uint8_t level = THINKPAD_ECFANLEVEL_AUTO;
+   uint8_t nlevel;
+
+   if (tmp  0 || psv  0)
+   return;
+
+   if (tmp  psv)
+   nlevel = THINKPAD_ECFANLEVEL_BLAST;
+   else if (tmp  psv-50)
+   /* EC firmware fan control is too slow in some models. When
+* we're getting within 5C of active cooling mode, turn the
+* fan to MAX. Helps with oscillation between blast and auto */
+   nlevel = THINKPAD_ECFANLEVEL_MAX;
+   else
+   nlevel = THINKPAD_ECFANLEVEL_AUTO;
+
+   if (nlevel != level) {
+   acpiec_write(acpi_softc-sc_ec, THINKPAD_ECOFFSET_FANLEVEL, 1,
+   nlevel);
+   level = nlevel;
+   }
 }
Index: acpitz.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/acpi/acpitz.c,v
retrieving revision 1.49
diff -u -p -r1.49 acpitz.c
--- acpitz.c6 May 2015 01:41:55 -   1.49
+++ acpitz.c14 Jul 2015 23:52:14 -
@@ -86,6 +86,7 @@ int   acpitz_setfan(struct acpitz_softc *,
 void   acpitz_init(struct acpitz_softc *, int);
 
 void   (*acpitz_cpu_setperf)(int);
+void(*acpitz_activecool)(int, int) = NULL;
 intacpitz_perflevel = -1;
 extern void(*cpu_setperf)(int);
 extern int perflevel;
@@ -427,6 +428,11 @@ acpitz_refresh(void *arg)
acpitz_setfan(sc, i, _OFF);
}
}
+
+   /* active cooling hook */
+   if (acpitz_activecool)
+   acpitz_activecool(sc-sc_tmp, sc-sc_psv);
+
sc-sc_sens.value = sc-sc_tmp * 10 - 5;
 }
 



Re: Thinkpad active cooling

2015-07-14 Thread Tobias Ulmer
Theo is asking for affected models, so lets compile a list.
All my Thinkpads can be provoked into shutdown due to overtemp because
the fan doesn't spin up:

T60
T61
X201



Re: Thinkpad active cooling

2015-07-14 Thread Tobias Ulmer
On Wed, Jul 15, 2015 at 05:12:41AM +0300, Paul Irofti wrote:
 I am not familiar with all the fan hack specifics so please keep that in mind
 if my questions and comments seem trivial.
 
  This is an attempt to solve the problem slightly differently.
  - Hook into acpitz and only speed the fan up when it is requesting active
cooling
  - Never set the fan to a mode that would endanger the hardware should we
crash
 
 Your diff applies to all Thinkpad models. Is that okay?

It applies to all Thinkpads that have a sensible value in
THINKPAD_ECOFFSET_FANLEVEL, as you noticed. There is no flag or
documentation indicating the existence of this register as far as I
know. It's somewhat of a tradition, every TP I've owned had it.

My hope is if they drop support or move the offset, the value will
change and we won't do any damage.

I'm thinking this can be improved further by querying ACPI for _AC, so
it doesn't ever interfere with  acpitz_setfan(). I'll look into this.

 
  
  PS: It would be nice if there was a function to add cooling methods to
  acpitz eg: acpitz_add(void (*fn)(struct acpitz_softc *, void *), void *arg)
  I tried but getting struct acpitz_softc into a header is a bit messy.
 
 If needed you can move the softc in the acpivar.h header file.
 Nothing messy about it. What other model drivers would need this though?

So far none, but I imagine we will see more software controlled power
management in the future. I guess I just don't like global variables and
extern declarations :)

 
   thinkpad_hotkey, sc, ACPIDEV_POLL);
  +
  +   /* Make sure fan is in auto mode, otherwise we're not sure of support */
  +   acpiec_read(acpi_softc-sc_ec, THINKPAD_ECOFFSET_FANLEVEL, 1, level);
  +   if (level == THINKPAD_ECFANLEVEL_AUTO)
  +   acpitz_activecool = thinkpad_activecool;
 
 Why is there no support if the fan is not in auto mode?

Trying not to break future models.

 
  +   else if (tmp  psv-50)
  +   /* EC firmware fan control is too slow in some models. When
  +* we're getting within 5C of active cooling mode, turn the
  +* fan to MAX. Helps with oscillation between blast and auto */
 
 This comment does not follow KNF :-)

Heh, I'll fix that to make you happy ;)

 
  +   nlevel = THINKPAD_ECFANLEVEL_MAX;
  +   else
  +   nlevel = THINKPAD_ECFANLEVEL_AUTO;
  +
  +   if (nlevel != level) {
  +   acpiec_write(acpi_softc-sc_ec, THINKPAD_ECOFFSET_FANLEVEL, 1,
  +   nlevel);
  +   level = nlevel;
  +   }
   }
  Index: acpitz.c
  ===
  RCS file: /home/vcs/cvs/openbsd/src/sys/dev/acpi/acpitz.c,v
  retrieving revision 1.49
  diff -u -p -r1.49 acpitz.c
  --- acpitz.c6 May 2015 01:41:55 -   1.49
  +++ acpitz.c14 Jul 2015 23:52:14 -
  @@ -86,6 +86,7 @@ int   acpitz_setfan(struct acpitz_softc *,
   void   acpitz_init(struct acpitz_softc *, int);
   
   void   (*acpitz_cpu_setperf)(int);
  +void(*acpitz_activecool)(int, int) = NULL;
   intacpitz_perflevel = -1;
   extern void(*cpu_setperf)(int);
   extern int perflevel;
  @@ -427,6 +428,11 @@ acpitz_refresh(void *arg)
  acpitz_setfan(sc, i, _OFF);
  }
  }
  +
  +   /* active cooling hook */
  +   if (acpitz_activecool)
  +   acpitz_activecool(sc-sc_tmp, sc-sc_psv);
  +
 
 I'm not sure, but is it ever possible for acpitz to attach BEFORE
 acpithinkpad and render this check false?
 Would you need to somehow tie the two together?

The check evaluating to false is not a problem, it will become true in
time, it's a slow running loop. I didn't see any locking around
acpitz_cpu_setperf(), so I'm guessing it's fine



Re: Thinkpad active cooling

2015-07-14 Thread Tobias Ulmer
On Wed, Jul 15, 2015 at 12:03:45AM -0400, Ted Unangst wrote:
 Tobias Ulmer wrote:
  As we all know, some Thinkpads have problems with their EC fan control.
  EC is not spinning up the fans to maximum speed, let alone blast mode.
  They also do not offer ACPI methods to spin the fan up.
  
  Previous diffs doing manual fan control were always rejected because
  hooking into the sensors framework with fixed temp limits is crude and
  there are concerns with slowing the fan down and frying the hardware.
  
  This is an attempt to solve the problem slightly differently.
  - Hook into acpitz and only speed the fan up when it is requesting active
cooling
  - Never set the fan to a mode that would endanger the hardware should we
crash
 
 Can you clarify what if any effect should be observed with this diff? Will it
 make my fans louder or quieter?
 
 (I was very happy to discover that with the C states diff, my one thinkpad now
 idles at 3000 rpm vs 3500 rpm, and that is actually a lot quieter.)
 

There should be zero change in behaviour for normal use.

Only if thermal zone temp reaches its passive cooling limit (93C on my
X201) and demands active cooling will it spin the fan up. At the same
time acpitz also reduces cpuspeed. Once temps are back to normal it
switches to automatic mode and the fans should quiet down.



awk: out of bounds error

2015-03-25 Thread Tobias Ulmer
ss10:~$ awk -f foo
awk: can't open file foo
 source line number 1 source file foo
  context is
ΓΏ 

Oh look, the international sign for buffer overflow.

Don't print context when ebuf is empty

--- lib.c.orig  Wed Mar 25 17:11:49 2015
+++ lib.c   Wed Mar 25 17:11:27 2015
@@ -648,7 +648,8 @@ void eprint(void)   /* try to print context around error
static int been_here = 0;
extern char ebuf[], *ep;
 
-   if (compile_time == 2 || compile_time == 0 || been_here++  0)
+   if (compile_time == 2 || compile_time == 0 || been_here++  0 ||
+   ebuf == ep)
return;
p = ep - 1;
if (p  ebuf  *p == '\n')



kill unused macppc system_type

2014-06-29 Thread Tobias Ulmer
grep and make agree that this stuff is unused.

Index: arch/macppc/include/autoconf.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/macppc/include/autoconf.h,v
retrieving revision 1.9
diff -u -p -r1.9 autoconf.h
--- arch/macppc/include/autoconf.h  22 Aug 2009 02:54:50 -  1.9
+++ arch/macppc/include/autoconf.h  29 Jun 2014 22:48:21 -
@@ -34,17 +34,6 @@
 
 #include machine/bus.h
 
-/*
- *   System types.
- */
-#define OFWMACH 0   /* Openfirmware drivers */
-#definePOWER4e 1   /* V.I Power.4e board */
-#definePWRSTK  2   /* Motorola Powerstack series */
-#defineAPPL3   /* Apple PowerMac machines (OFW?) */
-
-extern int system_type;
-
-/**/
 struct confargs;
 
 typedef int (*intr_handler_t)(void *);



Re: kill unused macppc system_type

2014-06-29 Thread Tobias Ulmer
While I'm at it...

Index: arch/macppc/include/autoconf.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/macppc/include/autoconf.h,v
retrieving revision 1.9
diff -u -p -r1.9 autoconf.h
--- arch/macppc/include/autoconf.h  22 Aug 2009 02:54:50 -  1.9
+++ arch/macppc/include/autoconf.h  30 Jun 2014 00:21:01 -
@@ -34,49 +34,9 @@
 
 #include machine/bus.h
 
-/*
- *   System types.
- */
-#define OFWMACH 0   /* Openfirmware drivers */
-#definePOWER4e 1   /* V.I Power.4e board */
-#definePWRSTK  2   /* Motorola Powerstack series */
-#defineAPPL3   /* Apple PowerMac machines (OFW?) */
-
-extern int system_type;
-
-/**/
-struct confargs;
-
-typedef int (*intr_handler_t)(void *);
-
-typedef struct bushook {
-   struct  device *bh_dv;
-   int bh_type;
-   void(*bh_intr_establish)(struct confargs *, intr_handler_t, void *);
-   void(*bh_intr_disestablish)(struct confargs *);
-   int (*bh_matchname)(struct confargs *, char *);
-} bushook_t;
-
-#defineBUS_MAIN1   /* mainbus */
-#defineBUS_ISABR   2   /* ISA Bridge Bus */
-#defineBUS_PCIBR   3   /* PCI bridge */
-#defineBUS_VMEBR   4   /* VME bridge */
-
-#defineBUS_INTR_ESTABLISH(ca, handler, val)
\
-   (*(ca)-ca_bus-bh_intr_establish)((ca), (handler), (val))
-#defineBUS_INTR_DISESTABLISH(ca)   
\
-   (*(ca)-ca_bus-bh_intr_establish)(ca)
-#defineBUS_CVTADDR(ca) 
\
-   (*(ca)-ca_bus-bh_cvtaddr)(ca)
-#defineBUS_MATCHNAME(ca, name) 
\
-   (*(ca)-ca_bus-bh_matchname)((ca), (name))
-
 struct confargs {
-   char*ca_name;   /* Device name. */
-   bushook_t *ca_bus;  /* bus device resides on. */
-   /* macobio hooks ?? */
+   char*ca_name;
bus_space_tag_t ca_iot;
-   bus_space_tag_t ca_memt; /* XXX */
bus_dma_tag_t ca_dmat;
u_int32_t ca_node;
int ca_nreg;
Index: arch/macppc/macppc/mainbus.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/macppc/macppc/mainbus.c,v
retrieving revision 1.21
diff -u -p -r1.21 mainbus.c
--- arch/macppc/macppc/mainbus.c19 Apr 2009 17:53:39 -  1.21
+++ arch/macppc/macppc/mainbus.c30 Jun 2014 00:21:01 -
@@ -38,7 +38,6 @@
 
 struct mainbus_softc {
struct  device sc_dv;
-   struct  bushook sc_bus;
 };
 
 /* Definition of the mainbus driver. */
@@ -58,11 +57,6 @@ extern char *hw_prod, *hw_ver, *hw_vendo
 
 #define HH_REG_CONF0x90
 
-void   mb_intr_establish(struct confargs *, int (*)(void *), void *);
-void   mb_intr_disestablish(struct confargs *);
-caddr_tmb_cvtaddr(struct confargs *);
-intmb_matchname(struct confargs *, char *);
-
 /*ARGSUSED*/
 static int
 mbmatch(struct device *parent, void *cfdata, void *aux)
@@ -77,7 +71,7 @@ mbmatch(struct device *parent, void *cfd
 static void
 mbattach(struct device *parent, struct device *self, void *aux)
 {
-   struct mainbus_softc *sc = (struct mainbus_softc *)self;
+   /* struct mainbus_softc *sc = (struct mainbus_softc *)self; */
struct confargs nca;
char name[64], *t = NULL;
int reg[4], cpucnt;
@@ -112,12 +106,6 @@ mbattach(struct device *parent, struct d
}
printf(: model %s\n, hw_prod);
 
-   sc-sc_bus.bh_dv = (struct device *)sc;
-   sc-sc_bus.bh_type = BUS_MAIN;
-   sc-sc_bus.bh_intr_establish = mb_intr_establish;
-   sc-sc_bus.bh_intr_disestablish = mb_intr_disestablish;
-   sc-sc_bus.bh_matchname = mb_matchname;
-
/*
 * Try to find and attach all of the CPUs in the machine.
 */
@@ -132,7 +120,6 @@ mbattach(struct device *parent, struct d
len = OF_getprop(node, reg, cpunum, sizeof cpunum);
if (len == 4  cpucnt == cpunum) {
nca.ca_name = cpu;
-   nca.ca_bus = sc-sc_bus;
nca.ca_reg = reg;
reg[0] = cpucnt;
config_found(self, nca, mbprint);
@@ -143,7 +130,6 @@ mbattach(struct device *parent, struct d
}
if (cpucnt == 0) {
nca.ca_name = cpu;
-   nca.ca_bus = sc-sc_bus;
nca.ca_reg = reg;
reg[0] = 0;
ncpusfound++;
@@ -167,7 +153,6 @@ mbattach(struct device *parent, struct d
}
if (twoway) {
nca.ca_name = cpu;
-   

fix modf() on sparc

2014-06-06 Thread Tobias Ulmer
If correct, this fixes a 22 year old bug that exists since 4.4BSD alpha :)

In modf, when we go down the Lbig jump, f0:f1 is never set and just
contains gibberish. Usually NAN or 0.0. What we really want is just copy
the input out and be done.

This completely corrupts python when hashing floats for a dictionary.
Since the resulting hash is not stable, it makes python crash all over
the place: http://bugs.python.org/issue7424

Sparc64 is not affected afaict, it's register passing convention seems
to put floats in f0..., making the copied code work just fine ;)

Index: arch/sparc/gen/modf.S
===
RCS file: /home/vcs/cvs/openbsd/src/lib/libc/arch/sparc/gen/modf.S,v
retrieving revision 1.8
diff -u -p -r1.8 modf.S
--- arch/sparc/gen/modf.S   22 Aug 2012 17:19:35 -  1.8
+++ arch/sparc/gen/modf.S   6 Jun 2014 21:16:40 -
@@ -175,11 +175,11 @@ Lbig:
 */
 #ifdef __PIC__
PICCY_SET(L0, %l0, %o7)
-   std %f0, [%i2]  ! *ival = val;
+   std %i0, [%i2]  ! *ival = val;
ldd [%l0], %f0  ! return 0.0;
 #else
sethi   %hi(L0), %l0
-   std %f0, [%i2]  ! *ival = val;
+   std %i0, [%i2]  ! *ival = val;
ldd [%l0 + %lo(L0)], %f0! return 0.0;
 #endif
ret



Re: fix modf() on sparc

2014-06-06 Thread Tobias Ulmer
And here's a quick and dirty regression test.

Index: Makefile
===
RCS file: /home/vcs/cvs/openbsd/src/regress/lib/libc/Makefile,v
retrieving revision 1.38
diff -u -p -r1.38 Makefile
--- Makefile29 Dec 2013 01:39:44 -  1.38
+++ Makefile6 Jun 2014 21:05:00 -
@@ -2,7 +2,7 @@
 
 SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env
 SUBDIR+= fmemopen fnmatch fpclassify getcap getopt_long glob
-SUBDIR+= hsearch longjmp locale malloc mkstemp netdb open_memstream 
+SUBDIR+= hsearch longjmp locale malloc mkstemp modf netdb open_memstream
 SUBDIR+= orientation popen printf
 SUBDIR+= regex setjmp setjmp-signal sigreturn sigsetjmp sprintf
 SUBDIR+= stdio_threading stpncpy strerror strtod strtol strtonum
Index: modf/Makefile
===
RCS file: modf/Makefile
diff -N modf/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -
+++ modf/Makefile   6 Jun 2014 21:05:00 -
@@ -0,0 +1,3 @@
+PROG=modf_test
+
+.include bsd.regress.mk
Index: modf/modf_test.c
===
RCS file: modf/modf_test.c
diff -N modf/modf_test.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ modf/modf_test.c6 Jun 2014 21:05:00 -
@@ -0,0 +1,35 @@
+/* Public domain, 2014, Tobias Ulmer tobi...@tmux.org */
+
+/* Test for bug introduced in 4.4BSD modf() on sparc */
+
+#include math.h
+
+#define BIGFLOAT (5e15) /* Number large enough to trigger the big case */
+
+int
+main(void)
+{
+   double f, i;
+
+   f = modf(BIGFLOAT, i);
+   if (i != BIGFLOAT)
+   return 1;
+   if (f != 0.0)
+   return 1;
+
+   /* Repeat, maybe we were lucky */
+   f = modf(BIGFLOAT, i);
+   if (i != BIGFLOAT)
+   return 1;
+   if (f != 0.0)
+   return 1;
+
+   /* With negative number, for good measure */
+   f = modf(-BIGFLOAT, i);
+   if (i != -BIGFLOAT)
+   return 1;
+   if (f != 0.0)
+   return 1;
+
+   return 0;
+}



provide etext symbol on sparc64

2014-01-05 Thread Tobias Ulmer
Profiling on sparc64 is broken because e(nd of)text is missing.
Once fixed, profiling works just fine on a Blade 1500. Am I missing
something?

OK?

Index: arch/sparc64/conf/ld.script
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/sparc64/conf/ld.script,v
retrieving revision 1.5
diff -u -p -r1.5 ld.script
--- arch/sparc64/conf/ld.script 28 Dec 2013 19:27:35 -  1.5
+++ arch/sparc64/conf/ld.script 6 Jan 2014 03:00:38 -
@@ -33,6 +33,7 @@ SECTIONS
.text :
{
*(.text)
+   PROVIDE(etext = .);
} :text
.rodata :
{



Re: Documentation for Realtek 8188* devices

2013-11-15 Thread Tobias Ulmer
On Fri, Nov 15, 2013 at 04:55:23AM +0100, Dmitrij D. Czarkoff wrote:
 Stefan Sperling said:
  I don't think there are any docs. The Linux driver is the only
  reference I could find.
  
  The linux driver has pci/usb shims around a common core, much like
  some other OpenBSD wireless drivers do (e.g. athn(4)).
  
  I believe a good approach would be to write a working PCI device driver
  based on our USB one (urtwn(4)), and then factor out common code from
  both into the sys/dev/ic/ directory in a separate step.
 
 That was my plan, though I hoped there is some documentation from
 Realtek i could use to avoid looking at Linux driver - I'm afraid Linux
 people would react badly if their driver is used even as plain
 reference, without any code copying.

No, this is not how copyright works. What you want to learn from looking
at their code is not the part that is copyrighted, but the facts, like
which registers needs to be set to what value at which time and sequence.

Whoever wrote the driver copied those facts out of a datasheet as well.

 
 -- 
 Dmitrij D. Czarkoff
 



Re: 'int stat(...)' hides constructor for 'struct stat'

2013-11-03 Thread Tobias Ulmer
On Sun, Nov 03, 2013 at 03:06:23PM +, Stuart Henderson wrote:
 cc1plus: warnings being treated as errors
 In file included from 
 /usr/obj/squid-3.4.0.2/squid-3.4.0.2/src/DiskIO/DiskThreads/aiops.cc:43:
 /usr/include/sys/stat.h:199: warning: 'int stat(const char*, stat*)' hides 
 constructor for 'struct stat'
 
 I can just get rid of -Werror, but is this important?


Unless struct stat turns out to be a class with a constructor, and the
code wants to construct a stat object instead of calling the syscall,
it's fine. Well for a value of fine between poor-choice-of-name and
squid-code-retarded.



Re: panic while resuming with connected ucom

2013-06-22 Thread Tobias Ulmer
On Fri, Jun 21, 2013 at 10:01:48PM +0200, Otto Moerbeek wrote:
 Hi,
 
 I have a Thinkpad T430 with an internal 3G modem that shows up as a
 (couple of) umodem. If I have a connection to the corresponding ucom
 active (with cu or pppd) and suspend the machine followed by a resume,
 it panics (or rather gets a trap) during resume; hand typed:
 
 kernel: protection fault trap, code=0
 Stopped atehci_check_intr+0xe:movbzl  0x3(%rax),%eax
 dddb{0} trace
 ehci_check_intr at ehci_check_int+0xe
 ehci_softintr() at ehci_softint+0x35
 softintr_dispatch at softintr_dispatch+0x5d
 Xsoftnet() at Xsoftnet+0x2d
 
 rax holds 0xdead0065deadbeef
 
 This is 100% reproducable. If I do not have an active connection to
 cuaU0 at the moment of suspend all is fine and the machine resumes ok.
 
 Could it be the refcounting is still rong in some cases?
 

Likely, but not the same ucom refcounting problem I hit.  movbzl
0x3(%rax),%eax is trying to deref bmAttributes, so edesc is freed most
likely. Maybe add some debug printfs to keep track of (de)allocation of
that struct?



Re: sgi: enable 24-bit audio on mavb(4) devices

2013-06-20 Thread Tobias Ulmer
On Sat, Jun 15, 2013 at 01:40:55PM +0200, Alexandre Ratchov wrote:
 This is a small diff to enable mavb(4) 24-bit native format. To
 test it, first check that audio works without the diff. Then, apply
 the diff, kill sndiod, and run it as:
 
   sndiod -dd -e s24be4lsb
 
 then play any audio file; sndiod should log something like:
 
 snd0: 48000Hz, s24be4lsb, play 0:1, rec 0:1, 9 blocks of 960 frames

mavb0 at macebus0 base 0x0030 irq 6: AD1843 rev 1
audio0 at mavb0

o2:~$ sndiod -dd -e s24be4lsb
snd0.default: rec=0:1 play=0:1 vol=23170 dup
snd0: 48000Hz, s24be4lsb, play 0:1, rec 0:1, 8 blocks of 1024 frames
mpg0: 48000Hz, s16be, play 0:15, 8 blocks of 1024 frames
snd0: device started

 
 does it? if so, does it sound right?

Sounds alright, no problems.

 
 Thanks!
 
 -- Alexandre
 
 Index: mavb.c
 ===
 RCS file: /cvs/src/sys/arch/sgi/dev/mavb.c,v
 retrieving revision 1.15
 diff -u -p -r1.15 mavb.c
 --- mavb.c15 May 2013 08:29:23 -  1.15
 +++ mavb.c15 Jun 2013 11:29:10 -
 @@ -522,7 +522,10 @@ mavb_set_params(void *hdl, int setmode, 
   return (EINVAL);
   }
   } else {
 - return (EINVAL);
 + play-factor = 1;
 + play-sw_code = NULL;
 + play-channels = 2;
 + play-precision = 24;
   }
   break;
   default:
 @@ -538,7 +541,7 @@ mavb_set_params(void *hdl, int setmode, 
   return (error);
  
   play-bps = AUDIO_BPS(play-precision);
 - play-msb = 1;
 + play-msb = 0;
   }
  
   if (setmode  AUMODE_RECORD) {
 @@ -556,7 +559,11 @@ mavb_set_params(void *hdl, int setmode, 
   rec-factor = 2;
   rec-sw_code = linear24_to_linear16_be;
   } else {
 - return (EINVAL);
 + rec-factor = 1;
 + rec-sw_code = NULL;
 + rec-channels = 2;
 + rec-precision = 24;
 + break;
   }
   break;
   default:
 @@ -575,7 +582,7 @@ mavb_set_params(void *hdl, int setmode, 
   return (error);
  
   rec-bps = AUDIO_BPS(rec-precision);
 - rec-msb = 1;
 + rec-msb = 0;
   }
  
   return (0);
 



Re: rm(1) static addition

2013-04-27 Thread Tobias Ulmer
On Sat, Apr 27, 2013 at 09:14:59PM +0200, Otto Moerbeek wrote:
 On Sat, Apr 27, 2013 at 09:09:25PM +0200, Franco Fichtner wrote:
 
  On Apr 27, 2013, at 7:36 PM, Ted Unangst t...@tedunangst.com wrote:
  
   On Sat, Apr 27, 2013 at 08:10, Otto Moerbeek wrote:
   On Sat, Apr 27, 2013 at 01:08:06AM -0400, Eitan Adler wrote:
   
   Adding static to internal function allows the compiler to better
   detect dead code (functions, variables, etc) and makes it easier for
   the compiler to optimize; e.g., since it knows a function will only
   called once it can inline code; or not output a symbol for a certain
   function.
   
   In general we don't lik this because it makes things harder to debug.
   For libraries, yes, but for programs, no.
   
   Isn't that rule only for the kernel? ddb can only see global symbols,
   but gdb should work fine in userland. Certainly I can set breakpoints
   on static functions, even when compiled without -g.
  
  On backtrace(3) (which is a GNU thing, I know), static functions don't
  show up with their respective names even though they are in the binary.
  That's a tad annoying, but I am not aware of any other limitation. Can
  someone please enlighten me?
 
 Inlined functions are pretyy confusing in gdb.

So basically we're making the code more difficult to understand because
we don't want to spend the one-time effort to move the static
inlinification from -O2 to -O3...

I'm not convinced we should give up that easily ;)

It should even be possible to have static functions including
breakpoints in the kernel. There is nothing particularly odd about
them as long as they are not inlined. There may be more than one with
the same name but the address-name mapping is distinct, isn't it?


 
   -Otto
 



Re: Remove an ugly uhci(4) hack

2013-04-14 Thread Tobias Ulmer
On Sun, Apr 14, 2013 at 12:48:28PM +0200, Martin Pieuchot wrote:
 So I'd like to remove the following hack from uhci(4) which is the 
 only piece of code that justifies another layer of abstraction around
 the memory allocation logic for the various USB controllers.
 
 I couldn't find any historical explanation for this code, not even from
 the NetBSD source repository. But what this hack does is to allocate
 then free some TDs, if the requested size is bigger than some magic
 value, to put them in the free list to avoid allocating them in
 interrupt context. 
 
 But as the comment says there's no guarantee that these TDs will still
 be on the free list when you'll need them.  There's also no guarantee
 that the number of TDs that you're pre-allocating will be big enough for
 your needs.  Anyway, after some time, the free list should already have
 enough TDs so that you won't need to allocate new ones.
 
 I'm running this without problem on amd64 with an Intel 82801GB USB
 and I'm quite confident this hack can goes away as neither ohci(4) nor
 ehci(4) use this kind of TDs pre-allocation when allocating memory for
 a transfer.

Tested on
uhci0 at pci0 dev 7 function 2 Intel 82371AB USB rev 0x01: apic 2 int 19
pushing almost(!) 4Mbps over one of these usb network thingies.

Seems OK to me.

 
 
 While here, put some splusb() around the code that modify the pointer to
 the first element of the list of free TDs, because it can also be
 modified from interrupt context.

I could not spot where it's modified, but then I didn't look very hard.

 
 
 ok?
 
 Index: uhci.c
 ===
 RCS file: /cvs/src/sys/dev/usb/uhci.c,v
 retrieving revision 1.93
 diff -u -p -r1.93 uhci.c
 --- uhci.c28 Mar 2013 03:58:03 -  1.93
 +++ uhci.c12 Apr 2013 15:11:55 -
 @@ -628,31 +628,6 @@ usbd_status
  uhci_allocm(struct usbd_bus *bus, usb_dma_t *dma, u_int32_t size)
  {
   struct uhci_softc *sc = (struct uhci_softc *)bus;
 - u_int32_t n;
 -
 - /*
 -  * XXX
 -  * Since we are allocating a buffer we can assume that we will
 -  * need TDs for it.  Since we don't want to allocate those from
 -  * an interrupt context, we allocate them here and free them again.
 -  * This is no guarantee that we'll get the TDs next time...
 -  */
 - n = size / 8;
 - if (n  16) {
 - u_int32_t i;
 - uhci_soft_td_t **stds;
 - DPRINTF((uhci_allocm: get %d TDs\n, n));
 - stds = malloc(sizeof(uhci_soft_td_t *) * n, M_TEMP,
 -   M_NOWAIT | M_ZERO);
 - if (stds == NULL)
 - panic(uhci_allocm);
 - for(i=0; i  n; i++)
 - stds[i] = uhci_alloc_std(sc);
 - for(i=0; i  n; i++)
 - if (stds[i] != NULL)
 - uhci_free_std(sc, stds[i]);
 - free(stds, M_TEMP);
 - }
  
   return (usb_allocmem(sc-sc_bus, size, 0, dma));
  }
 @@ -1584,6 +1559,7 @@ uhci_alloc_std(uhci_softc_t *sc)
   usbd_status err;
   int i, offs;
   usb_dma_t dma;
 + int s;
  
   if (sc-sc_freetds == NULL) {
   DPRINTFN(2,(uhci_alloc_std: allocating chunk\n));
 @@ -1591,6 +1567,7 @@ uhci_alloc_std(uhci_softc_t *sc)
 UHCI_TD_ALIGN, dma);
   if (err)
   return (0);
 + s = splusb();
   for(i = 0; i  UHCI_STD_CHUNK; i++) {
   offs = i * UHCI_STD_SIZE;
   std = KERNADDR(dma, offs);
 @@ -1598,16 +1575,23 @@ uhci_alloc_std(uhci_softc_t *sc)
   std-link.std = sc-sc_freetds;
   sc-sc_freetds = std;
   }
 + splx(s);
   }
 +
 + s = splusb();
   std = sc-sc_freetds;
   sc-sc_freetds = std-link.std;
   memset(std-td, 0, sizeof(uhci_td_t));
 - return std;
 + splx(s);
 +
 + return (std);
  }
  
  void
  uhci_free_std(uhci_softc_t *sc, uhci_soft_td_t *std)
  {
 + int s;
 +
  #ifdef DIAGNOSTIC
  #define TD_IS_FREE 0x12345678
   if (letoh32(std-td.td_token) == TD_IS_FREE) {
 @@ -1616,8 +1600,11 @@ uhci_free_std(uhci_softc_t *sc, uhci_sof
   }
   std-td.td_token = htole32(TD_IS_FREE);
  #endif
 +
 + s = splusb();
   std-link.std = sc-sc_freetds;
   sc-sc_freetds = std;
 + splx(s);
  }
  
  uhci_soft_qh_t *
 



Re: PATCH: merge.c white space cleanup

2013-01-27 Thread Tobias Ulmer
On Thu, Jan 24, 2013 at 09:37:33PM +0200, Ville Valkonen wrote:
 Hi,
 
 save a few precious bytes by removing unnecessary white spaces from
 libc/merge.c.

Please send diffs inline, it's a lot easier to review.

Usually whitespace diffs are not that well liked, they make for
annoying differences, introduce noise and require more effort to review
for questionable gain.

Otoh this file is quite bad. It makes my vim light up all red. The diff
itself is correct, the whitespace changes do not introduce any hidden
code changes as per sha1. From that perspective it's got my ok.

I'm still torn on this. Anyone else care to comment?

Same diff, as tested:
Index: stdlib/merge.c
===
RCS file: /home/vcs/cvs/openbsd/src/lib/libc/stdlib/merge.c,v
retrieving revision 1.9
diff -u -p -r1.9 merge.c
--- stdlib/merge.c  6 Mar 2011 00:55:38 -   1.9
+++ stdlib/merge.c  27 Jan 2013 18:29:30 -
@@ -73,7 +73,7 @@ static void insertionsort(u_char *, size
do  \
*dst++ = *src++;\
while (i -= 1)
-   
+
 /*
  * Find the next possible pointer head.  (Trickery for forcing an array
  * to do double duty as a linked list when objects do not align with word
@@ -120,91 +120,91 @@ mergesort(void *base, size_t nmemb, size
l2 = list1;
p1 = EVAL(list1);
for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) {
-   p2 = *EVAL(p2);
-   f1 = l2;
-   f2 = l1 = list1 + (p2 - list2);
-   if (p2 != last)
-   p2 = *EVAL(p2);
-   l2 = list1 + (p2 - list2);
-   while (f1  l1  f2  l2) {
-   if ((*cmp)(f1, f2) = 0) {
-   q = f2;
-   b = f1, t = l1;
-   sense = -1;
-   } else {
-   q = f1;
-   b = f2, t = l2;
-   sense = 0;
-   }
-   if (!big) { /* here i = 0 */
-   while ((b += size)  t  cmp(q, b) sense)
-   if (++i == 6) {
-   big = 1;
-   goto EXPONENTIAL;
-   }
-   } else {
-EXPONENTIAL:   for (i = size; ; i = 1)
-   if ((p = (b + i)) = t) {
-   if ((p = t - size)  b 
+   p2 = *EVAL(p2);
+   f1 = l2;
+   f2 = l1 = list1 + (p2 - list2);
+   if (p2 != last)
+   p2 = *EVAL(p2);
+   l2 = list1 + (p2 - list2);
+   while (f1  l1  f2  l2) {
+   if ((*cmp)(f1, f2) = 0) {
+   q = f2;
+   b = f1, t = l1;
+   sense = -1;
+   } else {
+   q = f1;
+   b = f2, t = l2;
+   sense = 0;
+   }
+   if (!big) { /* here i = 0 */
+   while ((b += size)  t  cmp(q, b) sense)
+   if (++i == 6) {
+   big = 1;
+   goto EXPONENTIAL;
+   }
+   } else {
+EXPONENTIAL:   for (i = size; ; i = 1)
+   if ((p = (b + i)) = t) {
+   if ((p = t - size)  b 
(*cmp)(q, p) = sense)
-   t = p;
-   else
-   b = p;
-   break;
-   } else if ((*cmp)(q, p) = sense) {
-   t = p;
-   if (i == size)
-   big = 0; 
-   goto FASTCASE;
-   } else
-   b = p;
-   while (t  b+size) {
-   i = (((t - b) / size)  1) * size;
-   if ((*cmp)(q, p = b + i) = sense)
-   t = p;
-   else
-   b 

Re: adduser: better locked password

2013-01-04 Thread Tobias Ulmer
On Fri, Jan 04, 2013 at 08:46:52AM +, Stuart Henderson wrote:
 On 2013/01/03 21:06, Chris Cappuccio wrote:
  Tobias Ulmer [tobi...@tmux.org] wrote:
   Adding a user with a locked password is a deliberate action.
   Set the password to * to stop security(8) from
   complaining about the new user.
   
  
  I think it'd make more sense if security(8) didn't flag :*: as unusual. 
  Since when is it unusual?
 
 The warning isn't just for a :*:'d account, it's for such an account with
 alternative access files, i.e. it's meant to tell you when you've disabled
 a password but forgotten about authorized_keys.

Right. This is sort of documented in passwd(5): login accounts not
allowing password authentication but allowing other authentication
methods, for example public key authentication, conventionally have 13
asterisks in the password field.

 Problem is, we now install an empty authorized_keys file from /etc/skel so
 this always triggers on a new :*:'d account. I'd rather prevent a 0-byte file
 from triggering security, or remove the empty file from skel.
 

I guess there are at least three related issues:
- adduser is inconsistent with useradd, which always creates
  disabled accounts with 13 *. I would like to commit the patch to fix
  this inconsistency.

- security(8) flags empty authorized_keys files. Looking at
  check_passwd() it seems a .ssh directory is enough to trigger the
  warning. That seems a bit excessive. Anyone wants to take this on?

- The users added for various ports should have their password set to
  * instead of 13 *. If _dbus suddenly gets an authorized_keys file, I
  would like to hear about it. usermod -p '*' is not allowed - however,
  13 * is...
  useradd: Password `*' is invalid: setting it to `*'
  Very helpful. ;)



adduser: better locked password

2013-01-02 Thread Tobias Ulmer
Adding a user with a locked password is a deliberate action.
Set the password to * to stop security(8) from
complaining about the new user.

OK?

Index: adduser.perl
===
RCS file: /home/vcs/cvs/openbsd/src/usr.sbin/adduser/adduser.perl,v
retrieving revision 1.58
diff -u -p -r1.58 adduser.perl
--- adduser.perl22 Sep 2011 10:59:23 -  1.58
+++ adduser.perl3 Jan 2013 03:29:54 -
@@ -800,7 +800,7 @@ sub new_users {
if (new_users_ok) {
$new_users_ok = 1;
 
-   $cryptpwd = *;# Locked by default
+   $cryptpwd = *; # Locked by default
$cryptpwd = encrypt($password, salt) if ($password ne );
$log_cl =  if ($log_cl eq default);



fix make depend in regress/sys/net

2012-11-30 Thread Tobias Ulmer
Nobody ever noticed that make depend fails when pf_print_host.c does
not yet exist? Hard to believe...

Anyway, here's a simple fix:

OK?


Index: Makefile
===
RCS file: /home/vcs/cvs/openbsd/src/regress/sys/net/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- Makefile22 Aug 2008 00:48:33 -  1.1
+++ Makefile30 Nov 2012 21:21:00 -
@@ -8,6 +8,8 @@ pf_print_host.c: ../../../sys/net/pf.c M
${.CURDIR}/../../../sys/net/pf.c $@.tmp
mv $@.tmp $@
 
+beforedepend: pf_print_host.c
+
 pf_print_test.o: pf_print_test.c pf_print_host.c
 
 .include bsd.regress.mk



Re: remove mapstore

2012-09-21 Thread Tobias Ulmer
ping?



Re: remove mapstore

2012-09-11 Thread Tobias Ulmer
On Sun, Sep 09, 2012 at 01:52:56AM +0200, Tobias Ulmer wrote:
 mapstore looks like an old error handling artifact. No binary change on
 amd64.

Btw, i've been testing this on armish, i386, landisk, socppc, sgi,
sparc, and hppa as part of another diff i'm cooking. This is really just
a noop ;-)



remove mapstore

2012-09-08 Thread Tobias Ulmer
mapstore looks like an old error handling artifact. No binary change on
amd64.

Index: alpha/dev/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/alpha/dev/bus_dma.c,v
retrieving revision 1.31
diff -u -p -r1.31 bus_dma.c
--- alpha/dev/bus_dma.c 23 Jun 2011 20:44:38 -  1.31
+++ alpha/dev/bus_dma.c 8 Sep 2012 23:32:56 -
@@ -64,7 +64,6 @@ _bus_dmamap_create(t, size, nsegments, m
bus_dmamap_t *dmamp;
 {
struct alpha_bus_dmamap *map;
-   void *mapstore;
size_t mapsize;
 
/*
@@ -81,11 +80,10 @@ _bus_dmamap_create(t, size, nsegments, m
 */
mapsize = sizeof(struct alpha_bus_dmamap) +
(sizeof(bus_dma_segment_t) * (nsegments - 1));
-   if ((mapstore = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
+   if ((map = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
(M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO))) == NULL)
return (ENOMEM);
 
-   map = (struct alpha_bus_dmamap *)mapstore;
map-_dm_size = size;
map-_dm_segcnt = nsegments;
map-_dm_maxsegsz = maxsegsz;
Index: amd64/amd64/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/amd64/amd64/bus_dma.c,v
retrieving revision 1.38
diff -u -p -r1.38 bus_dma.c
--- amd64/amd64/bus_dma.c   3 Jul 2011 18:31:02 -   1.38
+++ amd64/amd64/bus_dma.c   8 Sep 2012 23:32:58 -
@@ -125,7 +125,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
 {
struct bus_dmamap *map;
-   void *mapstore;
size_t mapsize;
 
/*
@@ -142,12 +141,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 */
mapsize = sizeof(struct bus_dmamap) +
(sizeof(bus_dma_segment_t) * (nsegments - 1));
-   if ((mapstore = malloc(mapsize, M_DEVBUF,
+   if ((map = malloc(mapsize, M_DEVBUF,
(flags  BUS_DMA_NOWAIT) ?
(M_NOWAIT|M_ZERO) : (M_WAITOK|M_ZERO))) == NULL)
return (ENOMEM);
 
-   map = (struct bus_dmamap *)mapstore;
map-_dm_size = size;
map-_dm_segcnt = nsegments;
map-_dm_maxsegsz = maxsegsz;
Index: arm/arm/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/arm/arm/bus_dma.c,v
retrieving revision 1.21
diff -u -p -r1.21 bus_dma.c
--- arm/arm/bus_dma.c   23 Jun 2011 20:44:39 -  1.21
+++ arm/arm/bus_dma.c   8 Sep 2012 23:33:00 -
@@ -86,7 +86,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
 {
struct arm32_bus_dmamap *map;
-   void *mapstore;
size_t mapsize;
 
 #ifdef DEBUG_DMA
@@ -108,11 +107,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 */
mapsize = sizeof(struct arm32_bus_dmamap) +
(sizeof(bus_dma_segment_t) * (nsegments - 1));
-   if ((mapstore = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
+   if ((map = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
(M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO))) == NULL)
return (ENOMEM);
 
-   map = (struct arm32_bus_dmamap *)mapstore;
map-_dm_size = size;
map-_dm_segcnt = nsegments;
map-_dm_maxsegsz = maxsegsz;
Index: aviion/aviion/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/aviion/aviion/bus_dma.c,v
retrieving revision 1.5
diff -u -p -r1.5 bus_dma.c
--- aviion/aviion/bus_dma.c 9 Oct 2011 17:08:21 -   1.5
+++ aviion/aviion/bus_dma.c 8 Sep 2012 23:33:03 -
@@ -70,7 +70,6 @@ bus_dmamap_create(t, size, nsegments, ma
 bus_dmamap_t *dmamp;
 {
 struct m88k_bus_dmamap *map;
-void *mapstore;
 size_t mapsize;
 
 /*
@@ -87,11 +86,10 @@ bus_dmamap_create(t, size, nsegments, ma
  */
 mapsize = sizeof(struct m88k_bus_dmamap) +
 (sizeof(bus_dma_segment_t) * (nsegments - 1));
-if ((mapstore = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
+if ((map = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
(M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO))) == NULL)
 return (ENOMEM);
 
-map = (struct m88k_bus_dmamap *)mapstore;
 map-_dm_size = size;
 map-_dm_segcnt = nsegments;
 map-_dm_maxsegsz = maxsegsz;
Index: i386/i386/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/i386/i386/bus_dma.c,v
retrieving revision 1.25
diff -u -p -r1.25 bus_dma.c
--- i386/i386/bus_dma.c 23 Jun 2011 20:44:39 -  1.25
+++ i386/i386/bus_dma.c 8 Sep 2012 23:33:20 -
@@ -90,7 +90,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_

gcc 3 in 5.2?

2012-09-07 Thread Tobias Ulmer
Don't think so, but I may be wrong.

Index: 52.html
===
RCS file: /home/vcs/cvs/openbsd/www/52.html,v
retrieving revision 1.32
diff -u -p -r1.32 52.html
--- 52.html 7 Sep 2012 02:27:05 -   1.32
+++ 52.html 7 Sep 2012 11:54:16 -
@@ -361,7 +361,7 @@ the package build process:
 liXenocara (based on X.Org 7.7 with xserver 1.12.2 + patches,
   freetype 2.4.10, fontconfig 2.8.0, Mesa 7.10.3, xterm 279,
   xkeyboard-config 2.6 and more)
-liGcc 4.2.1 (+patches), 3.3.5 (+ patches) and 2.95.3 (+ patches)
+liGcc 4.2.1 (+patches) and 2.95.3 (+ patches)
 liPerl 5.12.2 (+ patches)
 liOur improved and secured version of Apache 1.3, with
   SSL/TLS and DSO support



Re: ral rt2661 tx interrupt race fix

2012-08-16 Thread Tobias Ulmer
On Wed, Aug 15, 2012 at 10:17:09PM +0200, Stefan Sperling wrote:
 On Tue, Aug 14, 2012 at 08:31:31PM +0200, Tobias Ulmer wrote:
  Finally got around to dig out the card and put it in a Blade 1500. With
  -current, I get around 10Mb using tcpbench. With your diff,
  freelist corruption messages pop up rather quickly, speed is the same. I
  guess the panic at the end is just an effect of the modify after free.
 
 Thanks for catching this, Tobias!
 
 I could reproduce this problem on a Blade 100 with a Ralink RT2561S card.
 This updated diff should fix the problem. It works well for me in both
 hostap and STA modes.

Survived 9h of tcpbench testing here, no problems (except for a low
data rate today, but there was no difference to the stock kernel)



Re: ral rt2661 tx interrupt race fix

2012-08-14 Thread Tobias Ulmer
On Fri, Aug 03, 2012 at 01:31:18PM +0200, Stefan Sperling wrote:
 I haven't received any test reports so far, apart from my own
 testing and edd@'s testing. It's been working splendid for me
 so far but I would like to get more testing if possible.
 
 I've Bcc'd some people who were involved in testing earlier ral diffs
 or complained about ral not working for them. It would be great if
 some of you could try this diff on access points and clients. Cheers!

Finally got around to dig out the card and put it in a Blade 1500. With
-current, I get around 10Mb using tcpbench. With your diff,
freelist corruption messages pop up rather quickly, speed is the same. I
guess the panic at the end is just an effect of the modify after free.

Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2012 OpenBSD. All rights reserved.  http://www.OpenBSD.org

: Tue Aug 14 19:57:29 CEST 2012
tobi...@blade.tmux.org:/usr/src/sys/arch/sparc64/compile/GENERIC
real mem = 2147483648 (2048MB)
avail mem = 2100854784 (2003MB)
mainbus0 at root: Sun Blade 1500 (Silver)
cpu0 at mainbus0: SUNW,UltraSPARC-IIIi (rev 3.4) @ 1503 MHz
cpu0: physical 32K instruction (32 b/l), 64K data (32 b/l), 1024K external (64 
b/l)
memory-controller at mainbus0 not configured
schizo0 at mainbus0: Tomatillo, version 4, ign 780, bus A 0 to 1
schizo0: dvma map c000-dfff
pci0 at schizo0
ebus0 at pci0 dev 7 function 0 Acer Labs M1533 ISA rev 0x00
flashprom at ebus0 addr 0-f not configured
rtc0 at ebus0 addr 70-71: m5823
pcfiic0 at ebus0 addr 320-321 ivec 0x2e
iic0 at pcfiic0
admtt0 at iic0 addr 0x2e
spdmem0 at iic0 addr 0x50: 512MB DDR SDRAM registered ECC PC2300CL2.5
spdmem1 at iic0 addr 0x51: 512MB DDR SDRAM registered ECC PC2300CL2.5
spdmem2 at iic0 addr 0x52: 512MB DDR SDRAM registered ECC PC2300CL2.5
spdmem3 at iic0 addr 0x53: 512MB DDR SDRAM registered ECC PC2300CL2.5
ics951601 at iic0 addr 0x69 not configured
power0 at ebus0 addr 800-82f ivec 0x20
com0 at ebus0 addr 3f8-3ff ivec 0x2c: ns16550a, 16 byte fifo
com0: console
com1 at ebus0 addr 2e8-2ef ivec 0x2c: ns16550a, 16 byte fifo
dma at ebus0 addr 0- not configured
alipm0 at pci0 dev 6 function 0 Acer Labs M7101 Power rev 0x00: 223KHz clock
iic1 at alipm0
scm001 at alipm0 addr 0x20 skipped due to alipm0 bugs
autri0 at pci0 dev 8 function 0 Acer Labs M5451 Audio rev 0x02: ivec 0x7a4
ac97: codec id 0x41445348 (Analog Devices AD1881A)
ac97: codec features headphone, Analog Devices Phat Stereo
audio0 at autri0
midi0 at autri0: 4DWAVE MIDI UART
ohci0 at pci0 dev 10 function 0 Acer Labs M5237 USB rev 0x03: ivec 0x7a7, 
version 1.0, legacy support
ohci1 at pci0 dev 11 function 0 Acer Labs M5237 USB rev 0x03: ivec 0x7a6, 
version 1.0, legacy support
pciide0 at pci0 dev 13 function 0 Acer Labs M5229 UDMA IDE rev 0xc4: DMA, 
channel 0 configured to native-PCI, channel 1 configured to native-PCI
pciide0: using ivec 0x798 for native-PCI interrupt
wd0 at pciide0 channel 0 drive 0: ST3120026A
wd0: 16-sector PIO, LBA48, 114473MB, 234441648 sectors
wd1 at pciide0 channel 0 drive 1: ST3250620A
wd1: 16-sector PIO, LBA48, 238474MB, 488395055 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
wd1(pciide0:0:1): using PIO mode 4, Ultra-DMA mode 2
pciide0: channel 1 disabled (no drives)
ral0 at pci0 dev 2 function 0 Ralink RT2561 rev 0x00: ivec 0x790, address 
00:80:5a:38:c4:0b
ral0: MAC/BBP RT2661B, RF RT2527
ppb0 at pci0 dev 3 function 0 TI PCI2250 PCI-PCI rev 0x02
pci1 at ppb0 bus 1
ohci2 at pci1 dev 8 function 0 NEC USB rev 0x43: ivec 0x78c, version 1.0
ohci3 at pci1 dev 8 function 1 NEC USB rev 0x43: ivec 0x78d, version 1.0
ehci0 at pci1 dev 8 function 2 NEC USB rev 0x04: ivec 0x78e
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 NEC EHCI root hub rev 2.00/1.00 addr 1
TI TSB43AB23 FireWire rev 0x00 at pci1 dev 11 function 0 not configured
usb1 at ohci2: USB revision 1.0
uhub1 at usb1 NEC OHCI root hub rev 1.00/1.00 addr 1
usb2 at ohci3: USB revision 1.0
uhub2 at usb2 NEC OHCI root hub rev 1.00/1.00 addr 1
usb3 at ohci0: USB revision 1.0
uhub3 at usb3 Acer Labs OHCI root hub rev 1.00/1.00 addr 1
usb4 at ohci1: USB revision 1.0
uhub4 at usb4 Acer Labs OHCI root hub rev 1.00/1.00 addr 1
ppm at mainbus0 not configured
schizo1 at mainbus0: Tomatillo, version 4, ign 7c0, bus B 0 to 0
schizo1: dvma map c000-dfff
pci2 at schizo1
bge0 at pci2 dev 2 function 0 Broadcom BCM5703 rev 0x00, BCM5702/5703 A2 
(0x1002): ivec 0x7dc, address 00:14:4f:23:72:a2
brgphy0 at bge0 phy 1: BCM5703 10/100/1000baseT PHY, rev. 2
ifb0 at pci2 dev 3 function 0 3D Labs Wildcat 5110 rev 0x01
ifb0: XVR-1200 (SUNW,375-3101), 1152x900
wsdisplay0 at ifb0 mux 1
wsdisplay0: screen 0 added (std, sun emulation)
3D Labs Wildcat 5110 rev 0x01 at pci2 dev 3 function 1 not configured
i2c at mainbus0 not configured
vscsi0 at root
scsibus0 at vscsi0: 256 targets
softraid0 at root
scsibus1 at softraid0: 256 targets
bootpath: 

Re: BSD strip error handling V2

2012-07-03 Thread Tobias Ulmer
Anyone want to risk trying this on a GCC2_ARCH?



Re: cwm tiling

2012-06-09 Thread Tobias Ulmer
On Sun, Jun 03, 2012 at 09:07:13PM +0400, Alexander Polakov wrote:
 I'd like to start a discussion about adding tiling to cwm with
 these two diffs.

How hard can it be to import spectrwm... You're reinventing the wheel
here, badly.



Re: wpi: add sensor for rfkill

2012-05-23 Thread Tobias Ulmer
On Wed, May 23, 2012 at 01:27:26PM +1000, Brett wrote:
 On Tue, 22 May 2012 20:20:38 +0200
 Gregor Best g...@ring0.de wrote:
 
  Hi people,
  
  the attached patch adds an indicator sensor to wpi devices that describes 
  the
  current RFKill status.  If the RF killswitch is engaged, the sensor reads 
  Off,
  if it is not engaged and the device can operate, it reads On.
  
  If this is okay, I plan on adding similar sensors to other wireless devices,
  but in that case I'd need help testing those because I only have access to 
  wpi
  devices.
  
  -- 
  Gregor Best
 
 
 Hi Gregor,
 
 I wonder if it will be possible to tell interfaces to ignore the
 rfkill switches if this goes in? 
 
 I have an exopc tablet and it is impossible to run regular linux on
 it, because the rfkill is hardwired permanently off, so no wifi
 possible. Also I have seen a laptop (I think it was a HP) where the
 rfkill button is broken off, so again no wifi possible, as its
 killed by rfkill. 

This a read-only sensor, it has no effect on misbehaving
hardware as far as I can tell.

Gregor: try adding '-p' to cvs diff

 
 Brett.



Re: Thecus N1200 fix

2012-03-28 Thread Tobias Ulmer
On Wed, Mar 28, 2012 at 01:58:44PM +0600, Ivan Solonin wrote:
 Available disks are: wd0.
 Which one is the root disk? (or 'done') [wd0]
 Use DUIDs rather than device names in fstab? [yes] no
 Disk: wd0   geometry: 232581/16/63 [234441648 Sectors]
 Offset: 0   Signature: 0xAA55
 Starting Ending LBA Info:
  #: id  C   H   S -  C   H   S [   start:size ]
 ---
 *0: A6  0   1   1 -  16643  15  63 [  63:16777089 ] OpenBSD
  1: A6  16644   0   1 - 232437  15  63 [16777152:   217520352 ] OpenBSD
  2: 00  0   0   0 -  0   0   0 [   0:   0 ] unused
  3: A6 232438   0   1 - 232580  15  63 [   234297504:  144144 ] OpenBSD
 Use (W)hole disk, use the (O)penBSD area, or (E)dit the MBR?
 [OpenBSD] Illegal instruction (core dumped)
 Illegal instruction (core dumped)

Looks like fdisk can't handle the damaged partition table. Can you try
fdisk -i wd0? Or even dd if=/dev/zero of=/dev/rwd0c bs=1m count=1

For the record my installation of this snapshot went fine. The disk was
zero'ed beforehand though.



Re: one usb_mem pool per host controller

2012-03-14 Thread Tobias Ulmer
On Tue, Mar 13, 2012 at 10:59:36PM -0400, Ted Unangst wrote:
 I don't think it's necessary to allocate this structure.  Just stick
 it in usbd_bus entirely.
 

Alright, the intention was not to add another struct to the usb_mem
header, but I don't feel strongly about it.

The feedback so far indicates that it would be desirable to have
usb_mem_destroy() implemented and reclaim memory when a host controller
is detached. I think that's reasonable and will try make it work in v2
of this diff.

Does anyone have a model name of known working express card usb adapter?
I would like to get one if possible.



one usb_mem pool per host controller

2012-03-13 Thread Tobias Ulmer
I have a couple of machines with an EHCI controller that refuses to work
with memory above 2G, causing all kinds of trouble. This diff enables
setting a bus_dma boundary and allows me to make off-site backups again.

Due to the bus_dma pool being shared across all HCs, it was necessary to
pull the allocator apart and allow for restrictions on a host controller
basis.

Since I was already changing all the usb_*mem functions, I've
renamed them so that they are in the same module space as the bus_mem.c
file they reside in. If someone feels strongly about the old function
names, it could be reversed - but it does not decrease the number of
lines changed.

So far tested on amd64, i386 and sparc64 with affected and
unaffected ehci controllers. I could also test ohci, but not uhci due to
me being cheap and not buying/finding Intel hw.

Enough talk, here is the glorious diff

Index: dev//pci/ehci_pci.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/pci/ehci_pci.c,v
retrieving revision 1.23
diff -u -p -r1.23 ehci_pci.c
--- dev//pci/ehci_pci.c 26 Apr 2011 00:37:34 -  1.23
+++ dev//pci/ehci_pci.c 13 Mar 2012 22:34:34 -
@@ -109,6 +109,7 @@ ehci_pci_attach(struct device *parent, s
const char *vendor;
char *devname = sc-sc.sc_bus.bdev.dv_xname;
usbd_status r;
+   bus_size_t boundary = 0; /* No limit */
int s;
 
/* Map I/O registers */
@@ -162,6 +163,19 @@ ehci_pci_attach(struct device *parent, s
EHCI_VT6202_WORKAROUND_REG, value | 0x2000);
}
break;
+   case PCI_VENDOR_NVIDIA:
+   switch (PCI_PRODUCT(pa-pa_id)) {
+   /*
+* According to Nvidia, these chips can't do DMA
+* transfers above 2G (limited to QH, ITD, SITD)
+*/
+   case PCI_PRODUCT_NVIDIA_MCP04_EHCI:
+   case PCI_PRODUCT_NVIDIA_NFORCE3_EHCI:
+   case PCI_PRODUCT_NVIDIA_NFORCE3_250_EHCI:
+   case PCI_PRODUCT_NVIDIA_NFORCE4_EHCI:
+   boundary = 1UL31;
+   break;
+   }
}
 
/* Map and establish the interrupt. */
@@ -209,6 +223,7 @@ ehci_pci_attach(struct device *parent, s
sc-sc.sc_flags |= EHCIF_DROPPED_INTR_WORKAROUND;
 
ehci_pci_takecontroller(sc, 0);
+   usb_mem_init(sc-sc.sc_bus.umem, boundary);
r = ehci_init(sc-sc);
if (r != USBD_NORMAL_COMPLETION) {
printf(%s: init failed, error=%d\n, devname, r);
Index: dev//usb/ehci.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/usb/ehci.c,v
retrieving revision 1.118
diff -u -p -r1.118 ehci.c
--- dev//usb/ehci.c 10 Jul 2011 17:34:53 -  1.118
+++ dev//usb/ehci.c 13 Mar 2012 22:34:35 -
@@ -208,10 +208,11 @@ usbd_status   ehci_device_request(usbd_xfe
 usbd_statusehci_device_setintr(ehci_softc_t *, ehci_soft_qh_t *,
int ival);
 
-void   ehci_add_qh(ehci_soft_qh_t *, ehci_soft_qh_t *);
+void   ehci_add_qh(ehci_softc_t *, ehci_soft_qh_t *, ehci_soft_qh_t *);
 void   ehci_rem_qh(ehci_softc_t *, ehci_soft_qh_t *,
ehci_soft_qh_t *);
-void   ehci_set_qh_qtd(ehci_soft_qh_t *, ehci_soft_qtd_t *);
+void   ehci_set_qh_qtd(ehci_softc_t *, ehci_soft_qh_t *,
+   ehci_soft_qtd_t *);
 void   ehci_sync_hc(ehci_softc_t *);
 
 void   ehci_close_pipe(usbd_pipe_handle, ehci_soft_qh_t *);
@@ -225,7 +226,7 @@ voidehci_dump_link(ehci_link_t, int);
 void   ehci_dump_sqtds(ehci_soft_qtd_t *);
 void   ehci_dump_sqtd(ehci_soft_qtd_t *);
 void   ehci_dump_qtd(ehci_qtd_t *);
-void   ehci_dump_sqh(ehci_soft_qh_t *);
+void   ehci_dump_sqh(ehci_softc_t *, ehci_soft_qh_t *);
 #if notyet
 void   ehci_dump_sitd(struct ehci_soft_itd *itd);
 void   ehci_dump_itd(struct ehci_soft_itd *);
@@ -334,6 +335,7 @@ ehci_init(ehci_softc_t *sc)
u_int i, j;
usbd_status err;
ehci_soft_qh_t *sqh;
+   struct usb_mem *um = sc-sc_bus.umem;
 
 #ifdef EHCI_DEBUG
u_int32_t vers;
@@ -346,6 +348,11 @@ ehci_init(ehci_softc_t *sc)
vers  8, vers  0xff));
 #endif
 
+   if (sc-sc_bus.umem == NULL) {
+   usb_mem_init(sc-sc_bus.umem, 0);
+   um = sc-sc_bus.umem;
+   }
+
sc-sc_offs = EREAD1(sc, EHCI_CAPLENGTH);
 
sparams = EREAD4(sc, EHCI_HCSPARAMS);
@@ -394,7 +401,7 @@ ehci_init(ehci_softc_t *sc)
case 3:
return (USBD_IOERROR);
}
-   err = usb_allocmem(sc-sc_bus, sc-sc_flsize * sizeof(ehci_link_t),
+   err = usb_mem_alloc(um, sc-sc_bus, sc-sc_flsize * 
sizeof(ehci_link_t),
EHCI_FLALIGN_ALIGN, 

BSD strip error handling V2

2012-03-04 Thread Tobias Ulmer
V2

In the 'ofile' branch (process single file): Replaced ERROR with err(),
removing dead code and preventing the infinite read/write error loop.

Also fix printing of the close() errno which nobody cares about and make
lint less angry in a few cases.

I admit these are all rather obscure and unlikely...

Index: strip.c
===
RCS file: /home/vcs/cvs/openbsd/src/usr.bin/strip/strip.c,v
retrieving revision 1.29
diff -u -p -r1.29 strip.c
--- strip.c 1 Jun 2010 21:44:39 -   1.29
+++ strip.c 4 Mar 2012 14:48:37 -
@@ -119,22 +119,18 @@ main(int argc, char *argv[])
off_t off;
int wfd;
 
-   if ((fd = open(fn, O_RDONLY))  0) {
-   ERROR(errno);
-   break;
-   }
-   if ((wfd = open(ofile, O_RDWR|O_CREAT))  0) {
-   ERROR(errno);
-   break;
-   }
+   if ((fd = open(fn, O_RDONLY))  0)
+   err(1, %s, fn);
+
+   if ((wfd = open(ofile, O_RDWR|O_CREAT))  0)
+   err(1, %s, ofile);
+
do {
rn = read(fd, buf, sizeof buf);
if (rn == (ssize_t)-1) {
-   int save_errno = errno;
-
-   unlink(ofile);
-   ERROR(save_errno);
-   exit(errors);
+   warn(%s, fn);
+   (void)unlink(ofile);
+   exit(1);
}
if (rn == 0)
break;
@@ -143,37 +139,37 @@ main(int argc, char *argv[])
while (rn - off  0) {
wn = write(wfd, buf + off, rn - off);
if (wn == (ssize_t)-1) {
-   int save_errno = errno;
-
-   unlink(ofile);
-   ERROR(save_errno);
-   exit(errors);
+   warn(%s, ofile);
+   (void)unlink(ofile);
+   exit(1);
}
off += wn;
}
} while (rn  0);
 
fn = ofile;
-   close(fd);
+   (void)close(fd);
fd = wfd;
} else if ((fd = open(fn, O_RDWR))  0) {
ERROR(errno);
}
if (fstat(fd, sb)) {
+   int serrno = errno;
(void)close(fd);
-   ERROR(errno);
+   ERROR(serrno);
}
if (sb.st_size  sizeof(EXEC)) {
(void)close(fd);
ERROR(EFTYPE);
}
-   if ((ep = (EXEC *)mmap(NULL, sb.st_size, PROT_READ|PROT_WRITE,
+   if ((ep = mmap(NULL, sb.st_size, PROT_READ|PROT_WRITE,
MAP_SHARED, fd, (off_t)0)) == MAP_FAILED) {
+   int serrno = errno;
(void)close(fd);
-   ERROR(errno);
+   ERROR(serrno);
}
if (BAD_OBJECT(*ep)) {
-   munmap((caddr_t)ep, sb.st_size);
+   (void)munmap((caddr_t)ep, sb.st_size);
(void)close(fd);
ERROR(EFTYPE);
}
@@ -186,7 +182,7 @@ main(int argc, char *argv[])
newsize = 0;
errors |= sfcn(fn, fd, ep, sb, newsize);
fix_header_order(ep);
-   munmap((caddr_t)ep, sb.st_size);
+   (void)munmap((caddr_t)ep, sb.st_size);
if (newsize   ftruncate(fd, newsize)) {
warn(%s, fn);
errors = 1;



BSD strip(1) error handling

2012-03-01 Thread Tobias Ulmer
strip's error handling appears to be questionable. The ERROR() define
has a continue statement at the end, yet in use there are statements
behind it. gcc2 does not warn about this.

strip also tries to loop over multiple files despite previous errors and
returns an error code in the end. There are gotos sprinkled throughout
to support this. I don't think that is helpful at all and have changed
it to immediately terminate.

This patch survived a hp300 make build

Index: strip.c
===
RCS file: /home/vcs/cvs/openbsd/src/usr.bin/strip/strip.c,v
retrieving revision 1.29
diff -u -p -r1.29 strip.c
--- strip.c 1 Jun 2010 21:44:39 -   1.29
+++ strip.c 2 Mar 2012 01:52:26 -
@@ -78,7 +78,7 @@ main(int argc, char *argv[])
EXEC *ep;
struct stat sb;
int (*sfcn)(const char *, int, EXEC *, struct stat *, off_t *);
-   int ch, errors;
+   int ch;
char *fn, *ofile = NULL;
off_t newsize;
 
@@ -109,32 +109,24 @@ main(int argc, char *argv[])
 
if (ofile != NULL  argc  1)
usage();
-   errors = 0;
-#defineERROR(x) errors |= 1; warnx(%s: %s, fn, strerror(x)); 
continue;
while ((fn = *argv++)) {
if (ofile) {
char buf[8192];
-   ssize_t wn;
-   size_t rn;
+   ssize_t wn, rn;
off_t off;
int wfd;
 
-   if ((fd = open(fn, O_RDONLY))  0) {
-   ERROR(errno);
-   break;
-   }
-   if ((wfd = open(ofile, O_RDWR|O_CREAT))  0) {
-   ERROR(errno);
-   break;
-   }
+   if ((fd = open(fn, O_RDONLY))  0)
+   err(1, open: %s, fn);
+
+   if ((wfd = open(ofile, O_RDWR|O_CREAT))  0)
+   err(1, open: %s, ofile);
do {
rn = read(fd, buf, sizeof buf);
-   if (rn == (ssize_t)-1) {
-   int save_errno = errno;
-
-   unlink(ofile);
-   ERROR(save_errno);
-   exit(errors);
+   if (rn == -1) {
+   warn(read: %s, fn);
+   (void) unlink(ofile);
+   exit(1);
}
if (rn == 0)
break;
@@ -142,41 +134,35 @@ main(int argc, char *argv[])
off = 0;
while (rn - off  0) {
wn = write(wfd, buf + off, rn - off);
-   if (wn == (ssize_t)-1) {
-   int save_errno = errno;
-
-   unlink(ofile);
-   ERROR(save_errno);
-   exit(errors);
+   if (wn == -1) {
+   warn(write: %s, ofile);
+   (void) unlink(ofile);
+   exit(1);
}
off += wn;
}
} while (rn  0);
 
fn = ofile;
-   close(fd);
+   (void) close(fd);
fd = wfd;
} else if ((fd = open(fn, O_RDWR))  0) {
-   ERROR(errno);
-   }
-   if (fstat(fd, sb)) {
-   (void)close(fd);
-   ERROR(errno);
-   }
-   if (sb.st_size  sizeof(EXEC)) {
-   (void)close(fd);
-   ERROR(EFTYPE);
-   }
-   if ((ep = (EXEC *)mmap(NULL, sb.st_size, PROT_READ|PROT_WRITE,
-   MAP_SHARED, fd, (off_t)0)) == MAP_FAILED) {
-   (void)close(fd);
-   ERROR(errno);
+   err(1, open: %s, fn);
}
-   if (BAD_OBJECT(*ep)) {
-   munmap((caddr_t)ep, sb.st_size);
-   (void)close(fd);
-   ERROR(EFTYPE);
+
+   if (fstat(fd, sb))
+   err(1, fstat: %s, fn);
+
+   if (sb.st_size  sizeof(EXEC))
+   errx(1, %s: %s, fn, 

Re: transferred/transferring typos

2012-02-23 Thread Tobias Ulmer
Anyone brave enough to commit this diff or should I put it into the
round file? :)



Re: man segfault diff

2012-01-31 Thread Tobias Ulmer
Fix my own 'emtpy' typo, spotted by Theo.

Index: config.h
===
RCS file: /home/vcs/cvs/openbsd/src/usr.bin/man/config.h,v
retrieving revision 1.5
diff -u -p -r1.5 config.h
--- config.h15 Sep 2004 22:20:03 -  1.5
+++ config.h31 Jan 2012 19:38:00 -
@@ -38,13 +38,11 @@ typedef struct _tag {
 
TAILQ_HEAD(tqh, _entry) list;   /* Queue of entries. */
char *s;/* Associated string. */
-   size_t len; /* Length of 's'. */
 } TAG;
 typedef struct _entry {
TAILQ_ENTRY(_entry) q;  /* Queue of entries. */
 
char *s;/* Associated string. */
-   size_t len; /* Length of 's'. */
 } ENTRY;
 
 TAILQ_HEAD(_head, _tag);
Index: man.c
===
RCS file: /home/vcs/cvs/openbsd/src/usr.bin/man/man.c,v
retrieving revision 1.44
diff -u -p -r1.44 man.c
--- man.c   5 Jan 2012 21:46:15 -   1.44
+++ man.c   31 Jan 2012 19:38:00 -
@@ -95,7 +95,6 @@ main(int argc, char *argv[])
extern char *optarg;
extern int optind;
TAG *searchlist;
-   ENTRY *ep;
glob_t pg;
size_t len;
int ch, f_cat, f_how, found;
@@ -339,6 +338,10 @@ parse_path(TAG *t, char *path)
char *p, *slashp;
 
while ((p = strsep(path, :)) != NULL) {
+   /* Skip empty fields */
+   if (*p == '\0')
+   continue;
+
if ((ep = malloc(sizeof(ENTRY))) == NULL)
err(1, NULL);
 
@@ -434,7 +437,7 @@ manual(char *page, TAG *tag, glob_t *pg)
 {
ENTRY *ep, *e_sufp, *e_tag;
TAG *missp, *sufp;
-   int anyfound, cnt, found, globres;
+   int anyfound, cnt, found;
char *p, buf[MAXPATHLEN];
 
anyfound = 0;



man segfault diff

2012-01-30 Thread Tobias Ulmer
- Remove confusing unused len fields from TAG and ENTRY
- Remove a couple of internal unused variables
- Prevent parse_path() from inserting empty ENTRYs into the list,
  leading to a crash due to negative array access later on.

From what I can tell, changing config.h affects man, whatis and apropos
only. In my testing none of them used the len fields.

The crash can be reproduced with this extreme example:
man -m ::: test

It's occasionally triggered by git $command --help.

Index: config.h
===
RCS file: /home/vcs/cvs/openbsd/src/usr.bin/man/config.h,v
retrieving revision 1.5
diff -u -p -r1.5 config.h
--- config.h15 Sep 2004 22:20:03 -  1.5
+++ config.h31 Jan 2012 03:14:47 -
@@ -38,13 +38,11 @@ typedef struct _tag {
 
TAILQ_HEAD(tqh, _entry) list;   /* Queue of entries. */
char *s;/* Associated string. */
-   size_t len; /* Length of 's'. */
 } TAG;
 typedef struct _entry {
TAILQ_ENTRY(_entry) q;  /* Queue of entries. */
 
char *s;/* Associated string. */
-   size_t len; /* Length of 's'. */
 } ENTRY;
 
 TAILQ_HEAD(_head, _tag);
Index: man.c
===
RCS file: /home/vcs/cvs/openbsd/src/usr.bin/man/man.c,v
retrieving revision 1.44
diff -u -p -r1.44 man.c
--- man.c   5 Jan 2012 21:46:15 -   1.44
+++ man.c   31 Jan 2012 03:14:47 -
@@ -95,7 +95,6 @@ main(int argc, char *argv[])
extern char *optarg;
extern int optind;
TAG *searchlist;
-   ENTRY *ep;
glob_t pg;
size_t len;
int ch, f_cat, f_how, found;
@@ -339,6 +338,10 @@ parse_path(TAG *t, char *path)
char *p, *slashp;
 
while ((p = strsep(path, :)) != NULL) {
+   /* Skip emtpy fields */
+   if (*p == '\0')
+   continue;
+
if ((ep = malloc(sizeof(ENTRY))) == NULL)
err(1, NULL);
 
@@ -434,7 +437,7 @@ manual(char *page, TAG *tag, glob_t *pg)
 {
ENTRY *ep, *e_sufp, *e_tag;
TAG *missp, *sufp;
-   int anyfound, cnt, found, globres;
+   int anyfound, cnt, found;
char *p, buf[MAXPATHLEN];
 
anyfound = 0;



Re: small change to the scandir(3) manual page

2012-01-20 Thread Tobias Ulmer
On Thu, Jan 19, 2012 at 10:17:02AM -0800, Philip Guenther wrote:
 On Thu, Jan 19, 2012 at 4:18 AM, Edd Barrett vex...@gmail.com wrote:
  I recently got caught out by scandir's quirky memory allocation. Should
  we add a note so that others don't have to go through this pain too?
 
 Could you elaborate on how this affected your code?  I'm trying to
 think of some way for code to depend on this that isn't undefined
 behavior by the POSIX standard and (sorry) just a bad idea in
 practice...

Well, if I want to make a copy of a directory entry, I can either
memcpy() it or copy attribute by attribute, using strlcpy on the d_name.

Memcpy() will segfault sporadically since I'm not told that dirent isn't
fully allocated.

The problem as I see it is that the man page states builds an array of
pointers to directory entries using malloc(3).

But the implementation behaves according to IEEE Std 1003.1-2008: Entries
for which the function referenced by sel returns non-zero shall be
stored in strings allocated as if by a call to malloc()

I find strings a bit obscure, but at least it makes it somewhat
clearer that one can not just memcpy() based on sizeof(dirent). While
helping Edd debug his program, strings gave me enough of a hint to
suspect how the implementation works.

I would prefer something like:
- builds an array of pointers to nul terminated directory entries using
  malloc(3)

- builds an array of pointers to variable-size directory entries using
  malloc(3)

- builds an array of pointers to partially allocated directory entries
  using malloc(3)

however I'm not really happy with these...



Improve Lucida font family look

2012-01-08 Thread Tobias Ulmer
Ever wondered why xkcd.com looks so bad on OpenBSD?

This diff adds Dejavu replacements for the generic Lucida family as
well as replacements for all Lucida-type fonts shipped with OSX and
Windows.

Test: http://www.tmux.org/~tobiasu/tmp/fonttest.html

Index: 31-nonmst.conf
===
RCS file: /home/vcs/cvs/openbsd/xenocara/lib/fontconfig/conf.d/31-nonmst.conf,v
retrieving revision 1.3
diff -u -p -r1.3 31-nonmst.conf
--- 31-nonmst.conf  21 Jan 2010 19:57:57 -  1.3
+++ 31-nonmst.conf  8 Jan 2012 20:05:03 -
@@ -61,4 +61,49 @@
/edit
/match
 
+   match target=pattern
+   test qual=any name=family
+   stringLucida/string
+   /test
+   edit name=family mode=assign
+   stringDejaVu Sans/string
+   /edit
+  /match
+
+   match target=pattern
+   test qual=any name=family
+   stringLucida Grande/string
+   /test
+   edit name=family mode=assign
+   stringDejaVu Sans/string
+   /edit
+  /match
+
+   match target=pattern
+   test qual=any name=family
+   stringLucida Sans Unicode/string
+   /test
+   edit name=family mode=assign
+   stringDejaVu Sans/string
+   /edit
+  /match
+
+   match target=pattern
+   test qual=any name=family
+   stringLucida Sans Typewriter/string
+   /test
+   edit name=family mode=assign
+   stringDejaVu Sans Mono/string
+   /edit
+  /match
+
+   match target=pattern
+   test qual=any name=family
+   stringLucida Console/string
+   /test
+   edit name=family mode=assign
+   stringDejaVu Sans Mono/string
+   /edit
+  /match
+
 /fontconfig



transferred/transferring typos

2012-01-07 Thread Tobias Ulmer
After typing 'transferring' wrong one time too many...

I didn't touch gcc, binutils, bind, lynx, kerberos, openssl or perl on
purpose.

Index: lib/libsndio/sio_sun.c
===
RCS file: /home/vcs/cvs/openbsd/src/lib/libsndio/sio_sun.c,v
retrieving revision 1.4
diff -u -p -r1.4 sio_sun.c
--- lib/libsndio/sio_sun.c  15 Nov 2011 08:05:22 -  1.4
+++ lib/libsndio/sio_sun.c  7 Jan 2012 14:11:33 -
@@ -48,7 +48,7 @@ struct sio_sun_hdl {
int fd;
int filling;
unsigned ibpf, obpf;/* bytes per frame */
-   unsigned ibytes, obytes;/* bytes the hw transfered */
+   unsigned ibytes, obytes;/* bytes the hw transferred */
unsigned ierr, oerr;/* frames the hw dropped */
int offset; /* frames play is ahead of record */
int idelta, odelta; /* position reported to client */
Index: sys/arch/macppc/dev/tpms.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/macppc/dev/tpms.c,v
retrieving revision 1.15
diff -u -p -r1.15 tpms.c
--- sys/arch/macppc/dev/tpms.c  9 Apr 2010 17:01:30 -   1.15
+++ sys/arch/macppc/dev/tpms.c  7 Jan 2012 14:11:45 -
@@ -128,7 +128,7 @@
  * Magic numbers.
  */
 
-/* The amount of data transfered by the USB device. */
+/* The amount of data transferred by the USB device. */
 #define TPMS_DATA_LEN 81
 
 /* The maximum number of sensors. */
Index: sys/arch/vax/dec/sii.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/vax/dec/sii.c,v
retrieving revision 1.13
diff -u -p -r1.13 sii.c
--- sys/arch/vax/dec/sii.c  17 Jul 2011 22:46:47 -  1.13
+++ sys/arch/vax/dec/sii.c  7 Jan 2012 14:11:51 -
@@ -645,7 +645,7 @@ again:
printf(%s: Parity error\n, sc-sc_dev.dv_xname);
goto abort;
}
-   /* dmalen = amount left to transfer, i = amount transfered */
+   /* dmalen = amount left to transfer, i = amount transferred */
i = state-dmalen;
state-dmalen = 0;
state-dmaCurPhase = -1;
@@ -899,7 +899,7 @@ again:
 #endif
}
 
-   /* read amount transfered if DMA didn't finish */
+   /* read amount transferred if DMA didn't finish */
if (state-dmalen  0) {
i = state-dmalen - regs-dmlotc;
state-dmalen = 0;
Index: sys/dev/ata/wdvar.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/ata/wdvar.h,v
retrieving revision 1.18
diff -u -p -r1.18 wdvar.h
--- sys/dev/ata/wdvar.h 22 Sep 2011 22:12:45 -  1.18
+++ sys/dev/ata/wdvar.h 7 Jan 2012 14:11:57 -
@@ -44,8 +44,8 @@ struct ata_bio {
 struct disklabel *lp; /* pointer to drive's label info */
 daddr64_t blkno; /* block addr */
 daddr64_t blkdone; /* number of blks transferred */
-daddr64_t nblks; /* number of block currently transfering */
-int nbytes; /* number of bytes currently transfering */
+daddr64_t nblks; /* number of block currently transferring */
+int nbytes; /* number of bytes currently transferring */
 longbcount; /* total number of bytes */
 char   *databuf; /* data buffer address */
 volatile int error;
Index: sys/dev/ic/aic79xx.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/ic/aic79xx.c,v
retrieving revision 1.48
diff -u -p -r1.48 aic79xx.c
--- sys/dev/ic/aic79xx.c19 Apr 2011 21:59:51 -  1.48
+++ sys/dev/ic/aic79xx.c7 Jan 2012 14:11:57 -
@@ -1225,7 +1225,7 @@ ahd_handle_seqint(struct ahd_softc *ahd,
 * that requires host assistance for completion.
 * While handling the message phase(s), we will be
 * notified by the sequencer after each byte is
-* transfered so we can track bus phase changes.
+* transferred so we can track bus phase changes.
 *
 * If this is the first time we've seen a HOST_MSG_LOOP
 * interrupt, initialize the state of the host message
Index: sys/dev/ic/aic79xx.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/ic/aic79xx.h,v
retrieving revision 1.21
diff -u -p -r1.21 aic79xx.h
--- sys/dev/ic/aic79xx.h21 Dec 2006 02:28:47 -  1.21
+++ sys/dev/ic/aic79xx.h7 Jan 2012 14:11:57 -
@@ -519,7 +519,7 @@ struct hardware_scb {
  * o A residual has occurred if SG_FULL_RESID is set in sgptr,
  *   or residual_sgptr does not have SG_LIST_NULL set.
  *
- * o We are transfering the last 

usb typo 1

2011-12-11 Thread Tobias Ulmer
Fix typo in diagnostic messages

Index: sys/dev/usb/usbdi.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/usb/usbdi.c,v
retrieving revision 1.43
diff -u -p -r1.43 usbdi.c
--- sys/dev/usb/usbdi.c 16 Jan 2011 22:35:29 -  1.43
+++ sys/dev/usb/usbdi.c 12 Dec 2011 01:59:26 -
@@ -802,7 +802,7 @@ usb_transfer_complete(usbd_xfer_handle x
 
 #ifdef DIAGNOSTIC
if (pipe == NULL) {
-   printf(usbd_transfer_complete: pipe==0, xfer=%p\n, xfer);
+   printf(usb_transfer_complete: pipe==0, xfer=%p\n, xfer);
return;
}
 #endif
@@ -852,7 +852,7 @@ usb_transfer_complete(usbd_xfer_handle x
xfer-done = 1;
if (!xfer-status  xfer-actlen  xfer-length 
!(xfer-flags  USBD_SHORT_XFER_OK)) {
-   DPRINTFN(-1,(usbd_transfer_complete: short transfer %d%d\n,
+   DPRINTFN(-1,(usb_transfer_complete: short transfer %d%d\n,
xfer-actlen, xfer-length));
xfer-status = USBD_SHORT_XFER;
}



usb typo 2

2011-12-11 Thread Tobias Ulmer
Fix typo, requires rain, of course

Index: sys/dev/pci/pcidevs
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1626
diff -u -p -r1.1626 pcidevs
--- sys/dev/pci/pcidevs 12 Nov 2011 11:47:17 -  1.1626
+++ sys/dev/pci/pcidevs 12 Dec 2011 02:00:23 -
@@ -4066,7 +4066,7 @@ product NVIDIA MCP04_LAN1 0x0037  MCP04 L
 product NVIDIA MCP04_LAN2  0x0038  MCP04 LAN
 product NVIDIA MCP04_AC97  0x003a  MCP04 AC97
 product NVIDIA MCP04_OHCI  0x003b  MCP04 USB
-product NVIDIA MCP04_ECHI  0x003c  MCP04 USB
+product NVIDIA MCP04_EHCI  0x003c  MCP04 USB
 product NVIDIA MCP04_PPB   0x003d  MCP04 PCI-PCI
 product NVIDIA MCP04_SATA2 0x003e  MCP04 SATA
 product NVIDIA NFORCE4_ISA10x0050  nForce4 ISA



remove useless usbd cookie

2011-12-11 Thread Tobias Ulmer
Remove the unused usb device/event cookie, saves a couple of bytes.

We might want to keep this just because NetBSD has it, but it serves no
visible purpose. I think I've checked their code some time ago and they
don't do anything useful with it either (IIRC).

Index: sys/dev/usb/usb.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/usb/usb.h,v
retrieving revision 1.38
diff -u -p -r1.38 usb.h
--- sys/dev/usb/usb.h   9 Nov 2011 21:45:50 -   1.38
+++ sys/dev/usb/usb.h   12 Dec 2011 02:01:26 -
@@ -588,14 +588,11 @@ struct usb_ctl_report_desc {
u_char  ucrd_data[1024];/* filled data size will vary */
 };
 
-typedef struct { u_int32_t cookie; } usb_event_cookie_t;
-
 #define USB_MAX_DEVNAMES 4
 #define USB_MAX_DEVNAMELEN 16
 struct usb_device_info {
u_int8_tudi_bus;
u_int8_tudi_addr;   /* device address */
-   usb_event_cookie_t udi_cookie;
charudi_product[USB_MAX_STRING_LEN];
charudi_vendor[USB_MAX_STRING_LEN];
charudi_release[8];
@@ -625,7 +622,6 @@ struct usb_device_info {
 struct usb_device_info_48 {
u_int8_tudi_bus;
u_int8_tudi_addr;   /* device address */
-   usb_event_cookie_t udi_cookie;
charudi_product[USB_MAX_STRING_LEN];
charudi_vendor[USB_MAX_STRING_LEN];
charudi_release[8];
@@ -670,7 +666,6 @@ struct usb_event {
} ue_ctrlr;
struct usb_device_info  ue_device;
struct {
-   usb_event_cookie_t  ue_cookie;
charue_devname[16];
} ue_driver;
} u;
Index: sys/dev/usb/usb_subr.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.80
diff -u -p -r1.80 usb_subr.c
--- sys/dev/usb/usb_subr.c  25 Jan 2011 20:03:36 -  1.80
+++ sys/dev/usb/usb_subr.c  12 Dec 2011 02:01:26 -
@@ -73,8 +73,6 @@ void  usbd_kill_pipe(usbd_pipe_handle);
 usbd_statususbd_probe_and_attach(struct device *,
usbd_device_handle, int, int);
 
-u_int32_t  usb_cookie_no = 0;
-
 #ifdef USBVERBOSE
 #include dev/usb/usbdevs_data.h
 #endif /* USBVERBOSE */
@@ -1098,7 +1096,6 @@ usbd_new_device(struct device *parent, u
}
dev-speed = speed;
dev-langid = USBD_NOLANG;
-   dev-cookie.cookie = ++usb_cookie_no;
 
/* Establish the default pipe. */
err = usbd_setup_pipe(dev, 0, dev-def_ep, USBD_DEFAULT_INTERVAL,
@@ -1361,7 +1358,6 @@ usbd_fill_deviceinfo(usbd_device_handle 
 
di-udi_bus = dev-bus-bdev.dv_unit;
di-udi_addr = dev-address;
-   di-udi_cookie = dev-cookie;
usbd_devinfo_vp(dev, di-udi_vendor, sizeof(di-udi_vendor),
di-udi_product, sizeof(di-udi_product), usedev);
usbd_printBCD(di-udi_release, sizeof di-udi_release,
Index: sys/dev/usb/usbdivar.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/dev/usb/usbdivar.h,v
retrieving revision 1.42
diff -u -p -r1.42 usbdivar.h
--- sys/dev/usb/usbdivar.h  16 Jan 2011 22:35:29 -  1.42
+++ sys/dev/usb/usbdivar.h  12 Dec 2011 02:01:26 -
@@ -135,7 +135,6 @@ struct usbd_device {
u_int16_t   power; /* mA the device uses */
int16_t langid;/* language for strings */
 #define USBD_NOLANG (-1)
-   usb_event_cookie_t  cookie;/* unique connection id */
struct usbd_port   *powersrc;  /* upstream hub port, or 0 */
struct usbd_device *myhub; /* upstream hub */
struct usbd_port   *myhsport;  /* closest high speed port */



Re: malloc chunk_info diff

2011-09-13 Thread Tobias Ulmer
No visible issues on sparc64 running src, x and ports bulk builds



Re: ksh: bad number (with leading zeroes) should not work for 0 - 7

2011-09-12 Thread Tobias Ulmer
On Mon, Sep 12, 2011 at 04:45:28PM -0500, Abel Abraham Camarillo Ojeda wrote:
 Some of our shell scripts that work with dates and do something like:
 
 month=`date +%m`
 something  month=$((month-1))
 
 Suddenly started crashing on august... there seems to be a bug identifying
 not-numbers (numbers with leading zeroes) before '08' (eigth), how to 
 reproduce:
 
 $ for i in 0{0,1,2,3,4,5,6,7,8,9}; do a=$i; a=$((a-1)); echo $a; done
 -1
 0
 1
 2
 3
 4
 5
 6
 ksh: 08: bad number `08'


The string 08 can not be converted into a number for doing
calculations. The 0 prefix signifies an octal number and 08 is not valid in
the octal system. Bash will also tell you that this can not be done.

Fix your script, add the leading zero after you're done with the
calculation.

 $
 
 
 Thanks.



groupadd error message

2011-09-10 Thread Tobias Ulmer
creategid() already prints a precise warning in each error case, there
is no good reason for printing another generic/wrong error message when
it returns.

Index: user.c
===
RCS file: /home/vcs/cvs/openbsd/src/usr.sbin/user/user.c,v
retrieving revision 1.81
diff -u -p -r1.81 user.c
--- user.c  16 Apr 2011 07:41:08 -  1.81
+++ user.c  10 Sep 2011 13:52:14 -
@@ -2059,8 +2059,7 @@ groupadd(int argc, char **argv)
}
openlog(groupadd, LOG_PID, LOG_USER);
if (!creategid(*argv, gid, )) {
-   errx(EXIT_FAILURE, can't add group: problems with %s file,
-   _PATH_GROUP);
+   exit(EXIT_FAILURE);
}
return EXIT_SUCCESS;
 }



duid validation in disk_map()

2011-08-01 Thread Tobias Ulmer
Curiously, if DM_OPENPART is specified, disk_map() accepts the format
duid as well as duid.anypart. This may be a feature but I suspect
it's actually a small oversight in the validation part.

I'm proposing this stricter (and maybe more readable) version:

Index: kern/subr_disk.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/kern/subr_disk.c,v
retrieving revision 1.131
diff -u -p -r1.131 subr_disk.c
--- kern/subr_disk.c26 Jul 2011 12:32:14 -  1.131
+++ kern/subr_disk.c2 Aug 2011 01:09:50 -
@@ -1467,8 +1467,10 @@ disk_map(char *path, char *mappath, int 
return -1;
 
/* Verify that the device name is properly formed. */
-   if (!((strlen(path) == 16  (flags  DM_OPENPART)) ||
-   (strlen(path) == 18  path[16] == '.')))
+   if ((strlen(path) == 16  (flags  DM_OPENPART)) ||
+   (strlen(path) == 18  path[16] == '.'  !(flags  DM_OPENPART)))
+   ;
+   else
return -1;
 
/* Get partition. */



Re: wol for xl(4)

2011-06-25 Thread Tobias Ulmer
On Fri, Jun 24, 2011 at 06:06:58PM +0200, Thomas Gerlach wrote:
[..]
 this successfully enables wol during startup, without any error messages
 (assuming the patches from stefan are applied, of course).
 
 cheers,
 
 thomas


I've lost track which patches need to be applied or not, but once a
complete patch appears, I'm willing to test it on a machine that has
three different xl's.



typo in imsg_init.3

2011-06-23 Thread Tobias Ulmer
Index: imsg_init.3
===
RCS file: /srv/radon/data/vcs/cvs/openbsd/src/lib/libutil/imsg_init.3,v
retrieving revision 1.4
diff -u -p -r1.4 imsg_init.3
--- imsg_init.3 5 Mar 2011 15:05:39 -   1.4
+++ imsg_init.3 23 Jun 2011 21:51:57 -
@@ -161,7 +161,7 @@ imsgbuf.
 creates a new message with header specified by
 .Fa type ,
 .Fa peerid
-ands
+and
 .Fa pid .
 A
 .Fa pid



Re: wol for xl(4)

2011-04-18 Thread Tobias Ulmer
On Mon, Apr 18, 2011 at 10:17:33AM +0200, Stefan Sperling wrote:
 On Mon, Apr 18, 2011 at 04:18:01AM +0200, Tobias Ulmer wrote:
  On Sun, Apr 17, 2011 at 11:05:38AM +0200, Stefan Sperling wrote:
   On Thu, Mar 31, 2011 at 06:54:44PM +0200, Stefan Sperling wrote:
This is an attempt to add wol support to xl(4).
   
Unfortunately, while I have an xl(4) card to test with none of the
motherboards I have will do WOL with it since they all lack an
on-board WOL connector :(
   
So test reports are needed.
Please also check whether WOL is disabled by default.
  
   I haven't received any test reports yet.
  
  The (commited) diff has no effect on my onboard xl(4).
  The hardware supports this (BIOS setting checked):
  http://support.dell.com/support/edocs/systems/dvol/en/vol_mt/SETUP.HTM#Wakeup
  %20On%20LAN
 
 Please elaborate on no effect.
 
 Does WOL work at all? Or does it not work at all?

I've done tests with the integrated NIC and one in a PCI slot connected
to the WOL connector. WOL does not work in any configuration I've tried.

 Can it be enabled from the BIOS but not, independently, from ifconfig?

The BIOS has 3 WOL settings: Off, Integrated NIC, WOL Connector. I've
configured this according to which card was tested. WOL still did not
work.

 Can it be disabled via ifconfig even if enabled in the BIOS?

I've tried enabling WOL using ifconfig for the PCI NIC and set the BIOS
to WOL mainboard connector. WOL did not work.

shutdowns were always done with halt -p

No idea what else I could do...

 
 I have a similar problem with an on-board vr(4) where tweaking the WOL
 configuration registers before reboot shows the registers have changed,
 but the changes do not survive a reboot.
 I guess the BIOS writes to these registers on boot clobbering whatever
 the operating system did before it shut down. This way, WOL works with any
 operating system when configured from the BIOS, but the OS cannot configure 
 it.
 
 So far I've only seen this behaviour with on-board cards, but not with
 cards sitting in PCI slots.



Re: wol for xl(4)

2011-04-17 Thread Tobias Ulmer
On Sun, Apr 17, 2011 at 11:05:38AM +0200, Stefan Sperling wrote:
 On Thu, Mar 31, 2011 at 06:54:44PM +0200, Stefan Sperling wrote:
  This is an attempt to add wol support to xl(4).
 
  Unfortunately, while I have an xl(4) card to test with none of the
  motherboards I have will do WOL with it since they all lack an
  on-board WOL connector :(
 
  So test reports are needed.
  Please also check whether WOL is disabled by default.

 I haven't received any test reports yet.

The (commited) diff has no effect on my onboard xl(4).
The hardware supports this (BIOS setting checked):
http://support.dell.com/support/edocs/systems/dvol/en/vol_mt/SETUP.HTM#Wakeup
%20On%20LAN

OpenBSD 4.9-current (GENERIC.MP) #0: Mon Apr 18 02:39:32 CEST 2011
tobi...@boron.tmux.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel Pentium III (GenuineIntel 686-class, 512KB L2 cache) 499 MHz
cpu0:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PSE36,MMX,FXSR,
SSE
real mem  = 2147049472 (2047MB)
avail mem = 2101751808 (2004MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 01/11/02, BIOS32 rev. 0 @ 0xffe90,
SMBIOS rev. 2.2 @ 0xfb1b0 (83 entries)
bios0: vendor Dell Computer Corporation version A11 date 01/11/02
bios0: Dell Computer Corporation Precision WorkStation 610 MT
acpi0 at bios0: rev 0
acpi0: sleep states S0 S1 S4 S5
acpi0: tables DSDT FACP APIC
acpi0: wakeup devices PCI0(S5) USB0(S5) PCI1(S5)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0: invalid, skipping
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (PCI1)
mpbios0 at bios0: Intel MP Specification 1.4
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 99MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel Pentium III (GenuineIntel 686-class, 512KB L2 cache) 499 MHz
cpu1:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PSE36,MMX,FXSR,
SSE
mpbios0: bus 0 is type PCI
mpbios0: bus 1 is type PCI
mpbios0: bus 2 is type PCI
mpbios0: bus 3 is type ISA
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 11, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 2
bios0: ROM list: 0xc/0xc000 0xcc000/0x9800 0xd5800/0x800 0xd6000/0x2000
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 Intel 82440BX AGP rev 0x00
intelagp0 at pchb0
agp0 at intelagp0: aperture at 0xf000, size 0x400
ppb0 at pci0 dev 1 function 0 Intel 82440BX AGP rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 Trident Blade 3D rev 0x3a
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
piixpcib0 at pci0 dev 7 function 0 Intel 82371AB PIIX4 ISA rev 0x02
pciide0 at pci0 dev 7 function 1 Intel 82371AB IDE rev 0x01: DMA, channel 0
wired to compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 0: SAMSUNG SP1604N
wd0: 16-sector PIO, LBA48, 152626MB, 312579695 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
wd1 at pciide0 channel 1 drive 0: WDC WD1200BB-00DWA0
wd1: 16-sector PIO, LBA48, 114473MB, 234441648 sectors
wd1(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2
uhci0 at pci0 dev 7 function 2 Intel 82371AB USB rev 0x01: apic 2 int 19
(irq 11)
piixpm0 at pci0 dev 7 function 3 Intel 82371AB Power rev 0x02: SMI
iic0 at piixpm0
admtemp0 at iic0 addr 0x2b: adm1021
iic0: addr 0x2d 06=40 09=50 14=53 1a=02 20=cf 21=bd 22=b9 23=7c 24=7d 25=bb
26=3b 27=1d 28=ff 29=50 2a=ff 2b=db 2c=c2 2d=d0 2e=a7 2f=d0 30=a7 31=83 32=77
33=83 34=77 35=c9 36=ae 37=70 38=12 39=4b 3a=46 3b=9a 3c=fa 3d=40 40=03 41=40
42=08 43=50 44=b8 46=40 47=f1 48=2d 49=c0 4a=fa 4b=c0 4c=c0 4d=c0 50=03 53=50
54=b8 56=40 57=f1 58=2d 59=c0 5a=c0 5b=c0 5c=c0 5d=c0 5e=c0 60=cf 61=bd 62=b9
63=7c 64=7d 65=bb 66=3b 67=1d 68=ff 69=50 6a=ff 6b=db 6c=c2 6d=d0 6e=a7 6f=d0
70=a7 71=83 72=77 73=83 74=77 75=c9 76=ae 77=70 78=12 79=4b 7a=46 7b=9a 7c=fa
7d=40 86=40 89=50 94=53 9a=02 a0=cf a1=bd a2=b9 a3=7c a4=7d a5=bb a6=3b a7=1d
a8=ff a9=50 aa=ff ab=db ac=c2 ad=d0 ae=a7 af=d0 b0=a7 b1=83 b2=77 b3=83 b4=77
b5=c9 b6=ae b7=70 b8=12 b9=4b ba=46 bb=9a bc=fa bd=40 c0=03 c3=50 c4=b8 c6=40
c7=f1 c8=2d c9=c0 ca=c0 cb=c0 cc=c0 cd=c0 ce=c0 d0=03 d3=50 d4=b8 d6=40 d7=f1
d8=2d d9=c0 da=c0 db=c0 dc=c0 dd=c0 de=c0 e0=cf e1=bd e2=b9 e3=7c e4=7d e5=bb
e6=3b e7=1d e8=ff e9=50 ea=ff eb=db ec=c2 ed=d0 ee=a7 ef=d0 f0=a7 f1=83 f2=77
f3=83 f4=77 f5=c9 f6=ae f7=70 f8=12 f9=4b fa=46 fb=9a fc=fa fd=40 words
00=0080 01=0080 02=0080 03=0080 04=0080 05=0080 06=4080 07=0080
admtemp1 at iic0 addr 0x4e: adm1021
spdmem0 at iic0 addr 0x50: 512MB SDRAM non-parity PC133CL3
spdmem1 at iic0 addr 0x51: 512MB SDRAM non-parity PC133CL3
spdmem2 at iic0 addr 0x52: 512MB SDRAM non-parity PC133CL3
spdmem3 at iic0 addr 0x53: 512MB SDRAM non-parity PC133CL3
xl0 at pci0 dev 13 function 0 3Com 3c905C 100Base-TX rev 0x78: apic 2 int 16
(irq 10), address 00:04:75:b1:00:7d
exphy0 at xl0 phy 24: 3Com internal media interface
rl0 at pci0 dev 14 function 0 Realtek 8139 rev 0x10: apic 2 

bioctl: delete disk by duid

2010-12-29 Thread Tobias Ulmer
Given a duid, I want to be able to delete a disk.

There seems to be no elegant way to get just the disk (sd0) from a
duid. I didn't like my code using opendev, so I've tried sysctl. Looks
better imho. Still, is there a better way?

Index: bioctl.c
===
RCS file: /srv/boron/data/vcs/cvs/openbsd/src/sbin/bioctl/bioctl.c,v
retrieving revision 1.98
diff -u -p -r1.98 bioctl.c
--- bioctl.c1 Dec 2010 19:40:18 -   1.98
+++ bioctl.c29 Dec 2010 14:46:30 -
@@ -32,6 +32,7 @@
 #include sys/param.h
 #include sys/types.h
 #include sys/stat.h
+#include sys/sysctl.h
 #include dev/biovar.h
 #include dev/softraidvar.h
 
@@ -941,13 +942,38 @@ void
 bio_deleteraid(char *dev)
 {
struct bioc_deleteraid  bd;
+   char *disknames = NULL;
memset(bd, 0, sizeof(bd));
 
+   if (isduid(dev, OPENDEV_PART)) {
+   int mib[2];
+   size_t len;
+   char *duid, *name;
+
+   mib[0] = CTL_HW;
+   mib[1] = HW_DISKNAMES;
+   if (sysctl(mib, 2, NULL, len, NULL, 0) == -1)
+   err(1, sysctl);
+   if ((disknames = malloc(len)) == NULL)
+   err(1, malloc);
+   if (sysctl(mib, 2, disknames, len, NULL, 0) == -1)
+   err(1, sysctl);
+
+   duid = disknames;
+   while ((name = strsep(duid, :,)) != NULL)
+   if (duid  strcmp(dev, duid) == 0) {
+   dev = name;
+   break;
+   }
+   }
+
bd.bd_cookie = bd.bd_cookie;
/* XXX make this a dev_t instead of a string */
strlcpy(bd.bd_dev, dev, sizeof bd.bd_dev);
if (ioctl(devh, BIOCDELETERAID, bd))
errx(1, delete volume %s failed, dev);
+
+   free(disknames);
 }
 
 void



sync adduser with installer

2010-10-29 Thread Tobias Ulmer
The installer defaults to creating accounts with group users, adduser
creates a group for each user. Sync the two.
Takes effect only if /etc/addusers.conf is regenerated, ie. new
installations.

Index: adduser.perl
===
RCS file: /srv/boron/data/vcs/cvs/openbsd/src/usr.sbin/adduser/adduser.perl,v
retrieving revision 1.53
diff -u -p -r1.53 adduser.perl
--- adduser.perl3 Jan 2007 15:26:04 -   1.53
+++ adduser.perl29 Oct 2010 08:38:27 -
@@ -102,7 +102,7 @@ sub variables {
 
 $defaultshell = 'ksh'; # defaultshell if not empty
 $group_uniq = 'USER';
-$defaultgroup = $group_uniq;# login groupname, $group_uniq means username
+$defaultgroup = 'users';   # login groupname, $group_uniq means username
 $defaultclass = 'default';  # default user login class
 
 $uid_start = 1000; # new users get this uid



Re: softraid cleanup

2010-10-24 Thread Tobias Ulmer
On Wed, Oct 20, 2010 at 08:47:00PM -0500, Marco Peereboom wrote:
 On Thu, Sep 30, 2010 at 03:35:33AM +0200, Tobias Ulmer wrote:
  I got this after a while:
  
  panic: softraid0: sr_crypto_finish_io
  
  No serial, so there's no more info. You know where to find me
 
 new diff that should fix all them issues.

No issues.



ARM linker script

2010-10-13 Thread Tobias Ulmer
I'm currently loading the kernel at a fixed start address using u-boot.
There's no relocation going on.
Accessing anything in the data segment leads to crashes due to file- and
address offsets desyncing.

The patch below fixes this issue and, as a bonus, syncs the code with
the comment.
Possibly affected are armish, beagle, gumstix, palm and zaurus

Index: arch/arm/conf/ldscript.tail
===
RCS file: /srv/boron/data/vcs/cvs/openbsd/src/sys/arch/arm/conf/ldscript.tail,v
retrieving revision 1.4
diff -u -p -r1.4 ldscript.tail
--- arch/arm/conf/ldscript.tail 27 Jun 2009 14:44:39 -  1.4
+++ arch/arm/conf/ldscript.tail 13 Oct 2010 23:17:30 -
@@ -5,7 +5,7 @@
   PROVIDE (etext = .);
   /* Adjust the address for the data segment to start on the next page
  boundary.  */
-  . = ALIGN(0x8000);
+  . = ALIGN(0x1000);
   .data:
   AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
   {



Re: ARM linker script

2010-10-13 Thread Tobias Ulmer
On Wed, Oct 13, 2010 at 08:29:35PM -0500, Dale Rahn wrote:
 On Thu, Oct 14, 2010 at 01:50:36AM +0200, Tobias Ulmer wrote:
  I'm currently loading the kernel at a fixed start address using u-boot.
  There's no relocation going on.
  Accessing anything in the data segment leads to crashes due to file- and
  address offsets desyncing.
  
  The patch below fixes this issue and, as a bonus, syncs the code with
  the comment.
  Possibly affected are armish, beagle, gumstix, palm and zaurus
  
  Index: arch/arm/conf/ldscript.tail
  ===
  RCS file: 
  /srv/boron/data/vcs/cvs/openbsd/src/sys/arch/arm/conf/ldscript.tail,v
  retrieving revision 1.4
  diff -u -p -r1.4 ldscript.tail
  --- arch/arm/conf/ldscript.tail 27 Jun 2009 14:44:39 -  1.4
  +++ arch/arm/conf/ldscript.tail 13 Oct 2010 23:17:30 -
  @@ -5,7 +5,7 @@
 PROVIDE (etext = .);
 /* Adjust the address for the data segment to start on the next page
boundary.  */
  -  . = ALIGN(0x8000);
  +  . = ALIGN(0x1000);
 .data:
 AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
 {
  
 
 How are you loading the kernel with u-boot? 
 
 When I was doing this in the past, I was doing the following
 $ ${OBJCOPY} -O binary bsd bsd.img
 $ mkuboot -a arm -o linux -e ${KERNEL_BASE_PHYS} -l ${KERNEL_BASE_PHYS} 
 bsd.img bsd.umg
 
 This method had no problem with the current 'alignment'

I create bsd.umg without the intermediate OBJCOPY step. I remember that
not going well when I first tried it, not sure why.

The load address is KERNEL_BASE_PHYS minus the ELF header. This works
just fine, except for that small data segment detail.

bsd.umg: bsd
${MKUBOOT} -a arm -o OpenBSD -e ${KERNEL_BASE_PHYS} -l `printf
0x%x $$((${KERNEL_BASE_PHYS}-${KERNEL_BASE_EOFF}))` bsd bsd.umg

 
 I thought I recalled that the ldscript aligned the pages on 64k boundaries,
 but that does not appear to be the case. Not certian why 32k would be 
 desireable.
 Will look into this more.
 
 Dale Rahn dr...@dalerahn.com


Here's some objdump -h output, first one without the patch:

Idx Name  Size  VMA   LMA   File off  Algn
  0 .start00a8  00801000  00801000  1000  2**0
  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .text 001f1c77  c08010a8  008010a8  10a8  2**5
  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .data 8f70  c09f8000  009f8000  001f3000  2**2
  CONTENTS, ALLOC, LOAD, DATA

Idx Name  Size  VMA   LMA   File off  Algn
  0 .start00a8  00801000  00801000  1000  2**0
  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .text 001f20eb  c08010a8  008010a8  10a8  2**5
  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .data 8f70  c09f4000  009f4000  001f4000  2**2
  CONTENTS, ALLOC, LOAD, DATA

(sdram starts at 0x0, u-boot occupies 0-8M - I like to keep its illegal
instruction handler etc for the time being)



Re: softraid cleanup

2010-09-29 Thread Tobias Ulmer
I got this after a while:

panic: softraid0: sr_crypto_finish_io

No serial, so there's no more info. You know where to find me



Re: MCLGETI support for xl(4)

2010-09-18 Thread Tobias Ulmer
Works for me on

xl0 at pci0 dev 13 function 0 3Com 3c905C 100Base-TX rev 0x78: apic 2
int 16 (irq 10), address 00:04:75:b1:00:7d
xl1 at pci0 dev 17 function 0 3Com 3c905B 100Base-TX rev 0x24: apic 2
int 17 (irq 5), address 00:c0:4f:79:4d:d8



Repair cross compilation on gcc4 archs to gcc3 targets

2010-09-09 Thread Tobias Ulmer
MACHINE_ARCH is still set to the host architecture at this point.
Tested by compiling (and later booting) an ARM kernel on a i386 host.

Index: Makefile.cross
===
RCS file: /srv/boron/data/vcs/cvs/openbsd/src/Makefile.cross,v
retrieving revision 1.33
diff -u -p -r1.33 Makefile.cross
--- Makefile.cross  25 Aug 2010 08:04:01 -  1.33
+++ Makefile.cross  9 Sep 2010 07:39:50 -
@@ -78,9 +78,9 @@ CROSSGCC= ${CROSSDIR}/.gcc_done
 ${TARGET_ARCH} == sparc || ${TARGET_ARCH} == vax
 TARGET_USE_GCC3=No
 COMPILER_VERSION=gcc2
-.elif ${MACHINE_ARCH} == amd64 || ${MACHINE_ARCH} == hppa || \
-${MACHINE_ARCH} == i386 || ${MACHINE_ARCH} == powerpc || \
-${MACHINE_ARCH} == sparc64
+.elif ${TARGET_ARCH} == amd64 || ${TARGET_ARCH} == hppa || \
+${TARGET_ARCH} == i386 || ${TARGET_ARCH} == powerpc || \
+${TARGET_ARCH} == sparc64
 TARGET_USE_GCC4=Yes
 COMPILER_VERSION=gcc4
 .else



which

2010-05-27 Thread Tobias Ulmer
which(1) prints error messages on stdout, breaking shell scripts and
common usage patterns:

ldd `which foo`
ldd: foo:: No such file or directory
ldd: Command: No such file or directory
ldd: not: No such file or directory
ldd: found.: No such file or directory

X=$(which foo 2/dev/null)
test -n $X || echo foo not found

This works contrary to the csh builtin it was modeled after and `which'
from coreutils.

The patch below fixes that. As a bonus, print which:  in front of the
otherwise confusing error message.

While there, let err() do its job and print a standard error message for
strndup (replace with malloc|NULL if you like that better)

Index: which.c
===
RCS file: /vcs/cvs/openbsd/src/usr.bin/which/which.c,v
retrieving revision 1.15
diff -u -p -r1.15 which.c
--- which.c 27 Oct 2009 23:59:50 -  1.15
+++ which.c 27 May 2010 19:49:50 -
@@ -120,13 +120,13 @@ findprog(char *prog, char *path, int pro
(void)puts(prog);
return (1);
} else {
-   (void)printf(%s: Command not found.\n, prog);
+   warnx(%s: Command not found., prog);
return (0);
}
}
 
if ((path = strdup(path)) == NULL)
-   errx(1, Can't allocate memory.);
+   err(1, strdup);
pathcpy = path;
 
proglen = strlen(prog);
@@ -159,7 +159,7 @@ findprog(char *prog, char *path, int pro
 
/* whereis(1) is silent on failure. */
if (!rval  progmode != PROG_WHEREIS)
-   (void)printf(%s: Command not found.\n, prog);
+   warnx(%s: Command not found., prog);
return (rval);
 }



Re: /etc/security

2010-02-21 Thread Tobias Ulmer
On Sun, Feb 21, 2010 at 12:19:47PM +0100, Ingo Schwarze wrote:
 Tobias Ulmer wrote on Sun, Feb 21, 2010 at 02:36:43AM +0100:
 
  I've got a bunch of users with no password/no way to log in, just to
  keep services tidy and separated. Some of these have to connect to ssh
  servers, therefore they require a .ssh/known_hosts. /etc/security thinks
  this is a security risk and complains about it every night...
 
 I think the basic idea makes sense.
 
 The file name still in use for backward compatibility,
   .ssh/authorized_keys2,
 is obviously missing form the patch, though.

Oh fsck, where's that file documented? I was looking at sshd(8) which I
thought should be authoritative about these kind of things. A quick grep
through /usr/share/man has 0 matches.

Your patch looks fine to me.

 
 Reading /usr/src/usr.bin/ssh/pathnames.h, i found no other file
 name missing from the patch, but it would be nice if one of the
 OpenSSH hackers could confirm this.
 
 In case i receive an OK and no objections, i plan to put the
 following in after unlock:
 
 
 Index: security
 ===
 RCS file: /cvs/src/etc/security,v
 retrieving revision 1.88
 diff -u -r1.88 security
 --- security  3 Jun 2009 14:45:39 -   1.88
 +++ security  21 Feb 2010 10:28:14 -
 @@ -40,7 +40,7 @@
   printf(Login %s is off but still has a valid shell and 
 an entry in /etc/skey.\n, $1);
   if (system(test -d $9 -a ! -r $9) == 0)
   printf(Login %s is off but still has valid shell and 
 home directory is unreadable\n\t by root; cannot check for existence of 
 alternate access files.\n, $1);
 - else if (system(for file in .ssh .rhosts .shosts .klogin; do 
 if test -e $9/$file; then if ((ls -ld $9/$file | cut -b 2-10 | grep -q r) 
  (test ! -O $9/$file)) ; then exit 1; fi; fi; done))
 + else if (system(for file in .ssh/authorized_keys 
 .ssh/authorized_keys2 .rhosts .shosts .klogin; do if test -e $9/$file; then 
 if ((ls -ld $9/$file | cut -b 2-10 | grep -q r)  (test ! -O $9/$file)) 
 ; then exit 1; fi; fi; done))
printf(Login %s is off but still has a valid shell 
 and alternate access files in\n\t home directory are still readable.\n,$1);
   }
   if ($3 == 0  $1 != root)



/etc/security

2010-02-20 Thread Tobias Ulmer
I've got a bunch of users with no password/no way to log in, just to
keep services tidy and separated. Some of these have to connect to ssh
servers, therefore they require a .ssh/known_hosts. /etc/security thinks
this is a security risk and complains about it every night...


Index: etc/security
===
RCS file: /home/cvs/openbsd/src/etc/security,v
retrieving revision 1.88
diff -u -p -r1.88 security
--- etc/security3 Jun 2009 14:45:39 -   1.88
+++ etc/security21 Feb 2010 01:23:21 -
@@ -40,7 +40,7 @@ awk -F: '{
printf(Login %s is off but still has a valid shell and 
an entry in /etc/skey.\n, $1);
if (system(test -d $9 -a ! -r $9) == 0)
printf(Login %s is off but still has valid shell and 
home directory is unreadable\n\t by root; cannot check for existence of 
alternate access files.\n, $1);
-   else if (system(for file in .ssh .rhosts .shosts .klogin; do 
if test -e $9/$file; then if ((ls -ld $9/$file | cut -b 2-10 | grep -q r) 
 (test ! -O $9/$file)) ; then exit 1; fi; fi; done))
+   else if (system(for file in .ssh/authorized_keys .rhosts 
.shosts .klogin; do if test -e $9/$file; then if ((ls -ld $9/$file | cut -b 
2-10 | grep -q r)  (test ! -O $9/$file)) ; then exit 1; fi; fi; done))
 printf(Login %s is off but still has a valid shell 
and alternate access files in\n\t home directory are still readable.\n,$1);
}
if ($3 == 0  $1 != root)



Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-13 Thread Tobias Ulmer
On Tue, Jan 12, 2010 at 04:34:41PM -0700, Bob Beck wrote:
 My conern is what is actually behind your possible panic. We (including
myself)
 have been introducing and removing some dlg inspired breakage at the same
time
 here so it depends what you are doing.

 Please continue and let me know what you see.

ddb show panic
initiate_write_inodeblock: already doing I/O
ddb trace
Debugger(616a34d,0,3ec1,df01,d9fb6000) at Debugger+0x4
panic(d076a0a0,4f,dd02dddc,d037be23,616a34d) at panic+0x55
initiate_write_inodeblock_ufs1(dfb4c3fc,df2d02a4,dd02de1c,d037724b,dd02de04)
at
 initiate_write_inodeblock_ufs1+0xdf
softdep_disk_io_initiation(df2d02a4,d10e95c0,dd02de4c,d0379c79) at
softdep_disk
_io_initiation+0xa1
spec_strategy(dd02de64,df2d02a4,dd02de6c,d03a0e93,50) at spec_strategy+0x46
spec_vnoperate(dd02de64,d9fb6000,dd02de8c,80,d085eb24) at spec_vnoperate+0x16
VOP_STRATEGY(df2d02a4,0,1,0,3000) at VOP_STRATEGY+0x28
bwrite(df2d02a4,0,d9fb6000,50,df2d02a4) at bwrite+0xc8
spec_vnoperate(dd02ded4,d0752d00,d020211e,d6e3c698,d085eb30) at
spec_vnoperate+
0x16
VOP_BWRITE(df2d02a4,0,1,0) at VOP_BWRITE+0x28
ffs_fsync(dd02df24,df5e5518,dd02df2c,d7ad4e64,d085ea40) at ffs_fsync+0x1eb
VOP_FSYNC(d7ad4e64,d7b1b000,3,d7ae52bc,0) at VOP_FSYNC+0x34
sched_sync(d7ae52bc) at sched_sync+0xff
Bad frame pointer: 0xd0a2beb8
ddb ps
   PID   PPID   PGRPUID  S   FLAGS  WAIT  OMMAND
  4996  14371  26283  0  3  0x4082  pipewrgzip
 14371  26283  26283  0  3  0x4002  getblktar
 26283   5155  26283   1001  3  0x4082  pause sh
  5155   9016   5155   1001  3  0x4082  pause ksh
  9016  1   9016   1001  30x80  kqreadtmux
 14229   2711  14229   1001  3  0x4082  kqreadtmux
  2711  20702   2711   1001  3  0x4082  pause ksh
 20702   5204   5204   1001  3   0x180  selectsshd
  5204  22494   5204  0  3  0x4180  netio sshd
 12617  14992  12617   1000  3  0x4082  selectssh
 14992  31368  14992   1000  3  0x4082  pause ksh
 22489  32001  22489   1000  3  0x4082  kqreadtmux
 32001  19207  32001   1000  3  0x4082  pause ksh
 19207   6518   6518   1000  3   0x180  selectsshd
  6518  22494   6518  0  3  0x4180  netio sshd
 29850  25242  29850   1000  3  0x4082  poll  ncmpc
 17806  30978  17806503  30x88  poll  postgres
 30525  30978  30525503  30x88  selectpostgres
 12359  30978  12359503  30x88  selectpostgres
  9772  30978   9772503  30x88  selectpostgres
  6637  27574  16492515  3  0x4080  piperdunlinkd
--db_more--    30978  1   6831503  3
0x408a  selectpostgres
 27574  16492  16492515  3  0x4180  poll  squid
 16492  1  16492  0  30x80  poll  squid
 26032  1  26032   1000  30x80  poll  mpd
 17929  1  17929  0  3  0x4082  ttyin getty
 25242  31368  25242   1000  3  0x4082  pause ksh
 31368  1  31368   1000  30x80  kqreadtmux
 25796  1  25796  0  3  0x4082  ttyin getty
 26566  1  26566  0  3  0x4082  ttyin getty
 11591  1  11591  0  3  0x4082  ttyin getty
 12998  1  12998  0  3  0x4082  ttyin getty
 16752  1  16752  0  3  0x4082  ttyin getty
  9554  1   9554  0  3 0x40180  selectsendmail
  3160  1   3160  0  30x80  selectcron
 24298  1  17444  0  30x82  nanosleep perl
 32051  1  32051  0  3   0x180  selectinetd
  6565  1   6565 71  3   0x180  kqreadftp-proxy
 32243  1  32243 77  3   0x180  poll  dhcpd
 22494  1  22494  0  30x80  selectsshd
 30471  0  0  0  30x100280  nfsidlnfsio
 30278  0  0  0  30x100280  nfsidlnfsio
 18839  0  0  0  30x100280  nfsidlnfsio
 17005  0  0  0  30x100280  nfsidlnfsio
--db_more--    11650  1  11650  0  3
0x80  poll  ntpd
 27181  30711  27181 83  3   0x180  poll  ntpd
 30711  1  30711 83  3   0x180  poll  ntpd
 25200  27212  27212  0  30x80  nfsd  nfsd
  1514  27212  27212  0  30x80  nfsd  nfsd
 31283  27212  27212  0  30x80  nfsd  nfsd
  7937  27212  27212  0  30x80  nfsd  nfsd
 27212  1  27212  0  30x80  netconnfsd
 23698  1  23698  0  30x80  selectmountd
  1398  1   1398 28  3   0x180  poll  portmap
 11863   6310   6310 70  3   0x180  selectnamed
  6310  1   6310  0  3

Re: If you are one of the cool kids who cranks kern.bufcachepercent up..

2010-01-10 Thread Tobias Ulmer
On Sat, Jan 09, 2010 at 04:05:13AM -0700, Bob Beck wrote:
 Try this. 

Box locked up under make clean while building ports, hdd led still on.
Last time i've checked it had about 84000 vnodes, which gave a very
nice (subjective) speedup since no read access gets to the disk,
(almost) ever.


savecore: reboot after panic: pool_do_get(inodedeppl): free list
modified: page 0xddeb9000; item addr 0xddeb9dcc; offset 0x28=0xddfbaabb
savecore: system went down at Sun Jan 10 11:06:09 2010
savecore: no dump, not enough free space on device

OpenBSD 4.6-current (GENERIC) #0: Sat Jan  9 15:02:25 CET 2010

tobi...@nostromo.tmux.org:/home/tobiasu/work/openbsd/src/sys/arch/i386/compile/GENERIC
cpu0: AMD Athlon(tm) XP 2500+ (AuthenticAMD 686-class, 512KB L2 cache) 1.84 
GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE
real mem  = 1610117120 (1535MB)
avail mem = 1551421440 (1479MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 05/17/05, BIOS32 rev. 0 @ 0xfa390, SMBIOS 
rev. 2.3 @ 0xf0100 (38 entries)
bios0: vendor Award Software International, Inc. version F6 date 05/17/2005
bios0: Gigabyte Technology Co., Ltd. GA-7S748
apm0 at bios0: Power Management spec V1.2 (slowidle)
apm0: AC on, battery charge unknown
acpi at bios0 function 0x0 not configured
pcibios0 at bios0: rev 2.1 @ 0xf/0xc784
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfc6f0/144 (7 entries)
pcibios0: PCI Exclusive IRQs: 5 6 9 10 11
pcibios0: PCI Interrupt Router at 000:02:0 (SiS 85C503 System rev 0x00)
pcibios0: PCI bus #1 is the last bus
bios0: ROM list: 0xc/0xc000 0xcc000/0x8000!
cpu0 at mainbus0: (uniprocessor)
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 SiS 746 PCI rev 0x10
sisagp0 at pchb0
agp0 at sisagp0: aperture at 0xe800, size 0x400
ppb0 at pci0 dev 1 function 0 SiS 86C202 VGA rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 ATI Radeon VE rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
radeondrm0 at vga1: irq 10
drm0 at radeondrm0
pcib0 at pci0 dev 2 function 0 SiS 85C503 System rev 0x25
pciide0 at pci0 dev 2 function 5 SiS 5513 EIDE rev 0x00: 746: DMA, channel 0 
wired to compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 0: SAMSUNG SP1604N
wd0: 16-sector PIO, LBA48, 152626MB, 312579695 sectors
wd1 at pciide0 channel 0 drive 1: WDC WD1200BB-00DWA0
wd1: 16-sector PIO, LBA48, 114473MB, 234441648 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 5
wd1(pciide0:0:1): using PIO mode 4, Ultra-DMA mode 5
wd2 at pciide0 channel 1 drive 0: ST3250620A
wd2: 16-sector PIO, LBA48, 238474MB, 488395055 sectors
wd3 at pciide0 channel 1 drive 1: ST3250620A
wd3: 16-sector PIO, LBA48, 238475MB, 488397168 sectors
wd2(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 5
wd3(pciide0:1:1): using PIO mode 4, Ultra-DMA mode 5
ohci0 at pci0 dev 3 function 0 SiS 5597/5598 USB rev 0x0f: irq 10, version 
1.0, legacy support
ohci1 at pci0 dev 3 function 1 SiS 5597/5598 USB rev 0x0f: irq 11, version 
1.0, legacy support
ehci0 at pci0 dev 3 function 3 SiS 7002 USB rev 0x00: irq 6
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 SiS EHCI root hub rev 2.00/1.00 addr 1
ral0 at pci0 dev 10 function 0 Ralink RT2561 rev 0x00: irq 5, address 
00:80:5a:38:c4:0b
ral0: MAC/BBP RT2661B, RF RT2527
rl0 at pci0 dev 11 function 0 Realtek 8139 rev 0x10: irq 11, address 
00:08:54:01:0a:00
rlphy0 at rl0 phy 0: RTL internal PHY
rl1 at pci0 dev 12 function 0 Realtek 8139 rev 0x10: irq 10, address 
00:05:5d:2b:fa:b4
rlphy1 at rl1 phy 0: RTL internal PHY
cmpci0 at pci0 dev 13 function 0 C-Media Electronics CMI8738/C3DX Audio rev 
0x10: irq 9
audio0 at cmpci0
opl0 at cmpci0: model OPL3
midi0 at opl0: CMPCI Yamaha OPL3
mpu at cmpci0 not configured
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: console
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pcppi0 at isa0 port 0x61
midi1 at pcppi0: PC speaker
spkr0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
it0 at isa0 port 0x2e/2: IT8705F rev 2, EC port 0x290
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
usb1 at ohci0: USB revision 1.0
uhub1 at usb1 SiS OHCI root hub rev 1.00/1.00 addr 1
usb2 at ohci1: USB revision 1.0
uhub2 at usb2 SiS OHCI root hub rev 1.00/1.00 addr 1
biomask fd47 netmask fd67 ttymask fdff
mtrr: Pentium Pro MTRR support
vscsi0 at root
scsibus0 at vscsi0: 256 targets
softraid0 at root
root on wd0a swap on wd0b dump on wd0b
WARNING: / was not properly unmounted



patch: add OpenRD console to uftdi

2009-12-13 Thread Tobias Ulmer
This attaches OpenRD's SYSTEM console to uftdi. Some special casing is
needed to not attach to the JTAG interface as well. I know it's a bit
ugly, but I couldn't come up with something cleaner; suggestions?

obligatory dmesg snippet:
uftdi0 at uhub2 port 2 configuration 1 interface 1 FTDI OpenRD JTAGKey
FT2232D B rev 2.00/5.00 addr 2
ucom0 at uftdi0 portno 2

Index: dev/usb/uftdi.c
===
RCS file: /home/tobiasu/obsd/cvs/src/sys/dev/usb/uftdi.c,v
retrieving revision 1.54
diff -u -p -r1.54 uftdi.c
--- dev/usb/uftdi.c 13 Oct 2009 19:33:17 -  1.54
+++ dev/usb/uftdi.c 13 Dec 2009 14:22:51 -
@@ -261,6 +261,7 @@ static const struct usb_devno uftdi_devs
{ USB_VENDOR_FTDI, USB_PRODUCT_FTDI_OPENPORT_13M },
{ USB_VENDOR_FTDI, USB_PRODUCT_FTDI_OPENPORT_13S },
{ USB_VENDOR_FTDI, USB_PRODUCT_FTDI_OPENPORT_13U },
+   { USB_VENDOR_FTDI, USB_PRODUCT_FTDI_OPENRD },
{ USB_VENDOR_FTDI, USB_PRODUCT_FTDI_PCDJ_DAC2 },
{ USB_VENDOR_FTDI, USB_PRODUCT_FTDI_PYRAMID },
{ USB_VENDOR_FTDI, USB_PRODUCT_FTDI_SEMC_DSS20 },
@@ -426,6 +427,12 @@ uftdi_match(struct device *parent, void 
return (UMATCH_NONE);
usbd_set_config_index(uaa-device, USB_UNCONFIG_INDEX, 1);
}
+
+   /* JTAG on USB interface 0 */
+   if (uaa-vendor == USB_VENDOR_FTDI 
+   uaa-product == USB_PRODUCT_FTDI_OPENRD 
+   uaa-ifaceno == 0)
+   return (UMATCH_NONE);
 
if (nifaces = 1)
return (UMATCH_VENDOR_PRODUCT);
Index: dev/usb/usbdevs
===
RCS file: /home/tobiasu/obsd/cvs/src/sys/dev/usb/usbdevs,v
retrieving revision 1.462
diff -u -p -r1.462 usbdevs
--- dev/usb/usbdevs 8 Dec 2009 07:25:50 -   1.462
+++ dev/usb/usbdevs 12 Dec 2009 14:24:03 -
@@ -1414,6 +1414,7 @@ product FTDI FT232_6  0x6009  Serial
 product FTDI SERIAL_2232C  0x6010  2232C Serial
 product FTDI PS2KBDMS  0x8371  PS/2 Keyboard/Mouse
 product FTDI SERIAL_8U100AX0x8372  Serial
+product FTDI OPENRD0x9e90  OpenRD JTAGKey
 product FTDI LOCOBUFFER0xc7d0  RR-CirKits LocoBuffer
 product FTDI DMX4ALL   0xc850  DMX4ALL DMX interface
 product FTDI ASK_RDR4X7_1  0xc990  ASK RDR 4X7



Re: [PATCH] Fix interrupt handling in ral(4) for RT2661 under load

2009-12-05 Thread Tobias Ulmer
On Sun, Nov 22, 2009 at 08:31:07PM -0800, Roland Dreier wrote:
 The interrupt handling in ral(4) for RT2661 has a couple of problems,
 which causes the interface to get stuck under heavy load with OACTIVE
 set (the problems are likely especially severe on slow systems such as
 my 600MHz VIA system); bouncing the interface down and back up fixes
 things.  As I describe below, I think I've been able to fix it, and
 I'd be happy to see the patch below reviewed and applied.
 
 I've seen other reports that look similar to the problems I was
 having; eg bug kernel/5958 starts out talking about RT2860 (which is
 completely different code) but some of the me too replies are for
 RT2561S, which I hope this patch fixes (I've cc'ed those reporters;
 test reports welcome!).  I've not looked at the RT2860 code due to
 lack of hardware, but if someone wants to send me a PCI card

I've found an unused RT 2561 and did some tests with it.

 
 The first problem is that multiple TX completions may happen before
 the interrupt handler gets to rt2661_tx_intr().  When this happens,
 the TX interrupt handler only completes one entry in the TX ring,
 which leads to the driver getting behind the hardware.  To fix this, I
 extended the qid field in the TX descriptor to contain the index in
 the TX ring as well as the queue ID, and then when an interrupt is
 missed, free the earlier TX entries as well as the entry that the
 interrupt is for.  (I did see this code trigger under load)
 
 This exposes the second problem: there is a race that is inherent in
 separating TX completion handling between TX DMA interrupts and TX
 interrupts -- the driver may handle all the TX DMAs that finished when
 it called rt2661_tx_dma_intr(), but by the time it gets to
 rt2661_tx_intr(), another TX may have completed and the driver may end
 up processing a TX completion for which it hasn't handled the TX DMA
 completion.  This ends up leaking mbufs if a new send is enqueued
 before the TX DMA interrupt has a chance to catch up.  (This happens
 in practice on my system as well)
 
 It is probably possible to fix this and keep the split DMA/TX
 handling, but that seems to require unneeded complexity.  Instead, we
 can just ignore TX DMA interrupts and handle everything when the TX
 actually completes.  This means we don't free the mbuf quite as soon,
 but since we can't reuse the slot in the TX ring anyway, I don't see
 this as a problem in practice.
 
 With this patch applied, the ral interface on my access point is able
 to continue operating under load that would cause the interface to get
 stuck with the stock driver fairly quickly.

I don't see any difference between your patch and -current (but it
does work, no issues)

Mind sharing your hostname.ral0 and the tools you use to trigger this
situation? I've tried hping, tcpbench, ping -f, rsync, etc to no avail.

max ~8000 intr/s with hping
2.5MB/s with scp


OpenBSD 4.6-current (GENERIC) #0: Sat Dec  5 16:13:19 CET 2009
tobi...@neodym.tmux.org:/home/tobiasu/obsd/src/sys/arch/i386/compile/GENERIC
cpu0: AMD Athlon(tm) XP 2500+ (AuthenticAMD 686-class, 512KB L2 cache) 1.84 
GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE
real mem  = 1610117120 (1535MB)
avail mem = 1551433728 (1479MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 05/17/05, BIOS32 rev. 0 @ 0xfa390, SMBIOS 
rev. 2.3 @ 0xf0100 (38 entries)
bios0: vendor Award Software International, Inc. version F6 date 05/17/2005
bios0: Gigabyte Technology Co., Ltd. GA-7S748
apm0 at bios0: Power Management spec V1.2 (slowidle)
apm0: AC on, battery charge unknown
acpi at bios0 function 0x0 not configured
pcibios0 at bios0: rev 2.1 @ 0xf/0xc784
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfc6f0/144 (7 entries)
pcibios0: PCI Exclusive IRQs: 5 6 9 10 11
pcibios0: PCI Interrupt Router at 000:02:0 (SiS 85C503 System rev 0x00)
pcibios0: PCI bus #1 is the last bus
bios0: ROM list: 0xc/0xf600 0xd/0x8000!
cpu0 at mainbus0: (uniprocessor)
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 SiS 746 PCI rev 0x10
sisagp0 at pchb0
agp0 at sisagp0: aperture at 0xe000, size 0x400
ppb0 at pci0 dev 1 function 0 SiS 86C202 VGA rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 vendor ATI, unknown product 0x9505 rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
pcib0 at pci0 dev 2 function 0 SiS 85C503 System rev 0x25
pciide0 at pci0 dev 2 function 5 SiS 5513 EIDE rev 0x00: 746: DMA, channel 0 
wired to compatibility, channel 1 wired to compatibility
atapiscsi0 at pciide0 channel 0 drive 1
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: PLEXTOR, CD-R PX-W1210A, 1.02 ATAPI 5/cdrom 
removable
cd0(pciide0:0:1): using PIO mode 4, DMA mode 2
wd0 at pciide0 channel 1 drive 0: ST3250620A
wd0: 16-sector PIO, LBA48, 238474MB, 488395055 sectors
wd1 at pciide0 channel 1 drive 1: 

Re: add MAKECONF to default env in sudoers

2009-10-26 Thread Tobias Ulmer
On Fri, Oct 16, 2009 at 08:20:00PM +0200, Tobias Ulmer wrote:
 Add MAKECONF, otherwise building ports in non-standard locations without
 using /etc/mk.conf won't work.
 
 Index: sudoers
 ===
 RCS file: /home/tobiasu/obsd/cvs/src/usr.bin/sudo/sudoers,v
 retrieving revision 1.23
 diff -u -p -r1.23 sudoers
 --- sudoers   3 Jun 2009 20:25:23 -   1.23
 +++ sudoers   16 Oct 2009 16:53:31 -
 @@ -17,9 +17,10 @@
  
  # Defaults specification
  Defaults env_keep +=DESTDIR EDITOR FETCH_CMD FLAVOR FTPMODE GROUP MAKE
 -Defaults env_keep +=MULTI_PACKAGES NOMAN OKAY_FILES OWNER PKG_CACHE 
 PKG_DBDIR
 -Defaults env_keep +=PKG_DESTDIR PKG_PATH PKG_TMPDIR PORTSDIR RELEASEDIR
 -Defaults env_keep +=SHARED_ONLY SSH_AUTH_SOCK SUBPACKAGE VISUAL WRKOBJDIR
 +Defaults env_keep +=MAKECONF MULTI_PACKAGES NOMAN OKAY_FILES OWNER 
 PKG_CACHE
 +Defaults env_keep +=PKG_DBDIR PKG_DESTDIR PKG_PATH PKG_TMPDIR PORTSDIR
 +Defaults env_keep +=RELEASEDIR SHARED_ONLY SSH_AUTH_SOCK SUBPACKAGE VISUAL
 +Defaults env_keep +=WRKOBJDIR
  
  # Uncomment to disable the lecture the first time you run sudo
  #Defaults !lecture

Ping?



Re: bufcachepercent=90 freaks - you know who you are...

2009-10-13 Thread Tobias Ulmer
On Wed, Sep 30, 2009 at 08:24:06AM -0600, Bob Beck wrote:
 And I love you for it. 
 
 If you like playing with big giant buffer caches, please try this diff
 and let me know if you have any issues with it.

Something holding this off? I have it on 3 machines, no problems.



Re: acpi question

2009-09-05 Thread Tobias Ulmer
On Fri, Sep 04, 2009 at 10:13:53PM +0200, frantisek holop wrote:
 hi there,
 
 poking around in my bios i have found the following setting:
 
 Power Now!(tm) Technology [Enabled]
 
 the help message says:
 
 Enable/disable the generation of ACPI _PPC, _PSS, and _PCT objects.
 
 if anybody knowledgable reads this, what does this mean
 and how would flipping this affect openbsd?  thanks.

Well it provides acpi objects that tell OpenBSD which performance
states your cpu(s) supports.

You want to read 8.4.4 here:
http://www.acpi.info/DOWNLOADS/ACPIspec40.pdf

For the effect on OpenBSD, you would read some files in /usr/src/sys..

In short, leave it enabled.

Tobias

 
 -f
 -- 
 there is only one universal passion: fear.



Re: ASLR and OpenBSD

2009-05-18 Thread Tobias Ulmer
On Mon, May 18, 2009 at 05:07:21PM +0200, Sascha Fahl wrote:
 Hi,
 I could find out that OpenBSD was one of the first OSs supporting ASLR to
 make some kinds of exploits harder to work. Is there any documentation
 available to get some more information about the OpenBSD implementation of
 ASLR?
 
 Sascha

http://www.openbsd.org/papers/
http://www.dcbsdcon.org/speakers/videos/miller_dcbsdcon2009.avi
...