Re: uninitialized variables [Was: svn commit: r365445 - head/sys/cam/mmc]

2020-09-08 Thread Andriy Gapon
On 09/09/2020 08:49, Andriy Gapon wrote:
> On 08/09/2020 15:48, Mark Johnston wrote:
>> I observed the same thing recently as well: the compiler catches
>> uninitialized variables only in simple cases.  In my case, any uses of
>> goto within the function seemed to silence the warning, even if they
>> appeared after the uninitialized reference.
> 
> I am running a kernel build now with this addition (for clang):
> CWARNEXTRA+=   -Wconditional-uninitialized 
> -Wno-error-conditional-uninitialized
> 
> It produces a ton of warnings.
> Some of them are probably false positives, but some look quite reasonable.
> 
> E.g.:
> sys/cam/cam_periph.c:314:19: warning: variable 'p_drv' may be uninitialized 
> when
> used here [-Wconditional-uninitialized]
> TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
> 
> Indeed, there is a conditional 'goto failure' before a first assignment to 
> p_drv
> and the line is after the label.  So, maybe the situation is impossible, but 
> it
> is reasonable to warn about it.
> 
> But the number of false positives (and "possible but impossible" situations) 
> is
> too overwhelming.

But but:
/usr/devel/git//sys/cam/mmc/mmc_da.c:1824:6: warning: variable 'part_index' may
be uninitialized when used here [-Wconditional-uninitialized]
if (part_index != softc->part_curr) {
^~
/usr/devel/git//sys/cam/mmc/mmc_da.c:1800:16: note: initialize the variable
'part_index' to silence this warning
int part_index;
  ^
   = 0
1 warning generated.

There are useful true positives as well.

-- 
Andriy Gapon
___
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"


uninitialized variables [Was: svn commit: r365445 - head/sys/cam/mmc]

2020-09-08 Thread Andriy Gapon
On 08/09/2020 15:48, Mark Johnston wrote:
> I observed the same thing recently as well: the compiler catches
> uninitialized variables only in simple cases.  In my case, any uses of
> goto within the function seemed to silence the warning, even if they
> appeared after the uninitialized reference.

I am running a kernel build now with this addition (for clang):
CWARNEXTRA+=   -Wconditional-uninitialized -Wno-error-conditional-uninitialized

It produces a ton of warnings.
Some of them are probably false positives, but some look quite reasonable.

E.g.:
sys/cam/cam_periph.c:314:19: warning: variable 'p_drv' may be uninitialized when
used here [-Wconditional-uninitialized]
TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);

Indeed, there is a conditional 'goto failure' before a first assignment to p_drv
and the line is after the label.  So, maybe the situation is impossible, but it
is reasonable to warn about it.

But the number of false positives (and "possible but impossible" situations) is
too overwhelming.

-- 
Andriy Gapon
___
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: r365494 - head/lib/libc/tests/stdlib/dynthr_mod

2020-09-08 Thread Kyle Evans
Author: kevans
Date: Wed Sep  9 02:45:47 2020
New Revision: 365494
URL: https://svnweb.freebsd.org/changeset/base/365494

Log:
  libc tests: dynthr_mod: fix some WARNS issues
  
  This is being addressed as part of a side-patch I'm working on that builds
  all the things with WARNS=6, instead of relying on it being supplied in just
  shallow parts of the build with higher-level Makefile.inc.
  
  Provide a prototype for mod_main and annotate the thread function argument
  as unused.
  
  MFC after:1 week

Modified:
  head/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c

Modified: head/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c
==
--- head/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c  Wed Sep  9 02:42:21 
2020(r365493)
+++ head/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c  Wed Sep  9 02:45:47 
2020(r365494)
@@ -41,10 +41,12 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+void mod_main(int op);
+
 static pthread_t thr;
 
 static void *
-mod_thread(void *ptr)
+mod_thread(void *ptr __unused)
 {
char *volatile dummy;
 
___
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: r365493 - head/lib/libc/tests/resolv

2020-09-08 Thread Kyle Evans
Author: kevans
Date: Wed Sep  9 02:42:21 2020
New Revision: 365493
URL: https://svnweb.freebsd.org/changeset/base/365493

Log:
  libc/resolv: attempt to fix the test under WARNS=6
  
  In a side-change that I'm working on to start defaulting src builds to
  WARNS=6 where WARNS isn't otherwise specified, GCC6 (and clang, to a lesser
  extent) pointed out a number of issues with the resolv tests:
  
  - Global method variable that gets shadowed in run_tests()
  - Signed/unsigned comparison between i in run_tests() and hosts->sl_cur
  
  The shadowed variable looks like it might actually be bogus as written, as
  we pass it to RUN_TESTS -> run_tests, but other parts use the global method
  instead. This change is mainly geared towards correcting that by removing
  the global and plumbing the method through from run_tests -> run into the
  new thread.
  
  For the signed/unsigned comparison, there's no compelling reason to not just
  switch i/nthreads/nhosts to size_t.
  
  The review also included a change to the load() function that was better
  addressed by jhb in r365302.
  
  Reviewed by:  ngie, pstef
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D24844

Modified:
  head/lib/libc/tests/resolv/resolv_test.c

Modified: head/lib/libc/tests/resolv/resolv_test.c
==
--- head/lib/libc/tests/resolv/resolv_test.cWed Sep  9 00:41:31 2020
(r365492)
+++ head/lib/libc/tests/resolv/resolv_test.cWed Sep  9 02:42:21 2020
(r365493)
@@ -34,6 +34,8 @@ __RCSID("$NetBSD: resolv.c,v 1.6 2004/05/23 16:59:11 c
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -55,14 +57,13 @@ enum method {
 };
 
 static StringList *hosts = NULL;
-static enum method method = METHOD_GETADDRINFO;
 static int *ask = NULL;
 static int *got = NULL;
 
 static void load(const char *);
-static void resolvone(int);
+static void resolvone(int, enum method);
 static void *resolvloop(void *);
-static void run(int *);
+static void run(int *, enum method);
 
 static pthread_mutex_t stats = PTHREAD_MUTEX_INITIALIZER;
 
@@ -173,18 +174,18 @@ resolv_getipnodeby(pthread_t self, char *host)
 }
 
 static void
-resolvone(int n)
+resolvone(int n, enum method method)
 {
char buf[1024];
pthread_t self = pthread_self();
size_t i = (random() & 0x0fff) % hosts->sl_cur;
char *host = hosts->sl_str[i];
-   struct addrinfo hints, *res;
int error, len;
 
len = snprintf(buf, sizeof(buf), "%p: %d resolving %s %d\n",
self, n, host, (int)i);
(void)write(STDOUT_FILENO, buf, len);
+   error = 0;
switch (method) {
case METHOD_GETADDRINFO:
error = resolv_getaddrinfo(self, host, i);
@@ -196,6 +197,10 @@ resolvone(int n)
error = resolv_getipnodeby(self, host);
break;
default:
+   /* UNREACHABLE */
+   /* XXX Needs an __assert_unreachable() for userland. */
+   assert(0 && "Unreachable segment reached");
+   abort();
break;
}
pthread_mutex_lock();
@@ -204,35 +209,53 @@ resolvone(int n)
pthread_mutex_unlock();
 }
 
+struct resolvloop_args {
+   int *nhosts;
+   enum method method;
+};
+
 static void *
 resolvloop(void *p)
 {
-   int *nhosts = (int *)p;
-   if (*nhosts == 0)
+   struct resolvloop_args *args = p;
+
+   if (*args->nhosts == 0) {
+   free(args);
return NULL;
+   }
+
do
-   resolvone(*nhosts);
-   while (--(*nhosts));
+   resolvone(*args->nhosts, args->method);
+   while (--(*args->nhosts));
+   free(args);
return NULL;
 }
 
 static void
-run(int *nhosts)
+run(int *nhosts, enum method method)
 {
pthread_t self;
int rc;
+   struct resolvloop_args *args;
 
+   /* Created thread is responsible for free(). */
+   args = malloc(sizeof(*args));
+   ATF_REQUIRE(args != NULL);
+
+   args->nhosts = nhosts;
+   args->method = method;
self = pthread_self();
-   rc = pthread_create(, NULL, resolvloop, nhosts);
+   rc = pthread_create(, NULL, resolvloop, args);
ATF_REQUIRE_MSG(rc == 0, "pthread_create failed: %s", strerror(rc));
 }
 
 static int
 run_tests(const char *hostlist_file, enum method method)
 {
-   int nthreads = NTHREADS;
-   int nhosts = NHOSTS;
-   int i, c, done, *nleft;
+   size_t nthreads = NTHREADS;
+   size_t nhosts = NHOSTS;
+   size_t i;
+   int c, done, *nleft;
hosts = sl_init();
 
srandom(1234);
@@ -252,7 +275,7 @@ run_tests(const char *hostlist_file, enum method metho
 
for (i = 0; i < nthreads; i++) {
nleft[i] = nhosts;
-   run([i]);
+   run([i], method);
}
 
for (done = 0; !done;) {

svn commit: r365492 - head/share/man/man5

2020-09-08 Thread Kyle Evans
Author: kevans
Date: Wed Sep  9 00:41:31 2020
New Revision: 365492
URL: https://svnweb.freebsd.org/changeset/base/365492

Log:
  src.conf(5): regen after r365491

Modified:
  head/share/man/man5/src.conf.5

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Wed Sep  9 00:40:54 2020
(r365491)
+++ head/share/man/man5/src.conf.5  Wed Sep  9 00:41:31 2020
(r365492)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd September 7, 2020
+.Dd September 8, 2020
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -1370,12 +1370,6 @@ and related programs.
 Set to not build or install
 .Xr portsnap 8
 and related files.
-When set, it enforces these options:
-.Pp
-.Bl -item -compact
-.It
-.Va WITHOUT_FREEBSD_UPDATE
-.El
 .It Va WITHOUT_PPP
 Set to not build
 .Xr ppp 8
___
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: r365491 - head/share/mk

2020-09-08 Thread Kyle Evans
Author: kevans
Date: Wed Sep  9 00:40:54 2020
New Revision: 365491
URL: https://svnweb.freebsd.org/changeset/base/365491

Log:
  opts: FREEBSD_UPDATE no longer relies on PORTSNAP
  
  phttpget is no longer tied to the portsnap build as of r365490.
  
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D26255

Modified:
  head/share/mk/src.opts.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed Sep  9 00:39:47 2020(r365490)
+++ head/share/mk/src.opts.mk   Wed Sep  9 00:40:54 2020(r365491)
@@ -462,11 +462,6 @@ MK_AUTHPF:=no
 MK_OFED_EXTRA:=no
 .endif
 
-.if ${MK_PORTSNAP} == "no"
-# freebsd-update depends on phttpget from portsnap
-MK_FREEBSD_UPDATE:=no
-.endif
-
 .if ${MK_TESTS} == "no"
 MK_DTRACE_TESTS:= no
 .endif
___
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: r365490 - in head: libexec libexec/phttpget tools/build/mk usr.sbin/portsnap usr.sbin/portsnap/phttpget

2020-09-08 Thread Kyle Evans
Author: kevans
Date: Wed Sep  9 00:39:47 2020
New Revision: 365490
URL: https://svnweb.freebsd.org/changeset/base/365490

Log:
  phttpget: move out of portsnap
  
  Currently, WITHOUT_PORTSNAP forces WITHOUT_FREEBSD_UPDATE because the
  latter relies on phttpget, which lives inside the portsnap build bits.
  
  Remove the dependency between these two options by moving phttpget out into
  ^/libexec and building/installing it if either WITH_PORTSNAP or
  WITH_FREEBSD_UPDATE.
  
  Future work could remove the conditional if it's decided that users will use
  it independently of either the current in-base consumers.
  
  Reported by:  swills
  Reviewed by:  jilles, emaste
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D26255

Added:
  head/libexec/phttpget/
 - copied from r365489, head/usr.sbin/portsnap/phttpget/
Deleted:
  head/usr.sbin/portsnap/phttpget/
Modified:
  head/libexec/Makefile
  head/libexec/phttpget/Makefile
  head/tools/build/mk/OptionalObsoleteFiles.inc
  head/usr.sbin/portsnap/Makefile

Modified: head/libexec/Makefile
==
--- head/libexec/Makefile   Wed Sep  9 00:06:35 2020(r365489)
+++ head/libexec/Makefile   Wed Sep  9 00:39:47 2020(r365490)
@@ -13,6 +13,7 @@ SUBDIR=   ${_atf} \
${_mail.local} \
${_makewhatis.local} \
${_mknetid} \
+   ${_phttpget} \
${_pppoed} \
rc \
revnetgroup \
@@ -46,6 +47,10 @@ SUBDIR+= bootpd
 
 .if ${MK_FINGER} != "no"
 SUBDIR+=   fingerd
+.endif
+
+.if ${MK_FREEBSD_UPDATE} != "no" || ${MK_PORTSNAP} != "no"
+_phttpget= phttpget
 .endif
 
 .if ${MK_FTP} != "no"

Modified: head/libexec/phttpget/Makefile
==
--- head/usr.sbin/portsnap/phttpget/MakefileWed Sep  9 00:06:35 2020
(r365489)
+++ head/libexec/phttpget/Makefile  Wed Sep  9 00:39:47 2020
(r365490)
@@ -3,6 +3,4 @@
 PROG=  phttpget
 MAN=   phttpget.8
 
-BINDIR=${LIBEXECDIR}
-
 .include 

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Wed Sep  9 00:06:35 
2020(r365489)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Wed Sep  9 00:39:47 
2020(r365490)
@@ -2043,6 +2043,11 @@ OLD_FILES+=usr/share/man/man5/freebsd-update.conf.5.gz
 OLD_FILES+=usr/share/man/man8/freebsd-update.8.gz
 .endif
 
+.if ${MK_FREEBSD_UPDATE} == no && ${MK_PORTSNAP} == no
+OLD_FILES+=usr/libexec/phttpget
+OLD_FILES+=usr/share/man/man8/phttpget.8.gz
+.endif
+
 .if ${MK_GAMES} == no
 OLD_FILES+=usr/bin/caesar
 OLD_FILES+=usr/bin/factor
@@ -7330,10 +7335,8 @@ OLD_FILES+=usr/share/man/man8/pmcstudy.8.gz
 .if ${MK_PORTSNAP} == no
 OLD_FILES+=etc/portsnap.conf
 OLD_FILES+=usr/libexec/make_index
-OLD_FILES+=usr/libexec/phttpget
 OLD_FILES+=usr/sbin/portsnap
 OLD_FILES+=usr/share/examples/etc/portsnap.conf
-OLD_FILES+=usr/share/man/man8/phttpget.8.gz
 OLD_FILES+=usr/share/man/man8/portsnap.8.gz
 .endif
 

Modified: head/usr.sbin/portsnap/Makefile
==
--- head/usr.sbin/portsnap/Makefile Wed Sep  9 00:06:35 2020
(r365489)
+++ head/usr.sbin/portsnap/Makefile Wed Sep  9 00:39:47 2020
(r365490)
@@ -1,5 +1,5 @@
 # $FreeBSD$
 
-SUBDIR=portsnap make_index phttpget
+SUBDIR=portsnap make_index
 
 .include 
___
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: r365489 - head/contrib/elftoolchain/libelf

2020-09-08 Thread Brandon Bergren
Author: bdragon
Date: Wed Sep  9 00:06:35 2020
New Revision: 365489
URL: https://svnweb.freebsd.org/changeset/base/365489

Log:
  [PowerPC64LE] PPC64LE support for libelf.
  
  Fix native detection when building on powerpc64le.
  
  I will be submitting this and r361104 upstream shortly.
  
  Sponsored by: Tag1 Consulting, Inc.

Modified:
  head/contrib/elftoolchain/libelf/_libelf_config.h

Modified: head/contrib/elftoolchain/libelf/_libelf_config.h
==
--- head/contrib/elftoolchain/libelf/_libelf_config.h   Wed Sep  9 00:00:43 
2020(r365488)
+++ head/contrib/elftoolchain/libelf/_libelf_config.h   Wed Sep  9 00:06:35 
2020(r365489)
@@ -94,7 +94,11 @@
 #elif  defined(__powerpc64__)
 
 #defineLIBELF_ARCH EM_PPC64
+#if__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#defineLIBELF_BYTEORDERELFDATA2LSB
+#else
 #defineLIBELF_BYTEORDERELFDATA2MSB
+#endif
 #defineLIBELF_CLASSELFCLASS64
 
 #elif  defined(__powerpc__)
___
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: r365488 - head/sys/vm

2020-09-08 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 00:00:43 2020
New Revision: 365488
URL: https://svnweb.freebsd.org/changeset/base/365488

Log:
  Allow consumer to customize physical pager.
  
  Add support for user-supplied callbacks into phys pager operations,
  providing custom getpages(), haspage(), and populate() methods
  implementations.  Pager stores user data ptr/val in the object to
  provide context.
  
  Add phys_pager_allocate() helper that takes user ops table as one of
  the arguments.
  
  Current code for these methods is moved to the 'default' ops table,
  assigned automatically when vm_pager_alloc() is used.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/vm/phys_pager.c
  head/sys/vm/vm_object.c
  head/sys/vm/vm_object.h
  head/sys/vm/vm_pager.h

Modified: head/sys/vm/phys_pager.c
==
--- head/sys/vm/phys_pager.cTue Sep  8 23:48:49 2020(r365487)
+++ head/sys/vm/phys_pager.cWed Sep  9 00:00:43 2020(r365488)
@@ -51,6 +51,20 @@ static struct pagerlst phys_pager_object_list;
 /* protect access to phys_pager_object_list */
 static struct mtx phys_pager_mtx;
 
+static int default_phys_pager_getpages(vm_object_t object, vm_page_t *m,
+int count, int *rbehind, int *rahead);
+static int default_phys_pager_populate(vm_object_t object, vm_pindex_t pidx,
+int fault_type, vm_prot_t max_prot, vm_pindex_t *first, vm_pindex_t *last);
+static boolean_t default_phys_pager_haspage(vm_object_t object,
+vm_pindex_t pindex, int *before, int *after);
+struct phys_pager_ops default_phys_pg_ops = {
+   .phys_pg_getpages = default_phys_pager_getpages,
+   .phys_pg_populate = default_phys_pager_populate,
+   .phys_pg_haspage = default_phys_pager_haspage,
+   .phys_pg_ctor = NULL,
+   .phys_pg_dtor = NULL,
+};
+
 static void
 phys_pager_init(void)
 {
@@ -59,12 +73,13 @@ phys_pager_init(void)
mtx_init(_pager_mtx, "phys_pager list", NULL, MTX_DEF);
 }
 
-static vm_object_t
-phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
-vm_ooffset_t foff, struct ucred *cred)
+vm_object_t
+phys_pager_allocate(void *handle, struct phys_pager_ops *ops, void *data,
+vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff, struct ucred *cred)
 {
vm_object_t object, object1;
vm_pindex_t pindex;
+   bool init;
 
/*
 * Offset should be page aligned.
@@ -73,6 +88,7 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_p
return (NULL);
 
pindex = OFF_TO_IDX(foff + PAGE_MASK + size);
+   init = true;
 
if (handle != NULL) {
mtx_lock(_pager_mtx);
@@ -97,11 +113,15 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_p
 */
if (pindex > object->size)
object->size = pindex;
+   init = false;
} else {
object = object1;
object1 = NULL;
object->handle = handle;
-   vm_object_set_flag(object, OBJ_POPULATE);
+   object->un_pager.phys.ops = ops;
+   object->un_pager.phys.data_ptr = data;
+   if (ops->phys_pg_populate != NULL)
+   vm_object_set_flag(object, 
OBJ_POPULATE);
TAILQ_INSERT_TAIL(_pager_object_list,
object, pager_object_list);
}
@@ -113,12 +133,25 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_p
vm_object_deallocate(object1);
} else {
object = vm_object_allocate(OBJT_PHYS, pindex);
-   vm_object_set_flag(object, OBJ_POPULATE);
+   object->un_pager.phys.ops = ops;
+   object->un_pager.phys.data_ptr = data;
+   if (ops->phys_pg_populate != NULL)
+   vm_object_set_flag(object, OBJ_POPULATE);
}
+   if (init && ops->phys_pg_ctor != NULL)
+   ops->phys_pg_ctor(object, prot, foff, cred);
 
return (object);
 }
 
