svn commit: r367444 - head/sys/kern

2020-11-06 Thread Kyle Evans
Author: kevans
Date: Sat Nov  7 05:10:46 2020
New Revision: 367444
URL: https://svnweb.freebsd.org/changeset/base/367444

Log:
  imgact_binmisc: abstract away the list lock (NFC)
  
  This module handles relatively few execs (initial qemu-user-static, then
  qemu-user-static handles exec'ing itself for binaries it's already running),
  but all execs pay the price of at least taking the relatively expensive
  sx/slock to check for a match when this module is loaded. Future work will
  almost certainly swap this out for another lock, perhaps an rmslock.
  
  The RLOCK/WLOCK phrasing was chosen based on what the callers are really
  wanting, rather than using the verbiage typically appropriate for an sx.
  
  MFC after:1 week

Modified:
  head/sys/kern/imgact_binmisc.c

Modified: head/sys/kern/imgact_binmisc.c
==
--- head/sys/kern/imgact_binmisc.c  Sat Nov  7 04:15:24 2020
(r367443)
+++ head/sys/kern/imgact_binmisc.c  Sat Nov  7 05:10:46 2020
(r367444)
@@ -98,6 +98,16 @@ static int interp_list_entry_count;
 
 static struct sx interp_list_sx;
 
+#defineINTERP_LIST_WLOCK() sx_xlock(_list_sx)
+#defineINTERP_LIST_RLOCK() sx_slock(_list_sx)
+#defineINTERP_LIST_WUNLOCK()   sx_xunlock(_list_sx)
+#defineINTERP_LIST_RUNLOCK()   sx_sunlock(_list_sx)
+
+#defineINTERP_LIST_LOCK_INIT() sx_init(_list_sx, 
KMOD_NAME)
+#defineINTERP_LIST_LOCK_DESTROY()  sx_destroy(_list_sx)
+
+#defineINTERP_LIST_ASSERT_LOCKED() sx_assert(_list_sx, 
SA_LOCKED)
+
 /*
  * Populate the entry with the information about the interpreter.
  */
@@ -198,7 +208,7 @@ imgact_binmisc_find_entry(char *name)
 {
imgact_binmisc_entry_t *ibe;
 
-   sx_assert(_list_sx, SA_LOCKED);
+   INTERP_LIST_ASSERT_LOCKED();
 
SLIST_FOREACH(ibe, _list, link) {
if (strncmp(name, ibe->ibe_name, IBE_NAME_MAX) == 0)
@@ -256,9 +266,9 @@ imgact_binmisc_add_entry(ximgact_binmisc_entry_t *xbe)
}
}
 
-   sx_xlock(_list_sx);
+   INTERP_LIST_WLOCK();
if (imgact_binmisc_find_entry(xbe->xbe_name) != NULL) {
-   sx_xunlock(_list_sx);
+   INTERP_LIST_WUNLOCK();
return (EEXIST);
}
 
@@ -267,7 +277,7 @@ imgact_binmisc_add_entry(ximgact_binmisc_entry_t *xbe)
 
SLIST_INSERT_HEAD(_list, ibe, link);
interp_list_entry_count++;
-   sx_xunlock(_list_sx);
+   INTERP_LIST_WUNLOCK();
 
return (0);
 }
