Re: lld bug workaround

2017-03-18 Thread Philip Guenther
On Saturday, March 18, 2017, Mark Kettenis  wrote:

> The way lld applies version scripts is a bit broken for
> linker-generated symbols.  In particular, even if you explicitly mark
> rhose symbols als global, they will end up local if that's the default.
> So even with the following version script:
>
>   { global: _end; local: *; };
>
> The linker-generated _end will end up as a local symbol.
> Unfortunately our brk()/sbrk() implementation relies on _end being
> global.  The diff below adds a workaround while I take this up with
> upstream.
>
> ok?
>

I guess the alternative would be to change crt0 to pass &_end as an
additional argument to _csu_finish(), which could then set a variable local
to libc for brk/sbrk to use...but that'll require a major bump and now is
not the time for that.

So yeah, this diff seems like the reasonable fix for now.


Philip


Re: Making it easier to install clang alongside gcc

2017-03-18 Thread Jonathan Gray
On Sat, Mar 18, 2017 at 05:24:30PM +0100, Mark Kettenis wrote:
> > Date: Thu, 16 Mar 2017 11:32:07 +1100
> > From: Jonathan Gray 
> > 
> > On Wed, Mar 15, 2017 at 09:53:41PM +0100, Mark Kettenis wrote:
> > > It's currently a bit of a pain to install clang and ld.lld, but keep
> > > gcc and ld.bfd as the default compiler/linker.  You can't rebuild
> > > clang with base gcc and you really want to rebuild it with clang
> > > instead of the ports gcc after boostrapping.  And overwriting the
> > > default compiler/linker links is annoying.  Especially on platforms
> > > where lld doesn't work yet.  The diff below would make my life easier
> > > and hopefully get more people involved.
> > > 
> > > This partly reverts the changes made by jsg@ in Brisbane, but I think
> > > we need this if we want clang/lld on more platforms than just arm64.
> > > 
> > > ok?
> > > 
> > > 
> > > Index: gnu/usr.bin/clang/Makefile.inc
> > > ===
> > > RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
> > > retrieving revision 1.4
> > > diff -u -p -u -p -r1.4 Makefile.inc
> > > --- gnu/usr.bin/clang/Makefile.inc16 Feb 2017 02:08:42 -  
> > > 1.4
> > > +++ gnu/usr.bin/clang/Makefile.inc15 Mar 2017 20:21:06 -
> > > @@ -6,6 +6,9 @@ BOOTSTRAP_CLANG?=no
> > >  .if ${BOOTSTRAP_CLANG} == "yes"
> > >  CC=  egcc
> > >  CXX= eg++
> > > +.else
> > > +CC=  clang
> > > +CXX= clang++
> > >  .endif
> > 
> > This entire block should be just
> > 
> > .if ${COMPILER_VERSION:L} == "gcc4"
> > CC= clang
> > CXX=clang++
> > .endif
> > 
> > A list of compilers that don't handle the latest c++ standard.
> 
> And then we'd simply bootstrap with the ports clang instead of ports gcc?
> 

Yes, and overriding CC and CXX in environment or mk.conf would only
break for archs where clang isn't cc/c++ instead of all archs.



Re: Add a "random" target to bsd.regress.mk

2017-03-18 Thread trondd
On Sat, March 18, 2017 6:42 pm, Scott Cheloha wrote:
> In general, a test can put your system into a state that allows a
> subsequent test to pass when it would have otherwise failed.
>

>
> Any takers?  Thoughts?
>

If such a bug is revealed, how does someone rerun the tests in the same
order to reproduce the bug or verify when it's fixed?

"Manually" is tough if you don't know which previous test of many may have
caused the problematic system state.

Actually, rereading what I quoted, I see you're concerned with unmasking
false positives, which can be manually rerun in isolation to reproduce. 
My thought still stands for the flip-side where a test fails due to a
previous test.

Tim.



faq13.html: clarify cd burning instructions

2017-03-18 Thread Michael Reed

That way you don't do what I did and read through half the
"Creating data CD-ROMs" section before realizing you're reading
the wrong section. :)


diff --git a/faq/faq13.html b/faq/faq13.html
index 6f94803..28d04b9 100644
--- a/faq/faq13.html
+++ b/faq/faq13.html
@@ -615,6 +615,9 @@ copying files to your hard disk.
 
 Writing CDs
 
+We can create either a data CD for storage of arbitrary data, or an audio

+CD for use with a CD player.
+
 Creating data CD-ROMs
 
 First, you will want to create an ISO 9660 filesystem to put on a CD-ROM.




cwmrc(5) small cleanup

2017-03-18 Thread Michael Reed

The signatures for the functions bind-key and bind-mouse do
not match how they are used.