+static vm_object_t
+phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
+vm_ooffset_t foff, struct ucred *ucred)
+{
+   return (phys_pager_allocate(handle, _phys_pg_ops, NULL,
+   size, prot, foff, ucred));
+}
+
 static void
 phys_pager_dealloc(vm_object_t object)
 {
@@ -130,16 +163,18 @@ phys_pager_dealloc(vm_object_t object)
mtx_unlock(_pager_mtx);
VM_OBJECT_WLOCK(object);
}
-   object->handle = NULL;
object->type = OBJT_DEAD;
+   if 

svn commit: r365486 - in head/sys: sys vm

2020-09-08 Thread Konstantin Belousov
Author: kib
Date: Tue Sep  8 23:48:19 2020
New Revision: 365486
URL: https://svnweb.freebsd.org/changeset/base/365486

Log:
  Add kern_mmap_racct_check(), a helper to verify limits in vm_mmap*().
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/sys/syscallsubr.h
  head/sys/vm/vm_mmap.c

Modified: head/sys/sys/syscallsubr.h
==
--- head/sys/sys/syscallsubr.h  Tue Sep  8 23:38:49 2020(r365485)
+++ head/sys/sys/syscallsubr.h  Tue Sep  8 23:48:19 2020(r365486)
@@ -62,6 +62,7 @@ struct sockaddr;
 struct stat;
 struct thr_param;
 struct uio;
+struct vm_map;
 
 typedef int (*mmap_check_fp_fn)(struct file *, int, int, int);
 
@@ -197,8 +198,10 @@ intkern_mlock(struct proc *proc, struct ucred 
*cred, 
size_t len);
 intkern_mmap(struct thread *td, uintptr_t addr, size_t len, int prot,
int flags, int fd, off_t pos);
-intkern_mmap_req(struct thread *td, const struct mmap_req *mrp);
+intkern_mmap_racct_check(struct thread *td, struct vm_map *map,
+   vm_size_t size);
 intkern_mmap_maxprot(struct proc *p, int prot);
+intkern_mmap_req(struct thread *td, const struct mmap_req *mrp);
 intkern_mprotect(struct thread *td, uintptr_t addr, size_t size, int prot);
 intkern_msgctl(struct thread *, int, int, struct msqid_ds *);
 intkern_msgrcv(struct thread *, int, void *, size_t, long, int, long *);

Modified: head/sys/vm/vm_mmap.c
==
--- head/sys/vm/vm_mmap.c   Tue Sep  8 23:38:49 2020(r365485)
+++ head/sys/vm/vm_mmap.c   Tue Sep  8 23:48:19 2020(r365486)
@@ -1509,6 +1509,39 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t siz
return (error);
 }
 
+int
+kern_mmap_racct_check(struct thread *td, vm_map_t map, vm_size_t size)
+{
+   int error;
+
+   RACCT_PROC_LOCK(td->td_proc);
+   if (map->size + size > lim_cur(td, RLIMIT_VMEM)) {
+   RACCT_PROC_UNLOCK(td->td_proc);
+   return (ENOMEM);
+   }
+   if (racct_set(td->td_proc, RACCT_VMEM, map->size + size)) {
+   RACCT_PROC_UNLOCK(td->td_proc);
+   return (ENOMEM);
+   }
+   if (!old_mlock && map->flags & MAP_WIREFUTURE) {
+   if (ptoa(pmap_wired_count(map->pmap)) + size >
+   lim_cur(td, RLIMIT_MEMLOCK)) {
+   racct_set_force(td->td_proc, RACCT_VMEM, map->size);
+   RACCT_PROC_UNLOCK(td->td_proc);
+   return (ENOMEM);
+   }
+   error = racct_set(td->td_proc, RACCT_MEMLOCK,
+   ptoa(pmap_wired_count(map->pmap)) + size);
+   if (error != 0) {
+   racct_set_force(td->td_proc, RACCT_VMEM, map->size);
+   RACCT_PROC_UNLOCK(td->td_proc);
+   return (error);
+   }
+   }
+   RACCT_PROC_UNLOCK(td->td_proc);
+   return (0);
+}
+
 /*
  * Internal version of mmap that maps a specific VM object into an
  * map.  Called by mmap for MAP_ANON, vm_mmap, shm_mmap, and vn_mmap.
@@ -1518,39 +1551,15 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_siz
 vm_prot_t maxprot, int flags, vm_object_t object, vm_ooffset_t foff,
 boolean_t writecounted, struct thread *td)
 {
-   boolean_t curmap, fitit;
vm_offset_t max_addr;
int docow, error, findspace, rv;
+   bool curmap, fitit;
 
curmap = map == >td_proc->p_vmspace->vm_map;
if (curmap) {
-   RACCT_PROC_LOCK(td->td_proc);
-   if (map->size + size > lim_cur(td, RLIMIT_VMEM)) {
-   RACCT_PROC_UNLOCK(td->td_proc);
-   return (ENOMEM);
-   }
-   if (racct_set(td->td_proc, RACCT_VMEM, map->size + size)) {
-   RACCT_PROC_UNLOCK(td->td_proc);
-   return (ENOMEM);
-   }
-   if (!old_mlock && map->flags & MAP_WIREFUTURE) {
-   if (ptoa(pmap_wired_count(map->pmap)) + size >
-   lim_cur(td, RLIMIT_MEMLOCK)) {
-   racct_set_force(td->td_proc, RACCT_VMEM,
-   map->size);
-   RACCT_PROC_UNLOCK(td->td_proc);
-   return (ENOMEM);
-   }
-   error = racct_set(td->td_proc, RACCT_MEMLOCK,
-   ptoa(pmap_wired_count(map->pmap)) + size);
-   if (error != 0) {
-   racct_set_force(td->td_proc, RACCT_VMEM,
-   map->size);
-   

svn commit: r365487 - head/sys/powerpc/powernv

2020-09-08 Thread Brandon Bergren
Author: bdragon
Date: Tue Sep  8 23:48:49 2020
New Revision: 365487
URL: https://svnweb.freebsd.org/changeset/base/365487

Log:
  [PowerPC64] Fix xive order calculation in qemu TCG
  
  When emulating a single thread system for testing reasons, mp_maxid can
  be 0. This trips up our math for calculating the order.
  
  Account for this to fix xive attachment when emulating a single-thread
  core on qemu powernv (a configuration that doesn't exist in the real world.)
  
  Sponsored by: Tag1 Consulting, Inc.

Modified:
  head/sys/powerpc/powernv/xive.c

Modified: head/sys/powerpc/powernv/xive.c
==
--- head/sys/powerpc/powernv/xive.c Tue Sep  8 23:48:19 2020
(r365486)
+++ head/sys/powerpc/powernv/xive.c Tue Sep  8 23:48:49 2020
(r365487)
@@ -341,7 +341,11 @@ xive_attach(device_t dev)
 
mtx_init(>sc_mtx, "XIVE", NULL, MTX_DEF);
 
-   order = fls(mp_maxid + (mp_maxid - 1)) - 1;
+   /* Workaround for qemu single-thread powernv */
+   if (mp_maxid == 0)
+   order = 1;
+   else
+   order = fls(mp_maxid + (mp_maxid - 1)) - 1;
 