@@ -281,14 +291,14 @@ imgact_binmisc_remove_entry(char *name)
 {
imgact_binmisc_entry_t *ibe;
 
-   sx_xlock(_list_sx);
+   INTERP_LIST_WLOCK();
if ((ibe = imgact_binmisc_find_entry(name)) == NULL) {
-   sx_xunlock(_list_sx);
+   INTERP_LIST_WUNLOCK();
return (ENOENT);
}
SLIST_REMOVE(_list, ibe, imgact_binmisc_entry, link);
interp_list_entry_count--;
-   sx_xunlock(_list_sx);
+   INTERP_LIST_WUNLOCK();
 
imgact_binmisc_destroy_entry(ibe);
 
@@ -304,14 +314,14 @@ imgact_binmisc_disable_entry(char *name)
 {
imgact_binmisc_entry_t *ibe;
 
-   sx_xlock(_list_sx);
+   INTERP_LIST_WLOCK();
if ((ibe = imgact_binmisc_find_entry(name)) == NULL) {
-   sx_xunlock(_list_sx);
+   INTERP_LIST_WUNLOCK();
return (ENOENT);
}
 
ibe->ibe_flags &= ~IBF_ENABLED;
-   sx_xunlock(_list_sx);
+   INTERP_LIST_WUNLOCK();
 
return (0);
 }
@@ -325,14 +335,14 @@ imgact_binmisc_enable_entry(char *name)
 {
imgact_binmisc_entry_t *ibe;
 
-   sx_xlock(_list_sx);
+   INTERP_LIST_WLOCK();
if ((ibe = imgact_binmisc_find_entry(name)) == NULL) {
-   sx_xunlock(_list_sx);
+   INTERP_LIST_WUNLOCK();
return (ENOENT);
}
 
ibe->ibe_flags |= IBF_ENABLED;
-   sx_xunlock(_list_sx);
+   INTERP_LIST_WUNLOCK();
 
return (0);
 }
@@ -343,8 +353,7 @@ imgact_binmisc_populate_xbe(ximgact_binmisc_entry_t *x
 {
uint32_t i;
 
-   sx_assert(_list_sx, SA_LOCKED);
-
+   INTERP_LIST_ASSERT_LOCKED();
memset(xbe, 0, sizeof(*xbe));
strlcpy(xbe->xbe_name, ibe->ibe_name, IBE_NAME_MAX);
 
@@ -375,14 +384,14 @@ imgact_binmisc_lookup_entry(char *name, ximgact_binmis
imgact_binmisc_entry_t *ibe;
int error = 0;
 
-   sx_slock(_list_sx);
+   INTERP_LIST_RLOCK();
if ((ibe = imgact_binmisc_find_entry(name)) == NULL) {
-   sx_sunlock(_list_sx);
+   INTERP_LIST_RUNLOCK();
return (ENOENT);
}
 
error = imgact_binmisc_populate_xbe(xbe, ibe);
-   sx_sunlock(_list_sx);
+   INTERP_LIST_RUNLOCK();
 
return (error);
 }
@@ -397,7 +406,7 @@ imgact_binmisc_get_all_entries(struct sysctl_req *req)
  

svn commit: r367443 - in head: share/man/man5 usr.sbin/periodic usr.sbin/periodic/etc/daily

2020-11-06 Thread Robert Wing
Author: rew
Date: Sat Nov  7 04:15:24 2020
New Revision: 367443
URL: https://svnweb.freebsd.org/changeset/base/367443

Log:
  Add a periodic script to backup output generated from `gmirror list`.
  
  Disabled by default.
  
  PR: 86388
  Submitted by:   Miroslav Lachman <000.f...@quip.cz>
  Reviewed by:allanjude, gbe
  Approved by:allanjude (mentor)
  MFC after:  4 weeks
  Event:  July 2020 Bugathon
  Differential Revision:  https://reviews.freebsd.org/D25631

Added:
  head/usr.sbin/periodic/etc/daily/222.backup-gmirror   (contents, props 
changed)
Modified:
  head/share/man/man5/periodic.conf.5
  head/usr.sbin/periodic/etc/daily/Makefile
  head/usr.sbin/periodic/periodic.conf

Modified: head/share/man/man5/periodic.conf.5
==
--- head/share/man/man5/periodic.conf.5 Sat Nov  7 04:10:23 2020
(r367442)
+++ head/share/man/man5/periodic.conf.5 Sat Nov  7 04:15:24 2020
(r367443)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 6, 2020
+.Dd November 7, 2020
 .Dt PERIODIC.CONF 5
 .Os
 .Sh NAME
@@ -257,6 +257,20 @@ as configured in
 Set to
 .Dq Li YES
 to create backup of EFI System Partition (ESP).
+.It Va daily_backup_gmirror_enable
+.Pq Vt bool
+Set to
+.Dq Li YES
+to create backup of gmirror information (i.e., output of
+.Nm gmirror Cm list ) ,
+see
+.Xr gmirror 8 .
+.It Va daily_backup_gmirror_verbose
+.Pq Vt bool
+Set to
+.Dq Li YES
+to report a diff between the new backup and the existing backup
+in the daily output.
 .It Va daily_backup_gpart_enable
 .Pq Vt bool
 Set to

Added: head/usr.sbin/periodic/etc/daily/222.backup-gmirror
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/periodic/etc/daily/222.backup-gmirror Sat Nov  7 04:15:24 
2020(r367443)
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+# $FreeBSD$
+# Created by: Miroslav Lachman <000.f...@quip.cz>
+
+# Backup output from `gmirror list`, which provides detailed information
+# of all gmirrors. The backup will be stored in /var/backups/.
+
+# If there is a global system configuration file, suck it in.
+#
+if [ -r /etc/defaults/periodic.conf ]
+then
+   . /etc/defaults/periodic.conf
+   source_periodic_confs
+fi
+
+bak_dir=/var/backups
+
+rotate() {
+   base_name=$1
+   show_diff=$2
+   file="$bak_dir/$base_name"
+
+   if [ -f "${file}.bak" ]; then
+   rc=0
+   if cmp -s "${file}.bak" "${file}.tmp"; then
+   rm "${file}.tmp"
+   else
+   rc=1
+   [ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
+   mv "${file}.bak" "${file}.bak2" || rc=3
+   mv "${file}.tmp" "${file}.bak" || rc=3
+   fi
+   else
+   rc=1
+   mv "${file}.tmp" "${file}.bak" || rc=3
+   [ -n "$show_diff" ] && cat "${file}.bak"
+   fi
+}
+
+case "$daily_backup_gmirror_verbose" in
+   [Yy][Ee][Ss]) show="YES"
+esac
+
+case "$daily_backup_gmirror_enable" in
+   [Yy][Ee][Ss])
+
+   gmirrors=$(gmirror status 2> /dev/null | \
+   awk '$1 ~ /^mirror\// { sub(/mirror\//, ""); print $1 }')
+
+   if [ -z "$gmirrors"  ]; then
+echo ""
+   echo "daily_backup_gmirror_enable is set to YES but no gmirrors 
found."
+   rc=2
+   else
+   echo ""
+   echo "Backup of gmirror information for:";
+
+   for m in ${gmirrors}; do
+   echo "$m"
+   safe_name=$(echo "gmirror.${m}" | tr -cs ".[:alnum:]\n" 
"_")
+   if ! gmirror status -s "${m}" | grep -F -v "COMPLETE"; 
then
+   gmirror list "${m}" > "$bak_dir/$safe_name.tmp"
+   rotate "$safe_name" $show
+   fi
+   done
+   fi
+   ;;
+   *)  rc=0;;
+esac
+
+exit $rc

Modified: head/usr.sbin/periodic/etc/daily/Makefile
==
--- head/usr.sbin/periodic/etc/daily/Makefile   Sat Nov  7 04:10:23 2020
(r367442)
+++ head/usr.sbin/periodic/etc/daily/Makefile   Sat Nov  7 04:15:24 2020
(r367443)
@@ -11,6 +11,7 @@ CONFS=100.clean-disks \
200.backup-passwd \
210.backup-aliases \
221.backup-gpart \
+   222.backup-gmirror \
330.news \
400.status-disks \
401.status-graid \

Modified: head/usr.sbin/periodic/periodic.conf
==
--- head/usr.sbin/periodic/periodic.confSat Nov  7 04:10:23 2020
(r367442)
+++ head/usr.sbin/periodic/periodic.confSat Nov  7 04:15:24 2020
(r367443)
@@ -79,8 +79,12 @@ 

svn commit: r367442 - in head/sys: kern sys

2020-11-06 Thread Kyle Evans
Author: kevans
Date: Sat Nov  7 04:10:23 2020
New Revision: 367442
URL: https://svnweb.freebsd.org/changeset/base/367442

Log:
  imgact_binmisc: validate flags coming from userland
  
  We may want to reserve bits in the future for kernel-only use, so start
  rejecting any that aren't the two that we're currently expecting from
  userland.
  
  MFC after:1 week

Modified:
  head/sys/kern/imgact_binmisc.c
  head/sys/sys/imgact_binmisc.h

Modified: head/sys/kern/imgact_binmisc.c
==
--- head/sys/kern/imgact_binmisc.c  Sat Nov  7 03:43:45 2020
(r367441)
+++ head/sys/kern/imgact_binmisc.c  Sat Nov  7 04:10:23 2020
(r367442)
@@ -434,6 +434,8 @@ sysctl_kern_binmisc(SYSCTL_HANDLER_ARGS)
return (error);
if (IBE_VERSION != xbe.xbe_version)
return (EINVAL);
+   if ((xbe.xbe_flags & ~IBF_VALID_UFLAGS) != 0)
+   return (EINVAL);
if (interp_list_entry_count == IBE_MAX_ENTRIES)
return (ENOSPC);
error = imgact_binmisc_add_entry();

Modified: head/sys/sys/imgact_binmisc.h
==
--- head/sys/sys/imgact_binmisc.h   Sat Nov  7 03:43:45 2020
(r367441)
+++ head/sys/sys/imgact_binmisc.h   Sat Nov  7 04:10:23 2020
(r367442)
@@ -53,6 +53,8 @@
 #defineIBF_ENABLED 0x0001  /* Entry is active. */
 #defineIBF_USE_MASK0x0002  /* Use mask on header magic field. */
 
+#defineIBF_VALID_UFLAGS0x0003  /* Bits allowed from userland. 
*/
+
 /*
  * Used with sysctlbyname() to pass imgact bin misc entries in and out of the
  * kernel.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367441 - head/usr.sbin/binmiscctl

2020-11-06 Thread Kyle Evans
Author: kevans
Date: Sat Nov  7 03:43:45 2020
New Revision: 367441
URL: https://svnweb.freebsd.org/changeset/base/367441

Log:
  binmiscctl(8): miscellaneous cleanup
  
  - Bad whitespace in Makefile.
  - Reordered headers, sys/ first.
  - Annotated fatal/usage __dead2 to help `make analyze` out a little bit.
  - Spell a couple of sizeof constructs as "nitems" and "howmany" instead.
  
  MFC after:1 week

Modified:
  head/usr.sbin/binmiscctl/Makefile
  head/usr.sbin/binmiscctl/binmiscctl.c

Modified: head/usr.sbin/binmiscctl/Makefile
==
--- head/usr.sbin/binmiscctl/Makefile   Sat Nov  7 03:29:04 2020
(r367440)
+++ head/usr.sbin/binmiscctl/Makefile   Sat Nov  7 03:43:45 2020
(r367441)
@@ -3,7 +3,7 @@
 #
 
 .include 
-   
+
 PROG=  binmiscctl
 MAN=   binmiscctl.8
 

Modified: head/usr.sbin/binmiscctl/binmiscctl.c
==
--- head/usr.sbin/binmiscctl/binmiscctl.c   Sat Nov  7 03:29:04 2020
(r367440)
+++ head/usr.sbin/binmiscctl/binmiscctl.c   Sat Nov  7 03:43:45 2020
(r367441)
@@ -28,6 +28,12 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
+#include 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -37,12 +43,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 enum cmd {
CMD_ADD = 0,
CMD_REMOVE,
@@ -134,7 +134,7 @@ static char const *cmd_sysctl_name[] = {
IBE_SYSCTL_NAME_LIST
 };
 
-static void
+static void __dead2
 usage(const char *format, ...)
 {
va_list args;
@@ -150,7 +150,7 @@ usage(const char *format, ...)
fprintf(stderr, "\n");
fprintf(stderr, "usage: %s command [args...]\n\n", __progname);
 
-   for(i = 0; i < ( sizeof (cmds) / sizeof (cmds[0])); i++) {
+   for(i = 0; i < nitems(cmds); i++) {
fprintf(stderr, "%s:\n", cmds[i].desc);
fprintf(stderr, "\t%s %s %s\n\n", __progname, cmds[i].name,
cmds[i].args);
@@ -159,7 +159,7 @@ usage(const char *format, ...)
exit (error);
 }
 
-static void
+static void __dead2
 fatal(const char *format, ...)
 {
va_list args;
@@ -232,7 +232,7 @@ demux_cmd(__unused int argc, char *const argv[])
optind = 1;
optreset = 1;
 
-   for(i = 0; i < ( sizeof (cmds) / sizeof (cmds[0])); i++) {
+   for(i = 0; i < nitems(cmds); i++) {
if (!strcasecmp(cmds[i].name, argv[0])) {
return (i);
}
@@ -505,7 +505,7 @@ main(int argc, char **argv)
free(xbe_outp);
fatal("Fatal: %s", strerror(errno));
}
-   for(i = 0; i < (xbe_out_sz / sizeof(xbe_out)); i++)
+   for(i = 0; i < howmany(xbe_out_sz, sizeof(xbe_out)); i++)
printxbe(_outp[i]);
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367440 - head/sys/kern

2020-11-06 Thread Kyle Evans
Author: kevans
Date: Sat Nov  7 03:29:04 2020
New Revision: 367440
URL: https://svnweb.freebsd.org/changeset/base/367440

Log:
  epoch: support non-preemptible epochs checking in_epoch()
  
  Previously, non-preemptible epochs could not check; in_epoch() would always
  fail, usually because non-preemptible epochs don't imply THREAD_NO_SLEEPING.
  
  For default epochs, it's easy enough to verify that we're in the given
  epoch: if we're in a critical section and our record for the given epoch
  is active, then we're in it.
  
  This patch also adds some additional INVARIANTS bookkeeping. Notably, we set
  and check the recorded thread in epoch_enter/epoch_exit to try and catch
  some edge-cases for the caller. It also checks upon freeing that none of the
  records had a thread in the epoch, which may make it a little easier to
  diagnose some improper use if epoch_free() took place while some other
  thread was inside.
  
  This version differs slightly from what was just previously reviewed by the
  below-listed, in that in_epoch() will assert that no CPU has this thread
  recorded even if it *is* currently in a critical section. This is intended
  to catch cases where the caller might have somehow messed up critical
  section nesting, we can catch both if they exited the critical section or if
  they exited, migrated, then re-entered (on the wrong CPU).
  
  Reviewed by:  kib, markj (both previous version)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D27098

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Sat Nov  7 03:28:32 2020(r367439)
+++ head/sys/kern/subr_epoch.c  Sat Nov  7 03:29:04 2020(r367440)
@@ -72,6 +72,10 @@ typedef struct epoch_record {
volatile struct epoch_tdlist er_tdlist;
volatile uint32_t er_gen;
uint32_t er_cpuid;
+#ifdef INVARIANTS
+   /* Used to verify record ownership for non-preemptible epochs. */
+   struct thread *er_td;
+#endif
 } __aligned(EPOCH_ALIGN) *epoch_record_t;
 
 struct epoch {
@@ -377,6 +381,9 @@ done:
 void
 epoch_free(epoch_t epoch)
 {
+#ifdef INVARIANTS
+   int cpu;
+#endif
 
EPOCH_LOCK();
 
@@ -390,6 +397,21 @@ epoch_free(epoch_t epoch)
 * to zero, by calling epoch_wait() on the global_epoch:
 */
epoch_wait(global_epoch);
+#ifdef INVARIANTS
+   CPU_FOREACH(cpu) {
+   epoch_record_t er;
+
+   er = zpcpu_get_cpu(epoch->e_pcpu_record, cpu);
+
+   /*
+* Sanity check: none of the records should be in use anymore.
+* We drained callbacks above and freeing the pcpu records is
+* imminent.
+*/
+   MPASS(er->er_td == NULL);
+   MPASS(TAILQ_EMPTY(>er_tdlist));
+   }
+#endif
uma_zfree_pcpu(pcpu_zone_record, epoch->e_pcpu_record);
mtx_destroy(>e_drain_mtx);
sx_destroy(>e_drain_sx);
@@ -434,6 +456,8 @@ _epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et
sched_pin();
td->td_pre_epoch_prio = td->td_priority;
er = epoch_currecord(epoch);
+   /* Record-level tracking is reserved for non-preemptible epochs. */
+   MPASS(er->er_td == NULL);
TAILQ_INSERT_TAIL(>er_tdlist, et, et_link);
ck_epoch_begin(>er_record, >et_section);
critical_exit();
@@ -448,6 +472,15 @@ epoch_enter(epoch_t epoch)
INIT_CHECK(epoch);
critical_enter();
er = epoch_currecord(epoch);
+#ifdef INVARIANTS
+   if (er->er_record.active == 0) {
+   MPASS(er->er_td == NULL);
+   er->er_td = curthread;
+   } else {
+   /* We've recursed, just make sure our accounting isn't wrong. */
+   MPASS(er->er_td == curthread);
+   }
+#endif
ck_epoch_begin(>er_record, NULL);
 }
 
@@ -468,6 +501,8 @@ _epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et 
MPASS(et->et_td == td);
 #ifdef INVARIANTS
et->et_td = (void*)0xDEADBEEF;
+   /* Record-level tracking is reserved for non-preemptible epochs. */
+   MPASS(er->er_td == NULL);
 #endif
ck_epoch_end(>er_record, >et_section);
TAILQ_REMOVE(>er_tdlist, et, et_link);
@@ -488,6 +523,11 @@ epoch_exit(epoch_t epoch)
INIT_CHECK(epoch);
er = epoch_currecord(epoch);
ck_epoch_end(>er_record, NULL);
+#ifdef INVARIANTS
+   MPASS(er->er_td == curthread);
+   if (er->er_record.active == 0)
+   er->er_td = NULL;
+#endif
critical_exit();
 }
 
@@ -777,18 +817,18 @@ epoch_call_task(void *arg __unused)
}
 }
 
-int
-in_epoch_verbose(epoch_t epoch, int dump_onfail)
+static int
+in_epoch_verbose_preempt(epoch_t epoch, int dump_onfail)
 {
+   epoch_record_t er;
struct epoch_tracker *tdwait;
struct thread *td;
-   

svn commit: r367439 - head/sys/kern

2020-11-06 Thread Kyle Evans
Author: kevans
Date: Sat Nov  7 03:28:32 2020
New Revision: 367439
URL: https://svnweb.freebsd.org/changeset/base/367439

Log:
  imgact_binmisc: minor re-organization of imgact_binmisc_exec exits
  
  Notably, streamline error paths through the existing 'done' label, making it
  easier to quickly verify correct cleanup.
  
  Future work might add a kernel-only flag to indicate that a interpreter uses
  #a. Currently, all executions via imgact_binmisc pay the penalty of
  constructing sname/fname, even if they will not use it. qemu-user-static
  doesn't need it, the stock rc script for qemu-user-static certainly doesn't
  use it, and I suspect these are the vast majority of (if not the only)
  current users.
  
  MFC after:1 week

Modified:
  head/sys/kern/imgact_binmisc.c

Modified: head/sys/kern/imgact_binmisc.c
==
--- head/sys/kern/imgact_binmisc.c  Sat Nov  7 01:32:16 2020
(r367438)
+++ head/sys/kern/imgact_binmisc.c  Sat Nov  7 03:28:32 2020
(r367439)
@@ -580,24 +580,24 @@ imgact_binmisc_exec(struct image_params *imgp)
struct sbuf *sname;
char *s, *d;
 
+   sname = NULL;
/* Do we have an interpreter for the given image header? */
sx_slock(_list_sx);
if ((ibe = imgact_binmisc_find_interpreter(image_header)) == NULL) {
-   sx_sunlock(_list_sx);
-   return (-1);
+   error = -1;
+   goto done;
}
 
/* No interpreter nesting allowed. */
if (imgp->interpreted & IMGACT_BINMISC) {
-   sx_sunlock(_list_sx);
-   return (ENOEXEC);
+   error = ENOEXEC;
+   goto done;
}
 
imgp->interpreted |= IMGACT_BINMISC;
 
if (imgp->args->fname != NULL) {
fname = imgp->args->fname;
-   sname = NULL;
} else {
/* Use the fdescfs(5) path for fexecve(2). */
sname = sbuf_new_auto();
@@ -636,7 +636,6 @@ imgact_binmisc_exec(struct image_params *imgp)
 
default:
/* Hmm... This shouldn't happen. */
-   sx_sunlock(_list_sx);
printf("%s: Unknown macro #%c sequence in "
"interpreter string\n", KMOD_NAME, *(s + 1));
error = EINVAL;
@@ -648,7 +647,6 @@ imgact_binmisc_exec(struct image_params *imgp)
/* Make room for the interpreter */
error = exec_args_adjust_args(imgp->args, 0, offset);
if (error != 0) {
-   sx_sunlock(_list_sx);
goto done;
}
 
@@ -698,11 +696,11 @@ imgact_binmisc_exec(struct image_params *imgp)
s++;
}
*d = '\0';
-   sx_sunlock(_list_sx);
 
imgp->interpreter_name = imgp->args->begin_argv;
 
 done:
+   sx_sunlock(_list_sx);
if (sname)
sbuf_delete(sname);
return (error);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r367432 - in head: lib/libmemstat sys/cddl/dev/dtmalloc sys/kern sys/sys

2020-11-06 Thread Yasuhiro KIMURA
From: Mateusz Guzik 
Subject: Re: svn commit: r367432 - in head: lib/libmemstat 
sys/cddl/dev/dtmalloc sys/kern sys/sys
Date: Sat, 7 Nov 2020 02:25:05 +0100

> You need to recompile all modules.

Sorry, I forgot to recompile emulators/virtualbox-ose-additions-nox11.
After recompiling it panic disappeared.

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


svn commit: r367438 - head/sys/kern

2020-11-06 Thread Mateusz Guzik
Author: mjg
Date: Sat Nov  7 01:32:16 2020
New Revision: 367438
URL: https://svnweb.freebsd.org/changeset/base/367438

Log:
  malloc: tweak the version check in r367432 to include type name
  
  While here fix a whitespace problem.

Modified:
  head/sys/kern/kern_malloc.c

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Fri Nov  6 23:37:59 2020(r367437)
+++ head/sys/kern/kern_malloc.c Sat Nov  7 01:32:16 2020(r367438)
@@ -1201,7 +1201,7 @@ mallocinit(void *dummy)
NULL, NULL, NULL, NULL,
 #endif
UMA_ALIGN_PTR, UMA_ZONE_MALLOC);
-   }   
+   }
for (;i <= size; i+= KMEM_ZBASE)
kmemsize[i >> KMEM_ZSHIFT] = indx;
}
@@ -1218,8 +1218,8 @@ malloc_init(void *data)
 