diff --git a/app/cwm/cwmrc.5 b/app/cwm/cwmrc.5
index fbecaedb..1da9c08c 100644
--- a/app/cwm/cwmrc.5
+++ b/app/cwm/cwmrc.5
@@ -63,7 +63,7 @@ The name and class values, respectively, for existing windows
 are both set in the WM_CLASS property and may be obtained using
 .Xr xprop 1 .
 .Pp
-.It Ic bind-key Ar key function
+.It Ic bind-key Ar key Ns - Ns Ar function
 Bind or rebind key
 .Ar key
 to
@@ -92,7 +92,7 @@ may either be one from the
 .Sx BIND FUNCTION LIST
 (see below) or the command line that is to be executed.
 .Pp
-.It Ic bind-mouse Ar button function
+.It Ic bind-mouse Ar button Ns - Ns Ar function
 Bind or rebind button
 .Ar button
 to
@@ -245,7 +245,6 @@ A special
 keyword
 .Dq all
 can be used to unbind all buttons.
-.Pp
 .El
 .Sh BIND FUNCTION LIST
 .Bl -tag -width 23n -compact



cdio: don't print message about "file not multiple of block length"

2017-03-18 Thread Michael Reed

It seems as if cdio copes fine regardless of whether the file
is a multiple of the block length, so is it really so important
that the message is printed unconditionally?

This patch makes it so that the "-v" flag must be used at least
once for that warning to print.



diff --git a/usr.bin/cdio/mmc.c b/usr.bin/cdio/mmc.c
index 2866d8050..af07ae391 100644
--- a/usr.bin/cdio/mmc.c
+++ b/usr.bin/cdio/mmc.c
@@ -467,8 +467,10 @@ writetrack(struct track_info *tr, int track)
return (-1);
}
if (tr->sz % tr->blklen) {
-   warnx("file %s is not multiple of block length %d",
-   tr->file, tr->blklen);
+   if (verbose > 1) {
+   warnx("file %s is not multiple of block length %d",
+   tr->file, tr->blklen);
+   }
end_lba = tr->sz / tr->blklen + lba + 1;
} else {
end_lba = tr->sz / tr->blklen + lba;



Re: Optimize cerror on arm64

2017-03-18 Thread Mark Kettenis
> Date: Sat, 18 Mar 2017 14:58:36 -0700
> From: Philip Guenther 
> 
> > Hmm, the arm version still has the equivalent movn r1.  I'll let
> > guenther@ deal with that.
> 
> Ah, but it's necessary there...for correct error return from lseek(). 
> 64bit archs never need the second return register...and I've already 
> removed it from the equivalent of cerror on all the other 64bit archs.

Right.  Works fine here, so please commit that bit as well then.



Re: Optimize cerror on arm64

2017-03-18 Thread Philip Guenther
On Sat, 18 Mar 2017, Mark Kettenis wrote:
> > Date: Sat, 18 Mar 2017 17:20:21 +0100
> > From: Patrick Wildt 
> > 
> > On Sat, Mar 18, 2017 at 03:47:18PM +0100, Mark Kettenis wrote:
> > > Just like we did on other architectures.
> > > 
> > > ok?
> > 
> > guenther@ had the same diff (but he also removed the movn x1), which
> > looked good to me as well.  Basically still ok patrick@. ;)

iirc you hadn't had a chance to actually run it and I was waiting for 
someone who actually has the hardware to confirm I didn't miss something 
dumb...

So obviously ok guenther@


> Hmm, the arm version still has the equivalent movn r1.  I'll let
> guenther@ deal with that.

Ah, but it's necessary there...for correct error return from lseek(). 
64bit archs never need the second return register...and I've already 
removed it from the equivalent of cerror on all the other 64bit archs.


Philip



cdio(1): introduce acronym on first use

2017-03-18 Thread Michael Reed

That way the user doesn't have to scroll through the
man page to find what it stands for.

On a side note, googling for "tao cd" is not helpful,
but googling "track at once" is.



diff --git a/usr.bin/cdio/cdio.1 b/usr.bin/cdio/cdio.1
index ff350ca8f..900449b0a 100644
--- a/usr.bin/cdio/cdio.1
+++ b/usr.bin/cdio/cdio.1
@@ -45,7 +45,7 @@
 The
 .Nm
 program is a compact disc control utility,
-with support for playing audio CDs and TAO CD writing.
+with support for playing audio CDs and track-at-once (TAO) CD writing.
 .Pp
 If no command is given,
 .Nm



Re: Simplify arm64 vfork

2017-03-18 Thread Philip Guenther
On Sat, 18 Mar 2017, Mark Kettenis wrote:
> The return value munging isn't necessary anymore.  See for example 
> lib/libc/arch/arm/sys/OVfork.S:

ok guenther@



Add a "random" target to bsd.regress.mk

2017-03-18 Thread Scott Cheloha
Hi tech@,

The patch below adds a target, "random", to bsd.regress.mk, as
well as a description of the new target to bsd.regress.mk(5).