do {
vp_block = opal_call(OPAL_XIVE_ALLOCATE_VP_BLOCK, order);
___
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: r365485 - in head/sys: dev/ksyms dev/xen/gntdev kern

2020-09-08 Thread Konstantin Belousov
Author: kib
Date: Tue Sep  8 23:38:49 2020
New Revision: 365485
URL: https://svnweb.freebsd.org/changeset/base/365485

Log:
  Convert allocations of the phys pager to vm_pager_allocate().
  
  Future changes would require additional initialization of OBJT_PHYS
  objects, and vm_object_allocate() is not suitable for it.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/dev/ksyms/ksyms.c
  head/sys/dev/xen/gntdev/gntdev.c
  head/sys/kern/link_elf.c
  head/sys/kern/link_elf_obj.c

Modified: head/sys/dev/ksyms/ksyms.c
==
--- head/sys/dev/ksyms/ksyms.c  Tue Sep  8 23:28:09 2020(r365484)
+++ head/sys/dev/ksyms/ksyms.c  Tue Sep  8 23:38:49 2020(r365485)
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -51,6 +52,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "linker_if.h"
 
@@ -442,8 +445,8 @@ ksyms_open(struct cdev *dev, int flags, int fmt __unus
ksyms_size_calc();
elfsz = sizeof(struct ksyms_hdr) + ts.ts_symsz + ts.ts_strsz;
 
-   object = vm_object_allocate(OBJT_PHYS,
-   OFF_TO_IDX(round_page(elfsz)));
+   object = vm_pager_allocate(OBJT_PHYS, NULL, round_page(elfsz),
+   VM_PROT_ALL, 0, td->td_ucred);
sc->sc_obj = object;
sc->sc_objsz = elfsz;
 

Modified: head/sys/dev/xen/gntdev/gntdev.c
==
--- head/sys/dev/xen/gntdev/gntdev.cTue Sep  8 23:28:09 2020
(r365484)
+++ head/sys/dev/xen/gntdev/gntdev.cTue Sep  8 23:38:49 2020
(r365485)
@@ -1068,7 +1068,8 @@ mmap_gref(struct per_user_data *priv_user, struct gntd
vm_object_t mem_obj;
struct gntdev_gref *gref;
 
-   mem_obj = vm_object_allocate(OBJT_PHYS, size);
+   mem_obj = vm_pager_allocate(OBJT_PHYS, NULL, size, VM_PROT_ALL, 0,
+   curthread->td_ucred);
if (mem_obj == NULL)
return (ENOMEM);
 

Modified: head/sys/kern/link_elf.c
==
--- head/sys/kern/link_elf.cTue Sep  8 23:28:09 2020(r365484)
+++ head/sys/kern/link_elf.cTue Sep  8 23:38:49 2020(r365485)
@@ -1106,7 +1106,8 @@ link_elf_load_file(linker_class_t cls, const char* fil
 
ef = (elf_file_t) lf;
 #ifdef SPARSE_MAPPING
-   ef->object = vm_object_allocate(OBJT_PHYS, atop(mapsize));
+   ef->object = vm_pager_allocate(OBJT_PHYS, NULL, mapsize, VM_PROT_ALL,
+   0, thread0.td_ucred);
if (ef->object == NULL) {
error = ENOMEM;
goto out;

Modified: head/sys/kern/link_elf_obj.c
==
--- head/sys/kern/link_elf_obj.cTue Sep  8 23:28:09 2020
(r365484)
+++ head/sys/kern/link_elf_obj.cTue Sep  8 23:38:49 2020
(r365485)
@@ -34,16 +34,17 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
+#include 
+#include 
 #include 
-#include 
 
 #include 
 
@@ -53,11 +54,13 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
+#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -905,7 +908,8 @@ link_elf_load_file(linker_class_t cls, const char *fil
 * This stuff needs to be in a single chunk so that profiling etc
 * can get the bounds and gdb can associate offsets with modules
 */
-   ef->object = vm_object_allocate(OBJT_PHYS, atop(round_page(mapsize)));
+   ef->object = vm_pager_allocate(OBJT_PHYS, NULL, round_page(mapsize),
+   VM_PROT_ALL, 0, thread0.td_ucred);
if (ef->object == NULL) {
error = ENOMEM;
goto out;
___
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: r365484 - head/sys/vm

2020-09-08 Thread Konstantin Belousov
Author: kib
Date: Tue Sep  8 23:28:09 2020
New Revision: 365484
URL: https://svnweb.freebsd.org/changeset/base/365484

Log:
  Add interruptible variant of vm_wait(9), vm_wait_intr(9).
  
  Also add msleep flags argument to vm_wait_doms(9).
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/vm/uma_core.c
  head/sys/vm/vm_domainset.c
  head/sys/vm/vm_domainset.h
  head/sys/vm/vm_glue.c
  head/sys/vm/vm_page.c
  head/sys/vm/vm_pageout.h

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Tue Sep  8 23:22:11 2020(r365483)
+++ head/sys/vm/uma_core.c  Tue Sep  8 23:28:09 2020(r365484)
@@ -3611,7 +3611,7 @@ restart:
break;
if (rr && vm_domainset_iter_policy(, ) != 0) {
if ((flags & M_WAITOK) != 0) {
-   vm_wait_doms(>uk_dr.dr_policy->ds_mask);
+   vm_wait_doms(>uk_dr.dr_policy->ds_mask, 0);
goto restart;
}
break;
@@ -4755,7 +4755,7 @@ uma_prealloc(uma_zone_t zone, int items)
break;
}
if (vm_domainset_iter_policy(, ) != 0)
-   vm_wait_doms(>uk_dr.dr_policy->ds_mask);
+   vm_wait_doms(>uk_dr.dr_policy->ds_mask, 0);
}
}
 }

Modified: head/sys/vm/vm_domainset.c
==
--- head/sys/vm/vm_domainset.c  Tue Sep  8 23:22:11 2020(r365483)
+++ head/sys/vm/vm_domainset.c  Tue Sep  8 23:28:09 2020(r365484)
@@ -245,7 +245,7 @@ vm_domainset_iter_page(struct vm_domainset_iter *di, s
/* Wait for one of the domains to accumulate some free pages. */
if (obj != NULL)
VM_OBJECT_WUNLOCK(obj);
-   vm_wait_doms(>di_domain->ds_mask);
+   vm_wait_doms(>di_domain->ds_mask, 0);
if (obj != NULL)
VM_OBJECT_WLOCK(obj);
if ((di->di_flags & VM_ALLOC_WAITFAIL) != 0)
@@ -310,7 +310,7 @@ vm_domainset_iter_policy(struct vm_domainset_iter *di,
return (ENOMEM);
 
/* Wait for one of the domains to accumulate some free pages. */
-   vm_wait_doms(>di_domain->ds_mask);
+   vm_wait_doms(>di_domain->ds_mask, 0);
 
/* Restart the search. */
vm_domainset_iter_first(di, domain);

Modified: head/sys/vm/vm_domainset.h
==
--- head/sys/vm/vm_domainset.h  Tue Sep  8 23:22:11 2020(r365483)
+++ head/sys/vm/vm_domainset.h  Tue Sep  8 23:28:09 2020(r365484)
@@ -50,6 +50,6 @@ void  vm_domainset_iter_policy_init(struct vm_domainset
 void   vm_domainset_iter_policy_ref_init(struct vm_domainset_iter *,
struct domainset_ref *, int *, int *);
 
-void   vm_wait_doms(const domainset_t *);
+intvm_wait_doms(const domainset_t *, int mflags);
 
 #endif  /* __VM_DOMAINSET_H__ */

Modified: head/sys/vm/vm_glue.c
==
--- head/sys/vm/vm_glue.c   Tue Sep  8 23:22:11 2020(r365483)
+++ head/sys/vm/vm_glue.c   Tue Sep  8 23:28:09 2020(r365484)
@@ -565,7 +565,7 @@ vm_forkproc(struct thread *td, struct proc *p2, struct
}
dset = td2->td_domain.dr_policy;
while (vm_page_count_severe_set(>ds_mask)) {
-   vm_wait_doms(>ds_mask);
+   vm_wait_doms(>ds_mask, 0);
}
 
if ((flags & RFMEM) == 0) {

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Tue Sep  8 23:22:11 2020(r365483)
+++ head/sys/vm/vm_page.c   Tue Sep  8 23:28:09 2020(r365484)
@@ -3147,10 +3147,13 @@ vm_wait_count(void)
return (vm_severe_waiters + vm_min_waiters + vm_pageproc_waiters);
 }
 
-void
-vm_wait_doms(const domainset_t *wdoms)
+int
+vm_wait_doms(const domainset_t *wdoms, int mflags)
 {
+   int error;
 
+   error = 0;
+
/*
 * We use racey wakeup synchronization to avoid expensive global
 * locking for the pageproc when sleeping with a non-specific vm_wait.
@@ -3162,8 +3165,8 @@ vm_wait_doms(const domainset_t *wdoms)
if (curproc == pageproc) {
mtx_lock(_domainset_lock);
vm_pageproc_waiters++;
-   msleep(_pageproc_waiters, _domainset_lock, PVM | PDROP,
-   "pageprocwait", 1);
+   error = msleep(_pageproc_waiters, _domainset_lock,
+   PVM | PDROP | mflags, "pageprocwait", 1);
} else {
/*

svn commit: r365483 - head/stand/libofw

2020-09-08 Thread Brandon Bergren
Author: bdragon
Date: Tue Sep  8 23:22:11 2020
New Revision: 365483
URL: https://svnweb.freebsd.org/changeset/base/365483

Log:
  Fix 64-bit build of libofw.
  
  Adjust a couple of printf() lines that deal with dumping out addresses
  to cast to uintmax_t.
  
  This allows building a 64-bit libofw for use in things like a future
  Petitboot loader for PowerPC64, and other FDT platforms that require
  a 64-bit loader binary and want to use forth.
  
  Sponsored by: Tag1 Consulting, Inc.

Modified:
  head/stand/libofw/ofw_memory.c

Modified: head/stand/libofw/ofw_memory.c
==
--- head/stand/libofw/ofw_memory.c  Tue Sep  8 23:19:59 2020
(r365482)
+++ head/stand/libofw/ofw_memory.c  Tue Sep  8 23:22:11 2020
(r365483)
@@ -80,11 +80,11 @@ ofw_memmap(int acells)
"Physical Range", "#Pages", "Mode");
 
for (i = 0; i < nmapping; i++) {
-   sprintf(lbuf, "%08x-%08x\t%08x-%08x\t%8d\t%6x\n",
-   mapptr[i].va,
-   mapptr[i].va + mapptr[i].len,
-   mapptr[i].pa,
-   mapptr[i].pa + mapptr[i].len,
+   sprintf(lbuf, "%08jx-%08jx\t%08jx-%08jx\t%8d\t%6x\n",
+   (uintmax_t)mapptr[i].va,
+   (uintmax_t)mapptr[i].va + mapptr[i].len,
+   (uintmax_t)mapptr[i].pa,
+   (uintmax_t)mapptr[i].pa + mapptr[i].len,
mapptr[i].len / 0x1000,
mapptr[i].mode);
if (pager_output(lbuf))
@@ -98,11 +98,11 @@ ofw_memmap(int acells)
   "Physical Range", "#Pages", "Mode");
 
for (i = 0; i < nmapping; i++) {
-   sprintf(lbuf, "%08x-%08x\t%08x-%08x\t%8d\t%6x\n",
-   mapptr2[i].va,
-   mapptr2[i].va + mapptr2[i].len,
-   mapptr2[i].pa_lo,
-   mapptr2[i].pa_lo + mapptr2[i].len,
+   sprintf(lbuf, "%08jx-%08jx\t%08jx-%08jx\t%8d\t%6x\n",
+   (uintmax_t)mapptr2[i].va,
+   (uintmax_t)mapptr2[i].va + mapptr2[i].len,
+   (uintmax_t)mapptr2[i].pa_lo,
+   (uintmax_t)mapptr2[i].pa_lo + mapptr2[i].len,
mapptr2[i].len / 0x1000,
mapptr2[i].mode);
if (pager_output(lbuf))
___
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: r365481 - in head/sys/powerpc: aim powerpc

2020-09-08 Thread Brandon Bergren
Author: bdragon
Date: Tue Sep  8 22:59:43 2020
New Revision: 365481
URL: https://svnweb.freebsd.org/changeset/base/365481

Log:
  [PowerPC64] Hide dssall instruction from llvm assembler
  
  When doing a build for a modern CPUTYPE, llvm will throw errors if obsolete
  instructions are used, even if they will never run due to runtime checks.
  
  Hiding the dssall instruction from the assembler fixes kernel build when
  overriding CPUTYPE, without having any effect on the generated binary.
  
  This has been in my local tree for over a year and is well tested across
  a variety of machines.
  
  Sponsored by: Tag1 Consulting, Inc.

Modified:
  head/sys/powerpc/aim/aim_machdep.c
  head/sys/powerpc/powerpc/cpu.c

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Tue Sep  8 22:50:24 2020
(r365480)
+++ head/sys/powerpc/aim/aim_machdep.c  Tue Sep  8 22:59:43 2020
(r365481)
@@ -629,7 +629,8 @@ flush_disable_caches(void)
mtspr(SPR_MSSCR0, msscr0);
powerpc_sync();
isync();
-   __asm__ __volatile__("dssall; sync");
+   /* 7e00066c: dssall */
+   __asm__ __volatile__(".long 0x7e00066c; sync");
powerpc_sync();
isync();
__asm__ __volatile__("dcbf 0,%0" :: "r"(0));

Modified: head/sys/powerpc/powerpc/cpu.c
==
--- head/sys/powerpc/powerpc/cpu.c  Tue Sep  8 22:50:24 2020
(r365480)
+++ head/sys/powerpc/powerpc/cpu.c  Tue Sep  8 22:59:43 2020
(r365481)
@@ -753,8 +753,9 @@ cpu_idle_60x(sbintime_t sbt)
case MPC7450:
case MPC7455:
case MPC7457:
+   /* 0x7e00066c: dssall */
__asm __volatile("\
-   dssall; sync; mtmsr %0; isync"
+   .long 0x7e00066c; sync; mtmsr %0; isync"
:: "r"(msr | PSL_POW));
break;
default:
___
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: r365479 - head/sys/powerpc/powerpc

2020-09-08 Thread Brandon Bergren
Author: bdragon
Date: Tue Sep  8 22:42:41 2020
New Revision: 365479
URL: https://svnweb.freebsd.org/changeset/base/365479

Log:
  [PowerPC] Add root_pic assertion.
  
  When enabling an interrupt, assert that we do in fact have a root PIC.
  
  This would have saved me some debugging effort.
  
  Sponsored by: Tag1 Consulting, Inc.

Modified:
  head/sys/powerpc/powerpc/intr_machdep.c

Modified: head/sys/powerpc/powerpc/intr_machdep.c
==
--- head/sys/powerpc/powerpc/intr_machdep.c Tue Sep  8 22:41:35 2020
(r365478)
+++ head/sys/powerpc/powerpc/intr_machdep.c Tue Sep  8 22:42:41 2020
(r365479)
@@ -457,6 +457,8 @@ powerpc_enable_intr(void)
if (root_pic == NULL)
root_pic = piclist[0].dev;
 
+   KASSERT(root_pic != NULL, ("no root PIC!"));
+
 #ifdef SMP
/* Install an IPI handler. */
if (mp_ncpus > 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: r365478 - in head/sys: crypto/armv8 dev/hifn dev/safe

2020-09-08 Thread John Baldwin
Author: jhb
Date: Tue Sep  8 22:41:35 2020
New Revision: 365478
URL: https://svnweb.freebsd.org/changeset/base/365478

Log:
  Don't return errors from the cryptodev_process() method.
  
  The cryptodev_process() method should either return 0 if it has
  completed a request, or ERESTART to defer the request until later.  If
  a request encounters an error, the error should be reported via
  crp_etype before completing the request via crypto_done().
  
  Fix a few more drivers noticed by asomers@ similar to the fix in
  r365389.  This is an old bug, but went unnoticed since crypto requests
  did not start failing as a normal part of operation until digest
  verification was introduced which can fail requests with EBADMSG.
  
  PR:   247986
  Reported by:  asomers
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D26361

Modified:
  head/sys/crypto/armv8/armv8_crypto.c
  head/sys/dev/hifn/hifn7751.c
  head/sys/dev/safe/safe.c

Modified: head/sys/crypto/armv8/armv8_crypto.c
==
--- head/sys/crypto/armv8/armv8_crypto.cTue Sep  8 22:23:53 2020
(r365477)
+++ head/sys/crypto/armv8/armv8_crypto.cTue Sep  8 22:41:35 2020
(r365478)
@@ -281,7 +281,7 @@ armv8_crypto_process(device_t dev, struct cryptop *crp
 out:
crp->crp_etype = error;
crypto_done(crp);
-   return (error);
+   return (0);
 }
 
 static uint8_t *

Modified: head/sys/dev/hifn/hifn7751.c
==
--- head/sys/dev/hifn/hifn7751.cTue Sep  8 22:23:53 2020
(r365477)
+++ head/sys/dev/hifn/hifn7751.cTue Sep  8 22:41:35 2020
(r365478)
@@ -2517,7 +2517,7 @@ errout:
hifnstats.hst_nomem++;
crp->crp_etype = err;
crypto_done(crp);
-   return (err);
+   return (0);
 }
 
 static void

Modified: head/sys/dev/safe/safe.c
==
--- head/sys/dev/safe/safe.cTue Sep  8 22:23:53 2020(r365477)
+++ head/sys/dev/safe/safe.cTue Sep  8 22:41:35 2020(r365478)
@@ -1259,6 +1259,7 @@ errout:
if (err != ERESTART) {
crp->crp_etype = err;
crypto_done(crp);
+   err = 0;
} else {
sc->sc_needwakeup |= CRYPTO_SYMQ;
}
___
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: r365477 - head/sys/geom/part

2020-09-08 Thread Eugene Grosbein
Author: eugen
Date: Tue Sep  8 22:23:53 2020
New Revision: 365477
URL: https://svnweb.freebsd.org/changeset/base/365477

Log:
  geom_part: extend kern.geom.part.check_integrity to work on GPT
  
  There are multiple USB/SATA bridges on the market that unconditionally
  cut some LBAs off connected media. This could be a problem
  for pre-partitioned drives so GEOM complains and does not create
  devices in /dev for slices/partitions preventing access to existing data.
  
  We have kern.geom.part.check_integrity that allows us to correct
  partitioning if changed from default 1 to 0 but it works for MBR only.
  If backup copy of GPT is unavailable due to decreases number of LBAs,
  kernel still does not give access to partitions and prints to dmesg:
  
  GEOM: md0: corrupt or invalid GPT detected.
  GEOM: md0: GPT rejected -- may not be recoverable.
  
  This change makes it work for GPT too, so it created partitions in /dev
  and prints to dmesg this instead:
  
  GEOM: md0: the secondary GPT table is corrupt or invalid.
  GEOM: md0: using the primary only -- recovery suggested.
  
  Then "gpart recover" re-created backup copy of GPT
  and allows further manipulations with partitions.
  
  This change is no-op for default configuration having
  kern.geom.part.check_integrity=1
  
  Reported by:  Alex Korchmar
  MFC after:3 days.

Modified:
  head/sys/geom/part/g_part.c
  head/sys/geom/part/g_part_gpt.c

Modified: head/sys/geom/part/g_part.c
==
--- head/sys/geom/part/g_part.c Tue Sep  8 22:19:06 2020(r365476)
+++ head/sys/geom/part/g_part.c Tue Sep  8 22:23:53 2020(r365477)
@@ -140,9 +140,9 @@ struct g_part_alias_list {
 SYSCTL_DECL(_kern_geom);
 SYSCTL_NODE(_kern_geom, OID_AUTO, part, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
 "GEOM_PART stuff");
-static u_int check_integrity = 1;
+u_int geom_part_check_integrity = 1;
 SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity,
-CTLFLAG_RWTUN, _integrity, 1,
+CTLFLAG_RWTUN, _part_check_integrity, 1,
 "Enable integrity checking");
 static u_int auto_resize = 1;
 SYSCTL_UINT(_kern_geom_part, OID_AUTO, auto_resize,
@@ -428,7 +428,7 @@ g_part_check_integrity(struct g_part_table *table, str
if (failed != 0) {
printf("GEOM_PART: integrity check failed (%s, %s)\n",
pp->name, table->gpt_scheme->name);
-   if (check_integrity != 0)
+   if (geom_part_check_integrity != 0)
return (EINVAL);
table->gpt_corrupt = 1;
}

Modified: head/sys/geom/part/g_part_gpt.c
==
--- head/sys/geom/part/g_part_gpt.c Tue Sep  8 22:19:06 2020
(r365476)
+++ head/sys/geom/part/g_part_gpt.c Tue Sep  8 22:23:53 2020
(r365477)
@@ -66,6 +66,8 @@ SYSCTL_UINT(_kern_geom_part_gpt, OID_AUTO, allow_nesti
 CTASSERT(offsetof(struct gpt_hdr, padding) == 92);
 CTASSERT(sizeof(struct gpt_ent) == 128);
 
+extern u_int geom_part_check_integrity;
+
 #defineEQUUID(a,b) (memcmp(a, b, sizeof(struct uuid)) == 0)
 
 #defineMBRSIZE 512
@@ -480,8 +482,9 @@ gpt_read_hdr(struct g_part_gpt_table *table, struct g_
if (hdr->hdr_lba_self != table->lba[elt])
goto fail;
hdr->hdr_lba_alt = le64toh(buf->hdr_lba_alt);
-   if (hdr->hdr_lba_alt == hdr->hdr_lba_self ||
-   hdr->hdr_lba_alt > last)
+   if (hdr->hdr_lba_alt == hdr->hdr_lba_self)
+   goto fail;
+   if (hdr->hdr_lba_alt > last && geom_part_check_integrity)
goto fail;
 
/* Check the managed area. */
___
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: r365475 - head/sys/net/route

2020-09-08 Thread Ryan Stone
On Tue, Sep 8, 2020 at 5:39 PM Alexander V. Chernikov
 wrote:
> -CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0,
> +CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_MPSAFE, NULL, 0,

Don't you still need CTLFLAG_RW?  I don't believe that the sysctl is
usable at all without it.
___
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: r364465 - in head/sys: conf net net/route

2020-09-08 Thread Alexander V . Chernikov
08.09.2020, 21:03, "Andriy Gapon" :
> On 22/08/2020 00:34, Alexander V. Chernikov wrote:
>>  Author: melifaro
>>  Date: Fri Aug 21 21:34:52 2020
>>  New Revision: 364465
>>  URL: https://svnweb.freebsd.org/changeset/base/364465
>>
>>  Log:
>>    Make net.fibs growable.
>>
>>    Allow to dynamically grow the amount of fibs in each vnet.
>>
>>    This change alters current behavior. Currently, if one defines
>> ROUTETABLES > 1 in the kernel config, each vnet will be created
>> with the number of fibs defined in the kernel config.
>> After this commit vnets will be created with fibs=1.
>>
>>    Dynamic net.fibs is not compatible with net.add_addr_allfibs.
>> The plan is to deprecate the latter and make
>> net.add_addr_allfibs=0 default behaviour.
>>
>>    Reviewed by: glebius
>>    Relnotes: yes
>>    Differential Revision: https://reviews.freebsd.org/D26062
>
> I wonder why no one reported a problem that I am seeing after upgrading past
> this revision. Maybe because I do have net.fibs=2 in my loader.conf?
Hi Andriy,

Does r365475 fix the problem for you?
CTLFLAG_RWTUN flag got slipped through the cracks somewhere :-(

> The problem -- unfortunately I only have a screenshot -- but it's a page fault
> trap in this call chain:
> sysctl_register_all -> sysctl_load_tunable_by_oid_locked -> sysctl_fibs ->
> _sx_xlock.
>
> The crash is on the RTABLES_LOCK() line.
> And it's kind of obvious why.
>
> The tunables, including net.fibs which is declared as RWTUN, are set at
> SI_SUB_TUNABLES stage, but RTABLES_LOCK_INIT() is not called until
> SI_SUB_PROTO_DOMAIN much later. In other words, sysctal_fibs can be called
> earlier than vnet_rtables_init.
>
> I think that the best way to handle the problem would be to add 
> CTLFLAG_NOFETCH
> to the sysctl declaration and then to add -- if necessary at all -- an 
> explicit
> query of the kenv.
>
> --
> Andriy Gapon
___
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: r365475 - head/sys/net/route

2020-09-08 Thread Alexander V . Chernikov
08.09.2020, 22:39, "Alexander V. Chernikov" :
> Author: melifaro
> Date: Tue Sep 8 21:39:34 2020
> New Revision: 365475
> URL: https://svnweb.freebsd.org/changeset/base/365475
>
> Log:
>   Fix panic with net.fibs tunable set in loader.conf.
>
>   Fix by removing forgotten CTLFLAG_RWTUN flag from the sysctl,
>    loader variable will be read later in vnet_rtables_init().
>
>   Reported by: mav
^^ meant to be avg
>
> Modified:
>   head/sys/net/route/route_tables.c
>
> Modified: head/sys/net/route/route_tables.c
> ==
> --- head/sys/net/route/route_tables.c Tue Sep 8 20:53:44 2020 (r365474)
> +++ head/sys/net/route/route_tables.c Tue Sep 8 21:39:34 2020 (r365475)
> @@ -140,7 +140,7 @@ sysctl_fibs(SYSCTL_HANDLER_ARGS)
>  return (error);
>  }
>  SYSCTL_PROC(_net, OID_AUTO, fibs,
> - CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0,
> + CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_MPSAFE, NULL, 0,
>  _fibs, "IU",
>  "set number of fibs");
___
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: r365475 - head/sys/net/route

2020-09-08 Thread Alexander V. Chernikov
Author: melifaro
Date: Tue Sep  8 21:39:34 2020
New Revision: 365475
URL: https://svnweb.freebsd.org/changeset/base/365475

Log:
  Fix panic with net.fibs tunable set in loader.conf.
  
  Fix by removing forgotten CTLFLAG_RWTUN flag from the sysctl,
   loader variable will be read later in vnet_rtables_init().
  
  Reported by:  mav

Modified:
  head/sys/net/route/route_tables.c

Modified: head/sys/net/route/route_tables.c
==
--- head/sys/net/route/route_tables.c   Tue Sep  8 20:53:44 2020
(r365474)
+++ head/sys/net/route/route_tables.c   Tue Sep  8 21:39:34 2020
(r365475)
@@ -140,7 +140,7 @@ sysctl_fibs(SYSCTL_HANDLER_ARGS)
return (error);
 }
 SYSCTL_PROC(_net, OID_AUTO, fibs,
-CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0,
+CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_MPSAFE, NULL, 0,
 _fibs, "IU",
 "set number of fibs");
 
___
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: r364465 - in head/sys: conf net net/route

2020-09-08 Thread Andriy Gapon
On 22/08/2020 00:34, Alexander V. Chernikov wrote:
> Author: melifaro
> Date: Fri Aug 21 21:34:52 2020
> New Revision: 364465
> URL: https://svnweb.freebsd.org/changeset/base/364465
> 
> Log:
>   Make net.fibs growable.
>   
>   Allow to dynamically grow the amount of fibs in each vnet.
>   
>   This change alters current behavior. Currently, if one defines
>ROUTETABLES > 1 in the kernel config, each vnet will be created
>with the number of fibs defined in the kernel config.
>After this commit vnets will be created with fibs=1.
>   
>   Dynamic net.fibs is not compatible with net.add_addr_allfibs.
>The plan is to deprecate the latter and make
>net.add_addr_allfibs=0 default behaviour.
>   
>   Reviewed by:glebius
>   Relnotes:   yes
>   Differential Revision:  https://reviews.freebsd.org/D26062

I wonder why no one reported a problem that I am seeing after upgrading past
this revision.  Maybe because I do have net.fibs=2 in my loader.conf?

The problem -- unfortunately I only have a screenshot -- but it's a page fault
trap in this call chain:
sysctl_register_all -> sysctl_load_tunable_by_oid_locked -> sysctl_fibs ->
_sx_xlock.

The crash is on the RTABLES_LOCK() line.
And it's kind of obvious why.

The tunables, including net.fibs which is declared as RWTUN, are set at
SI_SUB_TUNABLES stage, but RTABLES_LOCK_INIT() is not called until
SI_SUB_PROTO_DOMAIN much later.  In other words, sysctal_fibs can be called
earlier than vnet_rtables_init.

I think that the best way to handle the problem would be to add CTLFLAG_NOFETCH
to the sysctl declaration and then to add -- if necessary at all -- an explicit
query of the kenv.


-- 
Andriy Gapon
___
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: r365466 - head/sys/modules/zfs

2020-09-08 Thread Matt Macy
Author: mmacy
Date: Tue Sep  8 17:47:30 2020
New Revision: 365466
URL: https://svnweb.freebsd.org/changeset/base/365466

Log:
  ZFS: remove some extra defines
  
  When merging a number of defines that are needed in the standalone
  build made it in to the module makefile.
  
  Reported by:  markj@

Modified:
  head/sys/modules/zfs/Makefile

Modified: head/sys/modules/zfs/Makefile
==
--- head/sys/modules/zfs/Makefile   Tue Sep  8 16:43:32 2020
(r365465)
+++ head/sys/modules/zfs/Makefile   Tue Sep  8 17:47:30 2020
(r365466)
@@ -27,21 +27,12 @@ CFLAGS+= -include ${INCDIR}/os/freebsd/spl/sys/ccompil
 CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/static_ccompile.h
 CFLAGS+= -I${.CURDIR}
 
-CFLAGS+= -D__KERNEL__ -DFREEBSD_NAMECACHE -DBUILDING_ZFS  -D__BSD_VISIBLE=1 \
+CFLAGS+= -D__KERNEL__ -DFREEBSD_NAMECACHE -DBUILDING_ZFS \
-DHAVE_UIO_ZEROCOPY -DWITHOUT_NETDUMP -D__KERNEL -D_SYS_CONDVAR_H_ \
-   -D_SYS_VMEM_H_ -DKDTRACE_HOOKS -DSMP -DIN_FREEBSD_BASE -DHAVE_KSID
+   -D_SYS_VMEM_H_ -DIN_FREEBSD_BASE -DHAVE_KSID
 
 .if ${MACHINE_ARCH} == "amd64"
 CFLAGS+= -DHAVE_AVX2 -DHAVE_AVX -D__x86_64 -DHAVE_SSE2 -DHAVE_AVX512F 
-DHAVE_AVX512BW -DHAVE_SSSE3
-.endif
-
-.if defined(WITH_VFS_DEBUG) && ${WITH_VFS_DEBUG} == "true"
-# kernel must also be built with this option for this to work
-CFLAGS+= -DDEBUG_VFS_LOCKS
-.endif
-
-.if defined(WITH_GCOV) && ${WITH_GCOV} == "true"
-CFLAGS+=-fprofile-arcs -ftest-coverage
 .endif
 
 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
___
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: r365464 - head/sys/kern

2020-09-08 Thread Mateusz Guzik
Author: mjg
Date: Tue Sep  8 16:07:47 2020
New Revision: 365464
URL: https://svnweb.freebsd.org/changeset/base/365464

Log:
  fd: fix fhold on an uninitialized var in fdcopy_remapped
  
  Reported by:  gcc9

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cTue Sep  8 16:06:46 2020
(r365463)
+++ head/sys/kern/kern_descrip.cTue Sep  8 16:07:47 2020
(r365464)
@@ -2213,7 +2213,7 @@ fdcopy_remapped(struct filedesc *fdp, const int *fds, 
error = EINVAL;
goto bad;
}
-   if (!fhold(nfde->fde_file)) {
+   if (!fhold(ofde->fde_file)) {
error = EBADF;
goto bad;
}
___
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: r365463 - head/sys/kern

2020-09-08 Thread Mateusz Guzik
Author: mjg
Date: Tue Sep  8 16:06:46 2020
New Revision: 365463
URL: https://svnweb.freebsd.org/changeset/base/365463

Log:
  cache: drop write-only tvp_seqc vars

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Tue Sep  8 16:06:26 2020(r365462)
+++ head/sys/kern/vfs_cache.c   Tue Sep  8 16:06:46 2020(r365463)
@@ -3714,14 +3714,13 @@ cache_fplookup_final_withparent(struct cache_fpl *fpl)
struct componentname *cnp;
enum vgetstate dvs, tvs;
struct vnode *dvp, *tvp;
-   seqc_t dvp_seqc, tvp_seqc;
+   seqc_t dvp_seqc;
int error;
 
cnp = fpl->cnp;
dvp = fpl->dvp;
dvp_seqc = fpl->dvp_seqc;
tvp = fpl->tvp;
-   tvp_seqc = fpl->tvp_seqc;
 
MPASS((cnp->cn_flags & (LOCKPARENT|WANTPARENT)) != 0);
 
@@ -3780,13 +3779,12 @@ cache_fplookup_final(struct cache_fpl *fpl)
struct componentname *cnp;
enum vgetstate tvs;
struct vnode *dvp, *tvp;
-   seqc_t dvp_seqc, tvp_seqc;
+   seqc_t dvp_seqc;
 
cnp = fpl->cnp;
dvp = fpl->dvp;
dvp_seqc = fpl->dvp_seqc;
tvp = fpl->tvp;
-   tvp_seqc = fpl->tvp_seqc;
 
VNPASS(cache_fplookup_vnode_supported(dvp), dvp);
 
___
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: r365462 - head/sys/kern

2020-09-08 Thread Mateusz Guzik
Author: mjg
Date: Tue Sep  8 16:06:26 2020
New Revision: 365462
URL: https://svnweb.freebsd.org/changeset/base/365462

Log:
  vfs: drop a write-only var in vfs_periodic_msync_inactive

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cTue Sep  8 15:39:19 2020(r365461)
+++ head/sys/kern/vfs_subr.cTue Sep  8 16:06:26 2020(r365462)
@@ -4668,11 +4668,8 @@ vfs_periodic_msync_inactive(struct mount *mp, int flag
 {
struct vnode *vp, *mvp;
struct vm_object *obj;
-   struct thread *td;
int lkflags, objflags;
bool seen_defer;
-
-   td = curthread;
 
lkflags = LK_EXCLUSIVE | LK_INTERLOCK;
if (flags != MNT_WAIT) {
___
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: r365460 - in head/sys/arm64: arm64 include

2020-09-08 Thread Mitchell Horne
On Tue, Sep 8, 2020 at 12:36 PM Mitchell Horne  wrote:
>
> Author: mhorne
> Date: Tue Sep  8 15:36:38 2020
> New Revision: 365460
> URL: https://svnweb.freebsd.org/changeset/base/365460
>
> Log:
>   arm64: export new HWCAP features
>
>   Expose some of the new HWCAP features added in r65304. This includes the

Small typo, this should be r365304.

>   addition of elf_hwcap2 into the sysvec, and a separate function to parse
>   for those features.
>
>   This only exposes features which require no further configuration, e.g.
>   indicating the presence of certain instructions. Larger features (SVE)
>   will not be advertised until we actually support them. The exact list of
>   features/extensions this patch exposes is:
> - ARMv8.0-DGH
> - ARMv8.0-SB
> - ARMv8.2-BF16
> - ARMv8.2-DCCVADP
> - ARMv8.2-I8MM
> - ARMv8.4-LRCPC
> - ARMv8.5-CondM
> - ARMv8.5-FRINT
> - ARMv8.5-RNG
> - PSTATE.SSBS
>
>   While here, annotate elf_hwcap and elf_hwcap2 as __read_frequently, and
>   move the declarations to the machine/md_var.h header.
>
>   Submitted by: mikael@ (D22314 portion)
>   MFC after:2 weeks
>   Sponsored by: The FreeBSD Foundation
>   Differential Revision:https://reviews.freebsd.org/D26031
>   Differential Revision:https://reviews.freebsd.org/D22314
>
> Modified:
>   head/sys/arm64/arm64/elf_machdep.c
>   head/sys/arm64/arm64/identcpu.c
>   head/sys/arm64/include/md_var.h
>
> Modified: head/sys/arm64/arm64/elf_machdep.c
> ==
> --- head/sys/arm64/arm64/elf_machdep.c  Tue Sep  8 15:08:20 2020
> (r365459)
> +++ head/sys/arm64/arm64/elf_machdep.c  Tue Sep  8 15:36:38 2020
> (r365460)
> @@ -55,7 +55,8 @@ __FBSDID("$FreeBSD$");
>
>  #include "linker_if.h"
>
> -u_long elf_hwcap;
> +u_long __read_frequently elf_hwcap;
> +u_long __read_frequently elf_hwcap2;
>
>  static struct sysentvec elf64_freebsd_sysvec = {
> .sv_size= SYS_MAXSYSCALL,
> @@ -92,6 +93,7 @@ static struct sysentvec elf64_freebsd_sysvec = {
> .sv_thread_detach = NULL,
> .sv_trap= NULL,
> .sv_hwcap   = _hwcap,
> +   .sv_hwcap2  = _hwcap2,
>  };
>  INIT_SYSENTVEC(elf64_sysvec, _freebsd_sysvec);
>
>
> Modified: head/sys/arm64/arm64/identcpu.c
> ==
> --- head/sys/arm64/arm64/identcpu.c Tue Sep  8 15:08:20 2020
> (r365459)
> +++ head/sys/arm64/arm64/identcpu.c Tue Sep  8 15:36:38 2020
> (r365460)
> @@ -43,11 +43,13 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
> +#include 
> +#include 
>
>  static void print_cpu_features(u_int cpu);
>  static u_long parse_cpu_features_hwcap(void);
> +static u_long parse_cpu_features_hwcap2(void);
>
>  char machine[] = "arm64";
>
> @@ -869,7 +871,7 @@ static struct mrs_field_value id_aa64pfr1_mte[] = {
>
>  static struct mrs_field id_aa64pfr1_fields[] = {
> MRS_FIELD(ID_AA64PFR1, BT, false, MRS_EXACT, id_aa64pfr1_bt),
> -   MRS_FIELD(ID_AA64PFR1, SSBS, false, MRS_EXACT, id_aa64pfr1_ssbs),
> +   MRS_FIELD(ID_AA64PFR1, SSBS, false, MRS_LOWER, id_aa64pfr1_ssbs),
> MRS_FIELD(ID_AA64PFR1, MTE, false, MRS_EXACT, id_aa64pfr1_mte),
> MRS_FIELD_END,
>  };
> @@ -1126,7 +1128,6 @@ update_special_regs(u_int cpu)
>  }
>
>  /* HWCAP */
> -extern u_long elf_hwcap;
>  bool __read_frequently lse_supported = false;
>
>  bool __read_frequently icache_aliasing = false;
> @@ -1156,8 +1157,9 @@ identify_cpu_sysinit(void *dummy __unused)
> idc = false;
> }
>
> -   /* Exposed to userspace as AT_HWCAP */
> +   /* Exposed to userspace as AT_HWCAP and AT_HWCAP2 */
> elf_hwcap = parse_cpu_features_hwcap();
> +   elf_hwcap2 = parse_cpu_features_hwcap2();
>
> if (dic && idc) {
> arm64_icache_sync_range = _dic_idc_icache_sync_range;
> @@ -1194,6 +1196,15 @@ parse_cpu_features_hwcap(void)
>  {
> u_long hwcap = 0;
>
> +   switch (ID_AA64ISAR0_TS_VAL(user_cpu_desc.id_aa64isar0)) {
> +   case ID_AA64ISAR0_TS_CondM_8_4:
> +   case ID_AA64ISAR0_TS_CondM_8_5:
> +   hwcap |= HWCAP_FLAGM;
> +   break;
> +   default:
> +   break;
> +   }
> +
> if (ID_AA64ISAR0_DP_VAL(user_cpu_desc.id_aa64isar0) ==
> ID_AA64ISAR0_DP_IMPL)
> hwcap |= HWCAP_ASIMDDP;
> @@ -1206,6 +1217,10 @@ parse_cpu_features_hwcap(void)
> ID_AA64ISAR0_SM3_IMPL)
> hwcap |= HWCAP_SM3;
>
> +   if (ID_AA64ISAR0_SHA3_VAL(user_cpu_desc.id_aa64isar0) ==
> +   ID_AA64ISAR0_SHA3_IMPL)
> +   hwcap |= HWCAP_SHA3;
> +
> if (ID_AA64ISAR0_RDM_VAL(user_cpu_desc.id_aa64isar0) ==
> ID_AA64ISAR0_RDM_IMPL)
> hwcap |= HWCAP_ASIMDRDM;
> @@ -1229,7 +1244,8 @@ 

svn commit: r365461 - head/sys/libkern

2020-09-08 Thread Mitchell Horne
Author: mhorne
Date: Tue Sep  8 15:39:19 2020
New Revision: 365461
URL: https://svnweb.freebsd.org/changeset/base/365461

Log:
  arm64: check for CRC32 support via HWCAP
  
  Doing it this way eliminates the assumption about homogeneous support
  for the feature, since HWCAP values are only set if support is present
  on all CPUs.
  
  Reviewed by:  tuexen, markj
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26032

Modified:
  head/sys/libkern/gsb_crc32.c

Modified: head/sys/libkern/gsb_crc32.c
==
--- head/sys/libkern/gsb_crc32.cTue Sep  8 15:36:38 2020
(r365460)
+++ head/sys/libkern/gsb_crc32.cTue Sep  8 15:39:19 2020
(r365461)
@@ -58,7 +58,8 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #if defined(__aarch64__)
-#include 
+#include 
+#include 
 #endif
 #endif /* _KERNEL */
 
@@ -755,14 +756,7 @@ calculate_crc32c(uint32_t crc32c,
} else
 #endif
 #if defined(__aarch64__)
-   uint64_t reg;
-
-   /*
-* We only test for CRC32 support on the CPU with index 0 assuming that
-* this applies to all CPUs.
-*/
-   reg = READ_SPECIALREG(id_aa64isar0_el1);
-   if (ID_AA64ISAR0_CRC32_VAL(reg) != ID_AA64ISAR0_CRC32_NONE) {
+   if ((elf_hwcap & HWCAP_CRC32) != 0) {
return (armv8_crc32c(crc32c, buffer, length));
} else
 #endif
___
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: r365460 - in head/sys/arm64: arm64 include

2020-09-08 Thread Mitchell Horne
Author: mhorne
Date: Tue Sep  8 15:36:38 2020
New Revision: 365460
URL: https://svnweb.freebsd.org/changeset/base/365460

Log:
  arm64: export new HWCAP features
  
  Expose some of the new HWCAP features added in r65304. This includes the
  addition of elf_hwcap2 into the sysvec, and a separate function to parse
  for those features.
  
  This only exposes features which require no further configuration, e.g.
  indicating the presence of certain instructions. Larger features (SVE)
  will not be advertised until we actually support them. The exact list of
  features/extensions this patch exposes is:
- ARMv8.0-DGH
- ARMv8.0-SB
- ARMv8.2-BF16
- ARMv8.2-DCCVADP
- ARMv8.2-I8MM
- ARMv8.4-LRCPC
- ARMv8.5-CondM
- ARMv8.5-FRINT
- ARMv8.5-RNG
- PSTATE.SSBS
  
  While here, annotate elf_hwcap and elf_hwcap2 as __read_frequently, and
  move the declarations to the machine/md_var.h header.
  
  Submitted by: mikael@ (D22314 portion)
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26031
  Differential Revision:https://reviews.freebsd.org/D22314

Modified:
  head/sys/arm64/arm64/elf_machdep.c
  head/sys/arm64/arm64/identcpu.c
  head/sys/arm64/include/md_var.h

Modified: head/sys/arm64/arm64/elf_machdep.c
==
--- head/sys/arm64/arm64/elf_machdep.c  Tue Sep  8 15:08:20 2020
(r365459)
+++ head/sys/arm64/arm64/elf_machdep.c  Tue Sep  8 15:36:38 2020
(r365460)
@@ -55,7 +55,8 @@ __FBSDID("$FreeBSD$");
 
 #include "linker_if.h"
 
-u_long elf_hwcap;
+u_long __read_frequently elf_hwcap;
+u_long __read_frequently elf_hwcap2;
 
 static struct sysentvec elf64_freebsd_sysvec = {
.sv_size= SYS_MAXSYSCALL,
@@ -92,6 +93,7 @@ static struct sysentvec elf64_freebsd_sysvec = {
.sv_thread_detach = NULL,
.sv_trap= NULL,
.sv_hwcap   = _hwcap,
+   .sv_hwcap2  = _hwcap2,
 };
 INIT_SYSENTVEC(elf64_sysvec, _freebsd_sysvec);
 

Modified: head/sys/arm64/arm64/identcpu.c
==
--- head/sys/arm64/arm64/identcpu.c Tue Sep  8 15:08:20 2020
(r365459)
+++ head/sys/arm64/arm64/identcpu.c Tue Sep  8 15:36:38 2020
(r365460)
@@ -43,11 +43,13 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
+#include 
 
 static void print_cpu_features(u_int cpu);
 static u_long parse_cpu_features_hwcap(void);
+static u_long parse_cpu_features_hwcap2(void);
 
 char machine[] = "arm64";
 
@@ -869,7 +871,7 @@ static struct mrs_field_value id_aa64pfr1_mte[] = {
 
 static struct mrs_field id_aa64pfr1_fields[] = {
MRS_FIELD(ID_AA64PFR1, BT, false, MRS_EXACT, id_aa64pfr1_bt),
-   MRS_FIELD(ID_AA64PFR1, SSBS, false, MRS_EXACT, id_aa64pfr1_ssbs),
+   MRS_FIELD(ID_AA64PFR1, SSBS, false, MRS_LOWER, id_aa64pfr1_ssbs),
MRS_FIELD(ID_AA64PFR1, MTE, false, MRS_EXACT, id_aa64pfr1_mte),
MRS_FIELD_END,
 };
@@ -1126,7 +1128,6 @@ update_special_regs(u_int cpu)
 }
 
 /* HWCAP */
-extern u_long elf_hwcap;
 bool __read_frequently lse_supported = false;
 
 bool __read_frequently icache_aliasing = false;
@@ -1156,8 +1157,9 @@ identify_cpu_sysinit(void *dummy __unused)
idc = false;
}
 
-   /* Exposed to userspace as AT_HWCAP */
+   /* Exposed to userspace as AT_HWCAP and AT_HWCAP2 */
elf_hwcap = parse_cpu_features_hwcap();
+   elf_hwcap2 = parse_cpu_features_hwcap2();
 
if (dic && idc) {
arm64_icache_sync_range = _dic_idc_icache_sync_range;
@@ -1194,6 +1196,15 @@ parse_cpu_features_hwcap(void)
 {
u_long hwcap = 0;
 
+   switch (ID_AA64ISAR0_TS_VAL(user_cpu_desc.id_aa64isar0)) {
+   case ID_AA64ISAR0_TS_CondM_8_4:
+   case ID_AA64ISAR0_TS_CondM_8_5:
+   hwcap |= HWCAP_FLAGM;
+   break;
+   default:
+   break;
+   }
+
if (ID_AA64ISAR0_DP_VAL(user_cpu_desc.id_aa64isar0) ==
ID_AA64ISAR0_DP_IMPL)
hwcap |= HWCAP_ASIMDDP;
@@ -1206,6 +1217,10 @@ parse_cpu_features_hwcap(void)
ID_AA64ISAR0_SM3_IMPL)
hwcap |= HWCAP_SM3;
 
+   if (ID_AA64ISAR0_SHA3_VAL(user_cpu_desc.id_aa64isar0) ==
+   ID_AA64ISAR0_SHA3_IMPL)
+   hwcap |= HWCAP_SHA3;
+
if (ID_AA64ISAR0_RDM_VAL(user_cpu_desc.id_aa64isar0) ==
ID_AA64ISAR0_RDM_IMPL)
hwcap |= HWCAP_ASIMDRDM;
@@ -1229,7 +1244,8 @@ parse_cpu_features_hwcap(void)
break;
}
 
-   if (ID_AA64ISAR0_SHA1_VAL(user_cpu_desc.id_aa64isar0))
+   if (ID_AA64ISAR0_SHA1_VAL(user_cpu_desc.id_aa64isar0) ==
+   ID_AA64ISAR0_SHA1_BASE)
hwcap |= HWCAP_SHA1;
 
switch (ID_AA64ISAR0_AES_VAL(user_cpu_desc.id_aa64isar0)) {
@@ -1243,9 +1259,20 @@ 

svn commit: r365459 - in head/sys: arm64/include sys

2020-09-08 Thread Mitchell Horne
Author: mhorne
Date: Tue Sep  8 15:08:20 2020
New Revision: 365459
URL: https://svnweb.freebsd.org/changeset/base/365459

Log:
  arm64: fix incorrect HWCAP definitions
  
  FreeBSD exports CPU features as bits in the AT_HWCAP and AT_HWCAP2
  vectors via elf_aux_info(3). This interface is similar to getauxval(3)
  on Linux, and for simplicity to consumers we try to maintain an
  identical set of feature flags on arm64.
  
  The first batch of AT_HWCAP flags were added in r350166, corresponding
  to definitions that already existed in Linux. Unfortunately, one flag
  was missed, and a portion of the values are shifted one bit to the right
  as a result.
  
  Add the missing definition for HWCAP_ASIMDHP, and adjust the affected
  values to match their Linux counterparts.
  
  Although this is an ABI-breaking change, there is no plan to provide
  compat code for old binaries. An audit of our ports tree and other
  software via Debian code search indicates that there are not yet any
  consumers of this interface for FreeBSD/arm64.
  
  Bump __FreeBSD_version to be on the safe side, in case compat code needs
  to be added in the future.
  
  Reviewed by:  emaste, manu
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26329

Modified:
  head/sys/arm64/include/elf.h
  head/sys/sys/param.h

Modified: head/sys/arm64/include/elf.h
==
--- head/sys/arm64/include/elf.hTue Sep  8 15:01:49 2020
(r365458)
+++ head/sys/arm64/include/elf.hTue Sep  8 15:08:20 2020
(r365459)
@@ -102,25 +102,29 @@ __ElfType(Auxinfo);
 #defineHWCAP_CRC32 0x0080
 #defineHWCAP_ATOMICS   0x0100
 #defineHWCAP_FPHP  0x0200
-/* XXX: The following bits don't match the Linux definitions */
-#defineHWCAP_CPUID 0x0400
-#defineHWCAP_ASIMDRDM  0x0800
-#defineHWCAP_JSCVT 0x1000
-#defineHWCAP_FCMA  0x2000
-#defineHWCAP_LRCPC 0x4000
-#defineHWCAP_DCPOP 0x8000
-#defineHWCAP_SHA3  0x0001
-#defineHWCAP_SM3   0x0002
-#defineHWCAP_SM4   0x0004
-#defineHWCAP_ASIMDDP   0x0008
-#defineHWCAP_SHA5120x0010
-#defineHWCAP_SVE   0x0020
-#defineHWCAP_ASIMDFHM  0x0040
-#defineHWCAP_DIT   0x0080
-#defineHWCAP_USCAT 0x0100
-#defineHWCAP_ILRCPC0x0200
-#defineHWCAP_FLAGM 0x0400
-/* XXX: end of incorrect definitions */
+#defineHWCAP_ASIMDHP   0x0400
+/*
+ * XXX: The following bits (from CPUID to FLAGM) were originally incorrect,
+ * but later changed to match the Linux definitions. No compatibility code is
+ * provided, as the fix was expected to result in near-zero fallout.
+ */
+#defineHWCAP_CPUID 0x0800
+#defineHWCAP_ASIMDRDM  0x1000
+#defineHWCAP_JSCVT 0x2000
+#defineHWCAP_FCMA  0x4000
+#defineHWCAP_LRCPC 0x8000
+#defineHWCAP_DCPOP 0x0001
+#defineHWCAP_SHA3  0x0002
+#defineHWCAP_SM3   0x0004
+#defineHWCAP_SM4   0x0008
+#defineHWCAP_ASIMDDP   0x0010
+#defineHWCAP_SHA5120x0020
+#defineHWCAP_SVE   0x0040
+#defineHWCAP_ASIMDFHM  0x0080
+#defineHWCAP_DIT   0x0100
+#defineHWCAP_USCAT 0x0200
+#defineHWCAP_ILRCPC0x0400
+#defineHWCAP_FLAGM 0x0800
 #defineHWCAP_SSBS  0x1000
 #defineHWCAP_SB0x2000
 #defineHWCAP_PACA  0x4000

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hTue Sep  8 15:01:49 2020(r365458)
+++ head/sys/sys/param.hTue Sep  8 15:08:20 2020(r365459)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1300113  /* Master, propagated to newvers */
+#define __FreeBSD_version 1300114  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
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: r365458 - head/usr.bin/sort

2020-09-08 Thread Gordon Bergling
Author: gbe (doc committer)
Date: Tue Sep  8 15:01:49 2020
New Revision: 365458
URL: https://svnweb.freebsd.org/changeset/base/365458

Log:
  sort(1): Remove duplicate option check
  
  Reviewed by:  lwhsu, emaste
  Approved by:  emaste
  Obtained from:DragonFlyBSD
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D23892

Modified:
  head/usr.bin/sort/file.c

Modified: head/usr.bin/sort/file.c
==
--- head/usr.bin/sort/file.cTue Sep  8 14:54:10 2020(r365457)
+++ head/usr.bin/sort/file.cTue Sep  8 15:01:49 2020(r365458)
@@ -1236,7 +1236,7 @@ sort_list_to_file(struct sort_list *list, const char *
 {
struct sort_mods *sm = &(keys[0].sm);
 
-   if (!(sm->Mflag) && !(sm->Rflag) && !(sm->Vflag) && !(sm->Vflag) &&
+   if (!(sm->Mflag) && !(sm->Rflag) && !(sm->Vflag) &&
!(sm->gflag) && !(sm->hflag) && !(sm->nflag)) {
if ((sort_opts_vals.sort_method == SORT_DEFAULT) && byte_sort)
sort_opts_vals.sort_method = SORT_RADIXSORT;
___
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: r365457 - head/sys/net

2020-09-08 Thread Kristof Provost
Author: kp
Date: Tue Sep  8 14:54:10 2020
New Revision: 365457
URL: https://svnweb.freebsd.org/changeset/base/365457

Log:
  net: mitigate vnet / epair cleanup races
  
  There's a race where dying vnets move their interfaces back to their original
  vnet, and if_epair cleanup (where deleting one interface also deletes the 
other
  end of the epair). This is commonly triggered by the pf tests, but also by
  cleanup of vnet jails.
  
  As we've not yet been able to fix the root cause of the issue work around the
  panic by not dereferencing a NULL softc in epair_qflush() and by not
  re-attaching DYING interfaces.
  
  This isn't a full fix, but makes a very common panic far less likely.
  
  PR:   244703, 238870
  Reviewed by:  lutz_donnerhacke.de
  MFC after:4 days
  Differential Revision:https://reviews.freebsd.org/D26324

Modified:
  head/sys/net/if.c
  head/sys/net/if_epair.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Tue Sep  8 13:24:44 2020(r365456)
+++ head/sys/net/if.c   Tue Sep  8 14:54:10 2020(r365457)
@@ -1298,6 +1298,11 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
ifindex_free_locked(ifp->if_index);
IFNET_WUNLOCK();
 
+
+   /* Don't re-attach DYING interfaces. */
+   if (ifp->if_flags & IFF_DYING)
+   return (0);
+
/*
 * Perform interface-specific reassignment tasks, if provided by
 * the driver.

Modified: head/sys/net/if_epair.c
==
--- head/sys/net/if_epair.c Tue Sep  8 13:24:44 2020(r365456)
+++ head/sys/net/if_epair.c Tue Sep  8 14:54:10 2020(r365457)
@@ -611,8 +611,14 @@ epair_qflush(struct ifnet *ifp)
struct epair_softc *sc;
 
sc = ifp->if_softc;
-   KASSERT(sc != NULL, ("%s: ifp=%p, epair_softc gone? sc=%p\n",
-   __func__, ifp, sc));
+
+   /*
+* See epair_clone_destroy(), we can end up getting called twice.
+* Don't do anything on the second call.
+*/
+   if (sc == NULL)
+   return;
+
/*
 * Remove this ifp from all backpointer lists. The interface will not
 * usable for flushing anyway nor should it have anything to flush
___
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: r365449 - head/sbin/rcorder

2020-09-08 Thread Mitchell Horne
Hi,

I think this change warrants an entry in RELNOTES.

Cheers,
Mitchell


On Tue, Sep 8, 2020 at 7:36 AM Andrey V. Elsukov  wrote:
>
> Author: ae
> Date: Tue Sep  8 10:36:11 2020
> New Revision: 365449
> URL: https://svnweb.freebsd.org/changeset/base/365449
>
> Log:
>   Add a few features to rcorder:
>
>   o Enhance dependency loop logging: print full chain instead of the
> last link competing the loop;
>   o Add -g option to generate dependency graph suitable for GraphViz
> visualization, loops and other graph generation issues are highlighted
> automatically;
>   o Add -p option that enables grouping items that can be processed in
> parallel.
>
>   Submitted by: Boris Lytochkin 
>   Reviewed by:  melifaro
>   MFC after:1 week
>   Differential Revision:https://reviews.freebsd.org/D25389
>
> Modified:
>   head/sbin/rcorder/rcorder.8
>   head/sbin/rcorder/rcorder.c
>
> Modified: head/sbin/rcorder/rcorder.8
> ==
> --- head/sbin/rcorder/rcorder.8 Tue Sep  8 07:37:45 2020(r365448)
> +++ head/sbin/rcorder/rcorder.8 Tue Sep  8 10:36:11 2020(r365449)
> @@ -31,7 +31,7 @@
>  .\"
>  .\" $FreeBSD$
>  .\"
> -.Dd June 22, 2020
> +.Dd September 8, 2020
>  .Dt RCORDER 8
>  .Os
>  .Sh NAME
> @@ -39,6 +39,7 @@
>  .Nd print a dependency ordering of interdependent files
>  .Sh SYNOPSIS
>  .Nm
> +.Op Fl gp
>  .Op Fl k Ar keep
>  .Op Fl s Ar skip
>  .Ar
> @@ -95,6 +96,9 @@ is reached, parsing stops.
>  .Pp
>  The options are as follows:
>  .Bl -tag -width "-k keep"
> +.It Fl g
> +Produce a GraphViz (.dot) of the complete dependency graph instead of
> +plaintext calling order list.
>  .It Fl k Ar keep
>  Add the specified keyword to the
>  .Dq "keep list" .
> @@ -102,6 +106,9 @@ If any
>  .Fl k
>  option is given, only those files containing the matching keyword are listed.
>  This option can be specified multiple times.
> +.It Fl p
> +Generate ordering suitable for parallel startup, placing files that can be
> +executed simultaneously on the same line.
>  .It Fl s Ar skip
>  Add the specified keyword to the
>  .Dq "skip list" .
> @@ -178,19 +185,46 @@ The
>  utility may print one of the following error messages and exit with a 
> non-zero
>  status if it encounters an error while processing the file list.
>  .Bl -diag
> -.It "Requirement %s has no providers, aborting."
> +.It "Requirement %s in file %s has no providers."
>  No file has a
>  .Ql PROVIDE
>  line corresponding to a condition present in a
>  .Ql REQUIRE
>  line in another file.
> -.It "Circular dependency on provision %s, aborting."
> +.It "Circular dependency on provision %s in file %s."
>  A set of files has a circular dependency which was detected while
>  processing the stated condition.
> -.It "Circular dependency on file %s, aborting."
> +Loop visualization follows this message.
> +.It "Circular dependency on file %s."
>  A set of files has a circular dependency which was detected while
>  processing the stated file.
> +.It "%s was seen in circular dependencies for %d times."
> +Each node that was a part of circular dependency loops reports total number 
> of
> +such encounters.
> +Start with files having biggest counter when fighting with broken 
> dependencies.
>  .El
> +.Sh DIAGNOSTICS WITH GRAPHVIZ
> +Direct dependency is drawn with solid line,
> +.Ql BEFORE
> +dependency is drawn as a dashed line.
> +Each node of a graph represents an item from
> +.Ql PROVIDE
> +lines.
> +In case there are more than one file providing an item, a list of filenames
> +shortened with
> +.Xr basename 3
> +is shown.
> +Shortened filenames are also shown in case
> +.Ql PROVIDE
> +item does not match file name.
> +.Pp
> +Edges and nodes where circular dependencies were detected are drawn bold red.
> +If a file has an item in
> +.Ql REQUIRE
> +or in
> +.Ql BEFORE
> +that could not be provided,
> +this missing provider and the requirement will be drawn bold red as well.
>  .Sh SEE ALSO
>  .Xr acpiconf 8 ,
>  .Xr rc 8 ,
>
> Modified: head/sbin/rcorder/rcorder.c
> ==
> --- head/sbin/rcorder/rcorder.c Tue Sep  8 07:37:45 2020(r365448)
> +++ head/sbin/rcorder/rcorder.c Tue Sep  8 10:36:11 2020(r365449)
> @@ -9,6 +9,8 @@
>   * All rights reserved.
>   * Copyright (c) 1998
>   * Perry E. Metzger.  All rights reserved.
> + * Copyright (c) 2020
> + * Boris N. Lytochkin. All rights reserved.
>   *
>   * Redistribution and use in source and binary forms, with or without
>   * modification, are permitted provided that the following conditions
> @@ -48,6 +50,8 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>
>  #include "ealloc.h"
>  #include "sprite.h"
> @@ -75,17 +79,21 @@ static int debug = 0;
>  #define KEYWORDS_STR   "# KEYWORDS:"
>  #define KEYWORDS_LEN   (sizeof(KEYWORDS_STR) - 1)
>
> +#defineFAKE_PROV_NAME  

svn commit: r365456 - head/sys/conf

2020-09-08 Thread Mitchell Horne
Author: mhorne
Date: Tue Sep  8 13:24:44 2020
New Revision: 365456
URL: https://svnweb.freebsd.org/changeset/base/365456

Log:
  RISC-V: enable MK_FORMAT_EXTENSIONS
  
  This option was marked as broken because our riscv64-xtoolchain-gcc
  package lacked support. Since we are moving away from xtoolchain gcc in
  favor of freebsd-gcc9, there should be no issue in enabling this option
  by default.
  
  Notably, this enables -Wformat errors.
  
  Reviewed by:  kp, jhb
  Differential Revision:https://reviews.freebsd.org/D26320

Modified:
  head/sys/conf/kern.opts.mk

Modified: head/sys/conf/kern.opts.mk
==
--- head/sys/conf/kern.opts.mk  Tue Sep  8 13:21:13 2020(r365455)
+++ head/sys/conf/kern.opts.mk  Tue Sep  8 13:24:44 2020(r365456)
@@ -80,10 +80,6 @@ BROKEN_OPTIONS+= CDDL ZFS SSP
 BROKEN_OPTIONS+= ZFS
 .endif
 
-.if ${MACHINE_CPUARCH} == "riscv"
-BROKEN_OPTIONS+= FORMAT_EXTENSIONS
-.endif
-
 # Things that don't work because the kernel doesn't have the support
 # for them.
 .if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
___
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: r365455 - in head/sys: dev/xilinx riscv/riscv

2020-09-08 Thread Mitchell Horne
Author: mhorne
Date: Tue Sep  8 13:21:13 2020
New Revision: 365455
URL: https://svnweb.freebsd.org/changeset/base/365455

Log:
  RISC-V: fix some mismatched format specifiers
  
  RISC-V is currently built with -Wno-format, which is how these went
  undetected. Address them now before re-enabling those warnings.
  
  Differential Revision:https://reviews.freebsd.org/D26319

Modified:
  head/sys/dev/xilinx/axidma.c
  head/sys/riscv/riscv/db_disasm.c
  head/sys/riscv/riscv/intr_machdep.c
  head/sys/riscv/riscv/pmap.c
  head/sys/riscv/riscv/sbi.c
  head/sys/riscv/riscv/trap.c

Modified: head/sys/dev/xilinx/axidma.c
==
--- head/sys/dev/xilinx/axidma.cTue Sep  8 12:38:34 2020
(r365454)
+++ head/sys/dev/xilinx/axidma.cTue Sep  8 13:21:13 2020
(r365455)
@@ -363,7 +363,7 @@ axidma_desc_alloc(struct axidma_softc *sc, struct xdma
chan->mem_vaddr = kva_alloc(chan->mem_size);
pmap_kenter_device(chan->mem_vaddr, chan->mem_size, chan->mem_paddr);
 
-   device_printf(sc->dev, "Allocated chunk %lx %d\n",
+   device_printf(sc->dev, "Allocated chunk %lx %lu\n",
chan->mem_paddr, chan->mem_size);
 
for (i = 0; i < nsegments; i++) {

Modified: head/sys/riscv/riscv/db_disasm.c
==
--- head/sys/riscv/riscv/db_disasm.cTue Sep  8 12:38:34 2020
(r365454)
+++ head/sys/riscv/riscv/db_disasm.cTue Sep  8 13:21:13 2020
(r365455)
@@ -416,7 +416,7 @@ oprint(struct riscv_op *op, vm_offset_t loc, int insn)
imm |= ((insn >> 12) & 0x1) << 5;
if (imm & (1 << 5))
imm |= (0x7ff << 5); /* sign ext */
-   db_printf("0x%lx", imm);
+   db_printf("0x%x", imm);
break;
case 'o':
imm = ((insn >> 2) & 0x1f) << 0;
@@ -524,7 +524,7 @@ oprint(struct riscv_op *op, vm_offset_t loc, int insn)
imm = (insn >> 12) & 0xf;
if (imm & (1 << 20))
imm |= (0xfff << 20);   /* sign extend */
-   db_printf("0x%lx", imm);
+   db_printf("0x%x", imm);
break;
case 'j':
/* imm[11:0] << 20 */

Modified: head/sys/riscv/riscv/intr_machdep.c
==
--- head/sys/riscv/riscv/intr_machdep.c Tue Sep  8 12:38:34 2020
(r365454)
+++ head/sys/riscv/riscv/intr_machdep.c Tue Sep  8 13:21:13 2020
(r365455)
@@ -73,9 +73,9 @@ struct intc_irqsrc isrcs[INTC_NIRQS];
 static void
 riscv_mask_irq(void *source)
 {
-   uintptr_t irq;
+   int irq;
 
-   irq = (uintptr_t)source;
+   irq = (int)(uintptr_t)source;
 
switch (irq) {
case IRQ_TIMER_SUPERVISOR:
@@ -95,9 +95,9 @@ riscv_mask_irq(void *source)
 static void
 riscv_unmask_irq(void *source)
 {
-   uintptr_t irq;
+   int irq;
 
-   irq = (uintptr_t)source;
+   irq = (int)(uintptr_t)source;
 
switch (irq) {
case IRQ_TIMER_SUPERVISOR:

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Tue Sep  8 12:38:34 2020(r365454)
+++ head/sys/riscv/riscv/pmap.c Tue Sep  8 13:21:13 2020(r365455)
@@ -590,7 +590,7 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart,
if (physmap[i + 1] > max_pa)
max_pa = physmap[i + 1];
}
-   printf("physmap_idx %lx\n", physmap_idx);
+   printf("physmap_idx %u\n", physmap_idx);
printf("min_pa %lx\n", min_pa);
printf("max_pa %lx\n", max_pa);
 

Modified: head/sys/riscv/riscv/sbi.c
==
--- head/sys/riscv/riscv/sbi.c  Tue Sep  8 12:38:34 2020(r365454)
+++ head/sys/riscv/riscv/sbi.c  Tue Sep  8 13:21:13 2020(r365455)
@@ -104,7 +104,7 @@ sbi_print_version(void)
 
switch (sbi_impl_id) {
case (SBI_IMPL_ID_BBL):
-   printf("SBI: Berkely Boot Loader %u\n", sbi_impl_version);
+   printf("SBI: Berkely Boot Loader %lu\n", sbi_impl_version);
break;
case (SBI_IMPL_ID_OPENSBI):
major = sbi_impl_version >> OPENSBI_VERSION_MAJOR_OFFSET;
@@ -112,7 +112,7 @@ sbi_print_version(void)
printf("SBI: OpenSBI v%u.%u\n", major, minor);
break;
default:
-   printf("SBI: Unrecognized Implementation: %u\n", sbi_impl_id);
+   printf("SBI: Unrecognized Implementation: %lu\n", sbi_impl_id);
break;

Re: svn commit: r365445 - head/sys/cam/mmc

2020-09-08 Thread Mark Johnston
On Tue, Sep 08, 2020 at 02:24:59PM +0200, Michal Meloun wrote:
> On 08.09.2020 9:10, Andriy Gapon wrote:
> > On 08/09/2020 08:46, Andriy Gapon wrote:
> >> Author: avg
> >> Date: Tue Sep  8 05:46:10 2020
> >> New Revision: 365445
> >> URL: https://svnweb.freebsd.org/changeset/base/365445
> >>
> >> Log:
> >>   mmc_da: make sure that part_index is not used uninitialized in sddastart
> > [snip]
> >> Modified: head/sys/cam/mmc/mmc_da.c
> >> ==
> >> --- head/sys/cam/mmc/mmc_da.c  Tue Sep  8 04:44:37 2020
> >> (r365444)
> >> +++ head/sys/cam/mmc/mmc_da.c  Tue Sep  8 05:46:10 2020
> >> (r365445)
> >> @@ -1808,6 +1808,7 @@ sddastart(struct cam_periph *periph, union ccb 
> >> *start_
> >>}
> >>  
> >>/* Find partition that has outstanding commands.  Prefer current 
> >> partition. */
> >> +  part_index = softc->part_curr;
> >>part = softc->part[softc->part_curr];
> >>bp = bioq_first(>bio_queue);
> >>if (bp == NULL) {
> >>
> > 
> > One thing that concerns me is that it was obvious (to a human) that 
> > part_index
> > could be used uninitialized if bp was not NULL.
> > Yet, there was no warning or error from the compiler when I built that code 
> > for
> > armv7.
> > 
> > I wonder if we disable some relevant warnings for that architecture.
> > Or if the compiler (clang 11) could not figure that out.
> > 
> Hmm, for this in kernel code :
> int foo(void);
> int foo(void)
> {
>  int rv;
> 
>  return (rv);
> }
> 
> warning is reported for both armv7 and arm64 for native or cross compile.
> 
> It seems that clang11 doesn't emit warnings only for more complicated
> cases...
> 
> I writing this because i just found another usage of uninitialized
> variable, in this case in much more complicated abort_handler() function
> in arm/trap-v6.c again without warning emitted.

I observed the same thing recently as well: the compiler catches
uninitialized variables only in simple cases.  In my case, any uses of
goto within the function seemed to silence the warning, even if they
appeared after the uninitialized reference.
___
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: r365445 - head/sys/cam/mmc

2020-09-08 Thread Michal Meloun



On 08.09.2020 9:10, Andriy Gapon wrote:
> On 08/09/2020 08:46, Andriy Gapon wrote:
>> Author: avg
>> Date: Tue Sep  8 05:46:10 2020
>> New Revision: 365445
>> URL: https://svnweb.freebsd.org/changeset/base/365445
>>
>> Log:
>>   mmc_da: make sure that part_index is not used uninitialized in sddastart
> [snip]
>> Modified: head/sys/cam/mmc/mmc_da.c
>> ==
>> --- head/sys/cam/mmc/mmc_da.cTue Sep  8 04:44:37 2020
>> (r365444)
>> +++ head/sys/cam/mmc/mmc_da.cTue Sep  8 05:46:10 2020
>> (r365445)
>> @@ -1808,6 +1808,7 @@ sddastart(struct cam_periph *periph, union ccb *start_
>>  }
>>  
>>  /* Find partition that has outstanding commands.  Prefer current 
>> partition. */
>> +part_index = softc->part_curr;
>>  part = softc->part[softc->part_curr];
>>  bp = bioq_first(>bio_queue);
>>  if (bp == NULL) {
>>
> 
> One thing that concerns me is that it was obvious (to a human) that part_index
> could be used uninitialized if bp was not NULL.
> Yet, there was no warning or error from the compiler when I built that code 
> for
> armv7.
> 
> I wonder if we disable some relevant warnings for that architecture.
> Or if the compiler (clang 11) could not figure that out.
> 
Hmm, for this in kernel code :
int foo(void);
int foo(void)
{
 int rv;

 return (rv);
}

warning is reported for both armv7 and arm64 for native or cross compile.

It seems that clang11 doesn't emit warnings only for more complicated
cases...

I writing this because i just found another usage of uninitialized
variable, in this case in much more complicated abort_handler() function
in arm/trap-v6.c again without warning emitted.
Michal
___
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: r365445 - head/sys/cam/mmc

2020-09-08 Thread Bjoern A. Zeeb

On 8 Sep 2020, at 7:10, Andriy Gapon wrote:


On 08/09/2020 08:46, Andriy Gapon wrote:

Author: avg
Date: Tue Sep  8 05:46:10 2020
New Revision: 365445
URL: https://svnweb.freebsd.org/changeset/base/365445

Log:
  mmc_da: make sure that part_index is not used uninitialized in 
sddastart

[snip]

Modified: head/sys/cam/mmc/mmc_da.c
==
--- head/sys/cam/mmc/mmc_da.c   Tue Sep  8 04:44:37 2020(r365444)
+++ head/sys/cam/mmc/mmc_da.c   Tue Sep  8 05:46:10 2020(r365445)
@@ -1808,6 +1808,7 @@ sddastart(struct cam_periph *periph, union ccb 
*start_

}

 	/* Find partition that has outstanding commands.  Prefer current 
partition. */

+   part_index = softc->part_curr;
part = softc->part[softc->part_curr];
bp = bioq_first(>bio_queue);
if (bp == NULL) {



One thing that concerns me is that it was obvious (to a human) that 
part_index

could be used uninitialized if bp was not NULL.
Yet, there was no warning or error from the compiler when I built that 
code for

armv7.

I wonder if we disable some relevant warnings for that architecture.
Or if the compiler (clang 11) could not figure that out.



I had just finished dissecting my hang in g_waitidle on boot on the 
nanopi-m4v2/arm64 this morning and when I saw your commits as I came 
back home .. guess what:


364132  boots
364219  boots
364263  boots
364274  boots
364283  boots
364284  no			<< 
https://svnweb.freebsd.org/base?view=revision=364284  (clang 
merge)

364285  no
364307  no
364482  no
364657  no
365335  no
365364  no
365448  boots

/bz

___
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: r365451 - head/sys/conf

2020-09-08 Thread Andrew Turner
Author: andrew
Date: Tue Sep  8 11:46:33 2020
New Revision: 365451
URL: https://svnweb.freebsd.org/changeset/base/365451

Log:
  Move gpio and hwpmc to the correct place in files.arm64
  
  Sponsored by: Innovate UK

Modified:
  head/sys/conf/files.arm64

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Tue Sep  8 11:35:35 2020(r365450)
+++ head/sys/conf/files.arm64   Tue Sep  8 11:46:33 2020(r365451)
@@ -255,6 +255,11 @@ dev/axgbe/xgbe-dev.c   optionalaxgbe
 dev/axgbe/xgbe-drv.c   optionalaxgbe
 dev/axgbe/xgbe-mdio.c  optionalaxgbe
 dev/cpufreq/cpufreq_dt.c   optionalcpufreq fdt
+dev/gpio/pl061.c   optionalpl061 gpio
+dev/gpio/pl061_acpi.c  optionalpl061 gpio acpi
+dev/gpio/pl061_fdt.c   optionalpl061 gpio fdt
+dev/hwpmc/hwpmc_arm64.coptionalhwpmc
+dev/hwpmc/hwpmc_arm64_md.c optionalhwpmc
 dev/ice/if_ice_iflib.c optionalice pci \
compile-with "${NORMAL_C} -I$S/dev/ice"
 dev/ice/ice_lib.c  optionalice pci \
@@ -305,11 +310,6 @@ dev/iicbus/sy8106a.c   optionalsy8106a 
fdt
 dev/iicbus/twsi/mv_twsi.c  optionaltwsi fdt
 dev/iicbus/twsi/a10_twsi.c optionaltwsi fdt
 dev/iicbus/twsi/twsi.c optionaltwsi fdt
-dev/gpio/pl061.c   optionalpl061 gpio
-dev/gpio/pl061_acpi.c  optionalpl061 gpio acpi
-dev/gpio/pl061_fdt.c   optionalpl061 gpio fdt
-dev/hwpmc/hwpmc_arm64.coptionalhwpmc
-dev/hwpmc/hwpmc_arm64_md.c optionalhwpmc
 dev/mbox/mbox_if.m optionalsoc_brcm_bcm2837
 dev/mmc/host/dwmmc.c   optionaldwmmc fdt
 dev/mmc/host/dwmmc_altera.coptionaldwmmc dwmmc_altera fdt
___
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: r365450 - in head/sys: arm64/conf conf dev/gpio

2020-09-08 Thread Andrew Turner
Author: andrew
Date: Tue Sep  8 11:35:35 2020
New Revision: 365450
URL: https://svnweb.freebsd.org/changeset/base/365450

Log:
  Add a GPIO driver for the Arm pl061 controller
  
  A PL061 is a simple 8 pin GPIO controller. This GPIO device is used to
  signal an internal request for shutdown on some virtual machines including
  Arm-based Amazon EC2 instances.
  
  Submitted by: Ali Saidi  (previouss version)
  Reviewed by:  Ali Saidi, manu
  Differential Revision:https://reviews.freebsd.org/D24065

Added:
  head/sys/dev/gpio/pl061.c   (contents, props changed)
  head/sys/dev/gpio/pl061.h   (contents, props changed)
  head/sys/dev/gpio/pl061_acpi.c   (contents, props changed)
  head/sys/dev/gpio/pl061_fdt.c   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Tue Sep  8 10:36:11 2020(r365449)
+++ head/sys/arm64/conf/GENERIC Tue Sep  8 11:35:35 2020(r365450)
@@ -257,6 +257,7 @@ device  gpioregulator
 device ls1046_gpio # LS1046A GPIO controller
 device mv_gpio # Marvell GPIO controller
 device mvebu_pinctrl   # Marvell Pinmux Controller
+device pl061   # Arm PL061 GPIO controller
 device rk_gpio # RockChip GPIO Controller
 device rk_pinctrl  # RockChip Pinmux Controller
 

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Tue Sep  8 10:36:11 2020(r365449)
+++ head/sys/conf/files.arm64   Tue Sep  8 11:35:35 2020(r365450)
@@ -305,6 +305,9 @@ dev/iicbus/sy8106a.coptionalsy8106a 
fdt
 dev/iicbus/twsi/mv_twsi.c  optionaltwsi fdt
 dev/iicbus/twsi/a10_twsi.c optionaltwsi fdt
 dev/iicbus/twsi/twsi.c optionaltwsi fdt
+dev/gpio/pl061.c   optionalpl061 gpio
+dev/gpio/pl061_acpi.c  optionalpl061 gpio acpi
+dev/gpio/pl061_fdt.c   optionalpl061 gpio fdt
 dev/hwpmc/hwpmc_arm64.coptionalhwpmc
 dev/hwpmc/hwpmc_arm64_md.c optionalhwpmc
 dev/mbox/mbox_if.m optionalsoc_brcm_bcm2837

Added: head/sys/dev/gpio/pl061.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/gpio/pl061.c   Tue Sep  8 11:35:35 2020(r365450)
@@ -0,0 +1,580 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2020 Amazon.com, Inc. or its affiliates.
+ * All rights reserved.
+ *
+ * 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.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "pl061.h"
+
+#include "gpio_if.h"
+#include "pic_if.h"
+
+#definePL061_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx)
+#definePL061_UNLOCK(_sc)   mtx_unlock_spin(&(_sc)->sc_mtx)
+#definePL061_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)
+#definePL061_ASSERT_LOCKED(_sc)mtx_assert(&(_sc)->sc_mtx, 
MA_OWNED)
+#definePL061_ASSERT_UNLOCKED(_sc)  mtx_assert(&(_sc)->sc_mtx, 
MA_NOTOWNED)
+
+#if 0
+#define dprintf(fmt, args...) do { \
+   printf(fmt, ##args);\
+} while (0)
+#else
+#define dprintf(fmt, args...)
+#endif
+
+#define PL061_PIN_TO_ADDR(pin)  (1 << 

svn commit: r365449 - head/sbin/rcorder

2020-09-08 Thread Andrey V. Elsukov
Author: ae
Date: Tue Sep  8 10:36:11 2020
New Revision: 365449
URL: https://svnweb.freebsd.org/changeset/base/365449

Log:
  Add a few features to rcorder:
  
  o Enhance dependency loop logging: print full chain instead of the
last link competing the loop;
  o Add -g option to generate dependency graph suitable for GraphViz
visualization, loops and other graph generation issues are highlighted
automatically;
  o Add -p option that enables grouping items that can be processed in
parallel.
  
  Submitted by: Boris Lytochkin 
  Reviewed by:  melifaro
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D25389

Modified:
  head/sbin/rcorder/rcorder.8
  head/sbin/rcorder/rcorder.c

Modified: head/sbin/rcorder/rcorder.8
==
--- head/sbin/rcorder/rcorder.8 Tue Sep  8 07:37:45 2020(r365448)
+++ head/sbin/rcorder/rcorder.8 Tue Sep  8 10:36:11 2020(r365449)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 22, 2020
+.Dd September 8, 2020
 .Dt RCORDER 8
 .Os
 .Sh NAME
@@ -39,6 +39,7 @@
 .Nd print a dependency ordering of interdependent files
 .Sh SYNOPSIS
 .Nm
+.Op Fl gp
 .Op Fl k Ar keep
 .Op Fl s Ar skip
 .Ar
@@ -95,6 +96,9 @@ is reached, parsing stops.
 .Pp
 The options are as follows:
 .Bl -tag -width "-k keep"
+.It Fl g
+Produce a GraphViz (.dot) of the complete dependency graph instead of
+plaintext calling order list.
 .It Fl k Ar keep
 Add the specified keyword to the
 .Dq "keep list" .
@@ -102,6 +106,9 @@ If any
 .Fl k
 option is given, only those files containing the matching keyword are listed.
 This option can be specified multiple times.
+.It Fl p
+Generate ordering suitable for parallel startup, placing files that can be
+executed simultaneously on the same line.
 .It Fl s Ar skip
 Add the specified keyword to the
 .Dq "skip list" .
@@ -178,19 +185,46 @@ The
 utility may print one of the following error messages and exit with a non-zero
 status if it encounters an error while processing the file list.
 .Bl -diag
-.It "Requirement %s has no providers, aborting."
+.It "Requirement %s in file %s has no providers."
 No file has a
 .Ql PROVIDE
 line corresponding to a condition present in a
 .Ql REQUIRE
 line in another file.
-.It "Circular dependency on provision %s, aborting."
+.It "Circular dependency on provision %s in file %s."
 A set of files has a circular dependency which was detected while
 processing the stated condition.
-.It "Circular dependency on file %s, aborting."
+Loop visualization follows this message.
+.It "Circular dependency on file %s."
 A set of files has a circular dependency which was detected while
 processing the stated file.
+.It "%s was seen in circular dependencies for %d times."
+Each node that was a part of circular dependency loops reports total number of
+such encounters.
+Start with files having biggest counter when fighting with broken dependencies.
 .El
+.Sh DIAGNOSTICS WITH GRAPHVIZ
+Direct dependency is drawn with solid line,
+.Ql BEFORE
+dependency is drawn as a dashed line.
+Each node of a graph represents an item from
+.Ql PROVIDE
+lines.
+In case there are more than one file providing an item, a list of filenames
+shortened with
+.Xr basename 3
+is shown.
+Shortened filenames are also shown in case
+.Ql PROVIDE
+item does not match file name.
+.Pp
+Edges and nodes where circular dependencies were detected are drawn bold red.
+If a file has an item in
+.Ql REQUIRE
+or in
+.Ql BEFORE
+that could not be provided,
+this missing provider and the requirement will be drawn bold red as well.
 .Sh SEE ALSO
 .Xr acpiconf 8 ,
 .Xr rc 8 ,

Modified: head/sbin/rcorder/rcorder.c
==
--- head/sbin/rcorder/rcorder.c Tue Sep  8 07:37:45 2020(r365448)
+++ head/sbin/rcorder/rcorder.c Tue Sep  8 10:36:11 2020(r365449)
@@ -9,6 +9,8 @@
  * All rights reserved.
  * Copyright (c) 1998
  * Perry E. Metzger.  All rights reserved.
+ * Copyright (c) 2020
+ * Boris N. Lytochkin. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -48,6 +50,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "ealloc.h"
 #include "sprite.h"
@@ -75,17 +79,21 @@ static int debug = 0;
 #define KEYWORDS_STR   "# KEYWORDS:"
 #define KEYWORDS_LEN   (sizeof(KEYWORDS_STR) - 1)
 
+#defineFAKE_PROV_NAME  "fake_prov_"
+
 static int exit_code;
 static int file_count;
 static char **file_list;
 
-typedef int bool;
 #define TRUE 1
 #define FALSE 0
 typedef bool flag;
 #define SET TRUE
 #define RESET FALSE
 
+static flag do_graphviz = false;
+static flag do_parallel = false;
+
 static Hash_Table provide_hash_s, *provide_hash;
 
 typedef struct provnode provnode;
@@ -97,12 +105,14 @@ typedef struct strnodelist strnodelist;
 

Re: svn commit: r365445 - head/sys/cam/mmc

2020-09-08 Thread Andriy Gapon
On 08/09/2020 10:10, Andriy Gapon wrote:
> On 08/09/2020 08:46, Andriy Gapon wrote:
>> Author: avg
>> Date: Tue Sep  8 05:46:10 2020
>> New Revision: 365445
>> URL: https://svnweb.freebsd.org/changeset/base/365445
>>
>> Log:
>>   mmc_da: make sure that part_index is not used uninitialized in sddastart
> [snip]
>> Modified: head/sys/cam/mmc/mmc_da.c
>> ==
>> --- head/sys/cam/mmc/mmc_da.cTue Sep  8 04:44:37 2020
>> (r365444)
>> +++ head/sys/cam/mmc/mmc_da.cTue Sep  8 05:46:10 2020
>> (r365445)
>> @@ -1808,6 +1808,7 @@ sddastart(struct cam_periph *periph, union ccb *start_
>>  }
>>  
>>  /* Find partition that has outstanding commands.  Prefer current 
>> partition. */
>> +part_index = softc->part_curr;
>>  part = softc->part[softc->part_curr];
>>  bp = bioq_first(>bio_queue);
>>  if (bp == NULL) {
>>
> 
> One thing that concerns me is that it was obvious (to a human) that part_index
> could be used uninitialized if bp was not NULL.
> Yet, there was no warning or error from the compiler when I built that code 
> for
> armv7.
> 
> I wonder if we disable some relevant warnings for that architecture.
> Or if the compiler (clang 11) could not figure that out.
> 

FWIW, I've just tried GENERIC-MMCCAM on amd64 and didn't get any warning either
(with a tree from before this commit).

-- 
Andriy Gapon
___
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: r365445 - head/sys/cam/mmc

2020-09-08 Thread Andriy Gapon
On 08/09/2020 08:46, Andriy Gapon wrote:
> Author: avg
> Date: Tue Sep  8 05:46:10 2020
> New Revision: 365445
> URL: https://svnweb.freebsd.org/changeset/base/365445
> 
> Log:
>   mmc_da: make sure that part_index is not used uninitialized in sddastart
[snip]
> Modified: head/sys/cam/mmc/mmc_da.c
> ==
> --- head/sys/cam/mmc/mmc_da.c Tue Sep  8 04:44:37 2020(r365444)
> +++ head/sys/cam/mmc/mmc_da.c Tue Sep  8 05:46:10 2020(r365445)
> @@ -1808,6 +1808,7 @@ sddastart(struct cam_periph *periph, union ccb *start_
>   }
>  
>   /* Find partition that has outstanding commands.  Prefer current 
> partition. */
> + part_index = softc->part_curr;
>   part = softc->part[softc->part_curr];
>   bp = bioq_first(>bio_queue);
>   if (bp == NULL) {
> 

One thing that concerns me is that it was obvious (to a human) that part_index
could be used uninitialized if bp was not NULL.
Yet, there was no warning or error from the compiler when I built that code for
armv7.

I wonder if we disable some relevant warnings for that architecture.
Or if the compiler (clang 11) could not figure that out.

-- 
Andriy Gapon
___
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: r365447 - head/sys/cam/mmc

2020-09-08 Thread Andriy Gapon
Author: avg
Date: Tue Sep  8 06:19:23 2020
New Revision: 365447
URL: https://svnweb.freebsd.org/changeset/base/365447

Log:
  mmc_da: universally use uint8_t for the partition index
  
  Also, assert in sdda_init_switch_part() that the index is within the
  defined range.
  
  MFC after:1 week

Modified:
  head/sys/cam/mmc/mmc_da.c

Modified: head/sys/cam/mmc/mmc_da.c
==
--- head/sys/cam/mmc/mmc_da.c   Tue Sep  8 06:18:34 2020(r365446)
+++ head/sys/cam/mmc/mmc_da.c   Tue Sep  8 06:19:23 2020(r365447)
@@ -182,7 +182,6 @@ static void sdda_start_init(void *context, union ccb *
 static void sdda_start_init_task(void *context, int pending);
 static void sdda_process_mmc_partitions(struct cam_periph *periph, union ccb 
*start_ccb);
 static uint32_t sdda_get_host_caps(struct cam_periph *periph, union ccb *ccb);
-static void sdda_init_switch_part(struct cam_periph *periph, union ccb 
*start_ccb, u_int part);
 static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t 
rca);
 static inline uint32_t mmc_get_sector_size(struct cam_periph *periph) {return 
MMC_SECTOR_SIZE;}
 
@@ -1770,10 +1769,13 @@ sdda_process_mmc_partitions(struct cam_periph *periph,
  * This function cannot fail, instead check switch errors in sddadone().
  */
 static void
-sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, u_int 
part) {
+sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb,
+uint8_t part)
+{
struct sdda_softc *sc = (struct sdda_softc *)periph->softc;
uint8_t value;
 
+   KASSERT(part < MMC_PART_MAX, ("%s: invalid partition index", __func__));
sc->part_requested = part;
 
value = (sc->raw_ext_csd[EXT_CSD_PART_CONFIG] &
@@ -1797,7 +1799,7 @@ sddastart(struct cam_periph *periph, union ccb *start_
struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
struct sdda_part *part;
struct mmc_params *mmcp = >path->device->mmc_ident_data;
-   int part_index;
+   uint8_t part_index;
 
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddastart\n"));
 
___
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: r365446 - head/sys/cam/mmc

2020-09-08 Thread Andriy Gapon
Author: avg
Date: Tue Sep  8 06:18:34 2020
New Revision: 365446
URL: https://svnweb.freebsd.org/changeset/base/365446

Log:
  mmc_da: fix a typo and a too long line
  
  MFC after:1 week

Modified:
  head/sys/cam/mmc/mmc_da.c

Modified: head/sys/cam/mmc/mmc_da.c
==
--- head/sys/cam/mmc/mmc_da.c   Tue Sep  8 05:46:10 2020(r365445)
+++ head/sys/cam/mmc/mmc_da.c   Tue Sep  8 06:18:34 2020(r365446)
@@ -1965,7 +1965,8 @@ sddadone(struct cam_periph *periph, union ccb *done_cc
/* Process result of switching MMC partitions */
if (softc->state == SDDA_STATE_PART_SWITCH) {
CAM_DEBUG(path, CAM_DEBUG_TRACE,
-   ("Compteting partition switch to %d\n", 
softc->part_requested));
+   ("Completing partition switch to %d\n",
+   softc->part_requested));
softc->outstanding_cmds--;
/* Complete partition switch */
softc->state = SDDA_STATE_NORMAL;
___
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"