mtp = data;
if (mtp->ks_version != M_VERSION)
-   panic("malloc_init: unsupported malloc type version %lu",
-   mtp->ks_version);
+   panic("malloc_init: type %s with unsupported version %lu",
+   mtp->ks_shortdesc, mtp->ks_version);
 
mtip = >ks_mti;
mtip->mti_stats = uma_zalloc_pcpu(mt_stats_zone, M_WAITOK | M_ZERO);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r367432 - in head: lib/libmemstat sys/cddl/dev/dtmalloc sys/kern sys/sys

2020-11-06 Thread Mateusz Guzik
You need to recompile all modules.

On 11/7/20, Yasuhiro KIMURA  wrote:
> From: Mateusz Guzik 
> Subject: svn commit: r367432 - in head: lib/libmemstat sys/cddl/dev/dtmalloc
> sys/kern sys/sys
> Date: Fri, 6 Nov 2020 21:33:59 + (UTC)
>
>> Author: mjg
>> Date: Fri Nov  6 21:33:59 2020
>> New Revision: 367432
>> URL: https://svnweb.freebsd.org/changeset/base/367432
>>
>> Log:
>>   malloc: move malloc_type_internal into malloc_type
>>
>>   According to code comments the original motivation was to allow for
>>   malloc_type_internal changes without ABI breakage. This can be
>> trivially
>>   accomplished by providing spare fields and versioning the struct, as
>>   implemented in the patch below.
>>
>>   The upshots are one less memory indirection on each alloc and
>> disappearance
>>   of mt_zone.
>>
>>   Reviewed by:   markj
>>   Differential Revision: https://reviews.freebsd.org/D27104
>
> With this commit kernel panic happens on amd64 as following.
>
> https://www.utahime.org/FreeBSD/FreeBSD.13-CURRENT.amd64.r367432.panic.png
>
> ---
> Yasuhiro KIMURA
>


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


Re: svn commit: r367432 - in head: lib/libmemstat sys/cddl/dev/dtmalloc sys/kern sys/sys

2020-11-06 Thread Yasuhiro KIMURA
From: Mateusz Guzik 
Subject: svn commit: r367432 - in head: lib/libmemstat sys/cddl/dev/dtmalloc 
sys/kern sys/sys
Date: Fri, 6 Nov 2020 21:33:59 + (UTC)

> Author: mjg
> Date: Fri Nov  6 21:33:59 2020
> New Revision: 367432
> URL: https://svnweb.freebsd.org/changeset/base/367432
> 
> Log:
>   malloc: move malloc_type_internal into malloc_type
>   
>   According to code comments the original motivation was to allow for
>   malloc_type_internal changes without ABI breakage. This can be trivially
>   accomplished by providing spare fields and versioning the struct, as
>   implemented in the patch below.
>   
>   The upshots are one less memory indirection on each alloc and disappearance
>   of mt_zone.
>   
>   Reviewed by:markj
>   Differential Revision:  https://reviews.freebsd.org/D27104

With this commit kernel panic happens on amd64 as following.

https://www.utahime.org/FreeBSD/FreeBSD.13-CURRENT.amd64.r367432.panic.png

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


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

2020-11-06 Thread John Baldwin
Author: jhb
Date: Fri Nov  6 23:37:59 2020
New Revision: 367437
URL: https://svnweb.freebsd.org/changeset/base/367437

Log:
  Update copies of ioctl structures to match recent changes in head.
  
  - Update for C99 types and void pointers.
  - Update example algorithms to not use removed algorithms.

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

Modified: head/share/man/man4/crypto.4
==
--- head/share/man/man4/crypto.4Fri Nov  6 22:58:31 2020
(r367436)
+++ head/share/man/man4/crypto.4Fri Nov  6 23:37:59 2020
(r367437)
@@ -60,7 +60,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 19, 2020
+.Dd November 6, 2020
 .Dt CRYPTO 4
 .Os
 .Sh NAME
@@ -209,15 +209,15 @@ is returned.
 .It Dv CIOCGSESSION Fa struct session_op *sessp
 .Bd -literal
 struct session_op {
-u_int32_t cipher;  /* e.g. CRYPTO_DES_CBC */
-u_int32_t mac; /* e.g. CRYPTO_MD5_HMAC */
+uint32_t cipher;   /* e.g. CRYPTO_AES_CBC */
+uint32_t mac;  /* e.g. CRYPTO_SHA2_256_HMAC */
 
-u_int32_t keylen;  /* cipher key */
+uint32_t keylen;   /* cipher key */
 const void *key;
 int mackeylen; /* mac key */
 const void *mackey;
 
-u_int32_t ses; /* returns: ses # */
+uint32_t ses;  /* returns: ses # */
 };
 
 .Ed
@@ -267,15 +267,15 @@ stand-alone non-fused operation.
 .It Dv CIOCGSESSION2 Fa struct session2_op *sessp
 .Bd -literal
 struct session2_op {
-u_int32_t cipher;  /* e.g. CRYPTO_DES_CBC */
-u_int32_t mac; /* e.g. CRYPTO_MD5_HMAC */
+uint32_t cipher;   /* e.g. CRYPTO_AES_CBC */
+uint32_t mac;  /* e.g. CRYPTO_SHA2_256_HMAC */
 
-u_int32_t keylen;  /* cipher key */
+uint32_t keylen;   /* cipher key */
 const void *key;
 int mackeylen; /* mac key */
 const void *mackey;
 
-u_int32_t ses; /* returns: ses # */
+uint32_t ses;  /* returns: ses # */
 intcrid;   /* driver id + flags (rw) */
 intpad[4]; /* for future expansion */
 };
@@ -291,13 +291,14 @@ field must be initialized to zero.
 .It Dv CIOCCRYPT Fa struct crypt_op *cr_op
 .Bd -literal
 struct crypt_op {
-u_int32_t ses;
-u_int16_t op;  /* e.g. COP_ENCRYPT */
-u_int16_t flags;
+uint32_t ses;
+uint16_t op;   /* e.g. COP_ENCRYPT */
+uint16_t flags;
 u_int len;
-caddr_t src, dst;
-caddr_t mac;   /* must be large enough for result */
-caddr_t iv;
+const void *src;
+void *dst;
+void *mac; /* must be large enough for result */
+const void *iv;
 };
 
 .Ed
@@ -330,16 +331,17 @@ and the output buffer will remain unchanged.
 .It Dv CIOCCRYPTAEAD Fa struct crypt_aead *cr_aead
 .Bd -literal
 struct crypt_aead {
-u_int32_t ses;
-u_int16_t op;  /* e.g. COP_ENCRYPT */
-u_int16_t flags;
+uint32_t ses;
+uint16_t op;   /* e.g. COP_ENCRYPT */
+uint16_t flags;
 u_int len;
 u_int aadlen;
 u_int ivlen;
-caddr_t src, dst;
-caddr_t aad;
-caddr_t tag;   /* must be large enough for result */
-caddr_t iv;
+const void *src;
+void *dst;
+const void *aad;   /* additional authenticated data */
+void *tag; /* must fit for chosen TAG length */
+const void *iv;
 };
 
 .Ed
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367436 - in head: share/man/man5 usr.sbin/periodic usr.sbin/periodic/etc/daily

2020-11-06 Thread Robert Wing
Author: rew
Date: Fri Nov  6 22:58:31 2020
New Revision: 367436
URL: https://svnweb.freebsd.org/changeset/base/367436

Log:
  Add a periodic script to backup output generated from `zfs list`, `zfs get`,
  `zpool list`, and `zpool get` commands.
  
  Disabled by default.
  
  PR: 86388
  Submitted by:   Miroslav Lachman <000.f...@quip.cz>
  Reviewed by:allanjude, 0mp
  Approved by:allanjude (mentor)
  MFC after:  4 weeks
  Event:  July 2020 Bugathon
  Differential Revision:  https://reviews.freebsd.org/D25638

Added:
  head/usr.sbin/periodic/etc/daily/223.backup-zfs   (contents, props changed)
Modified:
  head/share/man/man5/periodic.conf.5
  head/usr.sbin/periodic/etc/daily/Makefile
  head/usr.sbin/periodic/periodic.conf

Modified: head/share/man/man5/periodic.conf.5
==
--- head/share/man/man5/periodic.conf.5 Fri Nov  6 22:40:00 2020
(r367435)
+++ head/share/man/man5/periodic.conf.5 Fri Nov  6 22:58:31 2020
(r367436)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 9, 2020
+.Dd November 6, 2020
 .Dt PERIODIC.CONF 5
 .Os
 .Sh NAME
@@ -289,6 +289,57 @@ Set to
 if you want the
 .Pa /etc/mail/aliases
 file backed up and modifications to be displayed in your daily output.
+.It Va daily_backup_zfs_enable
+.Pq Vt bool
+Set to
+.Dq Li YES
+to create backup of the output generated from the
+.Xr zfs-list 8
+and
+.Xr zpool-list 8
+utilities.
+.It Va daily_backup_zfs_list_flags
+.Pq Vt str
+Set to the arguments for the
+.Xr zfs-list 8
+utility.
+The default is standard behavior.
+.It Va daily_backup_zpool_list_flags
+.Pq Vt str
+Set to the arguments for the
+.Xr zpool-list 8
+utility.
+The default is
+.Fl v .
+.It Va daily_backup_zfs_props_enable
+.Pq Vt bool
+Set to
+.Dq Li YES
+to create backup of the output generated from the
+.Xr zfs-get 8
+and
+.Xr zpool-get 8
+utilities.
+.It Va daily_backup_zfs_get_flags
+.Pq Vt str
+Set to the arguments for the
+.Xr zfs-get 8
+utility.
+The default is
+.Cm all .
+.It Va daily_backup_zpool_get_flags
+.Pq Vt str
+Set to the arguments for the
+.Xr zpool-get 8
+utility.
+The default is
+.Cm all .
+.It Va daily_backup_zfs_verbose
+.Pq Vt bool
+Set to
+.Dq Li YES
+to report a diff between the new backup and the existing backup
+in the daily output.
 .It Va daily_calendar_enable
 .Pq Vt bool
 Set to