The "random" target is the same as "regress", except that the
ordering of the regression targets is randomized each time.

My thinking is that statically ordered regression runs can mask
bugs in the software under test and the tests themselves.

For small utilities this is unlikely, but for long-running daemons,
kernel modules, etc., it is more likely because these programs are
more complex.

In general, a test can put your system into a state that allows a
subsequent test to pass when it would have otherwise failed.

Randomly ordered regression runs could help to weed these issues
out.  Even if no such bugs exist, your randomly ordered regression
runs are stronger statements about your software's correctness and
the independence of each test case.

Any takers?  Thoughts?

--
Scott Cheloha

Index: share/man/man5/bsd.regress.mk.5
===
RCS file: /cvs/src/share/man/man5/bsd.regress.mk.5,v
retrieving revision 1.11
diff -u -p -r1.11 bsd.regress.mk.5
--- bsd.regress.mk.516 Jan 2017 07:00:03 -  1.11
+++ bsd.regress.mk.518 Mar 2017 21:24:38 -
@@ -50,6 +50,10 @@ test programs.
 .It Cm depend
 Build any dependencies required to carry out the current set
 of regression tests.
+.It Cm random
+Identical to
+.Cm regress ,
+but regression targets are executed in a random order.
 .It Cm regress
 Executes all of the regression targets defined in the Makefile.
 If one of the tests fails, the line
