Re: amr64 acpipci(4)

2019-08-20 Thread Jonathan Gray
On Tue, Aug 20, 2019 at 08:49:19PM +0200, Mark Kettenis wrote:
> The Ampere/Lenvo HR330A firmware doesn't set the _TTP bit on the IO
> window of its host bridges.  It really should since these bridges
> translate memory transactions into io transactions.  But it isn't the
> only one that doesn't get this aspect right.  So it is probably best
> to ignore _TTP and just assume it converts memory transactions into io
> transactions.
> 
> ok?

ok jsg@

> 
> 
> Index: arch/arm64/dev/acpipci.c
> ===
> RCS file: /cvs/src/sys/arch/arm64/dev/acpipci.c,v
> retrieving revision 1.12
> diff -u -p -r1.12 acpipci.c
> --- arch/arm64/dev/acpipci.c  30 Jul 2019 21:44:15 -  1.12
> +++ arch/arm64/dev/acpipci.c  20 Aug 2019 18:43:15 -
> @@ -253,8 +253,10 @@ acpipci_parse_resources(int crsidx, unio
>   sc->sc_mem_trans = at;
>   break;
>   case LR_TYPE_IO:
> - if ((tflags & LR_IO_TTP) == 0)
> - return 0;
> + /*
> +  * Don't check _TTP as various firmwares don't set it,
> +  * even though they should!!
> +  */
>   extent_free(sc->sc_ioex, min, len, EX_WAITOK);
>   at = malloc(sizeof(struct acpipci_trans), M_DEVBUF, M_WAITOK);
>   at->at_iot = sc->sc_iot;
> 



update to tradcpp 0.5.3

2019-08-20 Thread Jonathan Gray
Update tradcpp to 0.5.3.  We already had the fixed mdoc.

release 0.5.3 (20190121)
   - Fix markup typo in the man page.
   - Abort on line numbering or column numbering overflow. Line
 numbers are limited to values that fit in "unsigned int". Also
 reject input lines longer than 2^32-1 characters. It seems
 reasonable to presume that any input that violates these
 constraints is someone screwing around and not a serious attempt
 to compile or preprocess anything useful. Done in response to
 n2129, but without getting into any of the silliness found there.
   - Recognize __ia64__ for IA64 builds.
   - Recognize __aarch64__ for 64-bit ARM builds, as sent in by
 various people.
   - Recognize __riscv__ and __riscv64__ for risc-v builds.

Index: config.h
===
RCS file: /cvs/src/libexec/tradcpp/config.h,v
retrieving revision 1.1
diff -u -p -r1.1 config.h
--- config.h30 Jul 2014 16:33:11 -  1.1
+++ config.h21 Aug 2019 04:02:28 -
@@ -124,6 +124,22 @@
 #define CONFIG_CPU "__ppc64__"
 #elif defined(__ARM__)
 #define CONFIG_CPU "__ARM__"
+#elif defined(__AARCH64__)
+#define CONFIG_CPU "__AARCH64__"
+#elif defined(__aarch64__)
+#define CONFIG_CPU "__aarch64__"
+#elif defined(__RISCV__)
+#define CONFIG_CPU "__RISCV__"
+#elif defined(__riscv__)
+#define CONFIG_CPU "__riscv__"
+#elif defined(__RISCV64__)
+#define CONFIG_CPU "__RISCV64__"
+#elif defined(__riscv64__)
+#define CONFIG_CPU "__riscv64__"
+#elif defined(__riscv64)
+#define CONFIG_CPU "__riscv64"
+#elif defined(__ia64__)
+#define CONFIG_CPU "__ia64__"
 #else
 /* let it go */
 #endif
Index: directive.c
===
RCS file: /cvs/src/libexec/tradcpp/directive.c,v
retrieving revision 1.2
diff -u -p -r1.2 directive.c
--- directive.c 2 Sep 2018 08:28:05 -   1.2
+++ directive.c 21 Aug 2019 04:02:28 -
@@ -114,7 +114,7 @@ oneword(const char *what, struct place *
 
pos = strcspn(line, ws);
if (line[pos] != '\0') {
-   p2->column += pos;
+   place_addcolumns(p2, pos);
complain(p2, "Garbage after %s argument", what);
complain_fail();
line[pos] = '\0';
@@ -348,13 +348,13 @@ d_define(struct lineplace *lp, struct pl
argpos = pos;
pos = pos + strcspn(line+pos, "()");
if (line[pos] == '(') {
-   p2->column += pos;
+   place_addcolumns(p2, pos);
complain(p2, "Left parenthesis in macro parameters");
complain_fail();
return;
}
if (line[pos] != ')') {
-   p2->column += pos;
+   place_addcolumns(p2, pos);
complain(p2, "Unclosed macro parameter list");
complain_fail();
return;
@@ -378,10 +378,10 @@ d_define(struct lineplace *lp, struct pl
pos += strspn(line+pos, ws);
 
p3 = *p2;
-   p3.column += argpos;
+   place_addcolumns(&p3, argpos);
 
p4 = *p2;
-   p4.column += pos;
+   place_addcolumns(&p4, pos);
 
if (argpos) {
debuglog(&lp->current, "Defining %s()", line);
@@ -490,7 +490,8 @@ d_line(struct lineplace *lp, struct plac
errno = 0;
val = strtoul(text, &moretext, 10);
if (errno) {
-   complain(&lp->current, "No line number in #line directive");
+   complain(&lp->current,
+"Invalid line number in #line directive");
goto fail;
}
 #if UINT_MAX < ULONG_MAX
@@ -502,7 +503,7 @@ d_line(struct lineplace *lp, struct plac
 #endif
moretext += strspn(moretext, ws);
moretextlen = strlen(moretext);
-   lp->current.column += (moretext - text);
+   place_addcolumns(&lp->current, moretext - text);
 
if (moretextlen > 2 &&
moretext[0] == '"' && moretext[moretextlen-1] == '"') {
@@ -610,7 +611,7 @@ directive_gotdirective(struct lineplace 
return;
}
skip = len + strspn(line+len, ws);
-   p2.column += skip;
+   place_addcolumns(&p2, skip);
line += skip;
 
len = strlen(line);
@@ -667,10 +668,10 @@ directive_scancomments(const struct line
pos++;
}
if (line[pos] == '\n') {
-   p2.line++;
+   place_addlines(&p2, 1);
p2.column = 0;
} else {
-   p2.column++;
+   place_addcolumns(&p2, 1);
}
}
 
@@ -692,13 +693,13 @@ directive_gotline(struct lineplace *lp, 
if (len > 0 && line[0]

amr64 acpipci(4)

2019-08-20 Thread Mark Kettenis
The Ampere/Lenvo HR330A firmware doesn't set the _TTP bit on the IO
window of its host bridges.  It really should since these bridges
translate memory transactions into io transactions.  But it isn't the
only one that doesn't get this aspect right.  So it is probably best
to ignore _TTP and just assume it converts memory transactions into io
transactions.

ok?


Index: arch/arm64/dev/acpipci.c
===
RCS file: /cvs/src/sys/arch/arm64/dev/acpipci.c,v
retrieving revision 1.12
diff -u -p -r1.12 acpipci.c
--- arch/arm64/dev/acpipci.c30 Jul 2019 21:44:15 -  1.12
+++ arch/arm64/dev/acpipci.c20 Aug 2019 18:43:15 -
@@ -253,8 +253,10 @@ acpipci_parse_resources(int crsidx, unio
sc->sc_mem_trans = at;
break;
case LR_TYPE_IO:
-   if ((tflags & LR_IO_TTP) == 0)
-   return 0;
+   /*
+* Don't check _TTP as various firmwares don't set it,
+* even though they should!!
+*/
extent_free(sc->sc_ioex, min, len, EX_WAITOK);
at = malloc(sizeof(struct acpipci_trans), M_DEVBUF, M_WAITOK);
at->at_iot = sc->sc_iot;



sysctl(2): kern.utc_offset: a successor to the DST/TIMEZONE options(4)

2019-08-20 Thread Scott Cheloha
Hi,

There is interest in keeping support for booting with an RTC running
at an offset from UTC.  The existing DST/TIMEZONE options(4) do not
cooperate with KARL.

So, here's a new sysctl(2) to bridge the gap: kern.utc_offset.

It's an integer representing the RTC's offset from UTC in minutes East
of UTC+0.  I've decided to flip from TIMEZONE's "minutes West" to
"minutes East" because timezone offsets are canonically expressed this
way.  For instance, Japanese Standard Time (JST) is UTC+0900, so the
corresponding kern.utc_offset is 540.  Newfoundland Daylight Time is
allegedly UTC-0230, so the corresponding kern.utc_offset is -150.

The kernel clock is adjusted the moment this is set, as if the current
time on the clock is fresh from the RTC.  To ensure that this assumption
is correct this value should be set in early boot from sysctl.conf(5).
This will apply the correction and jump the kernel clock *before* ntpd(8)
and cron(8) start.

To encourage people to only set this value in early boot it is locked
when kern.securelevel is greater than zero.

Valid inputs range from UTC-2400 to UTC+2400.  Timezones in current
use range from UTC-1200 to UTC+1400.  There is room for timezone
changes in the future without allowing the operator to do something
obviously dumb.

I've added documentation to sysctl.2 and securelevel.7.  The sysctl.2
bits could be a bit better... or maybe briefer?  Still mulling it over.
Should I mention that it ought to be set from sysctl.conf(5)?  I'm also
fumbling with the phrase "in UTC mode".  It isn't quite what I want to
say.

jmc: any ideas?

The FAQ entry on multibooting will need to be updated too.  That will
happen in a separate diff.  I'll talk to the relevant people to sort
it out.

--

ok?

-Scott

Index: lib/libc/sys/sysctl.2
===
RCS file: /cvs/src/lib/libc/sys/sysctl.2,v
retrieving revision 1.29
diff -u -p -r1.29 sysctl.2
--- lib/libc/sys/sysctl.2   11 Aug 2019 16:04:23 -  1.29
+++ lib/libc/sys/sysctl.2   20 Aug 2019 14:17:51 -
@@ -488,6 +488,7 @@ information.
 .It Dv KERN_TIMECOUNTER Ta "node" Ta "not applicable"
 .It Dv KERN_TTY Ta "node" Ta "not applicable"
 .It Dv KERN_TTYCOUNT Ta "integer" Ta "no"
+.It Dv KERN_UTC_OFFSET Ta "integer" Ta "yes"
 .It Dv KERN_VERSION Ta "string" Ta "no"
 .It Dv KERN_WATCHDOG Ta "node" Ta "not applicable"
 .It Dv KERN_WITNESS Ta "node" Ta "not applicable"
@@ -1079,6 +1080,22 @@ Returns the number of input characters i
 Number of available
 .Xr tty 4
 devices.
+.It Dv KERN_UTC_OFFSET Pq Va kern.utc_offset
+The real-time clock's
+.Pq RTC
+offset from
+Coordinated Universal Time
+.Pq UTC
+expressed as minutes East of UTC+0.
+When set,
+time read from the RTC is adjusted to remove the offset
+and time written to the RTC is adjusted to reapply it.
+This may simplify multibooting with an operating system that
+does not run the RTC in UTC mode.
+When running with a
+.Xr securelevel 7
+greater than 0,
+this variable may not be changed.
 .It Dv KERN_VERSION Pq Va kern.version
 The system version string.
 .It Dv KERN_WATCHDOG Pq Va kern.watchdog
Index: share/man/man7/securelevel.7
===
RCS file: /cvs/src/share/man/man7/securelevel.7,v
retrieving revision 1.30
diff -u -p -r1.30 securelevel.7
--- share/man/man7/securelevel.712 Sep 2017 02:22:15 -  1.30
+++ share/man/man7/securelevel.720 Aug 2019 14:17:51 -
@@ -76,6 +76,7 @@ the
 .Va fs.posix.setuid ,
 .Va hw.allowpowerdown ,
 .Va kern.allowkmem ,
+.Va kern.utc_offset ,
 .Va net.inet.ip.sourceroute ,
 and
 .Va machdep.kbdreset
Index: sys/arch/amd64/isa/clock.c
===
RCS file: /cvs/src/sys/arch/amd64/isa/clock.c,v
retrieving revision 1.30
diff -u -p -r1.30 clock.c
--- sys/arch/amd64/isa/clock.c  19 Jul 2019 14:50:43 -  1.30
+++ sys/arch/amd64/isa/clock.c  20 Aug 2019 14:17:51 -
@@ -475,9 +475,7 @@ inittodr(time_t base)
dt.dt_mon = bcdtobin(rtclk[MC_MONTH]);
dt.dt_year = clock_expandyear(bcdtobin(rtclk[MC_YEAR]));
 
-   ts.tv_sec = clock_ymdhms_to_secs(&dt) + tz.tz_minuteswest * 60;
-   if (tz.tz_dsttime)
-   ts.tv_sec -= 3600;
+   ts.tv_sec = clock_ymdhms_to_secs(&dt) - utc_offset;
 
if (base != 0 && base < ts.tv_sec - 5*SECYR)
printf("WARNING: file system time much less than clock time\n");
@@ -506,7 +504,7 @@ resettodr(void)
 {
mc_todregs rtclk;
struct clock_ymdhms dt;
-   int century, diff, s;
+   int century, s;
 
/*
 * We might have been called by boot() due to a crash early
@@ -520,10 +518,7 @@ resettodr(void)
memset(&rtclk, 0, sizeof(rtclk));
splx(s);
 
-   diff = tz.tz_minuteswest * 60;
-   if (tz.tz_dsttime)
-   diff -= 3600;
-   clock_secs_to_ymdhms(time_second - diff, &dt);
+   clock_secs_to_ymdhms(

Re: [PATCH v2] Provide static_ASN1_*(). From OpenSSL 1.1.0 API

2019-08-20 Thread Kinichiro Inoguchi
Hi,

This patch was applied, and thanks for your help.
Sorry for late, since we couldn't have time to review.

On Sat, Aug 17, 2019 at 07:11:28AM +0300, Stefan Strogin wrote:
> v1->v2:
> Use correct static_ASN1_ITEM_start macros instead of ASN1_ITEM_start in
> static_ASN1_SEQUENCE_END_ref definition.
> ---
>  src/lib/libcrypto/asn1/asn1t.h | 62 ++
>  1 file changed, 62 insertions(+)
> 
> diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h
> index ba380bdf4..e0d5bc1f7 100644
> --- a/src/lib/libcrypto/asn1/asn1t.h
> +++ b/src/lib/libcrypto/asn1/asn1t.h
> @@ -81,6 +81,9 @@ extern "C" {
>  #define ASN1_ITEM_start(itname) \
>   const ASN1_ITEM itname##_it = {
>  
> +#define static_ASN1_ITEM_start(itname) \
> + static const ASN1_ITEM itname##_it = {
> +
>  #define ASN1_ITEM_end(itname) \
>   };
>  
> @@ -102,6 +105,17 @@ extern "C" {
>   0,\
>   #tname \
>   ASN1_ITEM_end(tname)
> +#define static_ASN1_ITEM_TEMPLATE_END(tname) \
> + ;\
> + static_ASN1_ITEM_start(tname) \
> + ASN1_ITYPE_PRIMITIVE,\
> + -1,\
> + &tname##_item_tt,\
> + 0,\
> + NULL,\
> + 0,\
> + #tname \
> + ASN1_ITEM_end(tname)
>  
>  
>  /* This is a ASN1 type which just embeds a template */
> @@ -130,6 +144,7 @@ extern "C" {
>   static const ASN1_TEMPLATE tname##_seq_tt[] 
>  
>  #define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
> +#define static_ASN1_SEQUENCE_END(stname) 
> static_ASN1_SEQUENCE_END_name(stname, stname)
>  
>  #define ASN1_SEQUENCE_END_name(stname, tname) \
>   ;\
> @@ -142,6 +157,17 @@ extern "C" {
>   sizeof(stname),\
>   #stname \
>   ASN1_ITEM_end(tname)
> +#define static_ASN1_SEQUENCE_END_name(stname, tname) \
> + ;\
> + static_ASN1_ITEM_start(tname) \
> + ASN1_ITYPE_SEQUENCE,\
> + V_ASN1_SEQUENCE,\
> + tname##_seq_tt,\
> + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
> + NULL,\
> + sizeof(stname),\
> + #stname \
> + ASN1_ITEM_end(tname)
>  
>  #define ASN1_NDEF_SEQUENCE(tname) \
>   ASN1_SEQUENCE(tname)
> @@ -176,12 +202,24 @@ extern "C" {
>   sizeof(tname),\
>   #tname \
>   ASN1_ITEM_end(tname)
> +#define static_ASN1_NDEF_SEQUENCE_END(tname) \
> + ;\
> + static_ASN1_ITEM_start(tname) \
> + ASN1_ITYPE_NDEF_SEQUENCE,\
> + V_ASN1_SEQUENCE,\
> + tname##_seq_tt,\
> + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
> + NULL,\
> + sizeof(tname),\
> + #tname \
> + ASN1_ITEM_end(tname)
>  
>  #define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, 
> stname)
>  
>  #define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, 
> tname)
>  
>  #define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, 
> tname)
> +#define static_ASN1_SEQUENCE_END_cb(stname, tname) 
> static_ASN1_SEQUENCE_END_ref(stname, tname)
>  
>  #define ASN1_SEQUENCE_END_ref(stname, tname) \
>   ;\
> @@ -194,6 +232,17 @@ extern "C" {
>   sizeof(stname),\
>   #stname \
>   ASN1_ITEM_end(tname)
> +#define static_ASN1_SEQUENCE_END_ref(stname, tname) \
> + ;\
> + static_ASN1_ITEM_start(tname) \
> + ASN1_ITYPE_SEQUENCE,\
> + V_ASN1_SEQUENCE,\
> + tname##_seq_tt,\
> + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
> + &tname##_aux,\
> + sizeof(stname),\
> + #stname \
> + ASN1_ITEM_end(tname)
>  
>  #define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
>   ;\
> @@ -238,8 +287,10 @@ extern "C" {
>   ASN1_CHOICE(tname)
>  
>  #define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
> +#define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, 
> stname)
>  
>  #define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, 
> tname, type)
> +#define static_ASN1_CHOICE_END_name(stname, tname) 
> static_ASN1_CHOICE_END_selector(stname, tname, type)
>  
>  #define ASN1_CHOICE_END_selector(stname, tname, selname) \
>   ;\
> @@ -252,6 +303,17 @@ extern "C" {
>   sizeof(stname),\
>   #stname \
>   ASN1_ITEM_end(tname)
> +#define static_ASN1_CHOICE_END_selector(stname, tname, selname) \
> + ;\
> + static_ASN1_ITEM_start(tname) \
> + ASN1_ITYPE_CHOICE,\
> + offsetof(stname,selname) ,\
> + tname##_ch_tt,\
> + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
> + NULL,\
> + sizeof(stname),\
> + #stname \
> + ASN1_ITEM_end(tname)
>  
>  #define ASN1_CHOICE_END_cb(stname, tname, selname) \
>   ;\
> -- 
> 2.22.1
> 



Re: assorted improvements to less.1, more.1

2019-08-20 Thread Jason McIntyre
On Sun, Aug 11, 2019 at 02:18:08PM -0700, Evan Silberman wrote:
> - less(1) should explain what it does before it talks about more(1)
> - reference the COMMANDS section directly when mentioning commands
> - add HISTORY to less.1
> - credit Garret D'Amore in AUTHORS since he is also attributed in the
>   source code as a copyright holder
> - it is false that more(1) can be invoked with the options of less(1)
> 
> Regards,
> Evan Silberman
> 

hi.

a tweaked version of your diff now committed. thanks for the mail,
jmc

> P.S. patch generated with got(1), neat.
> 
> diff 3474c532363343e2e65328f8389848966744ce51 
> 99ab9c189b3b40d7b96cd17ef241b444a0bf456a
> blob - 8e6971c243372003b031bba7e37bc50ff3ab8030
> blob + 44d9b5001fa119c53e0cf27f9e103d23f5e48dc2
> --- usr.bin/less/less.1
> +++ usr.bin/less/less.1
> @@ -48,30 +48,22 @@
>  .Op Ar
>  .Sh DESCRIPTION
>  .Nm
> -is a program similar to the traditional
> -.Xr more 1 ,
> -but with many more features.
> -It displays text one screenful at a time.
> -After showing each screenful, it prompts the user for a command.
> +displays text one screenful at a time.
> +After showing each screenful, it prompts the user for a command,
> +as described in
> +.Sx COMMANDS .
>  When showing the last line of a file,
>  .Nm
>  displays a prompt indicating end of file and the name of the next file
>  to examine, if any.
>  It then waits for input from the user.
>  .Pp
> -Commands are based on both traditional
> -.Xr more 1
> -and
> -.Xr vi 1 .
> -Commands may be preceded by a decimal number,
> -called
> -.Ar N
> -in the descriptions below.
> -The number is used by some commands, as indicated.
> -.Pp
> -This version of
>  .Nm
> -also acts as
> +is similar to the traditional
> +.Xr more 1 ,
> +but with many more features.
> +.Nm
> +will behave like
>  .Xr more 1
>  if it is called as
>  .Nm more ,
> @@ -757,6 +749,14 @@ command described previously
>  may also be used to set (or change) an initial command for every file.
>  .El
>  .Sh COMMANDS
> +Commands are based on both traditional
> +.Xr more 1
> +and
> +.Xr vi 1 .
> +Commands may be preceded by a decimal number,
> +called
> +.Ar N
> +in the descriptions below.
>  In the following descriptions, ^X means control-X.
>  ESC stands for the ESCAPE key; for example ESC-v means the
>  two character sequence "ESCAPE", then "v".
> @@ -1916,5 +1916,16 @@ is used.
>  .Sh SEE ALSO
>  .Xr lesskey 1 ,
>  .Xr more 1
> +.Sh HISTORY
> +Mark Nudelman created
> +.Nm
> +beginning in 1983; it was first published in 1985.
> +.Nm
> +was included in
> +.Ox 2.0 .
> +The present implementation is based on a fork by Garret D'Amore and
> +first appeared in
> +.Ox 5.9 .
>  .Sh AUTHORS
> -.An Mark Nudelman .
> +.An Mark Nudelman Aq Mt ma...@greenwoodsoftware.com
> +.An Garret D'Amore
> blob - 66b4ee23971952e3f9297adf54dc1a5f0276f81b
> blob + e4eba49ed8b04c2a68ae66190cc1273fce350f3d
> --- usr.bin/less/more.1
> +++ usr.bin/less/more.1
> @@ -65,17 +65,6 @@ It then waits for input from the user.
>  Scrolling forward switches to the next file,
>  or exits if there is none.
>  .Pp
> -This version of
> -.Nm
> -is actually
> -.Xr less 1
> -in disguise.
> -As such, it will also accept options documented in
> -.Xr less 1 .
> -This manual page describes only features
> -relevant to a POSIX compliant
> -.Nm .
> -.Pp
>  The options are as follows:
>  .Bl -tag -width Ds
>  .It Fl c
> @@ -318,5 +307,9 @@ A
>  .Nm
>  command appeared in
>  .Bx 3.0 .
> +The present implementation is actually
> +.Xr less 1
> +in disguise.
>  .Sh AUTHORS
>  .An Mark Nudelman Aq Mt ma...@greenwoodsoftware.com
> +.An Garret D'Amore
>