svn commit: r345831 - in head/sys/powerpc: include powerpc

2019-04-02 Thread Justin Hibbits
Author: jhibbits
Date: Wed Apr  3 04:01:08 2019
New Revision: 345831
URL: https://svnweb.freebsd.org/changeset/base/345831

Log:
  powerpc: Allow emulating optional FPU instructions on CPUs with an FPU
  
  The e5500 has an FPU, but lacks the optional fsqrt instruction.  This
  instruction gets emulated in the kernel, but the emulation uses stale data,
  from the last switch out, and does not return the result of the operation
  immediately.  Fix both of these conditions by saving and restoring the FPRs
  around the emulation point.
  
  MFC after:1 week
  MFC with: r345829

Modified:
  head/sys/powerpc/include/trap.h
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/include/trap.h
==
--- head/sys/powerpc/include/trap.h Wed Apr  3 03:57:37 2019
(r345830)
+++ head/sys/powerpc/include/trap.h Wed Apr  3 04:01:08 2019
(r345831)
@@ -152,10 +152,10 @@
 
 #ifndef LOCORE
 struct trapframe;
-struct pcb;
+struct thread;
 extern int (*hmi_handler)(struct trapframe *);
 voidtrap(struct trapframe *);
-intppc_instr_emulate(struct trapframe *, struct pcb *);
+intppc_instr_emulate(struct trapframe *, struct thread *);
 #endif
 
 #endif /* _POWERPC_TRAP_H_ */

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==
--- head/sys/powerpc/powerpc/exec_machdep.c Wed Apr  3 03:57:37 2019
(r345830)
+++ head/sys/powerpc/powerpc/exec_machdep.c Wed Apr  3 04:01:08 2019
(r345831)
@@ -1081,8 +1081,9 @@ emulate_mtspr(int spr, int reg, struct trapframe *fram
 
 #define XFX 0xFC0007FF
 int
-ppc_instr_emulate(struct trapframe *frame, struct pcb *pcb)
+ppc_instr_emulate(struct trapframe *frame, struct thread *td)
 {
+   struct pcb *pcb;
uint32_t instr;
int reg, sig;
int rs, spr;
@@ -1109,12 +1110,16 @@ ppc_instr_emulate(struct trapframe *frame, struct pcb 
return (0);
}
 
+   pcb = td->td_pcb;
 #ifdef FPU_EMU
if (!(pcb->pcb_flags & PCB_FPREGS)) {
bzero(&pcb->pcb_fpu, sizeof(pcb->pcb_fpu));
pcb->pcb_flags |= PCB_FPREGS;
-   }
+   } else if (pcb->pcb_flags & PCB_FPU)
+   save_fpu(td);
sig = fpu_emulate(frame, &pcb->pcb_fpu);
+   if ((sig == 0 || sig == SIGFPE) && pcb->pcb_flags & PCB_FPU)
+   enable_fpu(td);
 #endif
if (sig == SIGILL) {
if (pcb->pcb_lastill != frame->srr0) {

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Wed Apr  3 03:57:37 2019
(r345830)
+++ head/sys/powerpc/powerpc/trap.c Wed Apr  3 04:01:08 2019
(r345831)
@@ -363,7 +363,7 @@ trap(struct trapframe *frame)
sig = SIGTRAP;
ucode = TRAP_BRKPT;
} else {
-   sig = ppc_instr_emulate(frame, td->td_pcb);
+   sig = ppc_instr_emulate(frame, td);
if (sig == SIGILL) {
if (frame->srr1 & EXC_PGM_PRIV)
ucode = ILL_PRVOPC;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345830 - in head: lib/libsecureboot lib/libsecureboot/h share/mk stand stand/common sys/conf sys/security/mac_veriexec_parser tools/build/options

2019-04-02 Thread Marcin Wojtas
Author: mw
Date: Wed Apr  3 03:57:37 2019
New Revision: 345830
URL: https://svnweb.freebsd.org/changeset/base/345830

Log:
  Create kernel module to parse Veriexec manifest based on envs
  
  The current approach of injecting manifest into mac_veriexec is to
  verify the integrity of it in userspace (veriexec (8)) and pass its
  entries into kernel using a char device (/dev/veriexec).
  This requires verifying root partition integrity in loader,
  for example by using memory disk and checking its hash.
  Otherwise if rootfs is compromised an attacker could inject their own data.
  
  This patch introduces an option to parse manifest in kernel based on envs.
  The loader sets manifest path and digest.
  EVENTHANDLER is used to launch the module right after the rootfs is mounted.
  It has to be done this way, since one might want to verify integrity of the 
init file.
  This means that manifest is required to be present on the root partition.
  Note that the envs have to be set right before boot to make sure that no one 
can spoof them.
  
  Submitted by: Kornel Duleba 
  Reviewed by: sjg
  Obtained from: Semihalf
  Sponsored by: Stormshield
  Differential Revision: https://reviews.freebsd.org/D19281

Added:
  head/lib/libsecureboot/pass_manifest.c   (contents, props changed)
  head/sys/security/mac_veriexec_parser/
  head/sys/security/mac_veriexec_parser/mac_veriexec_parser.c   (contents, 
props changed)
  head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST   (contents, 
props changed)
Modified:
  head/lib/libsecureboot/Makefile.libsa.inc
  head/lib/libsecureboot/h/verify_file.h
  head/lib/libsecureboot/libsecureboot-priv.h
  head/lib/libsecureboot/verify_file.c
  head/share/mk/src.opts.mk
  head/stand/common/boot.c
  head/stand/common/module.c
  head/stand/loader.mk
  head/sys/conf/files

Modified: head/lib/libsecureboot/Makefile.libsa.inc
==
--- head/lib/libsecureboot/Makefile.libsa.inc   Wed Apr  3 03:54:30 2019
(r345829)
+++ head/lib/libsecureboot/Makefile.libsa.inc   Wed Apr  3 03:57:37 2019
(r345830)
@@ -29,6 +29,11 @@ CFLAGS+= \
-I${SRCTOP}/stand/efi/include/${MACHINE}
 .endif
 
+.if ${MK_LOADER_VERIEXEC_PASS_MANIFEST} == "yes"
+SRCS+= \
+   pass_manifest.c
+.endif
+
 # this is the list of paths (relative to a file
 # that we need to verify) used to find a signed manifest.
 # the signature extensions in VE_SIGNATURE_EXT_LIST

Modified: head/lib/libsecureboot/h/verify_file.h
==
--- head/lib/libsecureboot/h/verify_file.h  Wed Apr  3 03:54:30 2019
(r345829)
+++ head/lib/libsecureboot/h/verify_file.h  Wed Apr  3 03:57:37 2019
(r345830)
@@ -32,6 +32,7 @@
 #define VE_WANT 1/* we want this verified */
 #define VE_MUST 2/* this must be verified */
 
+#define VE_NOT_CHECKED -42
 #define VE_VERIFIED 1/* all good */
 #define VE_UNVERIFIED_OK 0   /* not verified but that's ok */
 #define VE_NOT_VERIFYING 2  /* we are not verifying */
@@ -42,6 +43,8 @@ voidve_debug_set(int);
 int ve_status_get(int);
 voidve_efi_init(void);
 int load_manifest(const char *, const char *, const char *, struct stat *);
+int pass_manifest(const char *, const char *);
+int pass_manifest_export_envs(void);
 int verify_file(int, const char *, off_t, int);
 voidverify_pcr_export(void);
 

Modified: head/lib/libsecureboot/libsecureboot-priv.h
==
--- head/lib/libsecureboot/libsecureboot-priv.h Wed Apr  3 03:54:30 2019
(r345829)
+++ head/lib/libsecureboot/libsecureboot-priv.h Wed Apr  3 03:57:37 2019
(r345830)
@@ -31,6 +31,8 @@
 /* public api */
 #include "libsecureboot.h"
 
+struct stat;
+
 typedef struct {
unsigned char   *data;
size_t  hash_size;
@@ -49,6 +51,9 @@ int verify_rsa_digest(br_rsa_public_key *pkey,
 const unsigned char *hash_oid,
 unsigned char *mdata, size_t mlen,
 unsigned char *sdata, size_t slen);
+
+int is_verified(struct stat *stp);
+void add_verify_status(struct stat *stp, int status);
 
 int openpgp_self_tests(void);
 

Added: head/lib/libsecureboot/pass_manifest.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libsecureboot/pass_manifest.c  Wed Apr  3 03:57:37 2019
(r345830)
@@ -0,0 +1,152 @@
+/*-
+ * Copyright (c) 2019 Stormshield.
+ * Copyright (c) 2019 Semihalf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+

svn commit: r345829 - head/sys/powerpc/fpu

2019-04-02 Thread Justin Hibbits
Author: jhibbits
Date: Wed Apr  3 03:54:30 2019
New Revision: 345829
URL: https://svnweb.freebsd.org/changeset/base/345829

Log:
  powerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt
  
  This fix was committed less than 2 months after the code was forked into the
  powerpc kernel.  Though powerpc doesn't use quad-precision floating point,
  or need it for emulation, the changes do look like correctness fixes
  overall.
  
  This was found while trying to get fsqrt emulation working on e5500, which
  does have a real FPU, but lacks the fsqrt instruction.  This is not the
  complete fix, the rest is to be committed separately.
  
  MFC after:1 week

Modified:
  head/sys/powerpc/fpu/fpu_sqrt.c

Modified: head/sys/powerpc/fpu/fpu_sqrt.c
==
--- head/sys/powerpc/fpu/fpu_sqrt.c Wed Apr  3 03:50:16 2019
(r345828)
+++ head/sys/powerpc/fpu/fpu_sqrt.c Wed Apr  3 03:54:30 2019
(r345829)
@@ -353,7 +353,7 @@ fpu_sqrt(struct fpemu *fe)
FPU_SUBC(d0, x0, t0);
if ((int)d0 >= 0) {
x0 = d0, x1 = d1, x2 = d2;
-   q |= bit;
+   q = bit;
y1 |= 1;/* now t1, y1 are set in concrete */
}
ODD_DOUBLE;
@@ -385,12 +385,12 @@ fpu_sqrt(struct fpemu *fe)
FPU_SUBCS(d2, x2, t2);
FPU_SUBCS(d1, x1, t1);
FPU_SUBC(d0, x0, t0);
-   ODD_DOUBLE;
if ((int)d0 >= 0) {
-   x0 = d0, x1 = d1, x2 = d2;
-   q |= bit;
+   x0 = d0, x1 = d1, x2 = d2; x3 = d3;
+   q = bit;
y2 |= 1;
}
+   ODD_DOUBLE;
while ((bit >>= 1) != 0) {
EVEN_DOUBLE;
t3 = y3 | bit;
@@ -399,7 +399,7 @@ fpu_sqrt(struct fpemu *fe)
FPU_SUBCS(d1, x1, t1);
FPU_SUBC(d0, x0, t0);
if ((int)d0 >= 0) {
-   x0 = d0, x1 = d1, x2 = d2;
+   x0 = d0, x1 = d1, x2 = d2; x3 = d3;
q |= bit;
y3 |= bit << 1;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345828 - head/sys/rpc/rpcsec_gss

2019-04-02 Thread Rick Macklem
Author: rmacklem
Date: Wed Apr  3 03:50:16 2019
New Revision: 345828
URL: https://svnweb.freebsd.org/changeset/base/345828

Log:
  Add a comment to the r345818 patch to explain why cl_refs is initialized to 2.
  
  PR:   235582
  MFC after:2 weeks

Modified:
  head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c

Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
==
--- head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.cWed Apr  3 03:30:57 2019
(r345827)
+++ head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.cWed Apr  3 03:50:16 2019
(r345828)
@@ -568,6 +568,11 @@ svc_rpc_gss_create_client(void)
 
client = mem_alloc(sizeof(struct svc_rpc_gss_client));
memset(client, 0, sizeof(struct svc_rpc_gss_client));
+
+   /*
+* Set the initial value of cl_refs to two.  One for the caller
+* and the other to hold onto the client structure until it expires.
+*/
refcount_init(&client->cl_refs, 2);
sx_init(&client->cl_lock, "GSS-client");
getcredhostid(curthread->td_ucred, &hostid);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345804 - head/usr.bin/systat

2019-04-02 Thread Rodney W. Grimes
> Hi,
> 
> On Tue, 2 Apr 2019 07:08:17 -0700 (PDT)
> "Rodney W. Grimes"  wrote:
> 
> > > Author: mr
> > > Date: Tue Apr  2 14:01:03 2019
> > > New Revision: 345804
> > > URL: https://svnweb.freebsd.org/changeset/base/345804
> > > 
> > > Log:
> > >   systat -zarc to display disk activities like -vm
> > >   
> > >   PR: 213310
> > >   Submitted by:   ota
> > >   MFH:4 weeks
> > 
> > ? MFC:
> > 
> > >   Differential Revision:  https://reviews.freebsd.org/D18726
> > > 
> > > Modified:
> > >   head/usr.bin/systat/devs.c
> > >   head/usr.bin/systat/devs.h
> > >   head/usr.bin/systat/iostat.c
> > >   head/usr.bin/systat/swap.c
> > >   head/usr.bin/systat/systat.h
> > >   head/usr.bin/systat/vmstat.c
> > >   head/usr.bin/systat/zarc.c
> > > 
> > > Modified: head/usr.bin/systat/devs.c
> > > ==
> > > --- head/usr.bin/systat/devs.cTue Apr  2 13:59:04 2019
> > > (r345803)
> > > +++ head/usr.bin/systat/devs.cTue Apr  2 14:01:03 2019
> > > (r345804)
> > > @@ -2,6 +2,7 @@
> > >   * SPDX-License-Identifier: BSD-3-Clause
> > >   *
> > >   * Copyright (c) 1998 Kenneth D. Merry.
> > > + *   2015 Yoshihiro Ota
> > >   * All rights reserved.
> > 
> > 
> > Can we get in contact with Yoshihiro Ota about his
> > copyright statements, and correcting this to make
> > it clear that it is Kenneth D. Merry that is asserting
> > "All rights reserved" and if Ota does nor does not wish to assert
> > "All rights reserved".
> > 
> > As committed this makes a grey area on Kenneth's assertion,
> > also leaving out the word copyright on Yoshihiro's line is a bit iffy.
> > 
> > I am only commenting once, this issue appears several times.
> > We can go back out to D18726 to discuss it if need be.
> 
> I've fully written zarc.c (and copied copy-right section from another file)
> but all other changes in other files are refactoring and adjustments.
> 
> I don't know the policy/procedure of how to update copy right section of 
> FreeBSD.
> Please adjust them according the project.
> 
> Regards,
> Hiro
> 

I'll create a review with you as a reviewer that
takes what I believe is the appropriate steps,
and seek your approval for changes to your copyright statements.

-- 
Rod Grimes rgri...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345804 - head/usr.bin/systat

2019-04-02 Thread Yoshihiro Ota
Hi,

On Tue, 2 Apr 2019 07:08:17 -0700 (PDT)
"Rodney W. Grimes"  wrote:

> > Author: mr
> > Date: Tue Apr  2 14:01:03 2019
> > New Revision: 345804
> > URL: https://svnweb.freebsd.org/changeset/base/345804
> > 
> > Log:
> >   systat -zarc to display disk activities like -vm
> >   
> >   PR:   213310
> >   Submitted by: ota
> >   MFH:  4 weeks
> 
> ? MFC:
> 
> >   Differential Revision:https://reviews.freebsd.org/D18726
> > 
> > Modified:
> >   head/usr.bin/systat/devs.c
> >   head/usr.bin/systat/devs.h
> >   head/usr.bin/systat/iostat.c
> >   head/usr.bin/systat/swap.c
> >   head/usr.bin/systat/systat.h
> >   head/usr.bin/systat/vmstat.c
> >   head/usr.bin/systat/zarc.c
> > 
> > Modified: head/usr.bin/systat/devs.c
> > ==
> > --- head/usr.bin/systat/devs.c  Tue Apr  2 13:59:04 2019
> > (r345803)
> > +++ head/usr.bin/systat/devs.c  Tue Apr  2 14:01:03 2019
> > (r345804)
> > @@ -2,6 +2,7 @@
> >   * SPDX-License-Identifier: BSD-3-Clause
> >   *
> >   * Copyright (c) 1998 Kenneth D. Merry.
> > + *   2015 Yoshihiro Ota
> >   * All rights reserved.
> 
> 
> Can we get in contact with Yoshihiro Ota about his
> copyright statements, and correcting this to make
> it clear that it is Kenneth D. Merry that is asserting
> "All rights reserved" and if Ota does nor does not wish to assert
> "All rights reserved".
> 
> As committed this makes a grey area on Kenneth's assertion,
> also leaving out the word copyright on Yoshihiro's line is a bit iffy.
> 
> I am only commenting once, this issue appears several times.
> We can go back out to D18726 to discuss it if need be.

I've fully written zarc.c (and copied copy-right section from another file)
but all other changes in other files are refactoring and adjustments.

I don't know the policy/procedure of how to update copy right section of 
FreeBSD.
Please adjust them according the project.

Regards,
Hiro
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345818 - head/sys/rpc/rpcsec_gss

2019-04-02 Thread Rick Macklem
Author: rmacklem
Date: Tue Apr  2 23:51:08 2019
New Revision: 345818
URL: https://svnweb.freebsd.org/changeset/base/345818

Log:
  Fix a race in the RPCSEC_GSS server code that caused crashes.
  
  When a new client structure was allocated, it was added to the list
  so that it was visible to other threads before the expiry time was
  initialized, with only a single reference count.
  The caller would increment the reference count, but it was possible
  for another thread to decrement the reference count to zero and free
  the structure before the caller incremented the reference count.
  This could occur because the expiry time was still set to zero when
  the new client structure was inserted in the list and the list was
  unlocked.
  
  This patch fixes the race by initializing the reference count to two
  and initializing all fields, including the expiry time, before inserting
  it in the list.
  
  Tested by:pe...@ifm.liu.se
  PR:   235582
  MFC after:2 weeks

Modified:
  head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c

Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
==
--- head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.cTue Apr  2 20:27:56 2019
(r345817)
+++ head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.cTue Apr  2 23:51:08 2019
(r345818)
@@ -568,19 +568,13 @@ svc_rpc_gss_create_client(void)
 
client = mem_alloc(sizeof(struct svc_rpc_gss_client));
memset(client, 0, sizeof(struct svc_rpc_gss_client));
-   refcount_init(&client->cl_refs, 1);
+   refcount_init(&client->cl_refs, 2);
sx_init(&client->cl_lock, "GSS-client");
getcredhostid(curthread->td_ucred, &hostid);
client->cl_id.ci_hostid = hostid;
getboottime(&boottime);
client->cl_id.ci_boottime = boottime.tv_sec;
client->cl_id.ci_id = svc_rpc_gss_next_clientid++;
-   list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % 
svc_rpc_gss_client_hash_size];
-   sx_xlock(&svc_rpc_gss_lock);
-   TAILQ_INSERT_HEAD(list, client, cl_link);
-   TAILQ_INSERT_HEAD(&svc_rpc_gss_clients, client, cl_alllink);
-   svc_rpc_gss_client_count++;
-   sx_xunlock(&svc_rpc_gss_lock);
 
/*
 * Start the client off with a short expiration time. We will
@@ -590,6 +584,12 @@ svc_rpc_gss_create_client(void)
client->cl_locked = FALSE;
client->cl_expiration = time_uptime + 5*60;
 
+   list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % 
svc_rpc_gss_client_hash_size];
+   sx_xlock(&svc_rpc_gss_lock);
+   TAILQ_INSERT_HEAD(list, client, cl_link);
+   TAILQ_INSERT_HEAD(&svc_rpc_gss_clients, client, cl_alllink);
+   svc_rpc_gss_client_count++;
+   sx_xunlock(&svc_rpc_gss_lock);
return (client);
 }
 
@@ -1287,7 +1287,6 @@ svc_rpc_gss(struct svc_req *rqst, struct rpc_msg *msg)
goto out;
}
client = svc_rpc_gss_create_client();
-   refcount_acquire(&client->cl_refs);
} else {
struct svc_rpc_gss_clientid *p;
if (gc.gc_handle.length != sizeof(*p)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345817 - in head/sys: cam/nvme conf

2019-04-02 Thread Alexander Motin
Author: mav
Date: Tue Apr  2 20:27:56 2019
New Revision: 345817
URL: https://svnweb.freebsd.org/changeset/base/345817

Log:
  Build NVMe CAM transport unrelated to NVMe SIM.
  
  Before this I suppose it was impossible load CAM-based NVMe as module.
  Plus this appeared to be needed to build r345815 without NVMe driver.
  
  MFC after:2 weeks

Modified:
  head/sys/cam/nvme/nvme_da.c
  head/sys/conf/files

Modified: head/sys/cam/nvme/nvme_da.c
==
--- head/sys/cam/nvme/nvme_da.c Tue Apr  2 20:03:03 2019(r345816)
+++ head/sys/cam/nvme/nvme_da.c Tue Apr  2 20:27:56 2019(r345817)
@@ -770,10 +770,6 @@ ndaregister(struct cam_periph *periph, void *arg)
softc->quirks = quirks;
cam_iosched_set_sort_queue(softc->cam_iosched, 0);
softc->disk = disk = disk_alloc();
-   strlcpy(softc->disk->d_descr, cd->mn,
-   MIN(sizeof(softc->disk->d_descr), sizeof(cd->mn)));
-   strlcpy(softc->disk->d_ident, cd->sn,
-   MIN(sizeof(softc->disk->d_ident), sizeof(cd->sn)));
disk->d_rotation_rate = DISK_RR_NON_ROTATING;
disk->d_open = ndaopen;
disk->d_close = ndaclose;
@@ -812,9 +808,9 @@ ndaregister(struct cam_periph *periph, void *arg)
 * d_ident and d_descr are both far bigger than the length of either
 *  the serial or model number strings.
 */
-   nvme_strvis(disk->d_descr, cd->mn,
+   cam_strvis(disk->d_descr, cd->mn,
sizeof(disk->d_descr), NVME_MODEL_NUMBER_LENGTH);
-   nvme_strvis(disk->d_ident, cd->sn,
+   cam_strvis(disk->d_ident, cd->sn,
sizeof(disk->d_ident), NVME_SERIAL_NUMBER_LENGTH);
disk->d_hba_vendor = cpi.hba_vendor;
disk->d_hba_device = cpi.hba_device;

Modified: head/sys/conf/files
==
--- head/sys/conf/files Tue Apr  2 20:03:03 2019(r345816)
+++ head/sys/conf/files Tue Apr  2 20:27:56 2019(r345817)
@@ -86,9 +86,9 @@ cam/cam_xpt.c optional scbus
 cam/ata/ata_all.c  optional scbus
 cam/ata/ata_xpt.c  optional scbus
 cam/ata/ata_pmp.c  optional scbus
-cam/nvme/nvme_all.coptional scbus nvme
-cam/nvme/nvme_da.c optional scbus nvme da
-cam/nvme/nvme_xpt.coptional scbus nvme
+cam/nvme/nvme_all.coptional scbus
+cam/nvme/nvme_da.c optional nda | da
+cam/nvme/nvme_xpt.coptional scbus
 cam/scsi/scsi_xpt.coptional scbus
 cam/scsi/scsi_all.coptional scbus
 cam/scsi/scsi_cd.c optional cd
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345816 - head/share/man/man4

2019-04-02 Thread Guangyuan Yang
Author: ygy (doc committer)
Date: Tue Apr  2 20:03:03 2019
New Revision: 345816
URL: https://svnweb.freebsd.org/changeset/base/345816

Log:
  Correct SMC definition in asmc(4) man page.
  
  MFC after:3 days
  PR:   236954
  Submitted by: fbsdbu...@sentry.org

Modified:
  head/share/man/man4/asmc.4

Modified: head/share/man/man4/asmc.4
==
--- head/share/man/man4/asmc.4  Tue Apr  2 19:37:52 2019(r345815)
+++ head/share/man/man4/asmc.4  Tue Apr  2 20:03:03 2019(r345816)
@@ -25,12 +25,12 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 27, 2009
+.Dd April 2, 2019
 .Dt ASMC 4
 .Os
 .Sh NAME
 .Nm asmc
-.Nd device driver for the Apple System Management Console (SMC)
+.Nd device driver for the Apple System Management Controller (SMC)
 .Sh SYNOPSIS
 To compile this driver into the kernel, place the following line in your
 kernel configuration file:
@@ -47,7 +47,7 @@ asmc_load="YES"
 .Sh DESCRIPTION
 The
 .Nm
-driver controls the Apple System Management Console (SMC for short)
+driver controls the Apple System Management Controller (SMC for short)
 found on Intel Apple systems.
 .Pp
 The SMC is known to be found on the following systems:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345815 - in head: lib/libcam sys/cam sys/cam/nvme

2019-04-02 Thread Alexander Motin
Author: mav
Date: Tue Apr  2 19:37:52 2019
New Revision: 345815
URL: https://svnweb.freebsd.org/changeset/base/345815

Log:
  Make cam_error_print() decode NVMe commands.
  
  MFC after:2 weeks

Modified:
  head/lib/libcam/Makefile
  head/sys/cam/cam.c
  head/sys/cam/nvme/nvme_all.c
  head/sys/cam/nvme/nvme_all.h
  head/sys/cam/nvme/nvme_xpt.c

Modified: head/lib/libcam/Makefile
==
--- head/lib/libcam/MakefileTue Apr  2 19:20:55 2019(r345814)
+++ head/lib/libcam/MakefileTue Apr  2 19:37:52 2019(r345815)
@@ -4,7 +4,7 @@ PACKAGE=lib${LIB}
 LIB=   cam
 SHLIBDIR?= /lib
 SRCS=  camlib.c scsi_cmdparse.c scsi_all.c scsi_da.c scsi_sa.c cam.c \
-   ata_all.c smp_all.c
+   ata_all.c nvme_all.c smp_all.c
 INCS=  camlib.h
 
 LIBADD=sbuf
@@ -38,6 +38,7 @@ MLINKS+=  cam.3 cam_open_device.3 \
 
 .PATH: ${SRCTOP}/sys/cam \
${SRCTOP}/sys/cam/ata \
+   ${SRCTOP}/sys/cam/nvme \
${SRCTOP}/sys/cam/mmc \
${SRCTOP}/sys/cam/scsi
 

Modified: head/sys/cam/cam.c
==
--- head/sys/cam/cam.c  Tue Apr  2 19:20:55 2019(r345814)
+++ head/sys/cam/cam.c  Tue Apr  2 19:37:52 2019(r345815)
@@ -415,7 +415,6 @@ cam_error_string(struct cam_device *device, union ccb 
switch (ccb->ccb_h.func_code) {
case XPT_ATA_IO:
ata_command_sbuf(&ccb->ataio, &sb);
-   sbuf_printf(&sb, "\n");
break;
case XPT_SCSI_IO:
 #ifdef _KERNEL
@@ -423,17 +422,22 @@ cam_error_string(struct cam_device *device, union ccb 
 #else /* !_KERNEL */
scsi_command_string(device, &ccb->csio, &sb);
 #endif /* _KERNEL/!_KERNEL */
-   sbuf_printf(&sb, "\n");
break;
case XPT_SMP_IO:
smp_command_sbuf(&ccb->smpio, &sb, path_str, 79 -
 strlen(path_str), (proto_flags &
 CAM_ESMF_PRINT_FULL_CMD) ? 79 : 0);
-   sbuf_printf(&sb, "\n");
break;
+   case XPT_NVME_IO:
+   case XPT_NVME_ADMIN:
+   nvme_command_sbuf(&ccb->nvmeio, &sb);
+   break;
default:
+   sbuf_printf(&sb, "CAM func %#x",
+   ccb->ccb_h.func_code);
break;
}
+   sbuf_printf(&sb, "\n");
}
 
if (flags & CAM_ESF_CAM_STATUS) {

Modified: head/sys/cam/nvme/nvme_all.c
==
--- head/sys/cam/nvme/nvme_all.cTue Apr  2 19:20:55 2019
(r345814)
+++ head/sys/cam/nvme/nvme_all.cTue Apr  2 19:37:52 2019
(r345815)
@@ -111,37 +111,84 @@ nvme_opc2str[] = {
"COMPARE",
"RSVD-6",
"RSVD-7",
-   "DATASET_MANAGEMENT"
+   "WRITE_ZEROES",
+   "DATASET_MANAGEMENT",
+   "RSVD-a",
+   "RSVD-b",
+   "RSVD-c",
+   "RESERVATION_REGISTER",
+   "RESERVATION_REPORT",
+   "RSVD-f",
+   "RSVD-10",
+   "RESERVATION_ACQUIRE",
+   "RSVD-12",
+   "RSVD-13",
+   "RSVD-14",
+   "RESERVATION_RELEASE",
 };
 
 const char *
-nvme_op_string(const struct nvme_command *cmd)
+nvme_op_string(const struct nvme_command *cmd, int admin)
 {
 
-   if (cmd->opc >= nitems(nvme_opc2str))
-   return "UNKNOWN";
-
-   return nvme_opc2str[cmd->opc];
+   if (admin) {
+   return "ADMIN";
+   } else {
+   if (cmd->opc >= nitems(nvme_opc2str))
+   return "UNKNOWN";
+   return nvme_opc2str[cmd->opc];
+   }
 }
 
 const char *
 nvme_cmd_string(const struct nvme_command *cmd, char *cmd_string, size_t len)
 {
+   struct sbuf sb;
+   int error;
 
+   if (len == 0)
+   return ("");
+
+   sbuf_new(&sb, cmd_string, len, SBUF_FIXEDLEN);
+   nvme_cmd_sbuf(cmd, &sb);
+
+   error = sbuf_finish(&sb);
+   if (error != 0 && error != ENOMEM)
+   return ("");
+
+   return(sbuf_data(&sb));
+}
+
+void
+nvme_cmd_sbuf(const struct nvme_command *cmd, struct sbuf *sb)
+{
+
/*
 * cid, rsvd areas and mptr not printed, since they are used
 * only internally by the SIM.
 */
-   snprintf(cmd_string, len,
+   sbuf_printf(sb,
"opc=%x fuse=%x nsid=%x prp1=%llx prp2=%llx cdw=%x %x %x %x %x %x",
cmd->opc, cmd->fuse, cmd->nsid,
(unsigned long long)cmd->prp1, (unsigned long long)cmd->prp2,
cmd->cdw10, cmd->cdw11, cmd->cdw12,
cmd->cdw13, cmd-

svn commit: r345813 - head/sys/dev/ioat

2019-04-02 Thread Tycho Nightingale
Author: tychon
Date: Tue Apr  2 19:08:06 2019
New Revision: 345813
URL: https://svnweb.freebsd.org/changeset/base/345813

Log:
  ioat(4) should use bus_dma(9) for the operation source and destination
  addresses
  
  Reviewed by:  cem
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D19725

Modified:
  head/sys/dev/ioat/ioat.c
  head/sys/dev/ioat/ioat_internal.h

Modified: head/sys/dev/ioat/ioat.c
==
--- head/sys/dev/ioat/ioat.cTue Apr  2 19:06:25 2019(r345812)
+++ head/sys/dev/ioat/ioat.cTue Apr  2 19:08:06 2019(r345813)
@@ -320,10 +320,26 @@ err:
return (error);
 }
 
+static inline int
+ioat_bus_dmamap_destroy(struct ioat_softc *ioat, const char *func,
+bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+   int error;
+
+   error = bus_dmamap_destroy(dmat, map);
+   if (error != 0) {
+   ioat_log_message(0,
+   "%s: bus_dmamap_destroy failed %d\n", func, error);
+   }
+
+   return (error);
+}
+
 static int
 ioat_detach(device_t device)
 {
struct ioat_softc *ioat;
+   int i, error;
 
ioat = DEVICE2SOFTC(device);
 
@@ -359,6 +375,47 @@ ioat_detach(device_t device)
bus_release_resource(device, SYS_RES_MEMORY,
ioat->pci_resource_id, ioat->pci_resource);
 
+   if (ioat->data_tag != NULL) {
+   for (i = 0; i < 1 << ioat->ring_size_order; i++) {
+   error = ioat_bus_dmamap_destroy(ioat, __func__,
+   ioat->data_tag, ioat->ring[i].src_dmamap);
+   if (error != 0)
+   return (error);
+   }
+   for (i = 0; i < 1 << ioat->ring_size_order; i++) {
+   error = ioat_bus_dmamap_destroy(ioat, __func__,
+   ioat->data_tag, ioat->ring[i].dst_dmamap);
+   if (error != 0)
+   return (error);
+   }
+
+   for (i = 0; i < 1 << ioat->ring_size_order; i++) {
+   error = ioat_bus_dmamap_destroy(ioat, __func__,
+   ioat->data_tag, ioat->ring[i].src2_dmamap);
+   if (error != 0)
+   return (error);
+   }
+   for (i = 0; i < 1 << ioat->ring_size_order; i++) {
+   error = ioat_bus_dmamap_destroy(ioat, __func__,
+   ioat->data_tag, ioat->ring[i].dst2_dmamap);
+   if (error != 0)
+   return (error);
+   }
+
+   bus_dma_tag_destroy(ioat->data_tag);
+   }
+
+   if (ioat->data_crc_tag != NULL) {
+   for (i = 0; i < 1 << ioat->ring_size_order; i++) {
+   error = ioat_bus_dmamap_destroy(ioat, __func__,
+   ioat->data_crc_tag, ioat->ring[i].crc_dmamap);
+   if (error != 0)
+   return (error);
+   }
+
+   bus_dma_tag_destroy(ioat->data_crc_tag);
+   }
+
if (ioat->ring != NULL)
ioat_free_ring(ioat, 1 << ioat->ring_size_order, ioat->ring);
 
@@ -523,6 +580,25 @@ ioat3_attach(device_t device)
 
ioat->hw_desc_ring = hw_desc;
 
+   error = bus_dma_tag_create(bus_get_dma_tag(ioat->device),
+   1, 0, BUS_SPACE_MAXADDR_40BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+   ioat->max_xfer_size, 1, ioat->max_xfer_size, 0, NULL, NULL,
+   &ioat->data_crc_tag);
+   if (error != 0) {
+   ioat_log_message(0, "%s: bus_dma_tag_create failed %d\n",
+   __func__, error);
+   return (error);
+   }
+
+   error = bus_dma_tag_create(bus_get_dma_tag(ioat->device),
+   1, 0, BUS_SPACE_MAXADDR_48BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+   ioat->max_xfer_size, 1, ioat->max_xfer_size, 0, NULL, NULL,
+   &ioat->data_tag);
+   if (error != 0) {
+   ioat_log_message(0, "%s: bus_dma_tag_create failed %d\n",
+   __func__, error);
+   return (error);
+   }
ioat->ring = malloc(num_descriptors * sizeof(*ring), M_IOAT,
M_ZERO | M_WAITOK);
 
@@ -530,6 +606,46 @@ ioat3_attach(device_t device)
for (i = 0; i < num_descriptors; i++) {
memset(&ring[i].bus_dmadesc, 0, sizeof(ring[i].bus_dmadesc));
ring[i].id = i;
+   error = bus_dmamap_create(ioat->data_tag, 0,
+&ring[i].src_dmamap);
+   if (error != 0) {
+   ioat_log_message(0,
+   "%s: bus_dmamap_create failed %d\n", __func__,
+   error);
+   return (error);
+   }
+   error = bus_dmamap_create(ioat->data_t

svn commit: r345812 - in head: sys/dev/ioat tools/tools/ioat

2019-04-02 Thread Tycho Nightingale
Author: tychon
Date: Tue Apr  2 19:06:25 2019
New Revision: 345812
URL: https://svnweb.freebsd.org/changeset/base/345812

Log:
  ioatcontrol(8) could exercise 8k-aligned copy with page-break, crc and
  crc-copy modes.
  
  Reviewed by:  cem
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D19780

Modified:
  head/sys/dev/ioat/ioat_test.c
  head/sys/dev/ioat/ioat_test.h
  head/tools/tools/ioat/ioatcontrol.8
  head/tools/tools/ioat/ioatcontrol.c

Modified: head/sys/dev/ioat/ioat_test.c
==
--- head/sys/dev/ioat/ioat_test.c   Tue Apr  2 18:50:49 2019
(r345811)
+++ head/sys/dev/ioat/ioat_test.c   Tue Apr  2 19:06:25 2019
(r345812)
@@ -65,6 +65,7 @@ struct test_transaction {
void*buf[IOAT_MAX_BUFS];
uint32_tlength;
uint32_tdepth;
+   uint32_tcrc[IOAT_MAX_BUFS];
struct ioat_test*test;
TAILQ_ENTRY(test_transaction)   entry;
 };
@@ -312,6 +313,28 @@ ioat_test_submit_1_tx(struct ioat_test *test, bus_dmae
 
desc = ioat_copy_8k_aligned(dma, dest, dst2, src, src2,
cb, tx, flags);
+   } else if (test->testkind == IOAT_TEST_DMA_8K_PB) {
+   bus_addr_t src2, dst2;
+
+   src2 = vtophys((vm_offset_t)tx->buf[2*i+1] + PAGE_SIZE);
+   dst2 = vtophys((vm_offset_t)tx->buf[2*i] + PAGE_SIZE);
+
+   desc = ioat_copy_8k_aligned(dma, dest, dst2, src, src2,
+   cb, tx, flags);
+   } else if (test->testkind == IOAT_TEST_DMA_CRC) {
+   bus_addr_t crc;
+
+   tx->crc[i] = 0;
+   crc = vtophys((vm_offset_t)&tx->crc[i]);
+   desc = ioat_crc(dma, src, tx->length,
+   NULL, crc, cb, tx, flags | DMA_CRC_STORE);
+   } else if (test->testkind == IOAT_TEST_DMA_CRC_COPY) {
+   bus_addr_t crc;
+
+   tx->crc[i] = 0;
+   crc = vtophys((vm_offset_t)&tx->crc[i]);
+   desc = ioat_copy_crc(dma, dest, src, tx->length,
+   NULL, crc, cb, tx, flags | DMA_CRC_STORE);
}
if (desc == NULL)
break;
@@ -346,7 +369,8 @@ ioat_dma_test(void *arg)
test = arg;
memset(__DEVOLATILE(void *, test->status), 0, sizeof(test->status));
 
-   if (test->testkind == IOAT_TEST_DMA_8K &&
+   if ((test->testkind == IOAT_TEST_DMA_8K ||
+   test->testkind == IOAT_TEST_DMA_8K_PB) &&
test->buffer_size != 2 * PAGE_SIZE) {
ioat_test_log(0, "Asked for 8k test and buffer size isn't 
8k\n");
test->status[IOAT_TEST_INVALID_INPUT]++;

Modified: head/sys/dev/ioat/ioat_test.h
==
--- head/sys/dev/ioat/ioat_test.h   Tue Apr  2 18:50:49 2019
(r345811)
+++ head/sys/dev/ioat/ioat_test.h   Tue Apr  2 19:06:25 2019
(r345812)
@@ -44,6 +44,9 @@ enum ioat_test_kind {
IOAT_TEST_RAW_DMA,
IOAT_TEST_DMA_8K,
IOAT_TEST_MEMCPY,
+   IOAT_TEST_DMA_8K_PB,
+   IOAT_TEST_DMA_CRC,
+   IOAT_TEST_DMA_CRC_COPY,
IOAT_NUM_TESTKINDS
 };
 

Modified: head/tools/tools/ioat/ioatcontrol.8
==
--- head/tools/tools/ioat/ioatcontrol.8 Tue Apr  2 18:50:49 2019
(r345811)
+++ head/tools/tools/ioat/ioatcontrol.8 Tue Apr  2 19:06:25 2019
(r345812)
@@ -35,9 +35,12 @@
 .Nm
 .Op Fl c Ar period
 .Op Fl E
+.Op Fl e
 .Op Fl f
 .Op Fl m
 .Op Fl V
+.Op Fl x
+.Op Fl X
 .Op Fl z
 .Ar channel_number
 .Ar num_txns
@@ -65,6 +68,8 @@ The arguments are as follows:
 Configure the channel's interrupt coalescing period, in microseconds
 (defaults to 0).
 .It Fl E
+Test contiguous 8k copy.
+.It Fl e
 Test non-contiguous 8k copy.
 .It Fl f
 Test block fill (by default,
@@ -74,6 +79,10 @@ tests copy)
 Test memcpy instead of DMA.
 .It Fl V
 Verify copies/fills for accuracy
+.It Fl x
+Test DMA CRC.
+.It Fl X
+Test DMA copy with CRC.
 .It Fl z
 Zero device statistics before running test.
 .El

Modified: head/tools/tools/ioat/ioatcontrol.c
==
--- head/tools/tools/ioat/ioatcontrol.c Tue Apr  2 18:50:49 2019
(r345811)
+++ head/tools/tools/ioat/ioatcontrol.c Tue Apr  2 19:06:25 2019
(r345812)
@@ -54,13 +54,16 @@ usage(void)
printf("   %s -r [-c period] [-vVwz] channel-number address 
[]\n\n",
getprogname());
printf("   -c period - Enable interrupt coalescing (us) 
(default: 0)\n");
-   printf("   -E- Tes

svn commit: r345811 - head/sys/x86/iommu

2019-04-02 Thread Tycho Nightingale
Author: tychon
Date: Tue Apr  2 18:50:49 2019
New Revision: 345811
URL: https://svnweb.freebsd.org/changeset/base/345811

Log:
  DMAR driver assumes all physical addresses are backed by a fully
  initialized struct vm_page.
  
  Reviewed by:  kib
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D19753

Modified:
  head/sys/x86/iommu/busdma_dmar.c

Modified: head/sys/x86/iommu/busdma_dmar.c
==
--- head/sys/x86/iommu/busdma_dmar.cTue Apr  2 18:50:33 2019
(r345810)
+++ head/sys/x86/iommu/busdma_dmar.cTue Apr  2 18:50:49 2019
(r345811)
@@ -665,9 +665,9 @@ dmar_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmam
 {
struct bus_dma_tag_dmar *tag;
struct bus_dmamap_dmar *map;
-   vm_page_t *ma;
-   vm_paddr_t pstart, pend;
-   int error, i, ma_cnt, offset;
+   vm_page_t *ma, fma;
+   vm_paddr_t pstart, pend, paddr;
+   int error, i, ma_cnt, mflags, offset;
 
tag = (struct bus_dma_tag_dmar *)dmat;
map = (struct bus_dmamap_dmar *)map1;
@@ -675,14 +675,36 @@ dmar_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmam
pend = round_page(buf + buflen);
offset = buf & PAGE_MASK;
ma_cnt = OFF_TO_IDX(pend - pstart);
-   ma = malloc(sizeof(vm_page_t) * ma_cnt, M_DEVBUF, map->cansleep ?
-   M_WAITOK : M_NOWAIT);
+   mflags = map->cansleep ? M_WAITOK : M_NOWAIT;
+   ma = malloc(sizeof(vm_page_t) * ma_cnt, M_DEVBUF, mflags);
if (ma == NULL)
return (ENOMEM);
-   for (i = 0; i < ma_cnt; i++)
-   ma[i] = PHYS_TO_VM_PAGE(pstart + i * PAGE_SIZE);
+   fma = NULL;
+   for (i = 0; i < ma_cnt; i++) {
+   paddr = pstart + i * PAGE_SIZE;
+   ma[i] = PHYS_TO_VM_PAGE(paddr);
+   if (ma[i] == NULL || VM_PAGE_TO_PHYS(ma[i]) != paddr) {
+   /*
+* If PHYS_TO_VM_PAGE() returned NULL or the
+* vm_page was not initialized we'll use a
+* fake page.
+*/
+   if (fma == NULL) {
+   fma = malloc(sizeof(struct vm_page) * ma_cnt,
+   M_DEVBUF, mflags);
+   if (fma == NULL) {
+   free(ma, M_DEVBUF);
+   return (ENOMEM);
+   }
+   }
+   vm_page_initfake(&fma[i], pstart + i * PAGE_SIZE,
+   VM_MEMATTR_DEFAULT);
+   ma[i] = &fma[i];
+   }
+   }
error = dmar_bus_dmamap_load_something(tag, map, ma, offset, buflen,
flags, segs, segp);
+   free(fma, M_DEVBUF);
free(ma, M_DEVBUF);
return (error);
 }
@@ -696,7 +718,7 @@ dmar_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dm
struct bus_dmamap_dmar *map;
vm_page_t *ma, fma;
vm_paddr_t pstart, pend, paddr;
-   int error, i, ma_cnt, offset;
+   int error, i, ma_cnt, mflags, offset;
 
tag = (struct bus_dma_tag_dmar *)dmat;
map = (struct bus_dmamap_dmar *)map1;
@@ -704,41 +726,33 @@ dmar_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dm
pend = round_page((vm_offset_t)buf + buflen);
offset = (vm_offset_t)buf & PAGE_MASK;
ma_cnt = OFF_TO_IDX(pend - pstart);
-   ma = malloc(sizeof(vm_page_t) * ma_cnt, M_DEVBUF, map->cansleep ?
-   M_WAITOK : M_NOWAIT);
+   mflags = map->cansleep ? M_WAITOK : M_NOWAIT;
+   ma = malloc(sizeof(vm_page_t) * ma_cnt, M_DEVBUF, mflags);
if (ma == NULL)
return (ENOMEM);
-   if (dumping) {
-   /*
-* If dumping, do not attempt to call
-* PHYS_TO_VM_PAGE() at all.  It may return non-NULL
-* but the vm_page returned might be not initialized,
-* e.g. for the kernel itself.
-*/
-   KASSERT(pmap == kernel_pmap, ("non-kernel address write"));
-   fma = malloc(sizeof(struct vm_page) * ma_cnt, M_DEVBUF,
-   M_ZERO | (map->cansleep ? M_WAITOK : M_NOWAIT));
-   if (fma == NULL) {
-   free(ma, M_DEVBUF);
-   return (ENOMEM);
-   }
-   for (i = 0; i < ma_cnt; i++, pstart += PAGE_SIZE) {
+   fma = NULL;
+   for (i = 0; i < ma_cnt; i++, pstart += PAGE_SIZE) {
+   if (pmap == kernel_pmap)
paddr = pmap_kextract(pstart);
+   else
+   paddr = pmap_extract(pmap, pstart);
+   ma[i] = PHYS_TO_VM_PAGE(paddr);
+   if (ma[i] == NULL || VM_PAGE_TO_PHYS(ma[i]) != paddr) {
+   /*
+* If PHYS_TO

svn commit: r345810 - head/sys/dev/cxgbe/common

2019-04-02 Thread Navdeep Parhar
Author: np
Date: Tue Apr  2 18:50:33 2019
New Revision: 345810
URL: https://svnweb.freebsd.org/changeset/base/345810

Log:
  cxgbe(4): Add a flag to indicate that bits in interrupt cause but not in
  interrupt enable are not fatal.
  
  The firmware sets up all the interrupt enables based on run time
  configuration, which means the information in the enables is more
  accurate than what's compiled into the driver.  This change also allows
  the fatal bits to be updated without any changes in the driver in some
  cases.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/t4_hw.c

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Tue Apr  2 18:44:01 2019
(r345809)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Tue Apr  2 18:50:33 2019
(r345810)
@@ -3960,11 +3960,13 @@ struct intr_action {
bool (*action)(struct adapter *, int, bool);
 };
 
+#define NONFATAL_IF_DISABLED 1
 struct intr_info {
const char *name;   /* name of the INT_CAUSE register */
int cause_reg;  /* INT_CAUSE register */
int enable_reg; /* INT_ENABLE register */
u32 fatal;  /* bits that are fatal */
+   int flags;  /* hints */
const struct intr_details *details;
const struct intr_action *actions;
 };
@@ -3983,14 +3985,18 @@ intr_alert_char(u32 cause, u32 enable, u32 fatal)
 static void
 t4_show_intr_info(struct adapter *adap, const struct intr_info *ii, u32 cause)
 {
-   u32 enable, leftover;
+   u32 enable, fatal, leftover;
const struct intr_details *details;
char alert;
 
enable = t4_read_reg(adap, ii->enable_reg);
-   alert = intr_alert_char(cause, enable, ii->fatal);
+   if (ii->flags & NONFATAL_IF_DISABLED)
+   fatal = ii->fatal & t4_read_reg(adap, ii->enable_reg);
+   else
+   fatal = ii->fatal;
+   alert = intr_alert_char(cause, enable, fatal);
CH_ALERT(adap, "%c %s 0x%x = 0x%08x, E 0x%08x, F 0x%08x\n",
-   alert, ii->name, ii->cause_reg, cause, enable, ii->fatal);
+   alert, ii->name, ii->cause_reg, cause, enable, fatal);
 
leftover = cause;
for (details = ii->details; details && details->mask != 0; details++) {
@@ -4013,30 +4019,40 @@ static bool
 t4_handle_intr(struct adapter *adap, const struct intr_info *ii,
 u32 additional_cause, bool verbose)
 {
-   u32 cause;
-   bool fatal;
+   u32 cause, fatal;
+   bool rc;
const struct intr_action *action;
 
/* read and display cause. */
cause = t4_read_reg(adap, ii->cause_reg);
if (verbose || cause != 0)
t4_show_intr_info(adap, ii, cause);
-   fatal = (cause & ii->fatal) != 0;
+   /*
+* The top level interrupt cause is a bit special and we need to ignore
+* the bits that are not in the enable.  Note that we did display them
+* above in t4_show_intr_info but will not clear them.
+*/
+   if (ii->cause_reg == A_PL_INT_CAUSE)
+   cause &= t4_read_reg(adap, ii->enable_reg);
+   fatal = cause & ii->fatal;
+   if (fatal != 0 && ii->flags & NONFATAL_IF_DISABLED)
+   fatal &= t4_read_reg(adap, ii->enable_reg);
cause |= additional_cause;
if (cause == 0)
return (false);
 
+   rc = fatal != 0;
for (action = ii->actions; action && action->mask != 0; action++) {
if (!(action->mask & cause))
continue;
-   fatal |= (action->action)(adap, action->arg, verbose);
+   rc |= (action->action)(adap, action->arg, verbose);
}
 
/* clear */
t4_write_reg(adap, ii->cause_reg, cause);
(void)t4_read_reg(adap, ii->cause_reg);
 
-   return (fatal);
+   return (rc);
 }
 
 /*
@@ -4057,6 +4073,7 @@ static bool pcie_intr_handler(struct adapter *adap, in
.cause_reg = A_PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS,
.enable_reg = A_PCIE_CORE_UTL_SYSTEM_BUS_AGENT_INTERRUPT_ENABLE,
.fatal = F_RFTP | F_RCCP | F_RCIP | F_RPCP | F_RNPP,
+   .flags = 0,
.details = sysbus_intr_details,
.actions = NULL,
};
@@ -4078,6 +4095,7 @@ static bool pcie_intr_handler(struct adapter *adap, in
.enable_reg = A_PCIE_CORE_UTL_PCI_EXPRESS_PORT_INTERRUPT_ENABLE,
.fatal = F_TPCP | F_TNPP | F_TFTP | F_TCAP | F_TCIP | F_RCAP |
F_OTDD | F_RDPE | F_TDUE,
+   .flags = 0,
.details = pcie_port_intr_details,
.actions = NULL,
};
@@ -4152,7 +4170,8 @@ static bool pcie_intr_handler(struct adapter *adap, in
.name = "PCIE_INT_CAUSE",
.cause_reg = A_PCIE_INT_CAUSE,
 

svn commit: r345807 - head/usr.bin/top

2019-04-02 Thread Dimitry Andric
Author: dim
Date: Tue Apr  2 18:01:54 2019
New Revision: 345807
URL: https://svnweb.freebsd.org/changeset/base/345807

Log:
  Fix regression in top(1) after r344381, causing informational messages
  to no longer be displayed.  This was because the reimplementation of
  setup_buffer() did not copy the previous contents into any reallocated
  buffer.
  
  Reported by:  James Wright 
  PR:   236947
  MFC after:3 days

Modified:
  head/usr.bin/top/display.c

Modified: head/usr.bin/top/display.c
==
--- head/usr.bin/top/display.c  Tue Apr  2 17:51:28 2019(r345806)
+++ head/usr.bin/top/display.c  Tue Apr  2 18:01:54 2019(r345807)
@@ -1347,7 +1347,8 @@ i_uptime(struct timeval *bt, time_t *tod)
 static char *
 setup_buffer(char *buffer, int addlen)
 {
-size_t len;
+size_t len, old_len;
+char *new_buffer;
 
 setup_buffer_bufsiz = screen_width;
 if (setup_buffer_bufsiz < SETUPBUFFER_MIN_SCREENWIDTH)
@@ -1355,13 +1356,18 @@ setup_buffer(char *buffer, int addlen)
setup_buffer_bufsiz = SETUPBUFFER_MIN_SCREENWIDTH;
 }
 
-free(buffer);
 len = setup_buffer_bufsiz + addlen + SETUPBUFFER_REQUIRED_ADDBUFSIZ;
-buffer = calloc(len, sizeof(char));
-if (buffer == NULL)
+new_buffer = calloc(len, sizeof(char));
+if (new_buffer == NULL)
 {
errx(4, "can't allocate sufficient memory");
 }
+if (buffer != NULL)
+{
+   old_len = strlen(buffer);
+   memcpy(new_buffer, buffer, old_len < len - 1 ? old_len : len - 1);
+   free(buffer);
+}
 
-return buffer;
+return new_buffer;
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345806 - head/contrib/llvm/tools/clang/lib/CodeGen

2019-04-02 Thread Dimitry Andric
Author: dim
Date: Tue Apr  2 17:51:28 2019
New Revision: 345806
URL: https://svnweb.freebsd.org/changeset/base/345806

Log:
  Pull in r357362 from upstream clang trunk (by David Chisnall):
  
[objc-gnustep] Use .init_array not .ctors when requested.
  
This doesn't make a difference most of the time but FreeBSD/ARM
doesn't run anything in the .ctors array.
  
  This should help with updating the libobjc2 port for armv7.
  
  Requested by: theraven
  Upstream PR:  https://github.com/gnustep/libobjc2/issues/83
  MFC after:3 days

Modified:
  head/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp

Modified: head/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp
==
--- head/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp Tue Apr  2 
14:46:10 2019(r345805)
+++ head/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp Tue Apr  2 
17:51:28 2019(r345806)
@@ -1519,7 +1519,12 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 if (CGM.getTriple().isOSBinFormatCOFF())
 InitVar->setSection(".CRT$XCLz");
 else
-  InitVar->setSection(".ctors");
+{
+  if (CGM.getCodeGenOpts().UseInitArray)
+InitVar->setSection(".init_array");
+  else
+InitVar->setSection(".ctors");
+}
 InitVar->setVisibility(llvm::GlobalValue::HiddenVisibility);
 InitVar->setComdat(TheModule.getOrInsertComdat(".objc_ctor"));
 CGM.addUsedGlobal(InitVar);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345805 - head/sys/cam

2019-04-02 Thread Alexander Motin
Hi.

On 02.04.2019 12:43, Enji Cooper wrote:
>> On Apr 2, 2019, at 07:46, Alexander Motin  wrote:
>> @@ -1595,14 +1596,21 @@ camperiphscsistatuserror(union ccb *ccb, union ccb 
>> **o
>> * Restart the queue after either another
>> * command completes or a 1 second timeout.
>> */
>> -if ((sense_flags & SF_RETRY_BUSY) != 0 ||
>> -(ccb->ccb_h.retry_count--) > 0) {
>> +periph = xpt_path_periph(ccb->ccb_h.path);
>> +if (periph->flags & CAM_PERIPH_INVALID) {
> 
> Is there a reason why this style is inconsistent with the other part of the 
> change by not explicitly testing for “!= 0”?

Not really, I've just copied this chunk from other place where it was
this way.  Bug I generally prefer more compact code where possible, and
I don't see style(9) saying it is bad to do so here.  But if it hurts
somebody, I see no problem to change it.

-- 
Alexander Motin
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345805 - head/sys/cam

2019-04-02 Thread Enji Cooper
Hi Alexander,

> On Apr 2, 2019, at 07:46, Alexander Motin  wrote:
> 
> Author: mav
> Date: Tue Apr  2 14:46:10 2019
> New Revision: 345805
> URL: https://svnweb.freebsd.org/changeset/base/345805
> 
> Log:
>  Unify SCSI_STATUS_BUSY retry handling with other cases.
> 
>   - Do not retry if periph was invalidated.
>   - Do not decrement retry_count if already zero.
>   - Report action_string when applicable.
> 
>  MFC after:2 weeks
> 
> Modified:
>  head/sys/cam/cam_periph.c
> 
> Modified: head/sys/cam/cam_periph.c
> ==
> --- head/sys/cam/cam_periph.cTue Apr  2 14:01:03 2019(r345804)
> +++ head/sys/cam/cam_periph.cTue Apr  2 14:46:10 2019(r345805)
> @@ -1513,6 +1513,7 @@ camperiphscsistatuserror(union ccb *ccb, union ccb **o
> int *openings, u_int32_t *relsim_flags,
> u_int32_t *timeout, u_int32_t *action, const char **action_string)
> {
> +struct cam_periph *periph;
>int error;
> 
>switch (ccb->csio.scsi_status) {
> @@ -1595,14 +1596,21 @@ camperiphscsistatuserror(union ccb *ccb, union ccb **o
> * Restart the queue after either another
> * command completes or a 1 second timeout.
> */
> -if ((sense_flags & SF_RETRY_BUSY) != 0 ||
> -(ccb->ccb_h.retry_count--) > 0) {
> +periph = xpt_path_periph(ccb->ccb_h.path);
> +if (periph->flags & CAM_PERIPH_INVALID) {

Is there a reason why this style is inconsistent with the other part of the 
change by not explicitly testing for “!= 0”?

Thanks!
-Enji
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345804 - head/usr.bin/systat

2019-04-02 Thread Michael
Hi,

Am 2. April 2019 16:08:17 MESZ schrieb "Rodney W. Grimes" 
:
>> Author: mr
>> Date: Tue Apr  2 14:01:03 2019
>> New Revision: 345804
>> URL: https://svnweb.freebsd.org/changeset/base/345804
>> 
>> Log:
>>   systat -zarc to display disk activities like -vm
>>   
>>   PR:213310
>>   Submitted by:  ota
>>   MFH:   4 weeks
>
>? MFC:

Yes, indeed.

>
>>   Differential Revision: https://reviews.freebsd.org/D18726
>> 
>> Modified:
>>   head/usr.bin/systat/devs.c
>>   head/usr.bin/systat/devs.h
>>   head/usr.bin/systat/iostat.c
>>   head/usr.bin/systat/swap.c
>>   head/usr.bin/systat/systat.h
>>   head/usr.bin/systat/vmstat.c
>>   head/usr.bin/systat/zarc.c
>> 
>> Modified: head/usr.bin/systat/devs.c
>>
>==
>> --- head/usr.bin/systat/devs.c   Tue Apr  2 13:59:04 2019
>> (r345803)
>> +++ head/usr.bin/systat/devs.c   Tue Apr  2 14:01:03 2019
>> (r345804)
>> @@ -2,6 +2,7 @@
>>   * SPDX-License-Identifier: BSD-3-Clause
>>   *
>>   * Copyright (c) 1998 Kenneth D. Merry.
>> + *   2015 Yoshihiro Ota
>>   * All rights reserved.
>
>
>Can we get in contact with Yoshihiro Ota about his
>copyright statements, and correcting this to make
>it clear that it is Kenneth D. Merry that is asserting
>"All rights reserved" and if Ota does nor does not wish to assert
>"All rights reserved".
>
>As committed this makes a grey area on Kenneth's assertion,
>also leaving out the word copyright on Yoshihiro's line is a bit iffy.
>
>I am only commenting once, this issue appears several times.
>We can go back out to D18726 to discuss it if need be.
>

You could add a comment in the PR too, I intended to keep it open until MFC

>>   *
>>   * Redistribution and use in source and binary forms, with or
>without
>> @@ -69,7 +70,6 @@ static const char sccsid[] = "@(#)disks.c  8.1
>(Berkele
>>  #include 
>>  
>>  #include 
>> -#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -84,6 +84,8 @@ typedef enum {
>>  DS_MATCHTYPE_PATTERN
>>  } last_match_type;
>>  
>> +struct statinfo cur_dev, last_dev, run_dev;
>> +
>>  last_match_type last_type;
>>  struct device_selection *dev_select;
>>  long generation;
>> @@ -101,10 +103,8 @@ static int dsselect(const char *args,
>devstat_select_m
>>  int maxshowdevs, struct statinfo *s1);
>>  
>>  int
>> -dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2
>__unused,
>> -   struct statinfo *s3 __unused)
>> +dsinit(int maxshowdevs)
>>  {
>> -
>>  /*
>>   * Make sure that the userland devstat version matches the kernel
>>   * devstat version.  If not, exit and print a message informing
>> @@ -113,6 +113,18 @@ dsinit(int maxshowdevs, struct statinfo *s1,
>struct st
>>  if (devstat_checkversion(NULL) < 0)
>>  errx(1, "%s", devstat_errbuf);
>>  
>> +if( cur_dev.dinfo ) // init was alreay ran
>> +return(1);
>> +
>> +if ((num_devices = devstat_getnumdevs(NULL)) < 0) {
>> +warnx("%s", devstat_errbuf);
>> +return(0);
>> +}
>> +
>> +cur_dev.dinfo = calloc(1, sizeof(struct devinfo));
>> +last_dev.dinfo = calloc(1, sizeof(struct devinfo));
>> +run_dev.dinfo = calloc(1, sizeof(struct devinfo));
>> +
>>  generation = 0;
>>  num_devices = 0;
>>  num_selected = 0;
>> @@ -120,11 +132,11 @@ dsinit(int maxshowdevs, struct statinfo *s1,
>struct st
>>  select_generation = 0;
>>  last_type = DS_MATCHTYPE_NONE;
>>  
>> -if (devstat_getdevs(NULL, s1) == -1)
>> +if (devstat_getdevs(NULL, &cur_dev) == -1)
>>  errx(1, "%s", devstat_errbuf);
>>  
>> -num_devices = s1->dinfo->numdevs;
>> -generation = s1->dinfo->generation;
>> +num_devices = cur_dev.dinfo->numdevs;
>> +generation = cur_dev.dinfo->generation;
>>  
>>  dev_select = NULL;
>>  
>> @@ -134,13 +146,31 @@ dsinit(int maxshowdevs, struct statinfo *s1,
>struct st
>>   * or 1.  If we get back -1, though, there is an error.
>>   */
>>  if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
>> -&select_generation, generation, s1->dinfo->devices,
>num_devices,
>> +&select_generation, generation, cur_dev.dinfo->devices,
>num_devices,
>>  NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1)
>>  errx(1, "%d %s", __LINE__, devstat_errbuf);
>>  
>>  return(1);
>>  }
>>  
>> +
>> +void
>> +dsgetinfo(struct statinfo* dev)
>> +{
>> +switch (devstat_getdevs(NULL, dev)) {
>> +case -1:
>> +errx(1, "%s", devstat_errbuf);
>> +break;
>> +case 1:
>> +num_devices = dev->dinfo->numdevs;
>> +generation = dev->dinfo->generation;
>> +cmdkre("refresh", NULL);
>> +break;
>> +default:
>> +break;
>> +}
>> +}
>> +
>>  int
>>  dscmd(const char *cmd, const char *args, int maxshowdevs, struct
>statinfo *s1)
>>  {

svn commit: r345805 - head/sys/cam

2019-04-02 Thread Alexander Motin
Author: mav
Date: Tue Apr  2 14:46:10 2019
New Revision: 345805
URL: https://svnweb.freebsd.org/changeset/base/345805

Log:
  Unify SCSI_STATUS_BUSY retry handling with other cases.
  
   - Do not retry if periph was invalidated.
   - Do not decrement retry_count if already zero.
   - Report action_string when applicable.
  
  MFC after:2 weeks

Modified:
  head/sys/cam/cam_periph.c

Modified: head/sys/cam/cam_periph.c
==
--- head/sys/cam/cam_periph.c   Tue Apr  2 14:01:03 2019(r345804)
+++ head/sys/cam/cam_periph.c   Tue Apr  2 14:46:10 2019(r345805)
@@ -1513,6 +1513,7 @@ camperiphscsistatuserror(union ccb *ccb, union ccb **o
 int *openings, u_int32_t *relsim_flags,
 u_int32_t *timeout, u_int32_t *action, const char **action_string)
 {
+   struct cam_periph *periph;
int error;
 
switch (ccb->csio.scsi_status) {
@@ -1595,14 +1596,21 @@ camperiphscsistatuserror(union ccb *ccb, union ccb **o
 * Restart the queue after either another
 * command completes or a 1 second timeout.
 */
-   if ((sense_flags & SF_RETRY_BUSY) != 0 ||
-   (ccb->ccb_h.retry_count--) > 0) {
+   periph = xpt_path_periph(ccb->ccb_h.path);
+   if (periph->flags & CAM_PERIPH_INVALID) {
+   error = EIO;
+   *action_string = "Periph was invalidated";
+   } else if ((sense_flags & SF_RETRY_BUSY) != 0 ||
+   ccb->ccb_h.retry_count > 0) {
+   if ((sense_flags & SF_RETRY_BUSY) == 0)
+   ccb->ccb_h.retry_count--;
error = ERESTART;
*relsim_flags = RELSIM_RELEASE_AFTER_TIMEOUT
  | RELSIM_RELEASE_AFTER_CMDCMPLT;
*timeout = 1000;
} else {
error = EIO;
+   *action_string = "Retries exhausted";
}
break;
case SCSI_STATUS_RESERV_CONFLICT:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd

2019-04-02 Thread Harti Brandt
On Tue, 2 Apr 2019, Baptiste Daroussin wrote:

BD>On Tue, Apr 02, 2019 at 12:50:01PM +, Andrey V. Elsukov wrote:
BD>> Author: ae
BD>> Date: Tue Apr  2 12:50:01 2019
BD>> New Revision: 345797
BD>> URL: https://svnweb.freebsd.org/changeset/base/345797
BD>> 
BD>> Log:
BD>>   Add IPv6 transport for bsnmp.
BD>>   
BD>>   This patch adds a new table begemotSnmpdTransInetTable that uses the
BD>>   InetAddressType textual convention and can be used to create listening
BD>>   ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports
BD>>   future extension beyond UDP by adding a protocol identifier to the table
BD>>   index. In order to support this gensnmptree had to be modified.
BD>>   
BD>>   Submitted by:   harti
BD>>   MFC after:  1 month
BD>>   Relnotes:   yes
BD>>   Differential Revision:  https://reviews.freebsd.org/D16654
BD>> 
BD>Jumping in this commit, maybe it is time to move bsnmpd out of contrib, given
BD>that all the dev appears to only be in our own source tree right?

Actually I have a private tree that has some more stuff in it than there 
is in the contrib tree in FreeBSD. I usually do modifications first in 
that tree, then I bring it to FreeBSD. If somebody commits modifications 
to FreeBSD I feed that back.

One day I intend to put this into a public place.

harti
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345804 - head/usr.bin/systat

2019-04-02 Thread Rodney W. Grimes
> Author: mr
> Date: Tue Apr  2 14:01:03 2019
> New Revision: 345804
> URL: https://svnweb.freebsd.org/changeset/base/345804
> 
> Log:
>   systat -zarc to display disk activities like -vm
>   
>   PR: 213310
>   Submitted by:   ota
>   MFH:4 weeks

? MFC:

>   Differential Revision:  https://reviews.freebsd.org/D18726
> 
> Modified:
>   head/usr.bin/systat/devs.c
>   head/usr.bin/systat/devs.h
>   head/usr.bin/systat/iostat.c
>   head/usr.bin/systat/swap.c
>   head/usr.bin/systat/systat.h
>   head/usr.bin/systat/vmstat.c
>   head/usr.bin/systat/zarc.c
> 
> Modified: head/usr.bin/systat/devs.c
> ==
> --- head/usr.bin/systat/devs.cTue Apr  2 13:59:04 2019
> (r345803)
> +++ head/usr.bin/systat/devs.cTue Apr  2 14:01:03 2019
> (r345804)
> @@ -2,6 +2,7 @@
>   * SPDX-License-Identifier: BSD-3-Clause
>   *
>   * Copyright (c) 1998 Kenneth D. Merry.
> + *   2015 Yoshihiro Ota
>   * All rights reserved.


Can we get in contact with Yoshihiro Ota about his
copyright statements, and correcting this to make
it clear that it is Kenneth D. Merry that is asserting
"All rights reserved" and if Ota does nor does not wish to assert
"All rights reserved".

As committed this makes a grey area on Kenneth's assertion,
also leaving out the word copyright on Yoshihiro's line is a bit iffy.

I am only commenting once, this issue appears several times.
We can go back out to D18726 to discuss it if need be.

>   *
>   * Redistribution and use in source and binary forms, with or without
> @@ -69,7 +70,6 @@ static const char sccsid[] = "@(#)disks.c   8.1 (Berkele
>  #include 
>  
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -84,6 +84,8 @@ typedef enum {
>   DS_MATCHTYPE_PATTERN
>  } last_match_type;
>  
> +struct statinfo cur_dev, last_dev, run_dev;
> +
>  last_match_type last_type;
>  struct device_selection *dev_select;
>  long generation;
> @@ -101,10 +103,8 @@ static int dsselect(const char *args, devstat_select_m
>   int maxshowdevs, struct statinfo *s1);
>  
>  int
> -dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused,
> -   struct statinfo *s3 __unused)
> +dsinit(int maxshowdevs)
>  {
> -
>   /*
>* Make sure that the userland devstat version matches the kernel
>* devstat version.  If not, exit and print a message informing
> @@ -113,6 +113,18 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st
>   if (devstat_checkversion(NULL) < 0)
>   errx(1, "%s", devstat_errbuf);
>  
> + if( cur_dev.dinfo ) // init was alreay ran
> + return(1);
> +
> + if ((num_devices = devstat_getnumdevs(NULL)) < 0) {
> + warnx("%s", devstat_errbuf);
> + return(0);
> + }
> +
> + cur_dev.dinfo = calloc(1, sizeof(struct devinfo));
> + last_dev.dinfo = calloc(1, sizeof(struct devinfo));
> + run_dev.dinfo = calloc(1, sizeof(struct devinfo));
> +
>   generation = 0;
>   num_devices = 0;
>   num_selected = 0;
> @@ -120,11 +132,11 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st
>   select_generation = 0;
>   last_type = DS_MATCHTYPE_NONE;
>  
> - if (devstat_getdevs(NULL, s1) == -1)
> + if (devstat_getdevs(NULL, &cur_dev) == -1)
>   errx(1, "%s", devstat_errbuf);
>  
> - num_devices = s1->dinfo->numdevs;
> - generation = s1->dinfo->generation;
> + num_devices = cur_dev.dinfo->numdevs;
> + generation = cur_dev.dinfo->generation;
>  
>   dev_select = NULL;
>  
> @@ -134,13 +146,31 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st
>* or 1.  If we get back -1, though, there is an error.
>*/
>   if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
> - &select_generation, generation, s1->dinfo->devices, num_devices,
> + &select_generation, generation, cur_dev.dinfo->devices, num_devices,
>   NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1)
>   errx(1, "%d %s", __LINE__, devstat_errbuf);
>  
>   return(1);
>  }
>  
> +
> +void
> +dsgetinfo(struct statinfo* dev)
> +{
> + switch (devstat_getdevs(NULL, dev)) {
> + case -1:
> + errx(1, "%s", devstat_errbuf);
> + break;
> + case 1:
> + num_devices = dev->dinfo->numdevs;
> + generation = dev->dinfo->generation;
> + cmdkre("refresh", NULL);
> + break;
> + default:
> + break;
> + }
> +}
> +
>  int
>  dscmd(const char *cmd, const char *args, int maxshowdevs, struct statinfo 
> *s1)
>  {
> @@ -330,4 +360,84 @@ dsselect(const char *args, devstat_select_mode select_
>   return(2);
>   }
>   return(1);
> +}
> +
> +
> +void
> +dslabel(int maxdrives, int diskcol, int diskrow)
> +{
> + int i, j;
> +
> + mvprintw(diskrow,

svn commit: r345804 - head/usr.bin/systat

2019-04-02 Thread Michael Reifenberger
Author: mr
Date: Tue Apr  2 14:01:03 2019
New Revision: 345804
URL: https://svnweb.freebsd.org/changeset/base/345804

Log:
  systat -zarc to display disk activities like -vm
  
  PR:   213310
  Submitted by: ota
  MFH:  4 weeks
  Differential Revision:https://reviews.freebsd.org/D18726

Modified:
  head/usr.bin/systat/devs.c
  head/usr.bin/systat/devs.h
  head/usr.bin/systat/iostat.c
  head/usr.bin/systat/swap.c
  head/usr.bin/systat/systat.h
  head/usr.bin/systat/vmstat.c
  head/usr.bin/systat/zarc.c

Modified: head/usr.bin/systat/devs.c
==
--- head/usr.bin/systat/devs.c  Tue Apr  2 13:59:04 2019(r345803)
+++ head/usr.bin/systat/devs.c  Tue Apr  2 14:01:03 2019(r345804)
@@ -2,6 +2,7 @@
  * SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (c) 1998 Kenneth D. Merry.
+ *   2015 Yoshihiro Ota
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -69,7 +70,6 @@ static const char sccsid[] = "@(#)disks.c 8.1 (Berkele
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -84,6 +84,8 @@ typedef enum {
DS_MATCHTYPE_PATTERN
 } last_match_type;
 
+struct statinfo cur_dev, last_dev, run_dev;
+
 last_match_type last_type;
 struct device_selection *dev_select;
 long generation;
@@ -101,10 +103,8 @@ static int dsselect(const char *args, devstat_select_m
int maxshowdevs, struct statinfo *s1);
 
 int
-dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused,
-   struct statinfo *s3 __unused)
+dsinit(int maxshowdevs)
 {
-
/*
 * Make sure that the userland devstat version matches the kernel
 * devstat version.  If not, exit and print a message informing
@@ -113,6 +113,18 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st
if (devstat_checkversion(NULL) < 0)
errx(1, "%s", devstat_errbuf);
 
+   if( cur_dev.dinfo ) // init was alreay ran
+   return(1);
+
+   if ((num_devices = devstat_getnumdevs(NULL)) < 0) {
+   warnx("%s", devstat_errbuf);
+   return(0);
+   }
+
+   cur_dev.dinfo = calloc(1, sizeof(struct devinfo));
+   last_dev.dinfo = calloc(1, sizeof(struct devinfo));
+   run_dev.dinfo = calloc(1, sizeof(struct devinfo));
+
generation = 0;
num_devices = 0;
num_selected = 0;
@@ -120,11 +132,11 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st
select_generation = 0;
last_type = DS_MATCHTYPE_NONE;
 
-   if (devstat_getdevs(NULL, s1) == -1)
+   if (devstat_getdevs(NULL, &cur_dev) == -1)
errx(1, "%s", devstat_errbuf);
 
-   num_devices = s1->dinfo->numdevs;
-   generation = s1->dinfo->generation;
+   num_devices = cur_dev.dinfo->numdevs;
+   generation = cur_dev.dinfo->generation;
 
dev_select = NULL;
 
@@ -134,13 +146,31 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st
 * or 1.  If we get back -1, though, there is an error.
 */
if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
-   &select_generation, generation, s1->dinfo->devices, num_devices,
+   &select_generation, generation, cur_dev.dinfo->devices, num_devices,
NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1)
errx(1, "%d %s", __LINE__, devstat_errbuf);
 
return(1);
 }
 
+
+void
+dsgetinfo(struct statinfo* dev)
+{
+   switch (devstat_getdevs(NULL, dev)) {
+   case -1:
+   errx(1, "%s", devstat_errbuf);
+   break;
+   case 1:
+   num_devices = dev->dinfo->numdevs;
+   generation = dev->dinfo->generation;
+   cmdkre("refresh", NULL);
+   break;
+   default:
+   break;
+   }
+}
+
 int
 dscmd(const char *cmd, const char *args, int maxshowdevs, struct statinfo *s1)
 {
@@ -330,4 +360,84 @@ dsselect(const char *args, devstat_select_mode select_
return(2);
}
return(1);
+}
+
+
+void
+dslabel(int maxdrives, int diskcol, int diskrow)
+{
+   int i, j;
+
+   mvprintw(diskrow, diskcol, "Disks");
+   mvprintw(diskrow + 1, diskcol, "KB/t");
+   mvprintw(diskrow + 2, diskcol, "tps");
+   mvprintw(diskrow + 3, diskcol, "MB/s");
+   mvprintw(diskrow + 4, diskcol, "%%busy");
+   /*
+* For now, we don't support a fourth disk statistic.  So there's
+* no point in providing a label for it.  If someone can think of a
+* fourth useful disk statistic, there is room to add it.
+*/
+   /* mvprintw(diskrow + 4, diskcol, " msps"); */
+   j = 0;
+   for (i = 0; i < num_devices && j < maxdrives; i++)
+   if (dev_select[i].selected) {
+   char tmpstr[80];
+   sprintf(tmpstr, "%s

svn commit: r345803 - head/sys/fs/tmpfs

2019-04-02 Thread Konstantin Belousov
Author: kib
Date: Tue Apr  2 13:59:04 2019
New Revision: 345803
URL: https://svnweb.freebsd.org/changeset/base/345803

Log:
  tmpfs: plug holes on rw->ro mount update.
  
  In particular:
  - suspend the mount around vflush() to avoid new writes come after the
vnode is processed;
  - flush pending metadata updates (mostly node times);
  - remap all rw mappings of files from the mount into ro.
  
  It is not clear to me how to handle writeable mappings on rw->ro for
  tmpfs best.  Other filesystems, which use vnode vm object, call
  vgone() on vnodes with writers, which sets the vm object type to
  OBJT_DEAD, and keep the resident pages and installed ptes as is.  In
  particular, the existing mappings continue to work as far as
  application only accesses resident pages, but changes are not flushed
  to file.
  
  For tmpfs the vm object of VREG vnodes also serves as the data pages
  container, giving single copy of the mapped pages, so it cannot be set
  to OBJT_DEAD.  Alternatives for making rw mappings ro could be either
  invalidating them at all, or marking as CoW.
  
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D19737

Modified:
  head/sys/fs/tmpfs/tmpfs_vfsops.c

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==
--- head/sys/fs/tmpfs/tmpfs_vfsops.cTue Apr  2 13:58:31 2019
(r345802)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.cTue Apr  2 13:59:04 2019
(r345803)
@@ -60,10 +60,15 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -137,14 +142,235 @@ tmpfs_node_fini(void *mem, int size)
mtx_destroy(&node->tn_interlock);
 }
 
+/*
+ * Handle updates of time from writes to mmaped regions.  Use
+ * MNT_VNODE_FOREACH_ALL instead of MNT_VNODE_FOREACH_ACTIVE, since
+ * unmap of the tmpfs-backed vnode does not call vinactive(), due to
+ * vm object type is OBJT_SWAP.
+ * If lazy, only handle delayed update of mtime due to the writes to
+ * mapped files.
+ */
+static void
+tmpfs_update_mtime(struct mount *mp, bool lazy)
+{
+   struct vnode *vp, *mvp;
+   struct vm_object *obj;
+
+   MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {
+   if (vp->v_type != VREG) {
+   VI_UNLOCK(vp);
+   continue;
+   }
+   obj = vp->v_object;
+   KASSERT((obj->flags & (OBJ_TMPFS_NODE | OBJ_TMPFS)) ==
+   (OBJ_TMPFS_NODE | OBJ_TMPFS), ("non-tmpfs obj"));
+
+   /*
+* In lazy case, do unlocked read, avoid taking vnode
+* lock if not needed.  Lost update will be handled on
+* the next call.
+* For non-lazy case, we must flush all pending
+* metadata changes now.
+*/
+   if (!lazy || (obj->flags & OBJ_TMPFS_DIRTY) != 0) {
+   if (vget(vp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK,
+   curthread) != 0)
+   continue;
+   tmpfs_check_mtime(vp);
+   if (!lazy)
+   tmpfs_update(vp);
+   vput(vp);
+   } else {
+   VI_UNLOCK(vp);
+   continue;
+   }
+   }
+}
+
+struct tmpfs_check_rw_maps_arg {
+   bool found;
+};
+
+static bool
+tmpfs_check_rw_maps_cb(struct mount *mp __unused, vm_map_t map __unused,
+vm_map_entry_t entry __unused, void *arg)
+{
+   struct tmpfs_check_rw_maps_arg *a;
+
+   a = arg;
+   a->found = true;
+   return (true);
+}
+
+/*
+ * Revoke write permissions from all mappings of regular files
+ * belonging to the specified tmpfs mount.
+ */
+static bool
+tmpfs_revoke_rw_maps_cb(struct mount *mp __unused, vm_map_t map,
+vm_map_entry_t entry, void *arg __unused)
+{
+
+   /*
+* XXXKIB: might be invalidate the mapping
+* instead ?  The process is not going to be
+* happy in any case.
+*/
+   entry->max_protection &= ~VM_PROT_WRITE;
+   if ((entry->protection & VM_PROT_WRITE) != 0) {
+   entry->protection &= ~VM_PROT_WRITE;
+   pmap_protect(map->pmap, entry->start, entry->end,
+   entry->protection);
+   }
+   return (false);
+}
+
+static void
+tmpfs_all_rw_maps(struct mount *mp, bool (*cb)(struct mount *mp, vm_map_t,
+vm_map_entry_t, void *), void *cb_arg)
+{
+   struct proc *p;
+   struct vmspace *vm;
+   vm_map_t map;
+   vm_map_entry_t entry;
+   vm_object_t object;
+   struct vnode *vp;
+   int gen;
+   bool terminate;
+
+   terminate = false;
+   sx_slock(&allproc_lock);
+again:
+   gen = allproc_gen;
+

svn commit: r345800 - head/sys/fs/tmpfs

2019-04-02 Thread Konstantin Belousov
Author: kib
Date: Tue Apr  2 13:49:32 2019
New Revision: 345800
URL: https://svnweb.freebsd.org/changeset/base/345800

Log:
  tmpfs: ignore tmpfs_set_status() if mount point is read-only.
  
  In particular, this fixes atimes still changing for ro tmpfs.
  tmpfs_set_status() gains tmpfs_mount * argument.
  
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D19737

Modified:
  head/sys/fs/tmpfs/tmpfs.h
  head/sys/fs/tmpfs/tmpfs_fifoops.c
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs.h
==
--- head/sys/fs/tmpfs/tmpfs.h   Tue Apr  2 13:41:26 2019(r345799)
+++ head/sys/fs/tmpfs/tmpfs.h   Tue Apr  2 13:49:32 2019(r345800)
@@ -437,8 +437,8 @@ voidtmpfs_dir_destroy(struct tmpfs_mount *, struct 
tm
 struct tmpfs_dirent *  tmpfs_dir_lookup(struct tmpfs_node *node,
struct tmpfs_node *f,
struct componentname *cnp);
-inttmpfs_dir_getdents(struct tmpfs_node *, struct uio *, int,
-   u_long *, int *);
+inttmpfs_dir_getdents(struct tmpfs_mount *, struct tmpfs_node *,
+   struct uio *, int, u_long *, int *);
 inttmpfs_dir_whiteout_add(struct vnode *, struct componentname *);
 void   tmpfs_dir_whiteout_remove(struct vnode *, struct componentname *);
 inttmpfs_reg_resize(struct vnode *, off_t, boolean_t);
@@ -452,7 +452,8 @@ int tmpfs_chtimes(struct vnode *, struct vattr *, stru
 void   tmpfs_itimes(struct vnode *, const struct timespec *,
const struct timespec *);
 
-void   tmpfs_set_status(struct tmpfs_node *node, int status);
+void   tmpfs_set_status(struct tmpfs_mount *tm, struct tmpfs_node *node,
+   int status);
 void   tmpfs_update(struct vnode *);
 inttmpfs_truncate(struct vnode *, off_t);
 struct tmpfs_dirent *tmpfs_dir_first(struct tmpfs_node *dnode,

Modified: head/sys/fs/tmpfs/tmpfs_fifoops.c
==
--- head/sys/fs/tmpfs/tmpfs_fifoops.c   Tue Apr  2 13:41:26 2019
(r345799)
+++ head/sys/fs/tmpfs/tmpfs_fifoops.c   Tue Apr  2 13:49:32 2019
(r345800)
@@ -56,7 +56,8 @@ tmpfs_fifo_close(struct vop_close_args *v)
struct tmpfs_node *node;
 
node = VP_TO_TMPFS_NODE(v->a_vp);
-   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
+   tmpfs_set_status(VFS_TO_TMPFS(v->a_vp->v_mount), node,
+   TMPFS_NODE_ACCESSED);
tmpfs_update(v->a_vp);
return (fifo_specops.vop_close(v));
 }

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Tue Apr  2 13:41:26 2019
(r345799)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Tue Apr  2 13:49:32 2019
(r345800)
@@ -1110,7 +1110,8 @@ tmpfs_dir_destroy(struct tmpfs_mount *tmp, struct tmpf
  * error happens.
  */
 static int
-tmpfs_dir_getdotdent(struct tmpfs_node *node, struct uio *uio)
+tmpfs_dir_getdotdent(struct tmpfs_mount *tm, struct tmpfs_node *node,
+struct uio *uio)
 {
int error;
struct dirent dent;
@@ -1130,7 +1131,7 @@ tmpfs_dir_getdotdent(struct tmpfs_node *node, struct u
else
error = uiomove(&dent, dent.d_reclen, uio);
 
-   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
+   tmpfs_set_status(tm, node, TMPFS_NODE_ACCESSED);
 
return (error);
 }
@@ -1143,7 +1144,8 @@ tmpfs_dir_getdotdent(struct tmpfs_node *node, struct u
  * error happens.
  */
 static int
-tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struct uio *uio)
+tmpfs_dir_getdotdotdent(struct tmpfs_mount *tm, struct tmpfs_node *node,
+struct uio *uio)
 {
int error;
struct dirent dent;
@@ -1174,7 +1176,7 @@ tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struc
else
error = uiomove(&dent, dent.d_reclen, uio);
 
-   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
+   tmpfs_set_status(tm, node, TMPFS_NODE_ACCESSED);
 
return (error);
 }
@@ -1187,8 +1189,8 @@ tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struc
  * error code if another error happens.
  */
 int
-tmpfs_dir_getdents(struct tmpfs_node *node, struct uio *uio, int maxcookies,
-u_long *cookies, int *ncookies)
+tmpfs_dir_getdents(struct tmpfs_mount *tm, struct tmpfs_node *node,
+struct uio *uio, int maxcookies, u_long *cookies, int *ncookies)
 {
struct tmpfs_dir_cursor dc;
struct tmpfs_dirent *de;
@@ -1209,7 +1211,7 @@ tmpfs_dir_getdents(struct tmpfs_node *node, struct uio
 */
switch (uio->uio_offset) {
case TMPFS_DIRCOOKIE_DOT:
-   error = tmpfs_dir_getdotdent(node, uio);
+   error = tmpfs_dir_getdotdent(tm, node, uio);
if (error != 0)
return (err

Re: svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd

2019-04-02 Thread Andrey V. Elsukov
On 02.04.2019 16:40, Baptiste Daroussin wrote:
>> URL: https://svnweb.freebsd.org/changeset/base/345797
>>
>> Log:
>>   Add IPv6 transport for bsnmp.
>>   
>>   This patch adds a new table begemotSnmpdTransInetTable that uses the
>>   InetAddressType textual convention and can be used to create listening
>>   ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports
>>   future extension beyond UDP by adding a protocol identifier to the table
>>   index. In order to support this gensnmptree had to be modified.
>>   
>>   Submitted by:   harti
>>   MFC after:  1 month
>>   Relnotes:   yes
>>   Differential Revision:  https://reviews.freebsd.org/D16654
>>
> Jumping in this commit, maybe it is time to move bsnmpd out of contrib, given
> that all the dev appears to only be in our own source tree right?

I think it is better to ask harti@

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


svn commit: r345799 - head/sys/fs/tmpfs

2019-04-02 Thread Konstantin Belousov
Author: kib
Date: Tue Apr  2 13:41:26 2019
New Revision: 345799
URL: https://svnweb.freebsd.org/changeset/base/345799

Log:
  Block creation of the new nodes for read-only tmpfs mounts.
  
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D19737

Modified:
  head/sys/fs/tmpfs/tmpfs_subr.c

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Tue Apr  2 13:38:00 2019
(r345798)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Tue Apr  2 13:41:26 2019
(r345799)
@@ -218,6 +218,8 @@ tmpfs_alloc_node(struct mount *mp, struct tmpfs_mount 
 */
return (EBUSY);
}
+   if ((mp->mnt_kern_flag & MNT_RDONLY) != 0)
+   return (EROFS);
 
nnode = (struct tmpfs_node *)uma_zalloc_arg(tmp->tm_node_pool, tmp,
M_WAITOK);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd

2019-04-02 Thread Baptiste Daroussin
On Tue, Apr 02, 2019 at 12:50:01PM +, Andrey V. Elsukov wrote:
> Author: ae
> Date: Tue Apr  2 12:50:01 2019
> New Revision: 345797
> URL: https://svnweb.freebsd.org/changeset/base/345797
> 
> Log:
>   Add IPv6 transport for bsnmp.
>   
>   This patch adds a new table begemotSnmpdTransInetTable that uses the
>   InetAddressType textual convention and can be used to create listening
>   ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports
>   future extension beyond UDP by adding a protocol identifier to the table
>   index. In order to support this gensnmptree had to be modified.
>   
>   Submitted by:   harti
>   MFC after:  1 month
>   Relnotes:   yes
>   Differential Revision:  https://reviews.freebsd.org/D16654
> 
Jumping in this commit, maybe it is time to move bsnmpd out of contrib, given
that all the dev appears to only be in our own source tree right?

Best regards,
Bapt


signature.asc
Description: PGP signature


svn commit: r345798 - head/contrib/bsnmp/snmp_mibII

2019-04-02 Thread Andrey V. Elsukov
Author: ae
Date: Tue Apr  2 13:38:00 2019
New Revision: 345798
URL: https://svnweb.freebsd.org/changeset/base/345798

Log:
  Create 64bit mibII counters for all interfaces.
  
  PR:   157015
  Obtained from:Yandex LLC
  MFC after:1 month

Modified:
  head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c

Modified: head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
==
--- head/contrib/bsnmp/snmp_mibII/mibII_interfaces.cTue Apr  2 12:50:01 
2019(r345797)
+++ head/contrib/bsnmp/snmp_mibII/mibII_interfaces.cTue Apr  2 13:38:00 
2019(r345798)
@@ -373,11 +373,6 @@ op_ifxtable(struct snmp_context *ctx, struct snmp_valu
 
switch (op) {
 
-  again:
-   if (op != SNMP_OP_GETNEXT)
-   return (SNMP_ERR_NOSUCHNAME);
-   /* FALLTHROUGH */
-
  case SNMP_OP_GETNEXT:
if ((ifp = NEXT_OBJECT_INT(&mibif_list, &value->var, sub)) == 
NULL)
return (SNMP_ERR_NOSUCHNAME);
@@ -460,52 +455,36 @@ op_ifxtable(struct snmp_context *ctx, struct snmp_valu
break;
 
  case LEAF_ifHCInOctets:
-   if (!(ifp->flags & MIBIF_HIGHSPEED))
-   goto again;
value->v.counter64 = MIBIF_PRIV(ifp)->hc_inoctets;
break;
 
  case LEAF_ifHCInUcastPkts:
-   if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
-   goto again;
value->v.counter64 = MIBIF_PRIV(ifp)->hc_ipackets -
MIBIF_PRIV(ifp)->hc_imcasts;
break;
 
  case LEAF_ifHCInMulticastPkts:
-   if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
-   goto again;
value->v.counter64 = MIBIF_PRIV(ifp)->hc_imcasts;
break;
 
  case LEAF_ifHCInBroadcastPkts:
-   if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
-   goto again;
value->v.counter64 = 0;
break;
 
  case LEAF_ifHCOutOctets:
-   if (!(ifp->flags & MIBIF_HIGHSPEED))
-   goto again;
value->v.counter64 = MIBIF_PRIV(ifp)->hc_outoctets;
break;
 
  case LEAF_ifHCOutUcastPkts:
-   if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
-   goto again;
value->v.counter64 = MIBIF_PRIV(ifp)->hc_opackets -
MIBIF_PRIV(ifp)->hc_omcasts;
break;
 
  case LEAF_ifHCOutMulticastPkts:
-   if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
-   goto again;
value->v.counter64 = MIBIF_PRIV(ifp)->hc_omcasts;
break;
 
  case LEAF_ifHCOutBroadcastPkts:
-   if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
-   goto again;
value->v.counter64 = 0;
break;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd

2019-04-02 Thread Andrey V. Elsukov
Author: ae
Date: Tue Apr  2 12:50:01 2019
New Revision: 345797
URL: https://svnweb.freebsd.org/changeset/base/345797

Log:
  Add IPv6 transport for bsnmp.
  
  This patch adds a new table begemotSnmpdTransInetTable that uses the
  InetAddressType textual convention and can be used to create listening
  ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports
  future extension beyond UDP by adding a protocol identifier to the table
  index. In order to support this gensnmptree had to be modified.
  
  Submitted by:   harti
  MFC after:  1 month
  Relnotes:   yes
  Differential Revision:  https://reviews.freebsd.org/D16654

Added:
  head/contrib/bsnmp/snmpd/trans_inet.c
  head/contrib/bsnmp/snmpd/trans_inet.h
Modified:
  head/contrib/bsnmp/gensnmptree/gensnmptree.1
  head/contrib/bsnmp/gensnmptree/gensnmptree.c
  head/contrib/bsnmp/lib/snmpclient.c
  head/contrib/bsnmp/lib/snmpclient.h
  head/contrib/bsnmp/lib/tc.def
  head/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt
  head/contrib/bsnmp/snmpd/main.c
  head/contrib/bsnmp/snmpd/snmpd.config
  head/contrib/bsnmp/snmpd/snmpd.h
  head/contrib/bsnmp/snmpd/snmpmod.h
  head/contrib/bsnmp/snmpd/trans_lsock.c
  head/contrib/bsnmp/snmpd/trans_udp.c
  head/contrib/bsnmp/snmpd/tree.def
  head/lib/libbsnmp/libbsnmp/Makefile
  head/usr.sbin/bsnmpd/bsnmpd/Makefile
  head/usr.sbin/bsnmpd/bsnmpd/snmpd.config

Modified: head/contrib/bsnmp/gensnmptree/gensnmptree.1
==
--- head/contrib/bsnmp/gensnmptree/gensnmptree.1Tue Apr  2 12:02:35 
2019(r345796)
+++ head/contrib/bsnmp/gensnmptree/gensnmptree.1Tue Apr  2 12:50:01 
2019(r345797)
@@ -31,7 +31,7 @@
 .\"
 .\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $
 .\"
-.Dd June 29, 2018
+.Dd April 2, 2019
 .Dt GENSNMPTREE 1
 .Os
 .Sh NAME
@@ -100,25 +100,11 @@ is the length of the OID.
 is the last component of the OID.
 .El
 .It Fl F
-Together with
-.Fl E
-causes
-.Nm
-instead of the generation of enum definitions the generation of
-functions for checking a value to be one of the enumeration variants and
-for conversion between strings and the enum. The file is sent to standard
-output and is meant to be included into a C-file for compilation.
+emit definitions for C-functions includeable in a C-file that do some basic
+stuff on enums like value checking and conversion between value and strings.
 .It Fl f
-This flag can be used together with
-.Fl E
-or when generating the tree files. It causes
-.Nm
-to emit static inline functions for checking a value to be one of the
-enumeration values and for conversion between strings and the enum.
-If used when generating the tree files, the preprocessor symbol
-.Ar SNMPTREE_TYPES
-must be defined when including the tree header file for these definitions
-to become visible.
+emit definitions for inline C-functions that do some basic
+stuff on enums like value checking and conversion between value and strings.
 .It Fl h
 Print a short help page.
 .It Fl I Ar directory
@@ -136,36 +122,6 @@ Instead of normal output print the resulting tree.
 Prefix the file names and the table name with
 .Ar prefix .
 .El
-.Pp
-The following functions are generated by
-.Fl f
-or
-.Fl F :
-.Pp
-.Ft static inline int
-.Fn isok_EnumName "enum EnumName" ;
-.Pp
-.Ft static inline const char *
-.Fn tostr_EnumName "enum EnumName" ;
-.Pp
-.Ft static inline int
-.Fn fromstr_EnumName "const char *" "enum EnumName *" ;
-.Pp
-The
-.Fa EnumName
-is replaced with the enumeration name.
-.Fn isok_EnumName
-returns 1 if the argument is one of the valid enum values and 0 otherwise.
-.Fn tostr_EnumName
-returns a string representation of the enumeration value.
-If the values is not one of the legal values
-.Ar EnumName???
-is returned.
-.Fn fromstr_EnumName
-returns 1 if the string represents one of the legal enumeration values and
-0 otherwise.
-If 1 is return the variable pointed to by the second argument is set to
-the enumeration value.
 .Sh MIBS
 The syntax of the MIB description file can formally be specified as follows:
 .Bd -unfilled -offset indent

Modified: head/contrib/bsnmp/gensnmptree/gensnmptree.c
==
--- head/contrib/bsnmp/gensnmptree/gensnmptree.cTue Apr  2 12:02:35 
2019(r345796)
+++ head/contrib/bsnmp/gensnmptree/gensnmptree.cTue Apr  2 12:50:01 
2019(r345797)
@@ -110,7 +110,6 @@ static int debug;
 
 static const char usgtxt[] = "\
 Generate SNMP tables.\n\
-$Id$\n\
 usage: gensnmptree [-dEeFfhlt] [-I directory] [-i infile] [-p prefix]\n\
[name]...\n\
 options:\n\
@@ -127,6 +126,37 @@ options:\n\
   -t   generate a .def file\n\
 ";
 
+/**
+ * Program operation.
+ */
+enum op {
+   /** generate the tree */
+   OP_GEN,
+
+   /** extract OIDs */
+   OP_EXTRACT,
+
+   /** print the parsed tree */
+   OP_TREE,
+
+   /** extract enu

svn commit: r345796 - head/sys/riscv/riscv

2019-04-02 Thread Ruslan Bukin
Author: br
Date: Tue Apr  2 12:02:35 2019
New Revision: 345796
URL: https://svnweb.freebsd.org/changeset/base/345796

Log:
  o Grab the number of devices supported by PLIC from FDT.
  o Fix bug in PLIC_ENABLE macro when irq >= 32.
  
  Tested on the real hardware, which is HiFive Unleashed board.
  
  Thanks to SiFive, Inc. for the board provided.
  
  Reviewed by:  markj
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D19775

Modified:
  head/sys/riscv/riscv/plic.c

Modified: head/sys/riscv/riscv/plic.c
==
--- head/sys/riscv/riscv/plic.c Tue Apr  2 09:33:30 2019(r345795)
+++ head/sys/riscv/riscv/plic.c Tue Apr  2 12:02:35 2019(r345796)
@@ -52,9 +52,9 @@ __FBSDID("$FreeBSD$");
 
 #include "pic_if.h"
 
-#definePLIC_NIRQS  32
+#definePLIC_MAX_IRQS   2048
 #definePLIC_PRIORITY(n)(0x00 + (n) * 0x4)
-#definePLIC_ENABLE(n, h)   (0x002000 + (h) * 0x80 + (n) / 32)
+#definePLIC_ENABLE(n, h)   (0x002000 + (h) * 0x80 + 4 * ((n) / 32))
 #definePLIC_THRESHOLD(h)   (0x20 + (h) * 0x1000 + 0x0)
 #definePLIC_CLAIM(h)   (0x20 + (h) * 0x1000 + 0x4)
 
@@ -66,7 +66,8 @@ struct plic_irqsrc {
 struct plic_softc {
device_tdev;
struct resource *   intc_res;
-   struct plic_irqsrc  isrcs[PLIC_NIRQS];
+   struct plic_irqsrc  isrcs[PLIC_MAX_IRQS];
+   int ndev;
 };
 
 #defineRD4(sc, reg)\
@@ -158,7 +159,7 @@ plic_map_intr(device_t dev, struct intr_map_data *data
return (ENOTSUP);
 
daf = (struct intr_map_data_fdt *)data;
-   if (daf->ncells != 1 || daf->cells[0] >= PLIC_NIRQS)
+   if (daf->ncells != 1 || daf->cells[0] > sc->ndev)
return (EINVAL);
 
*isrcp = &sc->isrcs[daf->cells[0]].isrc;
@@ -189,6 +190,7 @@ plic_attach(device_t dev)
struct intr_pic *pic;
uint32_t irq;
const char *name;
+   phandle_t node;
phandle_t xref;
uint32_t cpu;
int error;
@@ -198,6 +200,20 @@ plic_attach(device_t dev)
 
sc->dev = dev;
 
+   node = ofw_bus_get_node(dev);
+   if ((OF_getencprop(node, "riscv,ndev", &sc->ndev,
+   sizeof(sc->ndev))) < 0) {
+   device_printf(dev,
+   "Error: could not get number of devices\n");
+   return (ENXIO);
+   }
+
+   if (sc->ndev >= PLIC_MAX_IRQS) {
+   device_printf(dev,
+   "Error: invalid ndev (%d)\n", sc->ndev);
+   return (ENXIO);
+   }
+
/* Request memory resources */
rid = 0;
sc->intc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
@@ -211,7 +227,7 @@ plic_attach(device_t dev)
isrcs = sc->isrcs;
name = device_get_nameunit(sc->dev);
cpu = PCPU_GET(cpuid);
-   for (irq = 0; irq < PLIC_NIRQS; irq++) {
+   for (irq = 1; irq <= sc->ndev; irq++) {
isrcs[irq].irq = irq;
error = intr_isrc_register(&isrcs[irq].isrc, sc->dev,
0, "%s,%u", name, irq);
@@ -223,7 +239,7 @@ plic_attach(device_t dev)
}
WR4(sc, PLIC_THRESHOLD(cpu), 0);
 
-   xref = OF_xref_from_node(ofw_bus_get_node(sc->dev));
+   xref = OF_xref_from_node(node);
pic = intr_pic_register(sc->dev, xref);
if (pic == NULL)
return (ENXIO);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"