Index: share/mk/bsd.regress.mk
===
RCS file: /cvs/src/share/mk/bsd.regress.mk,v
retrieving revision 1.13
diff -u -p -r1.13 bsd.regress.mk
--- bsd.regress.mk  19 Jul 2014 18:15:53 -  1.13
+++ bsd.regress.mk  18 Mar 2017 22:23:40 -
@@ -83,6 +83,11 @@ REGRESS_SKIP_TARGETS+=${REGRESS_ROOT_TAR
 .  endif
 .endif 
 
+.ifmake random
+REGRESS_TARGETS!=echo ${REGRESS_TARGETS} | tr ' ' '\n' | sort -R
+.endif
+random: regress
+
 regress: .SILENT
 .if ! ${REGRESS_LOG:M/*}
echo =



acme-client doc diff

2017-03-18 Thread Nick Holland
I found that the current man pages and example file for acme-client
are confusing and leave one with an imperfect certificate setup, with
the intermediate certs missing.  Doesn't generate an error on
OpenBSD, but does on some other OSs.  So I propose these changes to
the example file and man pages:

/etc/acme-client.conf: fetch a "domain full chain certificate" rather
than the "domain chain certificate" (I'd be happy with fetching both,
one extra tiny file won't hurt anything)

acme-client(1) : I know what a "host" key is, didn't recognize it in
this man page.  Also couldn't figure out how to generate the initial
host key without the help of the commit message. 

The example in /etc/acme-client.conf shows "example.com", but in 
acme-client(1), it's "www.example.com".  Not interchangeable, so
standardize on "example.com".

acme-client.conf(5) : Point out "full chain" is needed for
httpd(8) (and others, I'm sure).  Show a httpd.conf(5) server block.

Diff below is certainly tab mangled; raw diff can be pulled from:

https://holland-consulting.net/acme-client.diff

Nick.

Index: etc/acme-client.conf
===
RCS file: /cvs/src/etc/acme-client.conf,v
retrieving revision 1.3
diff -u -u -r1.3 acme-client.conf
--- etc/acme-client.conf21 Jan 2017 09:06:57 -  1.3
+++ etc/acme-client.conf18 Mar 2017 02:44:58 -
@@ -17,6 +17,6 @@
 #  alternative names { secure.example.com }
 #  domain key "/etc/ssl/private/example.com.key"
 #  domain certificate "/etc/ssl/example.com.crt"
-#  domain chain certificate "/etc/ssl/example.com.chain.pem"
+#  domain full chain certificate "/etc/ssl/example.com.fullchain.pem"
 #  sign with letsencrypt
 #}
Index: usr.sbin/acme-client/acme-client.1
===
RCS file: /cvs/src/usr.sbin/acme-client/acme-client.1,v
retrieving revision 1.20
diff -u -u -r1.20 acme-client.1
--- usr.sbin/acme-client/acme-client.1  28 Jan 2017 17:53:17 -  1.20
+++ usr.sbin/acme-client/acme-client.1  18 Mar 2017 02:44:58 -
@@ -34,7 +34,7 @@
 The options are as follows:
 .Bl -tag -width Ds
 .It Fl A
-Create a new RSA account key if one does not already exist.
+Create a new RSA account (host) key if one does not already exist.
 .It Fl D
 Create a new RSA domain key if one does not already exist.
 .It Fl F
@@ -98,11 +98,16 @@
 returns 1 on failure, 2 if the certificates didn't change (up to date),
 or 0 if certificates were changed (revoked or updated).
 .Sh EXAMPLES
+To initialize a new account (host) key:
+.Pp
+.Dl # acme-client -vAD example.com
+.Pp
+
 To create and submit a new key for a single domain, assuming that the
 web server has already been configured to map the challenge directory
 as above:
 .Pp
-.Dl # acme-client -vD www.example.com
+.Dl # acme-client -vD example.com
 .Pp
 A daily
 .Xr cron 8
@@ -110,7 +115,7 @@
 .Bd -literal -offset indent
 #! /bin/sh
 
-acme-client www.example.com
+acme-client example.com
 
 if [ $? -eq 0 ]
 then
Index: usr.sbin/acme-client/acme-client.conf.5
===
RCS file: /cvs/src/usr.sbin/acme-client/acme-client.conf.5,v
retrieving revision 1.8
diff -u -u -r1.8 acme-client.conf.5
--- usr.sbin/acme-client/acme-client.conf.5 21 Jan 2017 15:53:15 -  
1.8
+++ usr.sbin/acme-client/acme-client.conf.5 18 Mar 2017 02:44:58 -
@@ -134,6 +134,12 @@
 It needs to be in the same directory as the
 .Ar domain certificate
 (or in a subdirectory) and can be specified as a relative or absolute path.
+This is a combination of the
+.Ar domain certificate
+and the
+.Ar domain chain certificate
+in one file, and is required for many web servers, including
+.Xr httpd 8 .
 .It Ic sign with Ar authority
 The certificate authority (as declared above in the
 .Sx AUTHORITIES
@@ -151,8 +157,28 @@
alternative names { secure.example.com www.example.com }
domain key "/etc/ssl/private/example.com.key"
domain certificate "/etc/ssl/example.com.crt"
+   domain full chain certificate "/etc/ssl/example.com.fullchain.pem"
sign with letsencrypt
challengedir "/var/www/acme"
+}
+.Ed
+.Pp
+An
+.Xr httpd.conf 5
+server declaration to use that certificate looks like this:
+.Bd -literal -offset indent
+server "example.com" {
+alias "www.example.com"
+alias "secure.example.com"
+listen on $ext_addr port 80
+listen on $ext_addr tls port 443
+tls certificate "/etc/ssl/example.com.fullchain.pem"
+tls key "/etc/ssl/private/example.com.key"
+location "/.well-known/acme-challenge/*" { 
+root "/acme" 
+root strip 2 
+}
+root "/htdocs"
 }
 .Ed
 .Sh FILES



Re: Optimize cerror on arm64

2017-03-18 Thread Mark Kettenis
> Date: Sat, 18 Mar 2017 17:20:21 +0100
> From: Patrick Wildt 
> 
> On Sat, Mar 18, 2017 at 03:47:18PM +0100, Mark Kettenis wrote:
> > Just like we did on other architectures.
> > 
> > ok?
> 
> guenther@ had the same diff (but he also removed the movn x1), which
> looked good to me as well.  Basically still ok patrick@. ;)

Hmm, the arm version still has the equivalent movn r1.  I'll let
guenther@ deal with that.

> > Index: lib/libc/arch/aarch64/sys/cerror.S
> > ===
> > RCS file: /cvs/src/lib/libc/arch/aarch64/sys/cerror.S,v
> > retrieving revision 1.2
> > diff -u -p -r1.2 cerror.S
> > --- lib/libc/arch/aarch64/sys/cerror.S  25 Jan 2017 10:43:37 -  
> > 1.2
> > +++ lib/libc/arch/aarch64/sys/cerror.S  18 Mar 2017 14:45:58 -
> > @@ -28,17 +28,13 @@
> >  
> >  #include "SYS.h"
> >  
> > +/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
> > +#define TCB_OFFSET_ERRNO   (-12)
> > +
> >  _ENTRY(CERROR)
> > -   stp x0, x30, [sp,#-16]!
> > -   bl  _C_LABEL(__errno)
> > -   ldp x1, x30, [sp],#16
> > -   str w1, [x0]
> > +   mrs x1, tpidr_el0
> > +   str w0, [x1, #TCB_OFFSET_ERRNO]
> > movnx0, #0
> > movnx1, #0
> > ret
> >  END(CERROR)
> > -
> > -#if !defined(__PIC__)
> > -.Lerrno:
> > -   .word   errno
> > -#endif
> > 
> 



Re: Making it easier to install clang alongside gcc

2017-03-18 Thread Mark Kettenis
> Date: Thu, 16 Mar 2017 11:32:07 +1100
> From: Jonathan Gray 
> 
> On Wed, Mar 15, 2017 at 09:53:41PM +0100, Mark Kettenis wrote:
> > It's currently a bit of a pain to install clang and ld.lld, but keep
> > gcc and ld.bfd as the default compiler/linker.  You can't rebuild
> > clang with base gcc and you really want to rebuild it with clang
> > instead of the ports gcc after boostrapping.  And overwriting the
> > default compiler/linker links is annoying.  Especially on platforms
> > where lld doesn't work yet.  The diff below would make my life easier
> > and hopefully get more people involved.
> > 
> > This partly reverts the changes made by jsg@ in Brisbane, but I think
> > we need this if we want clang/lld on more platforms than just arm64.
> > 
> > ok?
> > 
> > 
> > Index: gnu/usr.bin/clang/Makefile.inc
> > ===
> > RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
> > retrieving revision 1.4
> > diff -u -p -u -p -r1.4 Makefile.inc
> > --- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
> > +++ gnu/usr.bin/clang/Makefile.inc  15 Mar 2017 20:21:06 -
> > @@ -6,6 +6,9 @@ BOOTSTRAP_CLANG?=no
> >  .if ${BOOTSTRAP_CLANG} == "yes"
> >  CC=egcc
> >  CXX=   eg++
> > +.else
> > +CC=clang
> > +CXX=   clang++
> >  .endif
> 
> This entire block should be just
> 
> .if ${COMPILER_VERSION:L} == "gcc4"
> CC=   clang
> CXX=  clang++
> .endif
> 
> A list of compilers that don't handle the latest c++ standard.

And then we'd simply bootstrap with the ports clang instead of ports gcc?



Re: lld -znodlopen support

2017-03-18 Thread Patrick Wildt
On Sat, Mar 18, 2017 at 04:17:30PM +0100, Mark Kettenis wrote:
> Diff below adds support for -Wl,-znodlopen.  This fixes the
> libexec/ld.so/df_1_noopen regression test.
> 
> ok?

Seems easy enough, looks good to me.

> 
> 
> Index: gnu/llvm/tools/lld/ELF/Config.h
> ===
> RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/Config.h,v
> retrieving revision 1.2
> diff -u -p -r1.2 Config.h
> --- gnu/llvm/tools/lld/ELF/Config.h   24 Jan 2017 10:20:27 -  1.2
> +++ gnu/llvm/tools/lld/ELF/Config.h   18 Mar 2017 15:14:56 -
> @@ -135,6 +135,7 @@ struct Configuration {
>bool ZCombreloc;
>bool ZExecstack;
>bool ZNodelete;
> +  bool ZNodlopen;
>bool ZNow;
>bool ZOrigin;
>bool ZRelro;
> Index: gnu/llvm/tools/lld/ELF/Driver.cpp
> ===
> RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/Driver.cpp,v
> retrieving revision 1.4
> diff -u -p -r1.4 Driver.cpp
> --- gnu/llvm/tools/lld/ELF/Driver.cpp 14 Mar 2017 08:11:34 -  1.4
> +++ gnu/llvm/tools/lld/ELF/Driver.cpp 18 Mar 2017 15:14:56 -
> @@ -537,6 +537,7 @@ void LinkerDriver::readConfigs(opt::Inpu
>Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
>Config->ZExecstack = hasZOption(Args, "execstack");
>Config->ZNodelete = hasZOption(Args, "nodelete");
> +  Config->ZNodlopen = hasZOption(Args, "nodlopen");
>Config->ZNow = hasZOption(Args, "now");
>Config->ZOrigin = hasZOption(Args, "origin");
>Config->ZRelro = !hasZOption(Args, "norelro");
> Index: gnu/llvm/tools/lld/ELF/SyntheticSections.cpp
> ===
> RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/SyntheticSections.cpp,v
> retrieving revision 1.3
> diff -u -p -r1.3 SyntheticSections.cpp
> --- gnu/llvm/tools/lld/ELF/SyntheticSections.cpp  14 Mar 2017 08:11:34 
> -  1.3
> +++ gnu/llvm/tools/lld/ELF/SyntheticSections.cpp  18 Mar 2017 15:14:56 
> -
> @@ -816,6 +816,8 @@ template  void DynamicSectio
>  DtFlags |= DF_SYMBOLIC;
>if (Config->ZNodelete)
>  DtFlags1 |= DF_1_NODELETE;
> +  if (Config->ZNodlopen)
> +DtFlags1 |= DF_1_NOOPEN;
>if (Config->ZNow) {
>  DtFlags |= DF_BIND_NOW;
>  DtFlags1 |= DF_1_NOW;
> 



Re: Optimize cerror on arm64

2017-03-18 Thread Patrick Wildt
On Sat, Mar 18, 2017 at 03:47:18PM +0100, Mark Kettenis wrote:
> Just like we did on other architectures.
> 
> ok?

guenther@ had the same diff (but he also removed the movn x1), which
looked good to me as well.  Basically still ok patrick@. ;)

> 
> 
> Index: lib/libc/arch/aarch64/sys/cerror.S
> ===
> RCS file: /cvs/src/lib/libc/arch/aarch64/sys/cerror.S,v
> retrieving revision 1.2
> diff -u -p -r1.2 cerror.S
> --- lib/libc/arch/aarch64/sys/cerror.S25 Jan 2017 10:43:37 -  
> 1.2
> +++ lib/libc/arch/aarch64/sys/cerror.S18 Mar 2017 14:45:58 -
> @@ -28,17 +28,13 @@
>  
>  #include "SYS.h"
>  
> +/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
> +#define TCB_OFFSET_ERRNO (-12)
> +
>  _ENTRY(CERROR)
> - stp x0, x30, [sp,#-16]!
> - bl  _C_LABEL(__errno)
> - ldp x1, x30, [sp],#16
> - str w1, [x0]
> + mrs x1, tpidr_el0
> + str w0, [x1, #TCB_OFFSET_ERRNO]
>   movnx0, #0
>   movnx1, #0
>   ret
>  END(CERROR)
> -
> -#if !defined(__PIC__)
> -.Lerrno:
> - .word   errno
> -#endif
> 



Simplify arm64 vfork

2017-03-18 Thread Mark Kettenis
The return value munging isn't necessary anymore.  See for example
lib/libc/arch/arm/sys/OVfork.S:

  revision 1.4
  date: 2015/03/31 04:32:01;  author: guenther;  state: Exp;  lines: +1 -10;  
commitid: 4lHzpIZZxMqyyel4;
  Simplify fork/vfork logic: the kernel has handled returning zero in the child
  for a long time, so there's no need to test the second return register here
  in the asm stub.

  ok and testing of many archs by krw@ miod@

ok?


Index: lib/libc/arch/aarch64/sys/Ovfork.S
===
RCS file: /cvs/src/lib/libc/arch/aarch64/sys/Ovfork.S,v
retrieving revision 1.1
diff -u -p -r1.1 Ovfork.S
--- lib/libc/arch/aarch64/sys/Ovfork.S  11 Jan 2017 18:09:24 -  1.1
+++ lib/libc/arch/aarch64/sys/Ovfork.S  18 Mar 2017 15:53:57 -
@@ -34,13 +34,6 @@
 
 #include "SYS.h"
 
-/*
- * pid = vfork();
- *
- * On return from the SWI:
- * r1 == 0 in parent process, r1 == 1 in child process.
- * r0 == pid of child in parent, r0 == pid of parent in child.
- */
.text
.align  0
 
@@ -48,8 +41,6 @@ SYSENTRY_HIDDEN(vfork)
mov x2, x30
SYSTRAP(vfork)
bcs CERROR
-   sub x1, x1, #1  /* r1 == 0x if parent, 0 if child */
-   and x0, x0, x1  /* r0 == 0 if child, else unchanged */
mov x30, x2
ret
 SYSCALL_END_HIDDEN(vfork)



add new em(4) variant for X270

2017-03-18 Thread Claudio Jeker
The X270 seems to have a new I219-LM variant that em(4) doesn't know.
Adding it to the driver seems to be enough.

OK?
-- 
:wq Claudio

OpenBSD 6.1-beta (GENERIC.MP) #1: Sat Mar 18 15:02:14 CET 2017
cje...@kimiko.zyd.ch:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 17054765056 (16264MB)
avail mem = 16533217280 (15767MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0xca7ae000 (62 entries)
bios0: vendor LENOVO version "R0IET30W (1.08 )" date 01/16/2017
bios0: LENOVO 20HMS03V00
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP UEFI SSDT SSDT HPET APIC MCFG ECDT SSDT SSDT BOOT BATB 
SSDT SSDT SSDT WSMT DBGP DBG2 POAT DMAR ASF! FPDT UEFI
acpi0: wakeup devices GLAN(S4) XHC_(S3) XDCI(S4) HDAS(S4) RP01(S4) RP02(S4) 
RP04(S4) RP05(S4) RP06(S4) RP07(S4) RP08(S4) RP09(S4) RP10(S4) RP11(S4) 
RP12(S4) RP13(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 2399 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz, 2904.00 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: TSC frequency 290400 Hz
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 23MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz, 2904.00 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 1 (application processor)
cpu2: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz, 2904.00 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 1, core 0, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz, 2904.00 MHz
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 120 pins
acpimcfg0 at acpi0 addr 0xf000, bus 0-63
acpiec0 at acpi0
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (RP01)
acpiprt2 at acpi0: bus -1 (RP02)
acpiprt3 at acpi0: bus 3 (RP03)
acpiprt4 at acpi0: bus -1 (RP04)
acpiprt5 at acpi0: bus 4 (RP05)
acpiprt6 at acpi0: bus -1 (RP06)
acpiprt7 at acpi0: bus -1 (RP07)
acpiprt8 at acpi0: bus -1 (RP08)
acpiprt9 at acpi0: bus -1 (RP09)
acpiprt10 at acpi0: bus -1 (RP10)
acpiprt11 at acpi0: bus -1 (RP11)
acpiprt12 at acpi0: bus -1 (RP12)
acpiprt13 at acpi0: bus -1 (RP13)
acpiprt14 at acpi0: bus -1 (RP14)
acpiprt15 at acpi0: bus -1 (RP15)
acpiprt16 at acpi0: bus -1 (RP16)
acpiprt17 at acpi0: bus -1 (RP17)
acpiprt18 at acpi0: bus -1 (RP18)
acpiprt19 at acpi0: bus -1 (RP19)
acpiprt20 at acpi0: bus -1 (RP20)
acpiprt21 at acpi0: bus -1 (RP21)
acpiprt22 at acpi0: bus -1 (RP22)
acpiprt23 at acpi0: bus -1 (RP23)
acpiprt24 at acpi0: bus -1 (RP24)
acpicpu0 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu2 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu3 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpipwrres0 at acpi0: PUBS, resource for XHC_
acpipwrres1 at acpi0: WRST
acpipwrres2 

lld bug workaround

2017-03-18 Thread Mark Kettenis
The way lld applies version scripts is a bit broken for
linker-generated symbols.  In particular, even if you explicitly mark
rhose symbols als global, they will end up local if that's the default.
So even with the following version script:

  { global: _end; local: *; };

The linker-generated _end will end up as a local symbol.
Unfortunately our brk()/sbrk() implementation relies on _end being
global.  The diff below adds a workaround while I take this up with
upstream.

ok?


Index: gnu/llvm/tools/lld/ELF/SymbolTable.cpp
===
RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/SymbolTable.cpp,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 SymbolTable.cpp
--- gnu/llvm/tools/lld/ELF/SymbolTable.cpp  14 Mar 2017 08:07:53 -  
1.1.1.3
+++ gnu/llvm/tools/lld/ELF/SymbolTable.cpp  18 Mar 2017 15:20:08 -
@@ -142,6 +142,12 @@ DefinedRegular *SymbolTable:
   SymbolBody *S = find(Name);
   if (!S || S->isInCurrentDSO())
 return nullptr;
+  if (Visibility == STV_DEFAULT) {
+for (SymbolVersion  : Config->VersionScriptGlobals) {
+  if (!Ver.HasWildcard && Ver.Name == S->getName())
+S->symbol()->VersionId = VER_NDX_GLOBAL;
+}
+  }
   return addAbsolute(Name, Visibility);
 }
 



lld -znodlopen support

2017-03-18 Thread Mark Kettenis
Diff below adds support for -Wl,-znodlopen.  This fixes the
libexec/ld.so/df_1_noopen regression test.

ok?


Index: gnu/llvm/tools/lld/ELF/Config.h
===
RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/Config.h,v
retrieving revision 1.2
diff -u -p -r1.2 Config.h
--- gnu/llvm/tools/lld/ELF/Config.h 24 Jan 2017 10:20:27 -  1.2
+++ gnu/llvm/tools/lld/ELF/Config.h 18 Mar 2017 15:14:56 -
@@ -135,6 +135,7 @@ struct Configuration {
   bool ZCombreloc;
   bool ZExecstack;
   bool ZNodelete;
+  bool ZNodlopen;
   bool ZNow;
   bool ZOrigin;
   bool ZRelro;
Index: gnu/llvm/tools/lld/ELF/Driver.cpp
===
RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/Driver.cpp,v
retrieving revision 1.4
diff -u -p -r1.4 Driver.cpp
--- gnu/llvm/tools/lld/ELF/Driver.cpp   14 Mar 2017 08:11:34 -  1.4
+++ gnu/llvm/tools/lld/ELF/Driver.cpp   18 Mar 2017 15:14:56 -
@@ -537,6 +537,7 @@ void LinkerDriver::readConfigs(opt::Inpu
   Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
   Config->ZExecstack = hasZOption(Args, "execstack");
   Config->ZNodelete = hasZOption(Args, "nodelete");
+  Config->ZNodlopen = hasZOption(Args, "nodlopen");
   Config->ZNow = hasZOption(Args, "now");
   Config->ZOrigin = hasZOption(Args, "origin");
   Config->ZRelro = !hasZOption(Args, "norelro");
Index: gnu/llvm/tools/lld/ELF/SyntheticSections.cpp
===
RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/SyntheticSections.cpp,v
retrieving revision 1.3
diff -u -p -r1.3 SyntheticSections.cpp
--- gnu/llvm/tools/lld/ELF/SyntheticSections.cpp14 Mar 2017 08:11:34 
-  1.3
+++ gnu/llvm/tools/lld/ELF/SyntheticSections.cpp18 Mar 2017 15:14:56 
-
@@ -816,6 +816,8 @@ template  void DynamicSectio
 DtFlags |= DF_SYMBOLIC;
   if (Config->ZNodelete)
 DtFlags1 |= DF_1_NODELETE;
+  if (Config->ZNodlopen)
+DtFlags1 |= DF_1_NOOPEN;
   if (Config->ZNow) {
 DtFlags |= DF_BIND_NOW;
 DtFlags1 |= DF_1_NOW;



chachatest.c patch

2017-03-18 Thread Steven Roberts
See attached.


chachatest.patch
Description: Binary data


chachatest.c patch

2017-03-18 Thread Steven Roberts
TC3 contained the data for TC4.
TC4 contained incorrect data.

Moved the data from TC3 into TC4.
Generated correct data for TC3.

Index: chachatest.c
===
RCS file: /cvs/src/regress/lib/libcrypto/chacha/chachatest.c,v
retrieving revision 1.3
diff -u -p -r1.3 chachatest.c
--- chachatest.c 24 Jun 2014 17:55:40 - 1.3
+++ chachatest.c 18 Mar 2017 14:14:59 -
@@ -83,6 +83,29 @@ struct chacha_tv chacha_test_vectors[] =
  {
  "TC3: Single bit in IV set, all zero key",
  {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ },
+ {
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ },
+ 64,
+ {
+ 0xef, 0x3f, 0xdf, 0xd6, 0xc6, 0x15, 0x78, 0xfb,
+ 0xf5, 0xcf, 0x35, 0xbd, 0x3d, 0xd3, 0x3b, 0x80,
+ 0x09, 0x63, 0x16, 0x34, 0xd2, 0x1e, 0x42, 0xac,
+ 0x33, 0x96, 0x0b, 0xd1, 0x38, 0xe5, 0x0d, 0x32,
+ 0x11, 0x1e, 0x4c, 0xaf, 0x23, 0x7e, 0xe5, 0x3c,
+ 0xa8, 0xad, 0x64, 0x26, 0x19, 0x4a, 0x88, 0x54,
+ 0x5d, 0xdc, 0x49, 0x7a, 0x0b, 0x46, 0x6e, 0x7d,
+ 0x6b, 0xbd, 0xb0, 0x04, 0x1b, 0x2f, 0x58, 0x6b,
+ },
+ },
+ {
+ "TC4: All bits in key and IV are set",
+ {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -101,29 +124,6 @@ struct chacha_tv chacha_test_vectors[] =
  0x0c, 0x52, 0xc8, 0xae, 0x43, 0x24, 0x0b, 0x79,
  0xd4, 0x90, 0x42, 0xb7, 0x77, 0xbf, 0xd6, 0xcb,
  0x80, 0xe9, 0x31, 0x27, 0x0b, 0x7f, 0x50, 0xeb,
- },
- },
- {
- "TC4: All bits in key and IV are set",
- {
- 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
- 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
- 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
- 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
- },
- {
- 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- },
- 64,
- {
- 0xaf, 0xf7, 0x41, 0x82, 0x93, 0xf3, 0xa5, 0x53,
- 0x89, 0x4b, 0x1e, 0x74, 0x84, 0xbd, 0x1e, 0x8e,
- 0xde, 0x19, 0x6e, 0xce, 0xd5, 0xa1, 0xd6, 0x81,
- 0x4d, 0xe3, 0x70, 0x91, 0xe0, 0x7e, 0x07, 0x6e,
- 0x34, 0xbb, 0xba, 0x81, 0x07, 0xa6, 0x86, 0xc9,
- 0x82, 0x85, 0x0f, 0x0a, 0x73, 0x53, 0x94, 0x0d,
- 0x40, 0xdb, 0x1a, 0xb0, 0xb5, 0x76, 0x5b, 0x78,
- 0xb4, 0xcf, 0x47, 0x3d, 0x94, 0x85, 0xa3, 0xdd,
  },
  },
  {



Optimize cerror on arm64

2017-03-18 Thread Mark Kettenis
Just like we did on other architectures.

ok?


Index: lib/libc/arch/aarch64/sys/cerror.S
===
RCS file: /cvs/src/lib/libc/arch/aarch64/sys/cerror.S,v
retrieving revision 1.2
diff -u -p -r1.2 cerror.S
--- lib/libc/arch/aarch64/sys/cerror.S  25 Jan 2017 10:43:37 -  1.2
+++ lib/libc/arch/aarch64/sys/cerror.S  18 Mar 2017 14:45:58 -
@@ -28,17 +28,13 @@
 
 #include "SYS.h"
 
+/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
+#define TCB_OFFSET_ERRNO   (-12)
+
 _ENTRY(CERROR)
-   stp x0, x30, [sp,#-16]!
-   bl  _C_LABEL(__errno)
-   ldp x1, x30, [sp],#16
-   str w1, [x0]
+   mrs x1, tpidr_el0
+   str w0, [x1, #TCB_OFFSET_ERRNO]
movnx0, #0
movnx1, #0
ret
 END(CERROR)
-
-#if !defined(__PIC__)
-.Lerrno:
-   .word   errno
-#endif