Added: head/usr.sbin/periodic/etc/daily/223.backup-zfs
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/periodic/etc/daily/223.backup-zfs Fri Nov  6 22:58:31 
2020(r367436)
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# $FreeBSD$
+# Created by: Miroslav Lachman <000.f...@quip.cz>
+
+# Backup of zpool list, zfs list, zpool properties and zfs properties
+# for each filesystem. The backup will be stored in /var/backups.
+
+# If there is a global system configuration file, suck it in.
+#
+if [ -r /etc/defaults/periodic.conf ]
+then
+   . /etc/defaults/periodic.conf
+   source_periodic_confs
+fi
+
+bak_dir=/var/backups
+
+rotate() {
+   base_name=$1
+   show_diff=$2
+   file="$bak_dir/$base_name"
+
+   if [ -f "${file}.bak" ] ; then
+   rc=0
+   if cmp -s "${file}.bak" "${file}.tmp"; then
+   rm "${file}.tmp"
+   else
+   rc=1
+   [ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
+   mv "${file}.bak" "${file}.bak2" || rc=3
+   mv "${file}.tmp" "${file}.bak" || rc=3
+   fi
+   else
+   rc=1
+   mv "${file}.tmp" "${file}.bak" || rc=3
+   [ -n "$show_diff" ] && cat "${file}.bak"
+   fi
+}
+
+case "$daily_backup_zfs_verbose" in
+   [Yy][Ee][Ss]) show="YES"
+esac
+
+case "$daily_backup_zfs_enable" in
+   [Yy][Ee][Ss])
+
+zpools=$(zpool list $daily_backup_zpool_list_flags)
+
+   if [ -z "$zpools"  ]; then
+   echo 'daily_backup_zfs_enable is set to YES but no zpools 
found.'
+   rc=2
+   else
+   echo ""
+   echo "Backup of ZFS information for all imported pools";
+
+   echo "$zpools" > "$bak_dir/zpool_list.tmp"
+   rotate "zpool_list" $show
+
+   zfs list $daily_backup_zfs_list_flags > "$bak_dir/zfs_list.tmp"
+   rotate "zfs_list" $show
+   fi
+   ;;
+   *)  rc=0;;
+esac
+
+case "$daily_backup_zfs_props_enable" in
+[Yy][Ee][Ss])
+
+zfs get $daily_backup_zfs_get_flags > "$bak_dir/zfs_props.tmp"
+rotate "zfs_props"
+
+zpool get $daily_backup_zpool_get_flags > "$bak_dir/zpool_props.tmp"
+rotate "zpool_props"
+;;
+esac
+
+exit $rc

Modified: head/usr.sbin/periodic/etc/daily/Makefile
==
--- 

svn commit: r367435 - head/sys/dev/usb

2020-11-06 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Nov  6 22:40:00 2020
New Revision: 367435
URL: https://svnweb.freebsd.org/changeset/base/367435

Log:
  usb_hub: giving up port reset - device vanished
  
  Improve the output of the recently often experienced debug message in order
  to gather further data.
  
  PR:   237666
  Reviewed by:  hselasky
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D27108

Modified:
  head/sys/dev/usb/usb_hub.c

Modified: head/sys/dev/usb/usb_hub.c
==
--- head/sys/dev/usb/usb_hub.c  Fri Nov  6 22:11:05 2020(r367434)
+++ head/sys/dev/usb/usb_hub.c  Fri Nov  6 22:40:00 2020(r367435)
@@ -720,8 +720,10 @@ repeat:
if ((sc->sc_st.port_change & UPS_C_CONNECT_STATUS) ||
(!(sc->sc_st.port_status & UPS_CURRENT_CONNECT_STATUS))) {
if (timeout) {
-   DPRINTFN(0, "giving up port reset "
-   "- device vanished\n");
+  DPRINTFN(0, "giving up port %d reset - "
+  "device vanished: change %#x status %#x\n",
+  portno, sc->sc_st.port_change,
+  sc->sc_st.port_status);
goto error;
}
timeout = 1;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367434 - head/usr.sbin/pkg

2020-11-06 Thread John-Mark Gurney
Author: jmg
Date: Fri Nov  6 22:11:05 2020
New Revision: 367434
URL: https://svnweb.freebsd.org/changeset/base/367434

Log:
  fix up docs, if signature checking is enabled, the file MUST exist...

Modified:
  head/usr.sbin/pkg/pkg.7

Modified: head/usr.sbin/pkg/pkg.7
==
--- head/usr.sbin/pkg/pkg.7 Fri Nov  6 22:04:57 2020(r367433)
+++ head/usr.sbin/pkg/pkg.7 Fri Nov  6 22:11:05 2020(r367434)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 12, 2013
+.Dd November 6, 2020
 .Dt PKG 7
 .Os
 .Sh NAME
@@ -69,11 +69,8 @@ If already installed, the command requested will be fo
 Install
 .Xr pkg 8
 from a local package instead of fetching from remote.
-If a
-.Pa pkg.txz.sig
-file exists and
-signature checking is enabled, then the signature will be verified
-before installing the package.
+If signature checking is enabled, then the correct signature file
+must exist and the signature valid before the package will be installed.
 If the
 .Fl f
 flag is specified, then
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367433 - in head/sys: compat/linux conf

2020-11-06 Thread Conrad Meyer
Author: cem
Date: Fri Nov  6 22:04:57 2020
New Revision: 367433
URL: https://svnweb.freebsd.org/changeset/base/367433

Log:
  linux(4): Fix loadable modules after r367395
  
  Move dtrace SDT definitions into linux_common module code.  Also, build
  linux_dummy.c into the linux_common kld -- we don't need separate
  versions of these stubs for 32- and 64-bit emulation.
  
  Reported by:  several
  PR:   250897
  Discussed with:   emaste, trasz
  Tested by:John Kennedy, Yasuhiro KIMURA, Oleg Sidorkin
  X-MFC-With:   r367395
  Differential Revision:https://reviews.freebsd.org/D27124

Modified:
  head/sys/compat/linux/linux_common.c
  head/sys/compat/linux/linux_dummy.c
  head/sys/compat/linux/linux_misc.c
  head/sys/conf/files.i386

Modified: head/sys/compat/linux/linux_common.c
==
--- head/sys/compat/linux/linux_common.cFri Nov  6 21:33:59 2020
(r367432)
+++ head/sys/compat/linux/linux_common.cFri Nov  6 22:04:57 2020
(r367433)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -48,6 +49,20 @@ FEATURE(linuxulator_v4l, "V4L ioctl wrapper support in
 FEATURE(linuxulator_v4l2, "V4L2 ioctl wrapper support in the linuxulator");
 
 MODULE_VERSION(linux_common, 1);
+
+/**
+ * Special DTrace provider for the linuxulator.
+ *
+ * In this file we define the provider for the entire linuxulator. All
+ * modules (= files of the linuxulator) use it.
+ *
+ * We define a different name depending on the emulated bitsize, see
+ * ../..//linux{,32}/linux.h, e.g.:
+ *  native bitsize  = linuxulator
+ *  amd64, 32bit emulation  = linuxulator32
+ */
+LIN_SDT_PROVIDER_DEFINE(linuxulator);
+LIN_SDT_PROVIDER_DEFINE(linuxulator32);
 
 SET_DECLARE(linux_device_handler_set, struct linux_device_handler);
 

Modified: head/sys/compat/linux/linux_dummy.c
==
--- head/sys/compat/linux/linux_dummy.c Fri Nov  6 21:33:59 2020
(r367432)
+++ head/sys/compat/linux/linux_dummy.c Fri Nov  6 22:04:57 2020
(r367433)
@@ -29,21 +29,19 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include "opt_compat.h"
-
 #include 
 #include 
 #include 
 #include 
 #include 
 
-#ifdef COMPAT_LINUX32
-#include 
-#include 
-#else
+/*
+ * Including linux vs linux32 here is arbitrary -- the syscall args structures
+ * (proto.h) are not dereferenced by the DUMMY stub implementations, and
+ * suitable for use by both native and compat32 entrypoints.
+ */
 #include 
 #include 
-#endif
 
 #include 
 #include 

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Fri Nov  6 21:33:59 2020
(r367432)
+++ head/sys/compat/linux/linux_misc.c  Fri Nov  6 22:04:57 2020
(r367433)
@@ -99,19 +99,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-/**
- * Special DTrace provider for the linuxulator.
- *
- * In this file we define the provider for the entire linuxulator. All
- * modules (= files of the linuxulator) use it.
- *
- * We define a different name depending on the emulated bitsize, see
- * ../..//linux{,32}/linux.h, e.g.:
- *  native bitsize  = linuxulator
- *  amd64, 32bit emulation  = linuxulator32
- */
-LIN_SDT_PROVIDER_DEFINE(LINUX_DTRACE);
-
 int stclohz;   /* Statistics clock frequency */
 
 static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] = {

Modified: head/sys/conf/files.i386
==
--- head/sys/conf/files.i386Fri Nov  6 21:33:59 2020(r367432)
+++ head/sys/conf/files.i386Fri Nov  6 22:04:57 2020(r367433)
@@ -52,6 +52,7 @@ cddl/dev/dtrace/i386/dtrace_asm.S 
optional dtrace co
 cddl/dev/dtrace/i386/dtrace_subr.c optional dtrace 
compile-with "${DTRACE_C}"
 compat/linprocfs/linprocfs.c   optional linprocfs
 compat/linsysfs/linsysfs.c optional linsysfs
+compat/linux/linux_common.coptional compat_linux
 compat/linux/linux_dummy.c optional compat_linux
 compat/linux/linux_event.c optional compat_linux
 compat/linux/linux_emul.c  optional compat_linux
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367432 - in head: lib/libmemstat sys/cddl/dev/dtmalloc sys/kern sys/sys

2020-11-06 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov  6 21:33:59 2020
New Revision: 367432
URL: https://svnweb.freebsd.org/changeset/base/367432

Log:
  malloc: move malloc_type_internal into malloc_type
  
  According to code comments the original motivation was to allow for
  malloc_type_internal changes without ABI breakage. This can be trivially
  accomplished by providing spare fields and versioning the struct, as
  implemented in the patch below.
  
  The upshots are one less memory indirection on each alloc and disappearance
  of mt_zone.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D27104

Modified:
  head/lib/libmemstat/memstat_malloc.c
  head/sys/cddl/dev/dtmalloc/dtmalloc.c
  head/sys/kern/kern_malloc.c
  head/sys/sys/malloc.h
  head/sys/sys/param.h

Modified: head/lib/libmemstat/memstat_malloc.c
==
--- head/lib/libmemstat/memstat_malloc.cFri Nov  6 21:27:54 2020
(r367431)
+++ head/lib/libmemstat/memstat_malloc.cFri Nov  6 21:33:59 2020
(r367432)
@@ -317,7 +317,7 @@ memstat_kvm_malloc(struct memory_type_list *list, void
int hint_dontsearch, j, mp_maxcpus, mp_ncpus, ret;
char name[MEMTYPE_MAXNAME];
struct malloc_type_stats mts;
-   struct malloc_type_internal mti, *mtip;
+   struct malloc_type_internal *mtip;
struct malloc_type type, *typep;
kvm_t *kvm;
 
@@ -372,18 +372,17 @@ memstat_kvm_malloc(struct memory_type_list *list, void
list->mtl_error = ret;
return (-1);
}
+   if (type.ks_version != M_VERSION) {
+   warnx("type %s with unsupported version %lu; skipped",
+   name, type.ks_version);
+   continue;
+   }
 
/*
 * Since our compile-time value for MAXCPU may differ from the
 * kernel's, we populate our own array.
 */
-   mtip = type.ks_handle;
-   ret = kread(kvm, mtip, , sizeof(mti), 0);
-   if (ret != 0) {
-   _memstat_mtl_empty(list);
-   list->mtl_error = ret;
-   return (-1);
-   }
+   mtip = _mti;
 
if (hint_dontsearch == 0) {
mtp = memstat_mtl_find(list, ALLOCATOR_MALLOC, name);
@@ -404,7 +403,7 @@ memstat_kvm_malloc(struct memory_type_list *list, void
 */
_memstat_mt_reset_stats(mtp, mp_maxcpus);
for (j = 0; j < mp_ncpus; j++) {
-   ret = kread_zpcpu(kvm, (u_long)mti.mti_stats, ,
+   ret = kread_zpcpu(kvm, (u_long)mtip->mti_stats, ,
sizeof(mts), j);
if (ret != 0) {
_memstat_mtl_empty(list);

Modified: head/sys/cddl/dev/dtmalloc/dtmalloc.c
==
--- head/sys/cddl/dev/dtmalloc/dtmalloc.c   Fri Nov  6 21:27:54 2020
(r367431)
+++ head/sys/cddl/dev/dtmalloc/dtmalloc.c   Fri Nov  6 21:33:59 2020
(r367432)
@@ -114,7 +114,7 @@ static void
 dtmalloc_type_cb(struct malloc_type *mtp, void *arg __unused)
 {
char name[DTRACE_FUNCNAMELEN];
-   struct malloc_type_internal *mtip = mtp->ks_handle;
+   struct malloc_type_internal *mtip = >ks_mti;
int i;
 
/*

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Fri Nov  6 21:27:54 2020(r367431)
+++ head/sys/kern/kern_malloc.c Fri Nov  6 21:33:59 2020(r367432)
@@ -175,14 +175,8 @@ struct {
 };
 
 /*
- * Zone to allocate malloc type descriptions from.  For ABI reasons, memory
- * types are described by a data structure passed by the declaring code, but
- * the malloc(9) implementation has its own data structure describing the
- * type and statistics.  This permits the malloc(9)-internal data structures
- * to be modified without breaking binary-compiled kernel modules that
- * declare malloc types.
+ * Zone to allocate per-CPU storage for statistics.
  */
-static uma_zone_t mt_zone;
 static uma_zone_t mt_stats_zone;
 
 u_long vm_kmem_size;
@@ -342,7 +336,7 @@ mtp_set_subzone(struct malloc_type *mtp)
size_t len;
u_int val;
 
-   mtip = mtp->ks_handle;
+   mtip = >ks_mti;
desc = mtp->ks_shortdesc;
if (desc == NULL || (len = strlen(desc)) == 0)
val = 0;
@@ -356,7 +350,7 @@ mtp_get_subzone(struct malloc_type *mtp)
 {
struct malloc_type_internal *mtip;
 
-   mtip = mtp->ks_handle;
+   mtip = >ks_mti;
 
KASSERT(mtip->mti_zone < numzones,
("mti_zone %u out of range %d",
@@ -371,7 +365,7 @@ mtp_set_subzone(struct malloc_type *mtp)

svn commit: r367431 - head/sys/dev/vt/hw/efifb

2020-11-06 Thread Toomas Soome
Author: tsoome
Date: Fri Nov  6 21:27:54 2020
New Revision: 367431
URL: https://svnweb.freebsd.org/changeset/base/367431

Log:
  efifb: vt_generate_cons_palette() takes max color, not mask
  
  vt_generate_cons_palette() does take max values of RGB component colours, not
  mask. Also we need to set info->fb_cmsize, or vt_fb_init() will re-initialize
  the info->fb_cmap.

Modified:
  head/sys/dev/vt/hw/efifb/efifb.c

Modified: head/sys/dev/vt/hw/efifb/efifb.c
==
--- head/sys/dev/vt/hw/efifb/efifb.cFri Nov  6 19:27:27 2020
(r367430)
+++ head/sys/dev/vt/hw/efifb/efifb.cFri Nov  6 21:27:54 2020
(r367431)
@@ -102,6 +102,7 @@ vt_efifb_init(struct vt_device *vd)
struct fb_info  *info;
struct efi_fb   *efifb;
caddr_t kmdp;
+   int roff, goff, boff;
 
info = vd->vd_softc;
if (info == NULL)
@@ -126,10 +127,14 @@ vt_efifb_init(struct vt_device *vd)
/* Stride in bytes, not pixels */
info->fb_stride = efifb->fb_stride * (info->fb_bpp / NBBY);
 
+   roff = ffs(efifb->fb_mask_red) - 1;
+   goff = ffs(efifb->fb_mask_green) - 1;
+   boff = ffs(efifb->fb_mask_blue) - 1;
vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB,
-   efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1,
-   efifb->fb_mask_green, ffs(efifb->fb_mask_green) - 1,
-   efifb->fb_mask_blue, ffs(efifb->fb_mask_blue) - 1);
+   efifb->fb_mask_red >> roff, roff,
+   efifb->fb_mask_green >> goff, goff,
+   efifb->fb_mask_blue >> boff, boff);
+   info->fb_cmsize = NCOLORS;
 
info->fb_size = info->fb_height * info->fb_stride;
info->fb_pbase = efifb->fb_addr;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367430 - head/sys/powerpc/include

2020-11-06 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Nov  6 19:27:27 2020
New Revision: 367430
URL: https://svnweb.freebsd.org/changeset/base/367430

Log:
  Make powerpc use MAXARGS (defined as 8) instead of hardcoding '10'.
  This brings its 'struct syscall_args' in sync with other architectures.
  
  Reviewed by:  bdragon, jhibbits
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26605

Modified:
  head/sys/powerpc/include/proc.h

Modified: head/sys/powerpc/include/proc.h
==
--- head/sys/powerpc/include/proc.h Fri Nov  6 19:19:51 2020
(r367429)
+++ head/sys/powerpc/include/proc.h Fri Nov  6 19:27:27 2020
(r367430)
@@ -59,10 +59,11 @@ struct mdproc {
 #defineKINFO_PROC_SIZE 816
 #endif
 
+#defineMAXARGS 8
 struct syscall_args {
u_int code;
struct sysent *callp;
-   register_t args[10];
+   register_t args[MAXARGS];
 };
 
 #ifdef _KERNEL
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367429 - in head/sys/mips: include mips

2020-11-06 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Nov  6 19:19:51 2020
New Revision: 367429
URL: https://svnweb.freebsd.org/changeset/base/367429

Log:
  Remove 'struct trapframe' pointer from mips64's 'struct syscall_args'.
  While here, use MAXARGS.  This brings its 'struct syscall_args' in sync
  with most other architectures.
  
  Reviewed by:  arichardson, brooks
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26619

Modified:
  head/sys/mips/include/proc.h
  head/sys/mips/mips/trap.c

Modified: head/sys/mips/include/proc.h
==
--- head/sys/mips/include/proc.hFri Nov  6 19:04:20 2020
(r367428)
+++ head/sys/mips/include/proc.hFri Nov  6 19:19:51 2020
(r367429)
@@ -81,11 +81,11 @@ struct mdproc {
size_t  md_tls_tcb_offset;  /* TCB offset */
 };
 
+#defineMAXARGS 8
 struct syscall_args {
u_int code;
struct sysent *callp;
-   register_t args[8];
-   struct trapframe *trapframe;
+   register_t args[MAXARGS];
 };
 
 #ifdef __mips_n64

Modified: head/sys/mips/mips/trap.c
==
--- head/sys/mips/mips/trap.c   Fri Nov  6 19:04:20 2020(r367428)
+++ head/sys/mips/mips/trap.c   Fri Nov  6 19:19:51 2020(r367429)
@@ -349,9 +349,9 @@ cpu_fetch_syscall_args(struct thread *td)
bzero(sa->args, sizeof(sa->args));
 
/* compute next PC after syscall instruction */
-   td->td_pcb->pcb_tpc = sa->trapframe->pc; /* Remember if restart */
-   if (DELAYBRANCH(sa->trapframe->cause))   /* Check BD bit */
-   locr0->pc = MipsEmulateBranch(locr0, sa->trapframe->pc, 0, 0);
+   td->td_pcb->pcb_tpc = locr0->pc; /* Remember if restart */
+   if (DELAYBRANCH(locr0->cause))   /* Check BD bit */
+   locr0->pc = MipsEmulateBranch(locr0, locr0->pc, 0, 0);
else
locr0->pc += sizeof(int);
sa->code = locr0->v0;
@@ -781,7 +781,6 @@ dofault:
 
case T_SYSCALL + T_USER:
{
-   td->td_sa.trapframe = trapframe;
syscallenter(td);
 
 #if !defined(SMP) && (defined(DDB) || defined(DEBUG))
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367428 - in head/sys: conf dev/cxgbe/firmware modules/cxgbe/t4_firmware modules/cxgbe/t5_firmware modules/cxgbe/t6_firmware

2020-11-06 Thread Navdeep Parhar
Author: np
Date: Fri Nov  6 19:04:20 2020
New Revision: 367428
URL: https://svnweb.freebsd.org/changeset/base/367428

Log:
  cxgbe(4):  Update firmwares to 1.25.0.40.
  
  This fixes a potential crash in firmware 1.25.0.0 on the passive open
  side during TOE operation.
  
  Obtained from:Chelsio Communications
  MFC after:1 week
  Sponsored by: Chelsio Communications

Added:
  head/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin   (contents, props changed)
Deleted:
  head/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin
  head/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin
  head/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin
Modified:
  head/sys/conf/files
  head/sys/dev/cxgbe/firmware/t4fw_interface.h
  head/sys/modules/cxgbe/t4_firmware/Makefile
  head/sys/modules/cxgbe/t5_firmware/Makefile
  head/sys/modules/cxgbe/t6_firmware/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri Nov  6 18:50:00 2020(r367427)
+++ head/sys/conf/files Fri Nov  6 19:04:20 2020(r367428)
@@ -1516,7 +1516,7 @@ t4fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t4fw.fwo"
 t4fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t4fw.fw"
@@ -1550,7 +1550,7 @@ t5fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t5fw.fwo"
 t5fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t5fw.fw"
@@ -1584,7 +1584,7 @@ t6fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t6fw.fwo"
 t6fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t6fw.fw"

Added: head/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin
==

Modified: head/sys/dev/cxgbe/firmware/t4fw_interface.h
==
--- head/sys/dev/cxgbe/firmware/t4fw_interface.hFri Nov  6 18:50:00 
2020(r367427)
+++ head/sys/dev/cxgbe/firmware/t4fw_interface.hFri Nov  6 19:04:20 
2020(r367428)
@@ -9985,17 +9985,17 @@ enum {
T4FW_VERSION_MAJOR  = 1,
T4FW_VERSION_MINOR  = 25,
T4FW_VERSION_MICRO  = 0,
-   T4FW_VERSION_BUILD  = 0,
+   T4FW_VERSION_BUILD  = 40,
 
T5FW_VERSION_MAJOR  = 1,
T5FW_VERSION_MINOR  = 25,
T5FW_VERSION_MICRO  = 0,
-   T5FW_VERSION_BUILD  = 0,
+   T5FW_VERSION_BUILD  = 40,
 
T6FW_VERSION_MAJOR  = 1,
T6FW_VERSION_MINOR  = 25,
T6FW_VERSION_MICRO  = 0,
-   T6FW_VERSION_BUILD  = 0,
+   T6FW_VERSION_BUILD  = 40,
 };
 
 enum {

Added: head/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin
==

Added: head/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin
==

Modified: head/sys/modules/cxgbe/t4_firmware/Makefile
==
--- head/sys/modules/cxgbe/t4_firmware/Makefile Fri Nov  6 18:50:00 2020
(r367427)
+++ head/sys/modules/cxgbe/t4_firmware/Makefile Fri Nov  6 19:04:20 2020
(r367428)
@@ -17,7 +17,7 @@ FIRMWS+=  ${F}:${F:C/.txt//}:1.0.0.0
 .endif
 .endfor
 
-T4FW_VER=  1.25.0.0
+T4FW_VER=  1.25.0.40
 FIRMWS+=   t4fw-${T4FW_VER}.bin:t4fw:${T4FW_VER}
 
 .include 

Modified: head/sys/modules/cxgbe/t5_firmware/Makefile

svn commit: r367427 - in head/sys: conf powerpc/aim

2020-11-06 Thread Leandro Lupori
Author: luporl
Date: Fri Nov  6 18:50:00 2020
New Revision: 367427
URL: https://svnweb.freebsd.org/changeset/base/367427

Log:
  Fix powerpc and LINT builds
  
  Fix build errors introduced by r367417 and r367390:
  
  - Guard label reached only by powerpc64
  - Guard vm_reserv_level_iffullpop call, that is not defined on powerpc
variants that don't support superpages
  - Add missing hwpmc file, for when hwpmc is built into kernel

Modified:
  head/sys/conf/files.powerpc
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/moea64_native.c

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Fri Nov  6 18:09:52 2020(r367426)
+++ head/sys/conf/files.powerpc Fri Nov  6 18:50:00 2020(r367427)
@@ -26,6 +26,7 @@ dev/agp/agp_apple.c   optionalagp powermac
 dev/fb/fb.coptionalsc
 dev/hwpmc/hwpmc_e500.c optionalhwpmc
 dev/hwpmc/hwpmc_mpc7xxx.c  optionalhwpmc
+dev/hwpmc/hwpmc_power8.c   optionalhwpmc
 dev/hwpmc/hwpmc_powerpc.c  optionalhwpmc
 dev/hwpmc/hwpmc_ppc970.c   optionalhwpmc
 dev/iicbus/ad7417.coptionalad7417 powermac

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cFri Nov  6 18:09:52 2020
(r367426)
+++ head/sys/powerpc/aim/mmu_oea64.cFri Nov  6 18:50:00 2020
(r367427)
@@ -1760,6 +1760,7 @@ out:
moea64_syncicache(pmap, va, pa, PAGE_SIZE);
}
 
+#if VM_NRESERVLEVEL > 0
/*
 * Try to promote pages.
 *
@@ -1773,6 +1774,7 @@ out:
(m->flags & PG_FICTITIOUS) == 0 &&
vm_reserv_level_iffullpop(m) == 0)
moea64_sp_promote(pmap, va, m);
+#endif
 
return (KERN_SUCCESS);
 }

Modified: head/sys/powerpc/aim/moea64_native.c
==
--- head/sys/powerpc/aim/moea64_native.cFri Nov  6 18:09:52 2020
(r367426)
+++ head/sys/powerpc/aim/moea64_native.cFri Nov  6 18:50:00 2020
(r367427)
@@ -211,6 +211,8 @@ TLBIE(uint64_t vpn, uint64_t oldptehi)
 */
__asm __volatile("li 0, 0 \n tlbie %0, 0" :: "r"(vpn) : "r0", "memory");
__asm __volatile("eieio; tlbsync; ptesync" ::: "memory");
+done:
+
 #else
vpn_hi = (uint32_t)(vpn >> 32);
vpn_lo = (uint32_t)vpn;
@@ -235,7 +237,6 @@ TLBIE(uint64_t vpn, uint64_t oldptehi)
intr_restore(intr);
 #endif
 
-done:
/* No barriers or special ops -- taken care of by ptesync above */
if (need_lock)
tlbie_lock = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367426 - head/sys/opencrypto

2020-11-06 Thread John Baldwin
Author: jhb
Date: Fri Nov  6 18:09:52 2020
New Revision: 367426
URL: https://svnweb.freebsd.org/changeset/base/367426

Log:
  Use void * in place of caddr_t.
  
  Reviewed by:  markj
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D27065

Modified:
  head/sys/opencrypto/cryptodev.h

Modified: head/sys/opencrypto/cryptodev.h
==
--- head/sys/opencrypto/cryptodev.h Fri Nov  6 18:05:29 2020
(r367425)
+++ head/sys/opencrypto/cryptodev.h Fri Nov  6 18:09:52 2020
(r367426)
@@ -220,9 +220,9 @@ struct session_op {
uint32_tmac;/* ie. CRYPTO_SHA2_256_HMAC */
 
uint32_tkeylen; /* cipher key */
-   c_caddr_t   key;
+   const void  *key;
int mackeylen;  /* mac key */
-   c_caddr_t   mackey;
+   const void  *mackey;
 
uint32_tses;/* returns: session # */ 
 };
@@ -237,9 +237,9 @@ struct session2_op {
uint32_tmac;/* ie. CRYPTO_SHA2_256_HMAC */
 
uint32_tkeylen; /* cipher key */
-   c_caddr_t   key;
+   const void  *key;
int mackeylen;  /* mac key */
-   c_caddr_t   mackey;
+   const void  *mackey;
 
uint32_tses;/* returns: session # */ 
int crid;   /* driver id + flags (rw) */
@@ -255,10 +255,10 @@ struct crypt_op {
 #defineCOP_F_CIPHER_FIRST  0x0001  /* Cipher before MAC. */
 #defineCOP_F_BATCH 0x0008  /* Batch op if possible */
u_int   len;
-   c_caddr_t   src;/* become iov[] inside kernel */
-   caddr_t dst;
-   caddr_t mac;/* must be big enough for chosen MAC */
-   c_caddr_t   iv;
+   const void  *src;   /* become iov[] inside kernel */
+   void*dst;
+   void*mac;   /* must be big enough for chosen MAC */
+   const void  *iv;
 };
 
 /* op and flags the same as crypt_op */
@@ -269,11 +269,11 @@ struct crypt_aead {
u_int   len;
u_int   aadlen;
u_int   ivlen;
-   c_caddr_t   src;/* become iov[] inside kernel */
-   caddr_t dst;
-   c_caddr_t   aad;/* additional authenticated data */
-   caddr_t tag;/* must fit for chosen TAG length */
-   c_caddr_t   iv;
+   const void  *src;   /* become iov[] inside kernel */
+   void*dst;
+   const void  *aad;   /* additional authenticated data */
+   void*tag;   /* must fit for chosen TAG length */
+   const void  *iv;
 };
 
 /*
@@ -288,7 +288,7 @@ struct crypt_find_op {
 
 /* bignum parameter, in packed bytes, ... */
 struct crparam {
-   caddr_t crp_p;
+   void*crp_p;
u_int   crp_nbits;
 };
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367425 - head/sys/opencrypto

2020-11-06 Thread John Baldwin
Author: jhb
Date: Fri Nov  6 18:05:29 2020
New Revision: 367425
URL: https://svnweb.freebsd.org/changeset/base/367425

Log:
  Group session management routines together before first use.
  
  - Rename cse*() to cse_*() to more closely match other local APIs in
this file.
  
  - Merge the old csecreate() into cryptodev_create_session() and rename
the new function to cse_create().
  
  Reviewed by:  markj
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D27070

Modified:
  head/sys/opencrypto/cryptodev.c

Modified: head/sys/opencrypto/cryptodev.c
==
--- head/sys/opencrypto/cryptodev.c Fri Nov  6 17:52:04 2020
(r367424)
+++ head/sys/opencrypto/cryptodev.c Fri Nov  6 18:05:29 2020
(r367425)
@@ -374,13 +374,6 @@ static struct fileops cryptofops = {
 .fo_fill_kinfo = cryptof_fill_kinfo,
 };
 
-static struct csession *csefind(struct fcrypt *, u_int);
-static bool csedelete(struct fcrypt *, u_int);
-static struct csession *csecreate(struct fcrypt *, crypto_session_t,
-struct crypto_session_params *, struct enc_xform *, void *,
-struct auth_hash *, void *);
-static void csefree(struct csession *);
-
 /*
  * Check a crypto identifier to see if it requested
  * a software device/driver.  This can be done either
@@ -409,7 +402,7 @@ checkforsoftware(int *cridp)
 }
 
 static int
-cryptodev_create_session(struct fcrypt *fcr, struct session2_op *sop)
+cse_create(struct fcrypt *fcr, struct session2_op *sop)
 {
struct crypto_session_params csp;
struct csession *cse;
@@ -685,15 +678,27 @@ cryptodev_create_session(struct fcrypt *fcr, struct se
goto bail;
}
 
-   cse = csecreate(fcr, cses, , txform, key, thash, mackey);
+   cse = malloc(sizeof(struct csession), M_XDATA, M_WAITOK | M_ZERO);
+   mtx_init(>lock, "cryptodev", "crypto session lock", MTX_DEF);
+   refcount_init(>refs, 1);
+   cse->key = key;
+   cse->mackey = mackey;
+   cse->mode = csp.csp_mode;
+   cse->cses = cses;
+   cse->txform = txform;
+   if (thash != NULL)
+   cse->hashsize = thash->hashsize;
+   else if (csp.csp_cipher_alg == CRYPTO_AES_NIST_GCM_16)
+   cse->hashsize = AES_GMAC_HASH_LEN;
+   else if (csp.csp_cipher_alg == CRYPTO_AES_CCM_16)
+   cse->hashsize = AES_CBC_MAC_HASH_LEN;
+   cse->ivsize = csp.csp_ivlen;
 
-   if (cse == NULL) {
-   crypto_freesession(cses);
-   error = EINVAL;
-   SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__);
-   CRYPTDEB("csecreate");
-   goto bail;
-   }
+   mtx_lock(>lock);
+   TAILQ_INSERT_TAIL(>csessions, cse, next);
+   cse->ses = fcr->sesn++;
+   mtx_unlock(>lock);
+
sop->ses = cse->ses;
 
/* return hardware/driver id */
@@ -706,6 +711,56 @@ bail:
return (error);
 }
 
+static struct csession *
+cse_find(struct fcrypt *fcr, u_int ses)
+{
+   struct csession *cse;
+
+   mtx_lock(>lock);
+   TAILQ_FOREACH(cse, >csessions, next) {
+   if (cse->ses == ses) {
+   refcount_acquire(>refs);
+   mtx_unlock(>lock);
+   return (cse);
+   }
+   }
+   mtx_unlock(>lock);
+   return (NULL);
+}
+
+static void
+cse_free(struct csession *cse)
+{
+
+   if (!refcount_release(>refs))
+   return;
+   crypto_freesession(cse->cses);
+   mtx_destroy(>lock);
+   if (cse->key)
+   free(cse->key, M_XDATA);
+   if (cse->mackey)
+   free(cse->mackey, M_XDATA);
+   free(cse, M_XDATA);
+}
+
+static bool
+cse_delete(struct fcrypt *fcr, u_int ses)
+{
+   struct csession *cse;
+
+   mtx_lock(>lock);
+   TAILQ_FOREACH(cse, >csessions, next) {
+   if (cse->ses == ses) {
+   TAILQ_REMOVE(>csessions, cse, next);
+   mtx_unlock(>lock);
+   cse_free(cse);
+   return (true);
+   }
+   }
+   mtx_unlock(>lock);
+   return (false);
+}
+
 static struct cryptop_data *
 cod_alloc(struct csession *cse, size_t aad_len, size_t len, struct thread *td)
 {
@@ -1383,26 +1438,26 @@ cryptof_ioctl(struct file *fp, u_long cmd, void *data,
} else
sop = (struct session2_op *)data;
 
-   error = cryptodev_create_session(fcr, sop);
+   error = cse_create(fcr, sop);
if (cmd == CIOCGSESSION && error == 0)
session2_op_to_op(sop, data);
break;
case CIOCFSESSION:
ses = *(uint32_t *)data;
-   if (!csedelete(fcr, ses)) {
+   if (!cse_delete(fcr, ses)) {
SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__);
 

svn commit: r367424 - in stable/12/sys: amd64/amd64 x86/include

2020-11-06 Thread John Baldwin
Author: jhb
Date: Fri Nov  6 17:52:04 2020
New Revision: 367424
URL: https://svnweb.freebsd.org/changeset/base/367424

Log:
  MFC 365642: Add constant for the DE_CFG MSR on AMD CPUs.

Modified:
  stable/12/sys/amd64/amd64/initcpu.c
  stable/12/sys/x86/include/specialreg.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/amd64/initcpu.c
==
--- stable/12/sys/amd64/amd64/initcpu.c Fri Nov  6 16:33:42 2020
(r367423)
+++ stable/12/sys/amd64/amd64/initcpu.c Fri Nov  6 17:52:04 2020
(r367424)
@@ -103,7 +103,7 @@ init_amd(void)
case 0x10:
case 0x12:
if ((cpu_feature2 & CPUID2_HV) == 0)
-   wrmsr(0xc0011029, rdmsr(0xc0011029) | 1);
+   wrmsr(MSR_DE_CFG, rdmsr(MSR_DE_CFG) | 1);
break;
}
 
@@ -152,9 +152,9 @@ init_amd(void)
if (CPUID_TO_FAMILY(cpu_id) == 0x17 && CPUID_TO_MODEL(cpu_id) == 0x1 &&
(cpu_feature2 & CPUID2_HV) == 0) {
/* 1021 */
-   msr = rdmsr(0xc0011029);
+   msr = rdmsr(MSR_DE_CFG);
msr |= 0x2000;
-   wrmsr(0xc0011029, msr);
+   wrmsr(MSR_DE_CFG, msr);
 
/* 1033 */
msr = rdmsr(MSR_LS_CFG);

Modified: stable/12/sys/x86/include/specialreg.h
==
--- stable/12/sys/x86/include/specialreg.h  Fri Nov  6 16:33:42 2020
(r367423)
+++ stable/12/sys/x86/include/specialreg.h  Fri Nov  6 17:52:04 2020
(r367424)
@@ -1091,6 +1091,7 @@
 #defineMSR_EXTFEATURES 0xc0011005  /* Extended CPUID Features 
override */
 #defineMSR_LS_CFG  0xc0011020
 #defineMSR_IC_CFG  0xc0011021  /* Instruction Cache 
Configuration */
+#defineMSR_DE_CFG  0xc0011029  /* Decode Configuration */
 
 /* MSR_VM_CR related */
 #defineVM_CR_SVMDIS0x10/* SVM: disabled by BIOS */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367423 - in head/libexec/rc: . rc.d

2020-11-06 Thread Rick Macklem
Author: rmacklem
Date: Fri Nov  6 16:33:42 2020
New Revision: 367423
URL: https://svnweb.freebsd.org/changeset/base/367423

Log:
  Add support for the new mountd -R option.
  
  r376026 added a new "-R" option to mountd, which tells it to
  not support the Mount protocol (not used by NFSv4) and not
  register with rpcbind.
  Rpcbind is considered a security issue by some sites now.
  
  This patch adds a new yes/no variable called nfsv4_server_only.
  When that is set, make vfs.nfsd.server_min_vers=4 and set "=R"
  for mountd.
  Setting vfs.nfsd.server_min_vers=4 tells nfsd to not register with rpcbind.
  While here, add a check for "load_kld nfsd" failing to nfsd.
  
  Reviewed by:  0mp
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D26938

Modified:
  head/libexec/rc/rc.conf
  head/libexec/rc/rc.d/mountd
  head/libexec/rc/rc.d/nfsd

Modified: head/libexec/rc/rc.conf
==
--- head/libexec/rc/rc.conf Fri Nov  6 16:12:06 2020(r367422)
+++ head/libexec/rc/rc.conf Fri Nov  6 16:33:42 2020(r367423)
@@ -380,6 +380,7 @@ rpc_ypupdated_enable="NO"   # Run if NIS master and Secu
 keyserv_enable="NO"# Run the SecureRPC keyserver (or NO).
 keyserv_flags=""   # Flags to keyserv (if enabled).
 nfsv4_server_enable="NO"   # Enable support for NFSv4
+nfsv4_server_only="NO" # Set NFS server to NFSv4 only
 nfscbd_enable="NO" # NFSv4 client side callback daemon
 nfscbd_flags=""# Flags for nfscbd
 nfsuserd_enable="NO"   # NFSv4 user/group name mapping daemon

Modified: head/libexec/rc/rc.d/mountd
==
--- head/libexec/rc/rc.d/mountd Fri Nov  6 16:12:06 2020(r367422)
+++ head/libexec/rc/rc.d/mountd Fri Nov  6 16:33:42 2020(r367423)
@@ -20,13 +20,33 @@ extra_commands="reload"
 
 mountd_precmd()
 {
-   force_depend rpcbind || return 1
 
+   # Load the modules now, so that the vfs.nfsd sysctl
+   # oids are available.
+   load_kld nfsd || return 1
+
+   # Do not force rpcbind to be running for an NFSv4 only server.
+   #
+   if checkyesno nfsv4_server_only; then
+   echo 'NFSv4 only server'
+   sysctl vfs.nfsd.server_min_nfsvers=4 > /dev/null
+   sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
+   rc_flags="${rc_flags} -R"
+   else
+   force_depend rpcbind || return 1
+   fi
+
# mountd flags will differ depending on rc.conf settings
#
-   if checkyesno nfs_server_enable ; then
+   if checkyesno nfs_server_enable || checkyesno nfsv4_server_only; then
if checkyesno weak_mountd_authentication; then
-   rc_flags="${mountd_flags} -n"
+   if checkyesno nfsv4_server_only; then
+   echo -n 'weak_mountd_authentication '
+   echo -n 'incompatible with nfsv4_server_only, '
+   echo 'ignored'
+   else
+   rc_flags="${rc_flags} -n"
+   fi
fi
else
if checkyesno mountd_enable; then

Modified: head/libexec/rc/rc.d/nfsd
==
--- head/libexec/rc/rc.d/nfsd   Fri Nov  6 16:12:06 2020(r367422)
+++ head/libexec/rc/rc.d/nfsd   Fri Nov  6 16:33:42 2020(r367423)
@@ -26,7 +26,7 @@ nfsd_precmd()
 
# Load the modules now, so that the vfs.nfsd sysctl
# oids are available.
-   load_kld nfsd
+   load_kld nfsd || return 1
 
if checkyesno nfs_reserved_port_only; then
echo 'NFS on reserved port only=YES'
@@ -41,12 +41,15 @@ nfsd_precmd()
 
if checkyesno nfsv4_server_enable; then
sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
-   else
+   elif ! checkyesno nfsv4_server_only; then
echo 'NFSv4 is disabled'
sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
fi
 
-   force_depend rpcbind || return 1
+   if ! checkyesno nfsv4_server_only; then
+   force_depend rpcbind || return 1
+   fi
+
force_depend mountd || return 1
if [ -n "${nfs_server_vhost}" ]; then
command_args="-V \"${nfs_server_vhost}\""
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367422 - head/sys/contrib/dev/qat

2020-11-06 Thread Mark Johnston
Author: markj
Date: Fri Nov  6 16:12:06 2020
New Revision: 367422
URL: https://svnweb.freebsd.org/changeset/base/367422

Log:
  Add firmware modules for qat(4), take two
  
  My script to convert git commits to svn patch does not handle binary
  files correctly, and r367387 committed a set of empty files as a result.
  
  MFC with: r367387
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/contrib/dev/qat/mmp_firmware_c2xxx.bin   (contents, props changed)
  head/sys/contrib/dev/qat/mof_firmware_c2xxx.bin   (contents, props changed)
  head/sys/contrib/dev/qat/qat_895xcc.bin   (contents, props changed)
  head/sys/contrib/dev/qat/qat_895xcc_mmp.bin   (contents, props changed)
  head/sys/contrib/dev/qat/qat_c3xxx.bin   (contents, props changed)
  head/sys/contrib/dev/qat/qat_c3xxx_mmp.bin   (contents, props changed)
  head/sys/contrib/dev/qat/qat_c62x.bin   (contents, props changed)
  head/sys/contrib/dev/qat/qat_c62x_mmp.bin   (contents, props changed)
  head/sys/contrib/dev/qat/qat_d15xx.bin   (contents, props changed)
  head/sys/contrib/dev/qat/qat_d15xx_mmp.bin   (contents, props changed)

Modified: head/sys/contrib/dev/qat/mmp_firmware_c2xxx.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/mof_firmware_c2xxx.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/qat_895xcc.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/qat_895xcc_mmp.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/qat_c3xxx.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/qat_c3xxx_mmp.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/qat_c62x.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/qat_c62x_mmp.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/qat_d15xx.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/contrib/dev/qat/qat_d15xx_mmp.bin
==
Binary file (source and/or target). No diff available.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367421 - svnadmin/conf

2020-11-06 Thread Mark Johnston
Author: markj
Date: Fri Nov  6 16:10:04 2020
New Revision: 367421
URL: https://svnweb.freebsd.org/changeset/base/367421

Log:
  Add myself to the sizelimit exemption list

Modified:
  svnadmin/conf/sizelimit.conf

Modified: svnadmin/conf/sizelimit.conf
==
--- svnadmin/conf/sizelimit.confFri Nov  6 15:55:13 2020
(r367420)
+++ svnadmin/conf/sizelimit.confFri Nov  6 16:10:04 2020
(r367421)
@@ -22,3 +22,4 @@ jkim
 mm
 np
 mmacy  21064397
+markj
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367420 - head/sbin/mdconfig

2020-11-06 Thread Mateusz Piotrowski
Author: 0mp (doc,ports committer)
Date: Fri Nov  6 15:55:13 2020
New Revision: 367420
URL: https://svnweb.freebsd.org/changeset/base/367420

Log:
  Use Cm macros instead of Ar when referring to a specific memory disk type
  
  MFC after:3 days

Modified:
  head/sbin/mdconfig/mdconfig.8

Modified: head/sbin/mdconfig/mdconfig.8
==
--- head/sbin/mdconfig/mdconfig.8   Fri Nov  6 15:38:51 2020
(r367419)
+++ head/sbin/mdconfig/mdconfig.8   Fri Nov  6 15:55:13 2020
(r367420)
@@ -127,7 +127,7 @@ Filename to use for the vnode type memory disk.
 The
 .Fl a
 and
-.Fl t Ar vnode
+.Fl t Cm vnode
 options are implied if not specified.
 .It Fl l
 List configured devices.
@@ -170,7 +170,7 @@ When used without the
 option, the
 .Fl a
 and
-.Fl t Ar swap
+.Fl t Cm swap
 options are implied if not specified.
 .It Fl S Ar sectorsize
 Sectorsize to use for the memory disk, in bytes.
@@ -272,7 +272,7 @@ The last form,
 is provided for convenience as an abbreviation of
 .Nm
 .Fl a
-.Fl t Ar vnode
+.Fl t Cm vnode
 .Fl f Ar file .
 .Sh EXAMPLES
 Create a disk with
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r367419 - head/sbin/mdconfig

2020-11-06 Thread Mateusz Piotrowski

On 11/6/20 4:38 PM, Mateusz Piotrowski wrote:

Author: 0mp (doc,ports committer)
Date: Fri Nov  6 15:38:51 2020
New Revision: 367419
URL: https://svnweb.freebsd.org/changeset/base/367419

Log:
   Fix a typo and remove Xr's to vn(4) and vnconfig(4)
   
   "mandoc -Tlint" complained about the Xr to vnconfig, which was removed in

   r238202.  I am not sure but maybe it's time to do the same to vn(4).


I've submitted a patch to Phabricator: https://reviews.freebsd.org/D27122

Cheers,

Mateusz


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


svn commit: r367419 - head/sbin/mdconfig

2020-11-06 Thread Mateusz Piotrowski
Author: 0mp (doc,ports committer)
Date: Fri Nov  6 15:38:51 2020
New Revision: 367419
URL: https://svnweb.freebsd.org/changeset/base/367419

Log:
  Fix a typo and remove Xr's to vn(4) and vnconfig(4)
  
  "mandoc -Tlint" complained about the Xr to vnconfig, which was removed in
  r238202.  I am not sure but maybe it's time to do the same to vn(4).
  
  MFC after:2 weeks

Modified:
  head/sbin/mdconfig/mdconfig.8

Modified: head/sbin/mdconfig/mdconfig.8
==
--- head/sbin/mdconfig/mdconfig.8   Fri Nov  6 15:21:53 2020
(r367418)
+++ head/sbin/mdconfig/mdconfig.8   Fri Nov  6 15:38:51 2020
(r367419)
@@ -37,7 +37,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 21, 2018
+.Dd November 6, 2020
 .Dt MDCONFIG 8
 .Os
 .Sh NAME
@@ -261,7 +261,7 @@ checksums or cryptographic signatures.
 Request a specific unit number or device name for the
 .Xr md 4
 device instead of automatic allocation.
-If a device name is specified, it must be start with
+If a device name is specified, it must start with
 .Dq md
 followed by the unit number.
 .El
@@ -350,11 +350,8 @@ The
 .Nm
 utility first appeared in
 .Fx 5.0
-as a cleaner replacement for the
-.Xr vn 4
-and
-.Xr vnconfig 8
-combo.
+as a cleaner replacement for the vn kernel module
+and the vnconfig utility combo.
 .Sh AUTHORS
 The
 .Nm
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367418 - head/release/packages

2020-11-06 Thread Emmanuel Vadot
Author: manu
Date: Fri Nov  6 15:21:53 2020
New Revision: 367418
URL: https://svnweb.freebsd.org/changeset/base/367418

Log:
  pkgbase: Remove %VCS_REVISION% from utilities comments
  
  We don't do that on other packages so be consistent.
  It also don't work when building from git.

Modified:
  head/release/packages/utilities.ucl

Modified: head/release/packages/utilities.ucl
==
--- head/release/packages/utilities.ucl Fri Nov  6 14:12:45 2020
(r367417)
+++ head/release/packages/utilities.ucl Fri Nov  6 15:21:53 2020
(r367418)
@@ -5,7 +5,7 @@
 name = "%PKG_NAME_PREFIX%-%PKGNAME%"
 origin = "base"
 version = "%VERSION%"
-comment = "%COMMENT% %VCS_REVISION%"
+comment = "%COMMENT%"
 categories = [ base ]
 maintainer = "%PKG_MAINTAINER%"
 www = "%PKG_WWW%"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367417 - in head/sys: powerpc/aim powerpc/include powerpc/powernv powerpc/powerpc powerpc/pseries vm

2020-11-06 Thread Leandro Lupori
Author: luporl
Date: Fri Nov  6 14:12:45 2020
New Revision: 367417
URL: https://svnweb.freebsd.org/changeset/base/367417

Log:
  Implement superpages for PowerPC64 (HPT)
  
  This change adds support for transparent superpages for PowerPC64
  systems using Hashed Page Tables (HPT). All pmap operations are
  supported.
  
  The changes were inspired by RISC-V implementation of superpages,
  by @markj (r344106), but heavily adapted to fit PPC64 HPT architecture
  and existing MMU OEA64 code.
  
  While these changes are not better tested, superpages support is disabled by
  default. To enable it, use vm.pmap.superpages_enabled=1.
  
  In this initial implementation, when superpages are disabled, system
  performance stays at the same level as without these changes. When
  superpages are enabled, buildworld time increases a bit (~2%). However,
  for workloads that put a heavy pressure on the TLB the performance boost
  is much bigger (see HPC Challenge and pgbench on D25237).
  
  Reviewed by:  jhibbits
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D25237

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/mmu_oea64.h
  head/sys/powerpc/aim/moea64_native.c
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/include/pte.h
  head/sys/powerpc/include/slb.h
  head/sys/powerpc/include/vmparam.h
  head/sys/powerpc/powernv/platform_powernv.c
  head/sys/powerpc/powerpc/pmap_dispatch.c
  head/sys/powerpc/pseries/mmu_phyp.c
  head/sys/vm/vm_fault.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cFri Nov  6 13:34:30 2020
(r367416)
+++ head/sys/powerpc/aim/mmu_oea64.cFri Nov  6 14:12:45 2020
(r367417)
@@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -111,9 +112,6 @@ uintptr_t moea64_get_unique_vsid(void);
 #defineVSID_TO_HASH(vsid)  (((vsid) >> 4) & 0xf)
 #defineVSID_HASH_MASK  0x007fULL
 
-/* Get physical address from PVO. */
-#definePVO_PADDR(pvo)  ((pvo)->pvo_pte.pa & LPTE_RPGN)
-
 /*
  * Locking semantics:
  *
@@ -146,6 +144,48 @@ static struct mtx_padalign pv_lock[PV_LOCK_COUNT];
 #define PV_PAGE_UNLOCK(m)  PV_UNLOCK(VM_PAGE_TO_PHYS(m))
 #define PV_PAGE_LOCKASSERT(m)  PV_LOCKASSERT(VM_PAGE_TO_PHYS(m))
 
+/* Superpage PV lock */
+
+#definePV_LOCK_SIZE(1pvo_pmap != kernel_pmap)
+
+/* Get physical address from PVO. */
+#definePVO_PADDR(pvo)  moea64_pvo_paddr(pvo)
+
+/* MD page flag indicating that the page is a superpage. */
+#defineMDPG_ATTR_SP0x4000
+
+static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0,
+"VM/pmap parameters");
+
+static int superpages_enabled = 0;
+SYSCTL_INT(_vm_pmap, OID_AUTO, superpages_enabled, CTLFLAG_RDTUN,
+_enabled, 0, "Enable support for transparent superpages");
+
+static SYSCTL_NODE(_vm_pmap, OID_AUTO, sp, CTLFLAG_RD, 0,
+"SP page mapping counters");
+
+static u_long sp_demotions;
+SYSCTL_ULONG(_vm_pmap_sp, OID_AUTO, demotions, CTLFLAG_RD,
+_demotions, 0, "SP page demotions");
+
+static u_long sp_mappings;
+SYSCTL_ULONG(_vm_pmap_sp, OID_AUTO, mappings, CTLFLAG_RD,
+_mappings, 0, "SP page mappings");
+
+static u_long sp_p_failures;
+SYSCTL_ULONG(_vm_pmap_sp, OID_AUTO, p_failures, CTLFLAG_RD,
+_p_failures, 0, "SP page promotion failures");
+
+static u_long sp_p_fail_pa;
+SYSCTL_ULONG(_vm_pmap_sp, OID_AUTO, p_fail_pa, CTLFLAG_RD,
+_p_fail_pa, 0, "SP page promotion failure: PAs don't match");
+
+static u_long sp_p_fail_flags;
+SYSCTL_ULONG(_vm_pmap_sp, OID_AUTO, p_fail_flags, CTLFLAG_RD,
+_p_fail_flags, 0, "SP page promotion failure: page flags don't match");
+
+static u_long sp_p_fail_prot;
+SYSCTL_ULONG(_vm_pmap_sp, OID_AUTO, p_fail_prot, CTLFLAG_RD,
+_p_fail_prot, 0,
+"SP page promotion failure: page protections don't match");
+
+static u_long sp_p_fail_wimg;
+SYSCTL_ULONG(_vm_pmap_sp, OID_AUTO, p_fail_wimg, CTLFLAG_RD,
+_p_fail_wimg, 0, "SP page promotion failure: WIMG bits don't match");
+
+static u_long sp_promotions;
+SYSCTL_ULONG(_vm_pmap_sp, OID_AUTO, promotions, CTLFLAG_RD,
+_promotions, 0, "SP page promotions");
+
+static bool moea64_ps_enabled(pmap_t);
+static void moea64_align_superpage(vm_object_t, vm_ooffset_t,
+vm_offset_t *, vm_size_t);
+
+static int moea64_sp_enter(pmap_t pmap, vm_offset_t va,
+vm_page_t m, vm_prot_t prot, u_int flags, int8_t psind);
+static struct pvo_entry *moea64_sp_remove(struct pvo_entry *sp,
+struct pvo_dlist *tofree);
+
+static void moea64_sp_promote(pmap_t pmap, vm_offset_t va, vm_page_t m);
+static void moea64_sp_demote_aligned(struct pvo_entry *sp);
+static void moea64_sp_demote(struct pvo_entry *pvo);
+

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

2020-11-06 Thread Alfredo Dal'Ava Junior
Author: alfredo
Date: Fri Nov  6 13:34:30 2020
New Revision: 367416
URL: https://svnweb.freebsd.org/changeset/base/367416

Log:
  [POWERPC] Floating-Point Exception trap support
  
  Add support for Floating-Point Exception traps on 32 and 64 bit platforms.
  Also make sure to clean FPSCR on EXEC and thread exit
  
  Author of initial version: Renato Riolino 
  
  Reviewed by:  jhibbits
  Sponsored by: Eldorado Research Institute (eldorado.org.br)
  Differential Revision:https://reviews.freebsd.org/D23623

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

Modified: head/sys/powerpc/include/cpufunc.h
==
--- head/sys/powerpc/include/cpufunc.h  Fri Nov  6 07:16:21 2020
(r367415)
+++ head/sys/powerpc/include/cpufunc.h  Fri Nov  6 13:34:30 2020
(r367416)
@@ -163,6 +163,25 @@ mttb(u_quad_t time)
mtspr(TBR_TBWL, (uint32_t)(time & 0x));
 }
 
+
+static __inline register_t
+mffs(void)
+{
+   register_t value;
+
+   __asm __volatile ("mffs 0; stfd 0,0(%0)"
+   :: "b"());
+
+   return (value);
+}
+
+static __inline void
+mtfsf(register_t value)
+{
+   __asm __volatile ("lfd 0,0(%0); mtfsf 0xff,0"
+   :: "b"());
+}
+
 static __inline void
 eieio(void)
 {

Modified: head/sys/powerpc/include/fpu.h
==
--- head/sys/powerpc/include/fpu.h  Fri Nov  6 07:16:21 2020
(r367415)
+++ head/sys/powerpc/include/fpu.h  Fri Nov  6 13:34:30 2020
(r367416)
@@ -75,6 +75,8 @@
 voidenable_fpu(struct thread *);
 voidsave_fpu(struct thread *);
 voidsave_fpu_nodrop(struct thread *);
+voidcleanup_fpscr(void);
+u_int   get_fpu_exception(struct thread *);
 
 #endif /* _KERNEL */
 

Modified: head/sys/powerpc/include/psl.h
==
--- head/sys/powerpc/include/psl.h  Fri Nov  6 07:16:21 2020
(r367415)
+++ head/sys/powerpc/include/psl.h  Fri Nov  6 13:34:30 2020
(r367416)
@@ -88,7 +88,7 @@
 #definePSL_FE_NONREC   PSL_FE1 /* imprecise non-recoverable */
 #definePSL_FE_REC  PSL_FE0 /* imprecise recoverable */
 #definePSL_FE_PREC (PSL_FE0 | PSL_FE1) /* precise */
-#definePSL_FE_DFLT PSL_FE_DIS  /* default == none */
+#definePSL_FE_DFLT PSL_FE_PREC /* default == precise */
 
 #ifndef LOCORE
 extern register_t psl_kernset; /* Default MSR values for kernel */

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==
--- head/sys/powerpc/powerpc/exec_machdep.c Fri Nov  6 07:16:21 2020
(r367415)
+++ head/sys/powerpc/powerpc/exec_machdep.c Fri Nov  6 13:34:30 2020
(r367416)
@@ -239,11 +239,14 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask
usfp = (void *)((sp - rndfsize) & ~0xFul);
}
 
-   /*
-* Save the floating-point state, if necessary, then copy it.
+   /* 
+* Set Floating Point facility to "Ignore Exceptions Mode" so signal
+* handler can run. 
 */
-   /* XXX */
+   if (td->td_pcb->pcb_flags & PCB_FPU)
+   tf->srr1 = tf->srr1 & ~(PSL_FE0 | PSL_FE1);
 
+
/*
 * Set up the registers to return to sigcode.
 *
@@ -333,6 +336,13 @@ sys_sigreturn(struct thread *td, struct sigreturn_args
 
kern_sigprocmask(td, SIG_SETMASK, _sigmask, NULL, 0);
 
+   /* 
+* Save FPU state if needed. User may have changed it on
+* signal handler 
+*/ 
+   if (uc.uc_mcontext.mc_srr1 & PSL_FP)
+   save_fpu(td);
+
CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x",
 td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]);
 
@@ -556,6 +566,8 @@ cleanup_power_extras(struct thread *td)
mtspr(SPR_FSCR, 0);
if (pcb_flags & PCB_CDSCR) 
mtspr(SPR_DSCRP, 0);
+
+   cleanup_fpscr();
 }
 
 /*
@@ -825,6 +837,14 @@ freebsd32_sigreturn(struct thread *td, struct freebsd3
return (error);
 
kern_sigprocmask(td, SIG_SETMASK, _sigmask, NULL, 0);
+
+   /*
+* Save FPU state if needed. User may have changed it on
+* signal handler
+*/
+   if (uc.uc_mcontext.mc_srr1 & PSL_FP)
+   save_fpu(td);
+
 
CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x",
 td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]);

Modified: head/sys/powerpc/powerpc/fpu.c
==
--- head/sys/powerpc/powerpc/fpu.c