svn commit: r363541 - in head/sys/fs: nfs nfsserver

2020-07-25 Thread Rick Macklem
Author: rmacklem
Date: Sun Jul 26 02:42:09 2020
New Revision: 363541
URL: https://svnweb.freebsd.org/changeset/base/363541

Log:
  Add support for ext_pgs mbufs to nfsrv_adj().
  
  This patch uses a slightly different algorithm for nfsrv_adj()
  since ext_pgs mbuf lists are not permitted to have m_len == 0 mbufs.
  As such, the code now frees mbufs after the adjustment in the list instead
  of setting their m_len field to 0.
  Since mbuf(s) may be trimmed off the tail of the list, the function now
  returns a pointer to the last mbuf in the list.  This saves the caller
  from needing to use m_last() to find the last mbuf.
  It also implies that it might return a nul list, which required a check for
  that in nfsrvd_readlink().
  
  This is another in the series of commits that add support to the NFS client
  and server for building RPC messages in ext_pgs mbufs with anonymous pages.
  This is useful so that the entire mbuf list does not need to be
  copied before calling sosend() when NFS over TLS is enabled.
  
  Use of ext_pgs mbufs will not be enabled until the kernel RPC is updated
  to handle TLS.

Modified:
  head/sys/fs/nfs/nfs_var.h
  head/sys/fs/nfsserver/nfs_nfsdport.c
  head/sys/fs/nfsserver/nfs_nfsdserv.c
  head/sys/fs/nfsserver/nfs_nfsdsubs.c

Modified: head/sys/fs/nfs/nfs_var.h
==
--- head/sys/fs/nfs/nfs_var.h   Sun Jul 26 01:45:26 2020(r363540)
+++ head/sys/fs/nfs/nfs_var.h   Sun Jul 26 02:42:09 2020(r363541)
@@ -391,7 +391,7 @@ int nfsv4_fillattr(struct nfsrv_descript *, struct mou
 struct vattr *, fhandle_t *, int, nfsattrbit_t *,
 struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t, struct statfs 
*);
 void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *);
-void nfsrv_adj(struct mbuf *, int, int);
+struct mbuf *nfsrv_adj(struct mbuf *, int, int);
 void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *);
 int nfsd_errmap(struct nfsrv_descript *);
 void nfsv4_uidtostr(uid_t, u_char **, int *);

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==
--- head/sys/fs/nfsserver/nfs_nfsdport.cSun Jul 26 01:45:26 2020
(r363540)
+++ head/sys/fs/nfsserver/nfs_nfsdport.cSun Jul 26 02:42:09 2020
(r363541)
@@ -757,7 +757,12 @@ nfsvno_readlink(struct vnode *vp, struct ucred *cred, 
if (uiop->uio_resid > 0) {
len -= uiop->uio_resid;
tlen = NFSM_RNDUP(len);
-   nfsrv_adj(mp3, NFS_MAXPATHLEN - tlen, tlen - len);
+   if (tlen == 0) {
+   m_freem(mp3);
+   mp3 = mp = NULL;
+   } else if (tlen != NFS_MAXPATHLEN || tlen != len)
+   mp = nfsrv_adj(mp3, NFS_MAXPATHLEN - tlen,
+   tlen - len);
}
*lenp = len;
*mpp = mp3;
@@ -872,9 +877,9 @@ nfsvno_read(struct vnode *vp, off_t off, int cnt, stru
tlen = NFSM_RNDUP(cnt);
if (tlen == 0) {
m_freem(m3);
-   m3 = NULL;
+   m3 = m = NULL;
} else if (len != tlen || tlen != cnt)
-   nfsrv_adj(m3, len - tlen, tlen - cnt);
+   m = nfsrv_adj(m3, len - tlen, tlen - cnt);
*mpp = m3;
*mpendp = m;
 
@@ -6247,7 +6252,11 @@ nfsvno_getxattr(struct vnode *vp, char *name, uint32_t
tlen = NFSM_RNDUP(len);
if (alen != tlen)
printf("nfsvno_getxattr: weird size read\n");
-   nfsrv_adj(m, alen - tlen, tlen - len);
+   if (tlen == 0) {
+   m_freem(m);
+   m = m2 = NULL;
+   } else if (alen != tlen || tlen != len)
+   m2 = nfsrv_adj(m, alen - tlen, tlen - len);
}
*lenp = len;
*mpp = m;

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==
--- head/sys/fs/nfsserver/nfs_nfsdserv.cSun Jul 26 01:45:26 2020
(r363540)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.cSun Jul 26 02:42:09 2020
(r363541)
@@ -690,9 +690,11 @@ nfsrvd_readlink(struct nfsrv_descript *nd, __unused in
goto out;
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
*tl = txdr_unsigned(len);
-   nd->nd_mb->m_next = mp;
-   nd->nd_mb = mpend;
-   nd->nd_bpos = mtod(mpend, caddr_t) + mpend->m_len;
+   if (mp != NULL) {
+   nd->nd_mb->m_next = mp;
+   nd->nd_mb = mpend;
+   nd->nd_bpos = mtod(mpend, caddr_t) + mpend->m_len;
+   }
 
 out:
NFSEXITCODE2(0, nd);

Modified: head/sys/fs/nfsserver/nfs_nfsdsubs.c
==
--- head/sys/fs/nfsserver/nfs_nfsdsubs.cSun Jul 26 01:45:26 2020
(r

svn commit: r363540 - in head/sys/geom: . part virstor

2020-07-25 Thread Xin LI
Author: delphij
Date: Sun Jul 26 01:45:26 2020
New Revision: 363540
URL: https://svnweb.freebsd.org/changeset/base/363540

Log:
  Use snprintf instead of sprintf.
  
  MFC after:2 weeks

Modified:
  head/sys/geom/geom_ccd.c
  head/sys/geom/part/g_part_vtoc8.c
  head/sys/geom/virstor/g_virstor.c

Modified: head/sys/geom/geom_ccd.c
==
--- head/sys/geom/geom_ccd.cSun Jul 26 01:11:30 2020(r363539)
+++ head/sys/geom/geom_ccd.cSun Jul 26 01:45:26 2020(r363540)
@@ -771,7 +771,7 @@ g_ccd_create(struct gctl_req *req, struct g_class *mp)
 
/* Check all providers are valid */
for (i = 0; i < *nprovider; i++) {
-   sprintf(buf, "provider%d", i);
+   snprintf(buf, sizeof(buf), "provider%d", i);
pp = gctl_get_provider(req, buf);
if (pp == NULL)
return;
@@ -788,7 +788,7 @@ g_ccd_create(struct gctl_req *req, struct g_class *mp)
 
/* Create consumers and attach to all providers */
for (i = 0; i < *nprovider; i++) {
-   sprintf(buf, "provider%d", i);
+   snprintf(buf, sizeof(buf), "provider%d", i);
pp = gctl_get_provider(req, buf);
cp = g_new_consumer(gp);
error = g_attach(cp, pp);

Modified: head/sys/geom/part/g_part_vtoc8.c
==
--- head/sys/geom/part/g_part_vtoc8.c   Sun Jul 26 01:11:30 2020
(r363539)
+++ head/sys/geom/part/g_part_vtoc8.c   Sun Jul 26 01:45:26 2020
(r363540)
@@ -224,7 +224,8 @@ g_part_vtoc8_create(struct g_part_table *basetable, st
ncyls = pcyls - acyls;
msize = ncyls * table->secpercyl;
 
-   sprintf(table->vtoc.ascii, "FreeBSD%lldM cyl %u alt %u hd %u sec %u",
+   snprintf(table->vtoc.ascii, sizeof(table->vtoc.ascii),
+   "FreeBSD%lldM cyl %u alt %u hd %u sec %u",
(long long)(msize / 2048), ncyls, acyls, basetable->gpt_heads,
basetable->gpt_sectors);
be32enc(&table->vtoc.version, VTOC_VERSION);
@@ -338,7 +339,8 @@ vtoc8_set_rawsize(struct g_part_table *basetable, stru
basetable->gpt_last = msize - 1;
 
bzero(table->vtoc.ascii, sizeof(table->vtoc.ascii));
-   sprintf(table->vtoc.ascii, "FreeBSD%lldM cyl %u alt %u hd %u sec %u",
+   snprintf(table->vtoc.ascii, sizeof(table->vtoc.ascii),
+   "FreeBSD%lldM cyl %u alt %u hd %u sec %u",
(long long)(msize / 2048), ncyls, acyls, basetable->gpt_heads,
basetable->gpt_sectors);
be16enc(&table->vtoc.physcyls, pcyls);

Modified: head/sys/geom/virstor/g_virstor.c
==
--- head/sys/geom/virstor/g_virstor.c   Sun Jul 26 01:11:30 2020
(r363539)
+++ head/sys/geom/virstor/g_virstor.c   Sun Jul 26 01:45:26 2020
(r363540)
@@ -227,7 +227,7 @@ virstor_ctl_stop(struct gctl_req *req, struct g_class 
struct g_virstor_softc *sc;
int error;
 
-   sprintf(param, "arg%d", i);
+   snprintf(param, sizeof(param), "arg%d", i);
name = gctl_get_asciiparam(req, param);
if (name == NULL) {
gctl_error(req, "No 'arg%d' argument", i);
@@ -565,7 +565,7 @@ virstor_ctl_remove(struct gctl_req *req, struct g_clas
int j, found;
struct g_virstor_component *newcomp, *compbak;
 
-   sprintf(param, "arg%d", i);
+   snprintf(param, sizeof(param), "arg%d", i);
prov_name = gctl_get_asciiparam(req, param);
if (prov_name == NULL) {
gctl_error(req, "Error fetching argument '%s'", param);
___
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: r363539 - stable/12/sbin/nvmecontrol

2020-07-25 Thread Alexander Motin
Author: mav
Date: Sun Jul 26 01:11:30 2020
New Revision: 363539
URL: https://svnweb.freebsd.org/changeset/base/363539

Log:
  MFC r363448: Add missing newlines.

Modified:
  stable/12/sbin/nvmecontrol/identify.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/nvmecontrol/identify.c
==
--- stable/12/sbin/nvmecontrol/identify.c   Sun Jul 26 01:04:53 2020
(r363538)
+++ stable/12/sbin/nvmecontrol/identify.c   Sun Jul 26 01:11:30 2020
(r363539)
@@ -151,15 +151,15 @@ print_namespace(struct nvme_namespace_data *nsdata)
   uint128_to_str(to128(nsdata->nvmcap), cbuf, sizeof(cbuf)));
if ((nsdata->nsfeat >> NVME_NS_DATA_NSFEAT_NPVALID_SHIFT) &
NVME_NS_DATA_NSFEAT_NPVALID_MASK) {
-   printf("Preferred Write Granularity: %u blocks",
+   printf("Preferred Write Granularity: %u blocks\n",
nsdata->npwg + 1);
-   printf("Preferred Write Alignment:   %u blocks",
+   printf("Preferred Write Alignment:   %u blocks\n",
nsdata->npwa + 1);
-   printf("Preferred Deallocate Granul: %u blocks",
+   printf("Preferred Deallocate Granul: %u blocks\n",
nsdata->npdg + 1);
-   printf("Preferred Deallocate Align:  %u blocks",
+   printf("Preferred Deallocate Align:  %u blocks\n",
nsdata->npda + 1);
-   printf("Optimal Write Size:  %u blocks",
+   printf("Optimal Write Size:  %u blocks\n",
nsdata->nows + 1);
}
printf("Globally Unique Identifier:  ");
___
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: r363538 - stable/12/sys/amd64/amd64

2020-07-25 Thread Konstantin Belousov
Author: kib
Date: Sun Jul 26 01:04:53 2020
New Revision: 363538
URL: https://svnweb.freebsd.org/changeset/base/363538

Log:
  MFC r363329:
  Simplify non-pti syscall entry on amd64.

Modified:
  stable/12/sys/amd64/amd64/exception.S
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/amd64/exception.S
==
--- stable/12/sys/amd64/amd64/exception.S   Sun Jul 26 00:44:59 2020
(r363537)
+++ stable/12/sys/amd64/amd64/exception.S   Sun Jul 26 01:04:53 2020
(r363538)
@@ -524,17 +524,17 @@ prot_addrf:
 IDTVEC(fast_syscall_pti)
swapgs
lfence
-   movq%rax,PCPU(SCRATCH_RAX)
cmpq$~0,PCPU(UCR3)
je  fast_syscall_common
+   movq%rax,PCPU(SCRATCH_RAX)
movqPCPU(KCR3),%rax
movq%rax,%cr3
+   movqPCPU(SCRATCH_RAX),%rax
jmp fast_syscall_common
SUPERALIGN_TEXT
 IDTVEC(fast_syscall)
swapgs
lfence
-   movq%rax,PCPU(SCRATCH_RAX)
 fast_syscall_common:
movq%rsp,PCPU(SCRATCH_RSP)
movqPCPU(RSP0),%rsp
@@ -545,7 +545,6 @@ fast_syscall_common:
movq%rcx,TF_RIP(%rsp)   /* %rcx original value is in %r10 */
movqPCPU(SCRATCH_RSP),%r11  /* %r11 already saved */
movq%r11,TF_RSP(%rsp)   /* user stack pointer */
-   movqPCPU(SCRATCH_RAX),%rax
/*
 * Save a few arg registers early to free them for use in
 * handle_ibrs_entry().  %r10 is especially tricky.  It is not an
___
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: r363537 - head/sys/geom/label

2020-07-25 Thread Xin LI
Author: delphij
Date: Sun Jul 26 00:44:59 2020
New Revision: 363537
URL: https://svnweb.freebsd.org/changeset/base/363537

Log:
  geom_label: Make glabel labels more trivial by separating the tasting
  routines out.
  
  While there, also simplify the creation of label paths a little bit
  by requiring the / suffix for label directory prefixes (ld_dir renamed
  to ld_dirprefix to indicate the change) and stop defining macros for
  these when they are only used once.
  
  Reviewed by:  cem
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D25597

Modified:
  head/sys/geom/label/g_label.c
  head/sys/geom/label/g_label.h
  head/sys/geom/label/g_label_disk_ident.c
  head/sys/geom/label/g_label_ext2fs.c
  head/sys/geom/label/g_label_flashmap.c
  head/sys/geom/label/g_label_gpt.c
  head/sys/geom/label/g_label_iso9660.c
  head/sys/geom/label/g_label_msdosfs.c
  head/sys/geom/label/g_label_ntfs.c
  head/sys/geom/label/g_label_reiserfs.c
  head/sys/geom/label/g_label_ufs.c

Modified: head/sys/geom/label/g_label.c
==
--- head/sys/geom/label/g_label.c   Sat Jul 25 23:08:51 2020
(r363536)
+++ head/sys/geom/label/g_label.c   Sun Jul 26 00:44:59 2020
(r363537)
@@ -63,9 +63,12 @@ static int g_label_destroy_geom(struct gctl_req *req, 
 static int g_label_destroy(struct g_geom *gp, boolean_t force);
 static struct g_geom *g_label_taste(struct g_class *mp, struct g_provider *pp,
 int flags __unused);
+static void g_label_generic_taste(struct g_consumer *, char *, size_t);
 static void g_label_config(struct gctl_req *req, struct g_class *mp,
 const char *verb);
 
+#defineG_LABEL_DIRPREFIX   "label/"
+
 struct g_class g_label_class = {
.name = G_LABEL_CLASS_NAME,
.version = G_VERSION,
@@ -74,6 +77,12 @@ struct g_class g_label_class = {
.destroy_geom = g_label_destroy_geom
 };
 
+static struct g_label_desc g_label_generic = {
+.ld_taste = g_label_generic_taste,
+.ld_dirprefix = G_LABEL_DIRPREFIX,
+.ld_enabled = 1
+};
+
 /*
  * To add a new file system where you want to look for volume labels,
  * you have to:
@@ -99,6 +108,7 @@ const struct g_label_desc *g_labels[] = {
&g_label_disk_ident,
&g_label_flashmap,
 #endif
+   &g_label_generic,
NULL
 };
 
@@ -213,7 +223,7 @@ g_label_mangle_name(char *label, size_t size)
 
 static struct g_geom *
 g_label_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
-const char *label, const char *dir, off_t mediasize)
+const char *label, const char *dirprefix, off_t mediasize)
 {
struct g_geom *gp;
struct g_provider *pp2;
@@ -232,7 +242,7 @@ g_label_create(struct gctl_req *req, struct g_class *m
}
gp = NULL;
cp = NULL;
-   if (snprintf(name, sizeof(name), "%s/%s", dir, label) >= sizeof(name)) {
+   if (snprintf(name, sizeof(name), "%s%s", dirprefix, label) >= 
sizeof(name)) {
if (req != NULL)
gctl_error(req, "Label name %s is too long.", label);
return (NULL);
@@ -300,13 +310,9 @@ g_label_read_metadata(struct g_consumer *cp, struct g_
u_char *buf;
int error;
 
-   g_topology_assert();
-
pp = cp->provider;
-   g_topology_unlock();
buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize,
&error);
-   g_topology_lock();
if (buf == NULL)
return (error);
/* Decode metadata. */
@@ -339,12 +345,43 @@ g_label_access_taste(struct g_provider *pp __unused, i
return (EOPNOTSUPP);
 }
 
+static void
+g_label_generic_taste(struct g_consumer *cp, char *label, size_t size)
+{
+   struct g_provider *pp;
+   struct g_label_metadata md;
+
+   g_topology_assert_not();
+   label[0] = '\0';
+   pp = cp->provider;
+
+   if (g_label_read_metadata(cp, &md) != 0)
+   return;
+
+   if (strcmp(md.md_magic, G_LABEL_MAGIC) != 0)
+   return;
+
+   if (md.md_version > G_LABEL_VERSION) {
+   printf("geom_label.ko module is too old to handle %s.\n",
+   pp->name);
+   return;
+   }
+   /*
+* Backward compatibility: there was no md_provsize field in
+* earlier versions of metadata, so only check if we have it.
+*/
+   if (md.md_version >= 2 && md.md_provsize != pp->mediasize)
+   return;
+
+   strlcpy(label, md.md_label, size);
+}
+
 static struct g_geom *
 g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 {
-   struct g_label_metadata md;
struct g_consumer *cp;
struct g_geom *gp;
+   off_t mediasize;
int i;
 
g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name);
@@ -367,33 +404,6 @@ g_label_taste(struct g_class *mp, struc

svn commit: r363536 - in stable/11: libexec/ftpd usr.bin/localedef usr.sbin/rrenumd

2020-07-25 Thread Don Lewis
Author: truckman
Date: Sat Jul 25 23:08:51 2020
New Revision: 363536
URL: https://svnweb.freebsd.org/changeset/base/363536

Log:
  MFC r362569 (by jkim):
  
  Fix build with recent byacc.
  
  S3curity:

Modified:
  stable/11/libexec/ftpd/ftpcmd.y
  stable/11/usr.bin/localedef/localedef.c
  stable/11/usr.bin/localedef/localedef.h
  stable/11/usr.sbin/rrenumd/parser.y
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/libexec/ftpd/ftpcmd.y
==
--- stable/11/libexec/ftpd/ftpcmd.y Sat Jul 25 23:06:47 2020
(r363535)
+++ stable/11/libexec/ftpd/ftpcmd.y Sat Jul 25 23:08:51 2020
(r363536)
@@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$");
 #include "extern.h"
 #include "pathnames.h"
 
+#defineyylex   ftpcmd_yylex
+
 off_t  restart_point;
 
 static int cmd_type;

Modified: stable/11/usr.bin/localedef/localedef.c
==
--- stable/11/usr.bin/localedef/localedef.c Sat Jul 25 23:06:47 2020
(r363535)
+++ stable/11/usr.bin/localedef/localedef.c Sat Jul 25 23:08:51 2020
(r363536)
@@ -257,7 +257,9 @@ main(int argc, char **argv)
init_numeric();
init_time();
 
+#if YYDEBUG
yydebug = 0;
+#endif
 
(void) setlocale(LC_ALL, "");
 

Modified: stable/11/usr.bin/localedef/localedef.h
==
--- stable/11/usr.bin/localedef/localedef.h Sat Jul 25 23:06:47 2020
(r363535)
+++ stable/11/usr.bin/localedef/localedef.h Sat Jul 25 23:08:51 2020
(r363536)
@@ -47,7 +47,9 @@ extern int mb_cur_max;
 extern int mb_cur_min;
 extern int last_kw;
 extern int verbose;
+#if YYDEBUG
 extern int yydebug;
+#endif
 extern int lineno;
 extern int undefok;/* mostly ignore undefined symbols */
 extern int warnok;

Modified: stable/11/usr.sbin/rrenumd/parser.y
==
--- stable/11/usr.sbin/rrenumd/parser.y Sat Jul 25 23:06:47 2020
(r363535)
+++ stable/11/usr.sbin/rrenumd/parser.y Sat Jul 25 23:08:51 2020
(r363536)
@@ -139,7 +139,7 @@ statement:
 debug_statement:
DEBUG_CMD flag EOS
{
-#ifdef YYDEBUG
+#if YYDEBUG
yydebug = $2;
 #endif /* YYDEBUG */
}
___
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: r363535 - in stable/12: libexec/ftpd usr.bin/localedef usr.sbin/rrenumd

2020-07-25 Thread Don Lewis
Author: truckman
Date: Sat Jul 25 23:06:47 2020
New Revision: 363535
URL: https://svnweb.freebsd.org/changeset/base/363535

Log:
  MFC r362569 (by jkim):
  
  Fix build with recent byacc.

Modified:
  stable/12/libexec/ftpd/ftpcmd.y
  stable/12/usr.bin/localedef/localedef.c
  stable/12/usr.bin/localedef/localedef.h
  stable/12/usr.sbin/rrenumd/parser.y
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/ftpd/ftpcmd.y
==
--- stable/12/libexec/ftpd/ftpcmd.y Sat Jul 25 21:37:07 2020
(r363534)
+++ stable/12/libexec/ftpd/ftpcmd.y Sat Jul 25 23:06:47 2020
(r363535)
@@ -74,6 +74,8 @@ __FBSDID("$FreeBSD$");
 #include "extern.h"
 #include "pathnames.h"
 
+#defineyylex   ftpcmd_yylex
+
 off_t  restart_point;
 
 static int cmd_type;

Modified: stable/12/usr.bin/localedef/localedef.c
==
--- stable/12/usr.bin/localedef/localedef.c Sat Jul 25 21:37:07 2020
(r363534)
+++ stable/12/usr.bin/localedef/localedef.c Sat Jul 25 23:06:47 2020
(r363535)
@@ -273,7 +273,9 @@ main(int argc, char **argv)
init_numeric();
init_time();
 
+#if YYDEBUG
yydebug = 0;
+#endif
 
(void) setlocale(LC_ALL, "");
 

Modified: stable/12/usr.bin/localedef/localedef.h
==
--- stable/12/usr.bin/localedef/localedef.h Sat Jul 25 21:37:07 2020
(r363534)
+++ stable/12/usr.bin/localedef/localedef.h Sat Jul 25 23:06:47 2020
(r363535)
@@ -47,7 +47,9 @@ extern int mb_cur_max;
 extern int mb_cur_min;
 extern int last_kw;
 extern int verbose;
+#if YYDEBUG
 extern int yydebug;
+#endif
 extern int lineno;
 extern int undefok;/* mostly ignore undefined symbols */
 extern int warnok;

Modified: stable/12/usr.sbin/rrenumd/parser.y
==
--- stable/12/usr.sbin/rrenumd/parser.y Sat Jul 25 21:37:07 2020
(r363534)
+++ stable/12/usr.sbin/rrenumd/parser.y Sat Jul 25 23:06:47 2020
(r363535)
@@ -141,7 +141,7 @@ statement:
 debug_statement:
DEBUG_CMD flag EOS
{
-#ifdef YYDEBUG
+#if YYDEBUG
yydebug = $2;
 #endif /* YYDEBUG */
}
___
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: r363534 - in head/sys: dev/iommu x86/iommu

2020-07-25 Thread Ruslan Bukin
Author: br
Date: Sat Jul 25 21:37:07 2020
New Revision: 363534
URL: https://svnweb.freebsd.org/changeset/base/363534

Log:
  o Make the _hw_iommu sysctl node non-static;
  o Move the dmar sysctl knobs to _hw_iommu_dmar.
  
  Reviewed by:  kib
  Sponsored by: DARPA/AFRL
  Differential Revision:https://reviews.freebsd.org/D25807

Modified:
  head/sys/dev/iommu/iommu.h
  head/sys/dev/iommu/iommu_gas.c
  head/sys/x86/iommu/intel_utils.c

Modified: head/sys/dev/iommu/iommu.h
==
--- head/sys/dev/iommu/iommu.h  Sat Jul 25 19:07:12 2020(r363533)
+++ head/sys/dev/iommu/iommu.h  Sat Jul 25 21:37:07 2020(r363534)
@@ -35,6 +35,7 @@
 #define _SYS_IOMMU_H_
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -209,5 +210,7 @@ int iommu_gas_map_region(struct iommu_domain *domain,
 struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma);
 int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start,
 iommu_gaddr_t end);
+
+SYSCTL_DECL(_hw_iommu);
 
 #endif /* !_SYS_IOMMU_H_ */

Modified: head/sys/dev/iommu/iommu_gas.c
==
--- head/sys/dev/iommu/iommu_gas.c  Sat Jul 25 19:07:12 2020
(r363533)
+++ head/sys/dev/iommu/iommu_gas.c  Sat Jul 25 21:37:07 2020
(r363534)
@@ -732,9 +732,9 @@ iommu_map_region(struct iommu_domain *domain, struct i
return (error);
 }
 
+SYSCTL_NODE(_hw, OID_AUTO, iommu, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, "");
+
 #ifdef INVARIANTS
-static SYSCTL_NODE(_hw, OID_AUTO, iommu, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
-"");
 SYSCTL_INT(_hw_iommu, OID_AUTO, check_free, CTLFLAG_RWTUN,
 &iommu_check_free, 0,
 "Check the GPA RBtree for free_down and free_after validity");

Modified: head/sys/x86/iommu/intel_utils.c
==
--- head/sys/x86/iommu/intel_utils.cSat Jul 25 19:07:12 2020
(r363533)
+++ head/sys/x86/iommu/intel_utils.cSat Jul 25 21:37:07 2020
(r363534)
@@ -655,15 +655,15 @@ dmar_timeout_sysctl(SYSCTL_HANDLER_ARGS)
return (error);
 }
 
-static SYSCTL_NODE(_hw, OID_AUTO, dmar, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
-"");
-SYSCTL_INT(_hw_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD,
+static SYSCTL_NODE(_hw_iommu, OID_AUTO, dmar, CTLFLAG_RD | CTLFLAG_MPSAFE,
+NULL, "");
+SYSCTL_INT(_hw_iommu_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD,
 &dmar_tbl_pagecnt, 0,
 "Count of pages used for DMAR pagetables");
-SYSCTL_INT(_hw_dmar, OID_AUTO, batch_coalesce, CTLFLAG_RWTUN,
+SYSCTL_INT(_hw_iommu_dmar, OID_AUTO, batch_coalesce, CTLFLAG_RWTUN,
 &dmar_batch_coalesce, 0,
 "Number of qi batches between interrupt");
-SYSCTL_PROC(_hw_dmar, OID_AUTO, timeout,
+SYSCTL_PROC(_hw_iommu_dmar, OID_AUTO, timeout,
 CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0,
 dmar_timeout_sysctl, "QU",
 "Timeout for command wait, in nanoseconds");
___
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: r363533 - in head/sys: dev/iommu x86/iommu

2020-07-25 Thread Ruslan Bukin
Author: br
Date: Sat Jul 25 19:07:12 2020
New Revision: 363533
URL: https://svnweb.freebsd.org/changeset/base/363533

Log:
  o Move iommu gas prototypes, DMAR flags to iommu.h;
  o Move hw.dmar sysctl node to iommu_gas.c.
  
  Reviewed by:  kib
  Sponsored by: DARPA/AFRL
  Differential Revision:https://reviews.freebsd.org/D25802

Modified:
  head/sys/dev/iommu/iommu.h
  head/sys/dev/iommu/iommu_gas.c
  head/sys/x86/iommu/intel_dmar.h
  head/sys/x86/iommu/intel_drv.c
  head/sys/x86/iommu/intel_utils.c

Modified: head/sys/dev/iommu/iommu.h
==
--- head/sys/dev/iommu/iommu.h  Sat Jul 25 18:29:10 2020(r363532)
+++ head/sys/dev/iommu/iommu.h  Sat Jul 25 19:07:12 2020(r363533)
@@ -133,6 +133,24 @@ struct iommu_ctx {
   ephemeral reference is kept
   to prevent context destruction */
 
+#defineDMAR_DOMAIN_GAS_INITED  0x0001
+#defineDMAR_DOMAIN_PGTBL_INITED0x0002
+#defineDMAR_DOMAIN_IDMAP   0x0010  /* Domain uses identity
+  page table */
+#defineDMAR_DOMAIN_RMRR0x0020  /* Domain contains RMRR 
entry,
+  cannot be turned off */
+
+/* Map flags */
+#defineIOMMU_MF_CANWAIT0x0001
+#defineIOMMU_MF_CANSPLIT   0x0002
+#defineIOMMU_MF_RMRR   0x0004
+
+#defineDMAR_PGF_WAITOK 0x0001
+#defineDMAR_PGF_ZERO   0x0002
+#defineDMAR_PGF_ALLOC  0x0004
+#defineDMAR_PGF_NOALLOC0x0008
+#defineDMAR_PGF_OBJL   0x0010
+
 #defineIOMMU_LOCK(unit)mtx_lock(&(unit)->lock)
 #defineIOMMU_UNLOCK(unit)  mtx_unlock(&(unit)->lock)
 #defineIOMMU_ASSERT_LOCKED(unit)   mtx_assert(&(unit)->lock, 
MA_OWNED)
@@ -173,5 +191,23 @@ int iommu_map(struct iommu_domain *iodom,
 u_int eflags, u_int flags, vm_page_t *ma, struct iommu_map_entry **res);
 int iommu_map_region(struct iommu_domain *domain,
 struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma);
+
+void iommu_gas_init_domain(struct iommu_domain *domain);
+void iommu_gas_fini_domain(struct iommu_domain *domain);
+struct iommu_map_entry *iommu_gas_alloc_entry(struct iommu_domain *domain,
+u_int flags);
+void iommu_gas_free_entry(struct iommu_domain *domain,
+struct iommu_map_entry *entry);
+void iommu_gas_free_space(struct iommu_domain *domain,
+struct iommu_map_entry *entry);
+int iommu_gas_map(struct iommu_domain *domain,
+const struct bus_dma_tag_common *common, iommu_gaddr_t size, int offset,
+u_int eflags, u_int flags, vm_page_t *ma, struct iommu_map_entry **res);
+void iommu_gas_free_region(struct iommu_domain *domain,
+struct iommu_map_entry *entry);
+int iommu_gas_map_region(struct iommu_domain *domain,
+struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma);
+int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start,
+iommu_gaddr_t end);
 
 #endif /* !_SYS_IOMMU_H_ */

Modified: head/sys/dev/iommu/iommu_gas.c
==
--- head/sys/dev/iommu/iommu_gas.c  Sat Jul 25 18:29:10 2020
(r363532)
+++ head/sys/dev/iommu/iommu_gas.c  Sat Jul 25 19:07:12 2020
(r363533)
@@ -79,6 +79,10 @@ __FBSDID("$FreeBSD$");
 
 static uma_zone_t iommu_map_entry_zone;
 
+#ifdef INVARIANTS
+static int iommu_check_free;
+#endif
+
 static void
 intel_gas_init(void)
 {
@@ -727,3 +731,11 @@ iommu_map_region(struct iommu_domain *domain, struct i
 
return (error);
 }
+
+#ifdef INVARIANTS
+static SYSCTL_NODE(_hw, OID_AUTO, iommu, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
+"");
+SYSCTL_INT(_hw_iommu, OID_AUTO, check_free, CTLFLAG_RWTUN,
+&iommu_check_free, 0,
+"Check the GPA RBtree for free_down and free_after validity");
+#endif

Modified: head/sys/x86/iommu/intel_dmar.h
==
--- head/sys/x86/iommu/intel_dmar.h Sat Jul 25 18:29:10 2020
(r363532)
+++ head/sys/x86/iommu/intel_dmar.h Sat Jul 25 19:07:12 2020
(r363533)
@@ -81,13 +81,6 @@ struct dmar_ctx {
u_int refs; /* (u) References from tags */
 };
 
-#defineDMAR_DOMAIN_GAS_INITED  0x0001
-#defineDMAR_DOMAIN_PGTBL_INITED0x0002
-#defineDMAR_DOMAIN_IDMAP   0x0010  /* Domain uses identity
-  page table */
-#defineDMAR_DOMAIN_RMRR0x0020  /* Domain contains RMRR 
entry,
-  cannot be turned off */
-
 #defineDMAR_DOMAIN_PGLOCK(dom) 
VM_OBJECT_WLOCK((dom)->pgt

svn commit: r363532 - in head/sys: kern sys vm

2020-07-25 Thread Doug Moore
Author: dougm
Date: Sat Jul 25 18:29:10 2020
New Revision: 363532
URL: https://svnweb.freebsd.org/changeset/base/363532

Log:
  Fix an overflow bug in the blist allocator that needlessly capped max
  swap size by dividing a value, which was always a multiple of 64, by
  64.  Remove the code that reduced max swap size down to that cap.
  
  Eliminate the distinction between BLIST_BMAP_RADIX and
  BLIST_META_RADIX.  Call them both BLIST_RADIX.
  
  Make improvments to the blist self-test code to silence compiler
  warnings and to test larger blists.
  
  Reported by:  jmallett
  Reviewed by:  alc
  Discussed with:   kib
  Tested by:pho
  Differential Revision:https://reviews.freebsd.org/D25736

Modified:
  head/sys/kern/subr_blist.c
  head/sys/sys/blist.h
  head/sys/vm/swap_pager.c

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Sat Jul 25 18:09:04 2020(r363531)
+++ head/sys/kern/subr_blist.c  Sat Jul 25 18:29:10 2020(r363532)
@@ -36,15 +36,14 @@
  *
  * A radix tree controls access to pieces of the bitmap, and includes
  * auxiliary information at each interior node about the availabilty of
- * contiguous free blocks in the subtree rooted at that node.  Two radix
- * constants are involved: one for the size of the bitmaps contained in the
- * leaf nodes (BLIST_BMAP_RADIX), and one for the number of descendents of
- * each of the meta (interior) nodes (BLIST_META_RADIX).  Each subtree is
- * associated with a range of blocks.  The root of any subtree stores a
- * hint field that defines an upper bound on the size of the largest
- * allocation that can begin in the associated block range.  A hint is an
- * upper bound on a potential allocation, but not necessarily a tight upper
- * bound.
+ * contiguous free blocks in the subtree rooted at that node.  A radix
+ * constant defines the size of the bitmaps contained in a leaf node
+ * and the number of descendents of each of the meta (interior) nodes.
+ * Each subtree is associated with a range of blocks.  The root of any
+ * subtree stores a hint field that defines an upper bound on the size
+ * of the largest allocation that can begin in the associated block
+ * range.  A hint is an upper bound on a potential allocation, but not
+ * necessarily a tight upper bound.
  *
  * The bitmap field in each node directs the search for available blocks.
  * For a leaf node, a bit is set if the corresponding block is free.  For a
@@ -64,17 +63,16 @@
  *
  * LAYOUT: The radix tree is laid out recursively using a linear array.
  * Each meta node is immediately followed (laid out sequentially in
- * memory) by BLIST_META_RADIX lower level nodes.  This is a recursive
+ * memory) by BLIST_RADIX lower-level nodes.  This is a recursive
  * structure but one that can be easily scanned through a very simple
  * 'skip' calculation.  The memory allocation is only large enough to
  * cover the number of blocks requested at creation time.  Nodes that
  * represent blocks beyond that limit, nodes that would never be read
  * or written, are not allocated, so that the last of the
- * BLIST_META_RADIX lower level nodes of a some nodes may not be
- * allocated.
+ * BLIST_RADIX lower-level nodes of a some nodes may not be allocated.
  *
  * NOTE: the allocator cannot currently allocate more than
- * BLIST_BMAP_RADIX blocks per call.  It will panic with 'allocation too
+ * BLIST_RADIX blocks per call.  It will panic with 'allocation too
  * large' if you try.  This is an area that could use improvement.  The
  * radix is large enough that this restriction does not effect the swap
  * system, though.  Currently only the allocation code is affected by
@@ -152,24 +150,19 @@ static void   blst_radix_print(blmeta_t *scan, 
daddr_t b
 static MALLOC_DEFINE(M_SWAP, "SWAP", "Swap space");
 #endif
 
-_Static_assert(BLIST_BMAP_RADIX % BLIST_META_RADIX == 0,
-"radix divisibility error");
-#defineBLIST_BMAP_MASK (BLIST_BMAP_RADIX - 1)
-#defineBLIST_META_MASK (BLIST_META_RADIX - 1)
+#defineBLIST_MASK  (BLIST_RADIX - 1)
 
 /*
  * For a subtree that can represent the state of up to 'radix' blocks, the
- * number of leaf nodes of the subtree is L=radix/BLIST_BMAP_RADIX.  If 'm'
- * is short for BLIST_META_RADIX, then for a tree of height h with L=m**h
+ * number of leaf nodes of the subtree is L=radix/BLIST_RADIX.  If 'm'
+ * is short for BLIST_RADIX, then for a tree of height h with L=m**h
  * leaf nodes, the total number of tree nodes is 1 + m + m**2 + ... + m**h,
  * or, equivalently, (m**(h+1)-1)/(m-1).  This quantity is called 'skip'
  * in the 'meta' functions that process subtrees.  Since integer division
  * discards remainders, we can express this computation as
  * skip = (m * m

svn commit: r363531 - head/sys/dev/usb/net

2020-07-25 Thread John-Mark Gurney
Author: jmg
Date: Sat Jul 25 18:09:04 2020
New Revision: 363531
URL: https://svnweb.freebsd.org/changeset/base/363531

Log:
  clean up whitespace...

Modified:
  head/sys/dev/usb/net/if_ure.c
  head/sys/dev/usb/net/if_urereg.h

Modified: head/sys/dev/usb/net/if_ure.c
==
--- head/sys/dev/usb/net/if_ure.c   Sat Jul 25 17:22:45 2020
(r363530)
+++ head/sys/dev/usb/net/if_ure.c   Sat Jul 25 18:09:04 2020
(r363531)
@@ -239,7 +239,7 @@ ure_read_1(struct ure_softc *sc, uint16_t reg, uint16_
 
shift = (reg & 3) << 3;
reg &= ~3;
-   
+
ure_read_mem(sc, reg, index, &temp, 4);
val = UGETDW(temp);
val >>= shift;
@@ -385,7 +385,7 @@ ure_miibus_writereg(device_t dev, int phy, int reg, in
locked = mtx_owned(&sc->sc_mtx);
if (!locked)
URE_LOCK(sc);
-   
+
ure_ocp_reg_write(sc, URE_OCP_BASE_MII + reg * 2, val);
 
if (!locked)
@@ -751,7 +751,7 @@ ure_init(struct usb_ether *ue)
ure_write_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA,
ure_read_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA) |
URE_FMC_FCR_MCU_EN);
-   
+
/* Enable transmit and receive. */
ure_write_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA,
ure_read_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA) | URE_CR_RE |
@@ -975,7 +975,7 @@ ure_rtl8152_init(struct ure_softc *sc)
ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) |
URE_RX_AGG_DISABLE);
 
-/* Disable ALDPS. */
+   /* Disable ALDPS. */
ure_ocp_reg_write(sc, URE_OCP_ALDPS_CONFIG, URE_ENPDNPS | URE_LINKENA |
URE_DIS_SDSAVE);
uether_pause(&sc->sc_ue, hz / 50);
@@ -1005,7 +1005,7 @@ ure_rtl8153_init(struct ure_softc *sc)
ure_write_mem(sc, URE_USB_TOLERANCE,
URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2));
 
-for (i = 0; i < URE_TIMEOUT; i++) {
+   for (i = 0; i < URE_TIMEOUT; i++) {
if (ure_read_2(sc, URE_PLA_BOOT_CTRL, URE_MCU_TYPE_PLA) &
URE_AUTOLOAD_DONE)
break;
@@ -1015,7 +1015,7 @@ ure_rtl8153_init(struct ure_softc *sc)
device_printf(sc->sc_ue.ue_dev,
"timeout waiting for chip autoload\n");
 
-for (i = 0; i < URE_TIMEOUT; i++) {
+   for (i = 0; i < URE_TIMEOUT; i++) {
val = ure_ocp_reg_read(sc, URE_OCP_PHY_STATUS) &
URE_PHY_STAT_MASK;
if (val == URE_PHY_STAT_LAN_ON || val == URE_PHY_STAT_PWRDN)
@@ -1025,7 +1025,7 @@ ure_rtl8153_init(struct ure_softc *sc)
if (i == URE_TIMEOUT)
device_printf(sc->sc_ue.ue_dev,
"timeout waiting for phy to stabilize\n");
-   
+
ure_write_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB,
ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB) &
~URE_U2P3_ENABLE);
@@ -1057,7 +1057,7 @@ ure_rtl8153_init(struct ure_softc *sc)
ure_write_1(sc, URE_USB_CSR_DUMMY2, URE_MCU_TYPE_USB,
ure_read_1(sc, URE_USB_CSR_DUMMY2, URE_MCU_TYPE_USB) |
URE_EP4_FULL_FC);
-   
+
ure_write_2(sc, URE_USB_WDT11_CTRL, URE_MCU_TYPE_USB,
ure_read_2(sc, URE_USB_WDT11_CTRL, URE_MCU_TYPE_USB) &
~URE_TIMER11_EN);
@@ -1065,7 +1065,7 @@ ure_rtl8153_init(struct ure_softc *sc)
ure_write_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA,
ure_read_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA) &
~URE_LED_MODE_MASK);
-   
+
if ((sc->sc_chip & URE_CHIP_VER_5C10) &&
usbd_get_speed(sc->sc_ue.ue_udev) != USB_SPEED_SUPER)
val = URE_LPM_TIMER_500MS;
@@ -1112,7 +1112,7 @@ ure_rtl8153_init(struct ure_softc *sc)
ure_write_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, val);
 
memset(u1u2, 0x00, sizeof(u1u2));
-ure_write_mem(sc, URE_USB_TOLERANCE,
+   ure_write_mem(sc, URE_USB_TOLERANCE,
URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2));
 
/* Disable ALDPS. */
@@ -1162,7 +1162,7 @@ ure_disable_teredo(struct ure_softc *sc)
 {
 
ure_write_4(sc, URE_PLA_TEREDO_CFG, URE_MCU_TYPE_PLA,
-   ure_read_4(sc, URE_PLA_TEREDO_CFG, URE_MCU_TYPE_PLA) & 
+   ure_read_4(sc, URE_PLA_TEREDO_CFG, URE_MCU_TYPE_PLA) &
~(URE_TEREDO_SEL | URE_TEREDO_RS_EVENT_MASK | URE_OOB_TEREDO_EN));
ure_write_2(sc, URE_PLA_WDT6_CTRL, URE_MCU_TYPE_PLA,
URE_WDT6_SET_MODE);
@@ -1194,7 +1194,7 @@ ure_init_fifo(struct ure_softc *sc)
}
if (sc->sc_chip & URE_CHIP_VER_5C00) {
ure_ocp_reg_write(sc, URE_OCP_EEE_CFG,
-   ure_ocp_reg_read(sc, URE_OCP_EEE_CFG) & 
+   ure_ocp_reg_read(sc, URE_OCP_EEE_CFG) &
~URE_CTAP_SHORT_EN);
}
   

svn commit: r363528 - head/sys/kern

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 15:34:29 2020
New Revision: 363528
URL: https://svnweb.freebsd.org/changeset/base/363528

Log:
  fd: put back FILEDESC_SUNLOCK to pwd_hold lost during rebase
  
  Reported by:  pho

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cSat Jul 25 15:19:38 2020
(r363527)
+++ head/sys/kern/kern_descrip.cSat Jul 25 15:34:29 2020
(r363528)
@@ -3354,6 +3354,7 @@ pwd_hold(struct thread *td)
FILEDESC_SLOCK(fdp);
pwd = pwd_hold_filedesc(fdp);
MPASS(pwd != NULL);
+   FILEDESC_SUNLOCK(fdp);
return (pwd);
 }
 
___
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: r363527 - in head: share/man/man9 sys/amd64/amd64 sys/amd64/include sys/i386/i386 sys/kern sys/sys sys/x86/include sys/x86/x86 sys/x86/xen

2020-07-25 Thread Alexander Motin
Author: mav
Date: Sat Jul 25 15:19:38 2020
New Revision: 363527
URL: https://svnweb.freebsd.org/changeset/base/363527

Log:
  Allow swi_sched() to be called from NMI context.
  
  For purposes of handling hardware error reported via NMIs I need a way to
  escape NMI context, being too restrictive to do something significant.
  
  To do it this change introduces new swi_sched() flag SWI_FROMNMI, making
  it careful about used KPIs.  On platforms allowing IPI sending from NMI
  context (x86 for now) it immediately wakes clk_intr_event via new IPI_SWI,
  otherwise it works just like SWI_DELAY.  To handle the delayed SWIs this
  patch calls clk_intr_event on every hardclock() tick.
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.
  Differential Revision:https://reviews.freebsd.org/D25754

Modified:
  head/share/man/man9/swi.9
  head/sys/amd64/amd64/apic_vector.S
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/amd64/include/smp.h
  head/sys/i386/i386/apic_vector.s
  head/sys/i386/i386/mp_machdep.c
  head/sys/kern/kern_clock.c
  head/sys/kern/kern_intr.c
  head/sys/sys/interrupt.h
  head/sys/x86/include/apicvar.h
  head/sys/x86/include/x86_smp.h
  head/sys/x86/x86/mp_x86.c
  head/sys/x86/xen/xen_apic.c

Modified: head/share/man/man9/swi.9
==
--- head/share/man/man9/swi.9   Sat Jul 25 14:27:12 2020(r363526)
+++ head/share/man/man9/swi.9   Sat Jul 25 15:19:38 2020(r363527)
@@ -23,7 +23,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 19, 2012
+.Dd July 25, 2020
 .Dt SWI 9
 .Os
 .Sh NAME
@@ -132,7 +132,7 @@ The
 .Fa flags
 argument specifies how and when the handler should be run and is a mask of one
 or more of the following flags:
-.Bl -tag -width SWI_DELAY
+.Bl -tag -width SWI_FROMNMI
 .It Dv SWI_DELAY
 Specifies that the kernel should mark the specified handler as needing to run,
 but the kernel should not schedule the software interrupt thread to run.
@@ -146,6 +146,13 @@ functionality performed by
 .Fn setdelayed
 in earlier versions of
 .Fx .
+.It Dv SWI_FROMNMI
+Specifies that
+.Fn swi_sched
+is called from NMI context and should be careful about used KPIs.
+On platforms allowing IPI sending from NMI context it immediately wakes
+.Va clk_intr_event
+via the IPI, otherwise it works just like SWI_DELAY.
 .El
 .Pp
 The

Modified: head/sys/amd64/amd64/apic_vector.S
==
--- head/sys/amd64/amd64/apic_vector.S  Sat Jul 25 14:27:12 2020
(r363526)
+++ head/sys/amd64/amd64/apic_vector.S  Sat Jul 25 15:19:38 2020
(r363527)
@@ -206,6 +206,16 @@ IDTVEC(spuriousint)
jmp doreti
 
 /*
+ * Executed by a CPU when it receives an IPI_SWI.
+ */
+   INTR_HANDLER ipi_swi
+   callas_lapic_eoi
+   FAKE_MCOUNT(TF_RIP(%rsp))
+   callipi_swi_handler
+   MEXITCOUNT
+   jmp doreti
+
+/*
  * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
  *
  * - Calls the generic rendezvous action function.

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Sat Jul 25 14:27:12 2020
(r363526)
+++ head/sys/amd64/amd64/mp_machdep.c   Sat Jul 25 15:19:38 2020
(r363527)
@@ -223,6 +223,10 @@ cpu_mp_start(void)
setidt(IPI_SUSPEND, pti ? IDTVEC(cpususpend_pti) : IDTVEC(cpususpend),
SDT_SYSIGT, SEL_KPL, 0);
 
+   /* Install an IPI for calling delayed SWI */
+   setidt(IPI_SWI, pti ? IDTVEC(ipi_swi_pti) : IDTVEC(ipi_swi),
+   SDT_SYSIGT, SEL_KPL, 0);
+
/* Set boot_cpu_id if needed. */
if (boot_cpu_id == -1) {
boot_cpu_id = PCPU_GET(apic_id);

Modified: head/sys/amd64/include/smp.h
==
--- head/sys/amd64/include/smp.hSat Jul 25 14:27:12 2020
(r363526)
+++ head/sys/amd64/include/smp.hSat Jul 25 15:19:38 2020
(r363527)
@@ -32,6 +32,7 @@ inthand_t
IDTVEC(invlop_pti),
IDTVEC(invlop),
IDTVEC(ipi_intr_bitmap_handler_pti),
+   IDTVEC(ipi_swi_pti),
IDTVEC(cpustop_pti),
IDTVEC(cpususpend_pti),
IDTVEC(rendezvous_pti);

Modified: head/sys/i386/i386/apic_vector.s
==
--- head/sys/i386/i386/apic_vector.sSat Jul 25 14:27:12 2020
(r363526)
+++ head/sys/i386/i386/apic_vector.sSat Jul 25 15:19:38 2020
(r363527)
@@ -309,6 +309,23 @@ IDTVEC(cpususpend)
jmp doreti
 
 /*
+ * Executed by a CPU when it receives an IPI_SWI.
+ */
+   .text
+   SUPERALIGN_TEXT
+IDTVEC(ipi_swi)
+   PUSH_FRAME
+   SET_KERNEL_SREGS
+   cld
+   KENTER
+   callas_lapic_eoi
+   FAKE_MCOUNT(TF_EIP(%esp))
+   movl$ipi_swi_handler, %eax
+   call*%

svn commit: r363526 - in stable: 11/contrib/ipfilter/man 11/contrib/ipfilter/tools 12/contrib/ipfilter/man 12/contrib/ipfilter/tools

2020-07-25 Thread Cy Schubert
Author: cy
Date: Sat Jul 25 14:27:12 2020
New Revision: 363526
URL: https://svnweb.freebsd.org/changeset/base/363526

Log:
  MFC r363277-r363283
  
  r363277:
  Only use the use_inet6 variable when INET6 is a build option.
  
  This is a prerequisite to upcoming argument processing cleanups which
  will resolve consistency as was done with ippool previously.
  
  PR:   247952
  
  r363278:
  fr_family (the protocol family) must be AF_INET or AF_INET6, as in
  the kernel, not an arbitrary 4 or 6.
  
  This only affected printing ipfilter stats and rules from a kernel
  dump. (This is currently undocumented.)
  
  PR:   247952
  
  r363279:
  Historically ipfstat listings and stats only listed IPv4 or IPv6 output.
  ipfstat would list IPv4 outputs by default while -6 would produce IPv6
  outputs. This commit combines the ipfstat -i and -o outputs into one
  listing of IPv4 and IPv6 rules. The -4 option lists only IPv4 rules
  (as the default before) while -6 continues to list only rules that affect
  IPv6.
  
  PR:   247952
  Reported by:  jo...@a1poweruser.com
  
  r363280:
  ipfstat -t defaults to IPv4 output. Make consistent with ipfstat -i
  and ipfstat -o where without an argument IPv4 and IPv6 states are
  shown. Use -4 and -6 to limit the display to IPv4 or IPv6 respectively.
  
  PR:   247952
  
  r363281:
  Make ipfstat -t header generic when IPv4 and IPv6 output are
  displayed in the same display.
  
  PR:   247952
  
  r363282:
  The output from usage() need not contain usage for -t when STATETOP
  is not compiled in.
  
  PR:   247952

Modified:
  stable/12/contrib/ipfilter/man/ipfstat.8
  stable/12/contrib/ipfilter/tools/ipfstat.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/contrib/ipfilter/man/ipfstat.8
  stable/11/contrib/ipfilter/tools/ipfstat.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/contrib/ipfilter/man/ipfstat.8
==
--- stable/12/contrib/ipfilter/man/ipfstat.8Sat Jul 25 11:57:39 2020
(r363525)
+++ stable/12/contrib/ipfilter/man/ipfstat.8Sat Jul 25 14:27:12 2020
(r363526)
@@ -5,7 +5,7 @@ ipfstat \- reports on packet filter statistics and fil
 .SH SYNOPSIS
 .B ipfstat
 [
-.B \-6aAdfghIilnoRsv
+.B \-46aAdfghIilnoRsv
 ]
 .br
 .B ipfstat -t
@@ -35,6 +35,11 @@ is to retrieve and display the accumulated statistics 
 accumulated over time as the kernel has put packets through the filter.
 .SH OPTIONS
 .TP
+.B \-4
+Display filter lists and states for IPv4, if available. This is the default
+when displaying states.  \fB-4\fP and \fB-6\fP is the default when
+displaying lists.
+.TP
 .B \-6
 Display filter lists and states for IPv6, if available.
 .TP
@@ -190,4 +195,5 @@ more entries is to resize the screen.
 .SH SEE ALSO
 ipf(8)
 .SH BUGS
-none known.
+\fB-4\fP and \fB-6\fP are only valid with \fB-i\fP, \fB-o\fP, and \fB-t\fP.
+An error should result when used with other arguments.

Modified: stable/12/contrib/ipfilter/tools/ipfstat.c
==
--- stable/12/contrib/ipfilter/tools/ipfstat.c  Sat Jul 25 11:57:39 2020
(r363525)
+++ stable/12/contrib/ipfilter/tools/ipfstat.c  Sat Jul 25 14:27:12 2020
(r363526)
@@ -57,7 +57,10 @@ static   wordtab_t   *state_fields = NULL;
 
 intnohdrfields = 0;
 intopts = 0;
+#ifdef USE_INET6
+intuse_inet4 = 0;
 intuse_inet6 = 0;
+#endif
 intlive_kernel = 1;
 intstate_fd = -1;
 intipf_fd = -1;
@@ -163,16 +166,18 @@ static void usage(name)
char *name;
 {
 #ifdef  USE_INET6
-   fprintf(stderr, "Usage: %s [-6aAdfghIilnoRsv]\n", name);
+   fprintf(stderr, "Usage: %s [-46aAdfghIilnoRsv]\n", name);
 #else
-   fprintf(stderr, "Usage: %s [-aAdfghIilnoRsv]\n", name);
+   fprintf(stderr, "Usage: %s [-4aAdfghIilnoRsv]\n", name);
 #endif
fprintf(stderr, "   %s [-M corefile] [-N symbol-list]\n", name);
+#ifdef STATETOP
 #ifdef USE_INET6
-   fprintf(stderr, "   %s -t [-6C] ", name);
+   fprintf(stderr, "   %s -t [-46C] ", name);
 #else
-   fprintf(stderr, "   %s -t [-C] ", name);
+   fprintf(stderr, "   %s -t [-4C] ", name);
 #endif
+#endif
fprintf(stderr, "[-D destination address] [-P protocol] [-S source 
address] [-T refresh time]\n");
exit(1);
 }
@@ -206,9 +211,9 @@ int main(argc,argv)
u_32_t frf;
 
 #ifdef USE_INET6
-   options = "6aACdfghIilnostvD:m:M:N:O:P:RS:T:";
+   options = "46aACdfghIilnostvD:m:M:N:O:P:RS:T:";
 #else
-   options = "aACdfghIilnostvD:m:M:N:O:P:RS:T:";
+   options = "4aACdfghIilnostvD:m:M:N:O:P:RS:T:";
 #endif
 
saddr.in4.s_addr = INADDR_ANY;  /* default any v4 source addr */
@@ -283,6 +288,9 @@ int main(argc,argv)
switch (c)
{
 #ifdef USE_

svn commit: r363526 - in stable: 11/contrib/ipfilter/man 11/contrib/ipfilter/tools 12/contrib/ipfilter/man 12/contrib/ipfilter/tools

2020-07-25 Thread Cy Schubert
Author: cy
Date: Sat Jul 25 14:27:12 2020
New Revision: 363526
URL: https://svnweb.freebsd.org/changeset/base/363526

Log:
  MFC r363277-r363283
  
  r363277:
  Only use the use_inet6 variable when INET6 is a build option.
  
  This is a prerequisite to upcoming argument processing cleanups which
  will resolve consistency as was done with ippool previously.
  
  PR:   247952
  
  r363278:
  fr_family (the protocol family) must be AF_INET or AF_INET6, as in
  the kernel, not an arbitrary 4 or 6.
  
  This only affected printing ipfilter stats and rules from a kernel
  dump. (This is currently undocumented.)
  
  PR:   247952
  
  r363279:
  Historically ipfstat listings and stats only listed IPv4 or IPv6 output.
  ipfstat would list IPv4 outputs by default while -6 would produce IPv6
  outputs. This commit combines the ipfstat -i and -o outputs into one
  listing of IPv4 and IPv6 rules. The -4 option lists only IPv4 rules
  (as the default before) while -6 continues to list only rules that affect
  IPv6.
  
  PR:   247952
  Reported by:  jo...@a1poweruser.com
  
  r363280:
  ipfstat -t defaults to IPv4 output. Make consistent with ipfstat -i
  and ipfstat -o where without an argument IPv4 and IPv6 states are
  shown. Use -4 and -6 to limit the display to IPv4 or IPv6 respectively.
  
  PR:   247952
  
  r363281:
  Make ipfstat -t header generic when IPv4 and IPv6 output are
  displayed in the same display.
  
  PR:   247952
  
  r363282:
  The output from usage() need not contain usage for -t when STATETOP
  is not compiled in.
  
  PR:   247952

Modified:
  stable/11/contrib/ipfilter/man/ipfstat.8
  stable/11/contrib/ipfilter/tools/ipfstat.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/contrib/ipfilter/man/ipfstat.8
  stable/12/contrib/ipfilter/tools/ipfstat.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/contrib/ipfilter/man/ipfstat.8
==
--- stable/11/contrib/ipfilter/man/ipfstat.8Sat Jul 25 11:57:39 2020
(r363525)
+++ stable/11/contrib/ipfilter/man/ipfstat.8Sat Jul 25 14:27:12 2020
(r363526)
@@ -5,7 +5,7 @@ ipfstat \- reports on packet filter statistics and fil
 .SH SYNOPSIS
 .B ipfstat
 [
-.B \-6aAdfghIilnoRsv
+.B \-46aAdfghIilnoRsv
 ]
 .br
 .B ipfstat -t
@@ -35,6 +35,11 @@ is to retrieve and display the accumulated statistics 
 accumulated over time as the kernel has put packets through the filter.
 .SH OPTIONS
 .TP
+.B \-4
+Display filter lists and states for IPv4, if available. This is the default
+when displaying states.  \fB-4\fP and \fB-6\fP is the default when
+displaying lists.
+.TP
 .B \-6
 Display filter lists and states for IPv6, if available.
 .TP
@@ -190,4 +195,5 @@ more entries is to resize the screen.
 .SH SEE ALSO
 ipf(8)
 .SH BUGS
-none known.
+\fB-4\fP and \fB-6\fP are only valid with \fB-i\fP, \fB-o\fP, and \fB-t\fP.
+An error should result when used with other arguments.

Modified: stable/11/contrib/ipfilter/tools/ipfstat.c
==
--- stable/11/contrib/ipfilter/tools/ipfstat.c  Sat Jul 25 11:57:39 2020
(r363525)
+++ stable/11/contrib/ipfilter/tools/ipfstat.c  Sat Jul 25 14:27:12 2020
(r363526)
@@ -57,7 +57,10 @@ static   wordtab_t   *state_fields = NULL;
 
 intnohdrfields = 0;
 intopts = 0;
+#ifdef USE_INET6
+intuse_inet4 = 0;
 intuse_inet6 = 0;
+#endif
 intlive_kernel = 1;
 intstate_fd = -1;
 intipf_fd = -1;
@@ -163,16 +166,18 @@ static void usage(name)
char *name;
 {
 #ifdef  USE_INET6
-   fprintf(stderr, "Usage: %s [-6aAdfghIilnoRsv]\n", name);
+   fprintf(stderr, "Usage: %s [-46aAdfghIilnoRsv]\n", name);
 #else
-   fprintf(stderr, "Usage: %s [-aAdfghIilnoRsv]\n", name);
+   fprintf(stderr, "Usage: %s [-4aAdfghIilnoRsv]\n", name);
 #endif
fprintf(stderr, "   %s [-M corefile] [-N symbol-list]\n", name);
+#ifdef STATETOP
 #ifdef USE_INET6
-   fprintf(stderr, "   %s -t [-6C] ", name);
+   fprintf(stderr, "   %s -t [-46C] ", name);
 #else
-   fprintf(stderr, "   %s -t [-C] ", name);
+   fprintf(stderr, "   %s -t [-4C] ", name);
 #endif
+#endif
fprintf(stderr, "[-D destination address] [-P protocol] [-S source 
address] [-T refresh time]\n");
exit(1);
 }
@@ -206,9 +211,9 @@ int main(argc,argv)
u_32_t frf;
 
 #ifdef USE_INET6
-   options = "6aACdfghIilnostvD:m:M:N:O:P:RS:T:";
+   options = "46aACdfghIilnostvD:m:M:N:O:P:RS:T:";
 #else
-   options = "aACdfghIilnostvD:m:M:N:O:P:RS:T:";
+   options = "4aACdfghIilnostvD:m:M:N:O:P:RS:T:";
 #endif
 
saddr.in4.s_addr = INADDR_ANY;  /* default any v4 source addr */
@@ -283,6 +288,9 @@ int main(argc,argv)
switch (c)
{
 #ifdef USE_

svn commit: r363525 - in stable/12: bin/csh bin/sh share/skel

2020-07-25 Thread Piotr Pawel Stefaniak
Author: pstef
Date: Sat Jul 25 11:57:39 2020
New Revision: 363525
URL: https://svnweb.freebsd.org/changeset/base/363525

Log:
  MFC r342576-342577,342645,342812,342881,343231,343399 (by trasz):
  
  r342577 Make sh(1) collapse $HOME into "~" in PS1
  r342576 Simplify the way we set the default sh(1) PS1
  r342645 Add current working directory to the default sh prompt
  r342812 Give sh(1) a proper default prompt instead of just "$".
  r342881 Make sh(1) recognize the default $HOME
  r343231 Don't mess with BLOCKSIZE in shell startup files
  r343399 Make sh(1) support \u in PS1

Modified:
  stable/12/bin/csh/csh.login
  stable/12/bin/csh/dot.cshrc
  stable/12/bin/sh/parser.c
  stable/12/bin/sh/profile
  stable/12/bin/sh/sh.1
  stable/12/share/skel/dot.cshrc
  stable/12/share/skel/dot.profile
  stable/12/share/skel/dot.shrc
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/bin/csh/csh.login
==
--- stable/12/bin/csh/csh.login Sat Jul 25 11:34:50 2020(r363524)
+++ stable/12/bin/csh/csh.login Sat Jul 25 11:57:39 2020(r363525)
@@ -1,9 +1,6 @@
 # $FreeBSD$
 #
 # System-wide .login file for csh(1).
-# Uncomment this to give you the default 4.2 behavior, where disk
-# information is shown in K-Blocks
-# setenv BLOCKSIZE K
 #
 # For the setting of languages and character sets please see
 # login.conf(5) and in particular the charset and lang options.

Modified: stable/12/bin/csh/dot.cshrc
==
--- stable/12/bin/csh/dot.cshrc Sat Jul 25 11:34:50 2020(r363524)
+++ stable/12/bin/csh/dot.cshrc Sat Jul 25 11:57:39 2020(r363525)
@@ -23,7 +23,6 @@ set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/s
 
 setenv EDITOR  vi
 setenv PAGER   less
-setenv BLOCKSIZE   K
 
 if ($?prompt) then
# An interactive shell -- set some stuff up

Modified: stable/12/bin/sh/parser.c
==
--- stable/12/bin/sh/parser.c   Sat Jul 25 11:34:50 2020(r363524)
+++ stable/12/bin/sh/parser.c   Sat Jul 25 11:57:39 2020(r363525)
@@ -40,6 +40,8 @@ static char sccsid[] = "@(#)parser.c  8.7 (Berkeley) 5/
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -130,6 +132,7 @@ static void synexpect(int) __dead2;
 static void synerror(const char *) __dead2;
 static void setprompt(int);
 static int pgetc_linecont(void);
+static void getusername(char *, size_t);
 
 
 static void *
@@ -1969,6 +1972,53 @@ pgetc_linecont(void)
return (c);
 }
 
+
+static struct passwd *
+getpwlogin(void)
+{
+   const char *login;
+
+   login = getlogin();
+   if (login == NULL)
+   return (NULL);
+
+   return (getpwnam(login));
+}
+
+
+static void
+getusername(char *name, size_t namelen)
+{
+   static char cached_name[MAXLOGNAME];
+   struct passwd *pw;
+   uid_t euid;
+
+   if (cached_name[0] == '\0') {
+   euid = geteuid();
+
+   /*
+* Handle the case when there is more than one
+* login with the same UID, or when the login
+* returned by getlogin(2) does no longer match
+* the current UID.
+*/
+   pw = getpwlogin();
+   if (pw == NULL || pw->pw_uid != euid)
+   pw = getpwuid(euid);
+
+   if (pw != NULL) {
+   strlcpy(cached_name, pw->pw_name,
+   sizeof(cached_name));
+   } else {
+   snprintf(cached_name, sizeof(cached_name),
+   "%u", euid);
+   }
+   }
+
+   strlcpy(name, cached_name, namelen);
+}
+
+
 /*
  * called by editline -- any expansions to the prompt
  *should be added here.
@@ -1978,7 +2028,9 @@ getprompt(void *unused __unused)
 {
static char ps[PROMPTLEN];
const char *fmt;
+   const char *home;
const char *pwd;
+   size_t homelen;
int i, trim;
static char internal_error[] = "??";
 
@@ -2025,6 +2077,17 @@ getprompt(void *unused __unused)
break;
 
/*
+* User name.
+*/
+   case 'u':
+   ps[i] = '\0';
+   getusername(&ps[i], PROMPTLEN - i);
+   /* Skip to end of username. */
+   while (ps[i + 1] != '\0')
+   i++;
+   break;
+
+   /*
 * Working directory.
 *
 * \W specifies just the final component,
@@ -2039,

svn commit: r363524 - in head/sys: conf dev/iommu x86/iommu

2020-07-25 Thread Ruslan Bukin
Author: br
Date: Sat Jul 25 11:34:50 2020
New Revision: 363524
URL: https://svnweb.freebsd.org/changeset/base/363524

Log:
  Move Intel GAS to dev/iommu/ as now a part of generic iommu framework.
  
  Reviewed by:  kib
  Sponsored by: DARPA/AFRL
  Differential Revision:https://reviews.freebsd.org/D25799

Added:
  head/sys/dev/iommu/iommu_gas.c
 - copied unchanged from r363523, head/sys/x86/iommu/intel_gas.c
Deleted:
  head/sys/x86/iommu/intel_gas.c
Modified:
  head/sys/conf/files.x86

Modified: head/sys/conf/files.x86
==
--- head/sys/conf/files.x86 Sat Jul 25 10:40:38 2020(r363523)
+++ head/sys/conf/files.x86 Sat Jul 25 11:34:50 2020(r363524)
@@ -166,6 +166,7 @@ dev/imcsmb/imcsmb_pci.c optionalimcsmb 
pci
 dev/intel/spi.coptionalintelspi
 dev/io/iodev.c optionalio
 dev/iommu/busdma_iommu.c   optionalacpi acpi_dmar pci
+dev/iommu/iommu_gas.c  optionalacpi acpi_dmar pci
 dev/ipmi/ipmi.coptionalipmi
 dev/ipmi/ipmi_acpi.c   optionalipmi acpi
 dev/ipmi/ipmi_isa.coptionalipmi isa
@@ -304,7 +305,6 @@ x86/cpufreq/powernow.c  optionalcpufreq
 x86/iommu/intel_ctx.c  optionalacpi acpi_dmar pci
 x86/iommu/intel_drv.c  optionalacpi acpi_dmar pci
 x86/iommu/intel_fault.coptionalacpi acpi_dmar pci
-x86/iommu/intel_gas.c  optionalacpi acpi_dmar pci
 x86/iommu/intel_idpgtbl.c  optionalacpi acpi_dmar pci
 x86/iommu/intel_intrmap.c  optionalacpi acpi_dmar pci
 x86/iommu/intel_qi.c   optionalacpi acpi_dmar pci

Copied: head/sys/dev/iommu/iommu_gas.c (from r363523, 
head/sys/x86/iommu/intel_gas.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/iommu/iommu_gas.c  Sat Jul 25 11:34:50 2020
(r363524, copy of r363523, head/sys/x86/iommu/intel_gas.c)
@@ -0,0 +1,729 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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$");
+
+#defineRB_AUGMENT(entry) iommu_gas_augment_entry(entry)
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#if defined(__amd64__) || defined(__i386__)
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
+/*
+ * Guest Address Space management.
+ */
+
+static uma_zone_t iommu_map_entry_zone;
+
+static void
+intel_gas_init(void)
+{
+
+   iommu_map_entry_zone = uma_zcreate("IOMMU_MAP_ENTRY",
+   sizeof(struct iommu_map_entry), NULL, NULL,
+   NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NODUMP);
+}
+SYSINIT(intel_gas, SI_SUB_DRIVERS, SI_ORDER_FIRST, intel_gas_init, NULL);
+
+struct iommu_map_entry *
+iommu_gas_alloc_entry(struct iommu_domain *domain, u_int flags)
+{
+   struct iommu_map_entry *res;
+
+   KASSERT((flags & ~(DMAR_PGF_WAITOK)) == 0,
+   ("unsupported flags %x", flags));
+
+   res = uma_zalloc(iommu_map_entry_zone, ((flags &

svn commit: r363523 - head/sys/kern

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 10:40:38 2020
New Revision: 363523
URL: https://svnweb.freebsd.org/changeset/base/363523

Log:
  vfs: add support for !LOCKLEAF to lockless lookup
  
  Tested by:  pho (in a patchset)
  Differential Revision:https://reviews.freebsd.org/D23916

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Sat Jul 25 10:39:41 2020(r363522)
+++ head/sys/kern/vfs_cache.c   Sat Jul 25 10:40:38 2020(r363523)
@@ -3029,10 +3029,6 @@ cache_can_fplookup(struct cache_fpl *fpl)
cache_fpl_aborted(fpl);
return (false);
}
-   if ((cnp->cn_flags & LOCKLEAF) == 0) {
-   cache_fpl_aborted(fpl);
-   return (false);
-   }
if (cnp->cn_nameiop != LOOKUP) {
cache_fpl_aborted(fpl);
return (false);
@@ -3120,7 +3116,6 @@ cache_fplookup_final(struct cache_fpl *fpl)
tvp_seqc = fpl->tvp_seqc;
 
VNPASS(cache_fplookup_vnode_supported(dvp), dvp);
-   MPASS((cnp->cn_flags & LOCKLEAF) != 0);
 
tvs = vget_prep_smr(tvp);
if (tvs == VGET_NONE) {
@@ -3135,13 +3130,20 @@ cache_fplookup_final(struct cache_fpl *fpl)
 
cache_fpl_smr_exit(fpl);
 
-   error = vget_finish(tvp, cnp->cn_lkflags, tvs);
-   if (error != 0) {
-   return (cache_fpl_aborted(fpl));
+   if ((cnp->cn_flags & LOCKLEAF) != 0) {
+   error = vget_finish(tvp, cnp->cn_lkflags, tvs);
+   if (error != 0) {
+   return (cache_fpl_aborted(fpl));
+   }
+   } else {
+   vget_finish_ref(tvp, tvs);
}
 
if (!vn_seqc_consistent(tvp, tvp_seqc)) {
-   vput(tvp);
+   if ((cnp->cn_flags & LOCKLEAF) != 0)
+   vput(tvp);
+   else
+   vrele(tvp);
return (cache_fpl_aborted(fpl));
}
 
___
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: r363522 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 10:39:41 2020
New Revision: 363522
URL: https://svnweb.freebsd.org/changeset/base/363522

Log:
  zfs: add support for lockless lookup
  
  Tested by:pho (in a patchset, previous version)
  Differential Revision:https://reviews.freebsd.org/D25581

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h Sat Jul 
25 10:38:44 2020(r363521)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h Sat Jul 
25 10:39:41 2020(r363522)
@@ -246,6 +246,8 @@ VTOZ(vnode_t *vp)
 #defineVTOZ(VP)((znode_t *)(VP)->v_data)
 #endif
 
+#defineVTOZ_SMR(VP)((znode_t *)vn_load_v_data_smr(VP))
+
 /* Called on entry to each ZFS vnode and vfs operation  */
 #defineZFS_ENTER(zfsvfs) \
{ \

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c   Sat Jul 
25 10:38:44 2020(r363521)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c   Sat Jul 
25 10:39:41 2020(r363522)
@@ -1146,6 +1146,7 @@ zfs_acl_chown_setattr(znode_t *zp)
 
ASSERT_VOP_ELOCKED(ZTOV(zp), __func__);
ASSERT(MUTEX_HELD(&zp->z_acl_lock));
+   ASSERT_VOP_IN_SEQC(ZTOV(zp));
 
if ((error = zfs_acl_node_read(zp, &aclp, B_FALSE)) == 0)
zp->z_mode = zfs_mode_compute(zp->z_mode, aclp,
@@ -1172,6 +1173,8 @@ zfs_aclset_common(znode_t *zp, zfs_acl_t *aclp, cred_t
uint64_tctime[2];
int count = 0;
zfs_acl_phys_t  acl_phys;
+
+   ASSERT_VOP_IN_SEQC(ZTOV(zp));
 
mode = zp->z_mode;
 

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cSat Jul 
25 10:38:44 2020(r363521)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cSat Jul 
25 10:39:41 2020(r363522)
@@ -1391,6 +1391,9 @@ zfs_domount(vfs_t *vfsp, char *osname)
 
vfsp->vfs_data = zfsvfs;
vfsp->mnt_flag |= MNT_LOCAL;
+#if defined(_KERNEL) && !defined(KMEM_DEBUG)
+   vfsp->mnt_kern_flag |= MNTK_FPLOOKUP;
+#endif
vfsp->mnt_kern_flag |= MNTK_LOOKUP_SHARED;
vfsp->mnt_kern_flag |= MNTK_SHARED_WRITES;
vfsp->mnt_kern_flag |= MNTK_EXTENDED_SHARED;

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sat Jul 
25 10:38:44 2020(r363521)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sat Jul 
25 10:39:41 2020(r363522)
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -78,6 +79,8 @@
 #include 
 #include 
 
+VFS_SMR_DECLARE;
+
 /*
  * Programming rules.
  *
@@ -3698,6 +3701,7 @@ zfs_rename(vnode_t *sdvp, vnode_t **svpp, struct compo
char*snm = scnp->cn_nameptr;
char*tnm = tcnp->cn_nameptr;
int error = 0;
+   boolwant_seqc_end = false;
 
/* Reject renames across filesystems. */
if ((*svpp)->v_mount != tdvp->v_mount ||
@@ -3828,6 +3832,14 @@ zfs_rename(vnode_t *sdvp, vnode_t **svpp, struct compo
}
}
 
+   vn_seqc_write_begin(*svpp);
+   vn_seqc_write_begin(sdvp);
+   if (*tvpp != NULL)
+   vn_seqc_write_begin(*tvpp);
+   if (tdvp != *tvpp)
+   vn_seqc_write_begin(tdvp);
+   want_seqc_end = true;
+
vnevent_rename_src(*svpp, sdvp, scnp->cn_nameptr, ct);
if (tzp)
vnevent_rename_dest(*tvpp, tdvp, tnm, ct);
@@ -3914,10 +3926,20 @@ zfs_rename(vnode_t *sdvp, vnode_t **svpp, struct compo
 
 unlockout: /* all 4 vnodes are locked, ZFS_ENTER called */
ZFS_EXIT(zfsvfs);
+   if (want_seqc_end) {
+   vn_seqc_write_end(*svpp);
+   vn_seqc_write_end(sdvp);
+   if (*tvpp != NULL)
+   vn_seqc_write_end(*tvpp);
+   if (tdvp != *tvpp)
+   vn_seqc_write_end(tdvp);
+   want_seqc_end = false;
+   }
   

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

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 10:38:44 2020
New Revision: 363521
URL: https://svnweb.freebsd.org/changeset/base/363521

Log:
  tmpfs: add support for lockless lookup
  
  Reviewed by:kib
  Tested by:  pho (in a patchset)
  Differential Revision:https://reviews.freebsd.org/D25580

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

Modified: head/sys/fs/tmpfs/tmpfs.h
==
--- head/sys/fs/tmpfs/tmpfs.h   Sat Jul 25 10:38:05 2020(r363520)
+++ head/sys/fs/tmpfs/tmpfs.h   Sat Jul 25 10:38:44 2020(r363521)
@@ -526,6 +526,9 @@ VP_TO_TMPFS_NODE(struct vnode *vp)
return (node);
 }
 
+#defineVP_TO_TMPFS_NODE_SMR(vp)\
+   ((struct tmpfs_node *)vn_load_v_data_smr(vp))
+
 static inline struct tmpfs_node *
 VP_TO_TMPFS_DIR(struct vnode *vp)
 {

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Sat Jul 25 10:38:05 2020
(r363520)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Sat Jul 25 10:38:44 2020
(r363521)
@@ -75,6 +75,7 @@ static long tmpfs_pages_reserved = TMPFS_PAGES_MINRESE
 
 static uma_zone_t tmpfs_dirent_pool;
 static uma_zone_t tmpfs_node_pool;
+VFS_SMR_DECLARE;
 
 static int
 tmpfs_node_ctor(void *mem, int size, void *arg, int flags)
@@ -131,6 +132,7 @@ tmpfs_subr_init(void)
tmpfs_node_pool = uma_zcreate("TMPFS node",
sizeof(struct tmpfs_node), tmpfs_node_ctor, tmpfs_node_dtor,
tmpfs_node_init, tmpfs_node_fini, UMA_ALIGN_PTR, 0);
+   VFS_SMR_ZONE_SET(tmpfs_node_pool);
 }
 
 void
@@ -288,7 +290,7 @@ tmpfs_alloc_node(struct mount *mp, struct tmpfs_mount 
if ((mp->mnt_kern_flag & MNT_RDONLY) != 0)
return (EROFS);
 
-   nnode = uma_zalloc_arg(tmpfs_node_pool, tmp, M_WAITOK);
+   nnode = uma_zalloc_smr(tmpfs_node_pool, M_WAITOK);
 
/* Generic initialization. */
nnode->tn_type = type;
@@ -435,7 +437,7 @@ tmpfs_free_node_locked(struct tmpfs_mount *tmp, struct
panic("tmpfs_free_node: type %p %d", node, (int)node->tn_type);
}
 
-   uma_zfree(tmpfs_node_pool, node);
+   uma_zfree_smr(tmpfs_node_pool, node);
TMPFS_LOCK(tmp);
tmpfs_free_tmp(tmp);
return (true);
@@ -1621,8 +1623,10 @@ tmpfs_chmod(struct vnode *vp, mode_t mode, struct ucre
 {
int error;
struct tmpfs_node *node;
+   mode_t newmode;
 
ASSERT_VOP_ELOCKED(vp, "chmod");
+   ASSERT_VOP_IN_SEQC(vp);
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1656,10 +1660,10 @@ tmpfs_chmod(struct vnode *vp, mode_t mode, struct ucre
return (error);
}
 
+   newmode = node->tn_mode & ~ALLPERMS;
+   newmode |= mode & ALLPERMS;
+   atomic_store_short(&node->tn_mode, newmode);
 
-   node->tn_mode &= ~ALLPERMS;
-   node->tn_mode |= mode & ALLPERMS;
-
node->tn_status |= TMPFS_NODE_CHANGED;
 
ASSERT_VOP_ELOCKED(vp, "chmod2");
@@ -1682,8 +1686,10 @@ tmpfs_chown(struct vnode *vp, uid_t uid, gid_t gid, st
struct tmpfs_node *node;
uid_t ouid;
gid_t ogid;
+   mode_t newmode;
 
ASSERT_VOP_ELOCKED(vp, "chown");
+   ASSERT_VOP_IN_SEQC(vp);
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1729,8 +1735,10 @@ tmpfs_chown(struct vnode *vp, uid_t uid, gid_t gid, st
node->tn_status |= TMPFS_NODE_CHANGED;
 
if ((node->tn_mode & (S_ISUID | S_ISGID)) && (ouid != uid || ogid != 
gid)) {
-   if (priv_check_cred(cred, PRIV_VFS_RETAINSUGID))
-   node->tn_mode &= ~(S_ISUID | S_ISGID);
+   if (priv_check_cred(cred, PRIV_VFS_RETAINSUGID)) {
+   newmode = node->tn_mode & ~(S_ISUID | S_ISGID);
+   atomic_store_short(&node->tn_mode, newmode);
+   }
}
 
ASSERT_VOP_ELOCKED(vp, "chown2");

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==
--- head/sys/fs/tmpfs/tmpfs_vfsops.cSat Jul 25 10:38:05 2020
(r363520)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.cSat Jul 25 10:38:44 2020
(r363521)
@@ -462,6 +462,8 @@ tmpfs_mount(struct mount *mp)
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED |
MNTK_TEXT_REFS | MNTK_NOMSYNC;
+   if (!nonc)
+   mp->mnt_kern_flag |= MNTK_FPLOOKUP;
MNT_IUNLOCK(mp);
 
mp->mnt_data = tmp;

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==
--- head/sys/fs/tmpfs/tmpfs_vnops.c Sat Jul 25 10:38:05 2020
(r363520)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c Sat Jul 25 10:38:44

svn commit: r363520 - in head/sys/ufs: ffs ufs

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 10:38:05 2020
New Revision: 363520
URL: https://svnweb.freebsd.org/changeset/base/363520

Log:
  ufs: add support for lockless lookup
  
  ACLs are not supported, meaning their presence will force the use of the old 
lookup.
  
  Reviewed by:kib
  Tested by:  pho (in a patchset)
  Differential Revision:https://reviews.freebsd.org/D25579

Modified:
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ffs/ffs_vnops.c
  head/sys/ufs/ufs/inode.h
  head/sys/ufs/ufs/ufs_acl.c
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/ufs/ffs/ffs_vfsops.c
==
--- head/sys/ufs/ffs/ffs_vfsops.c   Sat Jul 25 10:37:15 2020
(r363519)
+++ head/sys/ufs/ffs/ffs_vfsops.c   Sat Jul 25 10:38:05 2020
(r363520)
@@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 static uma_zone_t uma_inode, uma_ufs1, uma_ufs2;
+VFS_SMR_DECLARE;
 
 static int ffs_mountfs(struct vnode *, struct mount *, struct thread *);
 static voidffs_oldfscompat_read(struct fs *, struct ufsmount *,
@@ -393,6 +394,7 @@ ffs_mount(struct mount *mp)
uma_ufs2 = uma_zcreate("FFS2 dinode",
sizeof(struct ufs2_dinode), NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR, 0);
+   VFS_SMR_ZONE_SET(uma_inode);
}
 
vfs_deleteopt(mp->mnt_optnew, "groupquota");
@@ -455,6 +457,7 @@ ffs_mount(struct mount *mp)
}
 
MNT_ILOCK(mp);
+   mp->mnt_kern_flag &= ~MNTK_FPLOOKUP;
mp->mnt_flag |= mntorflags;
MNT_IUNLOCK(mp);
/*
@@ -795,6 +798,17 @@ ffs_mount(struct mount *mp)
}
}
}
+
+   MNT_ILOCK(mp);
+   /*
+* This is racy versus lookup, see ufs_fplookup_vexec for details.
+*/
+   if ((mp->mnt_kern_flag & MNTK_FPLOOKUP) != 0)
+   panic("MNTK_FPLOOKUP set on mount %p when it should not be", 
mp);
+   if ((mp->mnt_flag & (MNT_ACLS | MNT_NFS4ACLS)) == 0)
+   mp->mnt_kern_flag |= MNTK_FPLOOKUP;
+   MNT_IUNLOCK(mp);
+
vfs_mountedfrom(mp, fspec);
return (0);
 }
@@ -1968,14 +1982,14 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags)
 
ump = VFSTOUFS(mp);
fs = ump->um_fs;
-   ip = uma_zalloc(uma_inode, M_WAITOK | M_ZERO);
+   ip = uma_zalloc_smr(uma_inode, M_WAITOK | M_ZERO);
 
/* Allocate a new vnode/inode. */
error = getnewvnode("ufs", mp, fs->fs_magic == FS_UFS1_MAGIC ?
&ffs_vnodeops1 : &ffs_vnodeops2, &vp);
if (error) {
*vpp = NULL;
-   uma_zfree(uma_inode, ip);
+   uma_zfree_smr(uma_inode, ip);
return (error);
}
/*
@@ -2004,7 +2018,7 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags)
vp->v_vflag |= VV_FORCEINSMQ;
error = insmntque(vp, mp);
if (error != 0) {
-   uma_zfree(uma_inode, ip);
+   uma_zfree_smr(uma_inode, ip);
*vpp = NULL;
return (error);
}
@@ -2327,7 +2341,7 @@ ffs_ifree(struct ufsmount *ump, struct inode *ip)
uma_zfree(uma_ufs1, ip->i_din1);
else if (ip->i_din2 != NULL)
uma_zfree(uma_ufs2, ip->i_din2);
-   uma_zfree(uma_inode, ip);
+   uma_zfree_smr(uma_inode, ip);
 }
 
 static int dobkgrdwrite = 1;

Modified: head/sys/ufs/ffs/ffs_vnops.c
==
--- head/sys/ufs/ffs/ffs_vnops.cSat Jul 25 10:37:15 2020
(r363519)
+++ head/sys/ufs/ffs/ffs_vnops.cSat Jul 25 10:38:05 2020
(r363520)
@@ -905,8 +905,10 @@ ffs_write(ap)
if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid &&
ap->a_cred) {
if (priv_check_cred(ap->a_cred, PRIV_VFS_RETAINSUGID)) {
-   ip->i_mode &= ~(ISUID | ISGID);
+   vn_seqc_write_begin(vp);
+   UFS_INODE_SET_MODE(ip, ip->i_mode & ~(ISUID | ISGID));
DIP_SET(ip, i_mode, ip->i_mode);
+   vn_seqc_write_end(vp);
}
}
if (error) {
@@ -1152,8 +1154,10 @@ ffs_extwrite(struct vnode *vp, struct uio *uio, int io
 */
if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid && ucred) {
if (priv_check_cred(ucred, PRIV_VFS_RETAINSUGID)) {
-   ip->i_mode &= ~(ISUID | ISGID);
+   vn_seqc_write_begin(vp);
+   UFS_INODE_SET_MODE(ip, ip->i_mode & ~(ISUID | ISGID));
dp->di_mode = ip->i_mode;
+   vn_seqc_write_end(vp);
}
}
if (error) {

Modified: head/sys/ufs/ufs/inode.h
==
--- head/sys/ufs/ufs/inode.hSat Jul 25 10:37:15 2020

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

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 10:37:15 2020
New Revision: 363519
URL: https://svnweb.freebsd.org/changeset/base/363519

Log:
  vfs: lockless lookup
  
  Provides full scalability as long as all visited filesystems support the
  lookup and terminal vnodes are different.
  
  Inner workings are explained in the comment above cache_fplookup.
  
  Capabilities and fd-relative lookups are not supported and will result in
  immediate fallback to regular code.
  
  Symlinks, ".." in the path, mount points without support for lockless lookup
  and mismatched counters will result in an attempt to get a reference to the
  directory vnode and continue in regular lookup. If this fails, the entire
  operation is aborted and regular lookup starts from scratch. However, care is
  taken that data is not copied again from userspace.
  
  Sample benchmark:
  incremental -j 104 bzImage on tmpfs:
  before: 142.96s user 1025.63s system 4924% cpu 23.731 total
  after: 147.36s user 313.40s system 3216% cpu 14.326 total
  
  Sample microbenchmark: access calls to separate files in /tmpfs, 104 workers, 
ops/s:
  before:   2165816
  after:  151216530
  
  Reviewed by:kib
  Tested by:  pho (in a patchset)
  Differential Revision:https://reviews.freebsd.org/D25578

Modified:
  head/sys/kern/vfs_cache.c
  head/sys/kern/vfs_lookup.c
  head/sys/sys/namei.h

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Sat Jul 25 10:32:45 2020(r363518)
+++ head/sys/kern/vfs_cache.c   Sat Jul 25 10:37:15 2020(r363519)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -67,6 +68,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+#include 
+
+#include 
+#include 
+
 #ifdef DDB
 #include 
 #endif
@@ -100,6 +106,10 @@ SDT_PROBE_DEFINE2(vfs, namecache, zap_negative, done, 
 SDT_PROBE_DEFINE2(vfs, namecache, shrink_negative, done, "struct vnode *",
 "char *");
 
+SDT_PROBE_DEFINE3(vfs, fplookup, lookup, done, "struct nameidata", "int", 
"bool");
+SDT_PROBE_DECLARE(vfs, namei, lookup, entry);
+SDT_PROBE_DECLARE(vfs, namei, lookup, return);
+
 /*
  * This structure describes the elements in the cache of recent
  * names looked up by namei.
@@ -2835,3 +2845,859 @@ DB_SHOW_COMMAND(vpath, db_show_vpath)
 }
 
 #endif
+
+extern uma_zone_t namei_zone;
+
+static bool __read_frequently cache_fast_lookup = true;
+SYSCTL_BOOL(_vfs, OID_AUTO, cache_fast_lookup, CTLFLAG_RW,
+&cache_fast_lookup, 0, "");
+
+#define CACHE_FPL_FAILED   -2020
+
+static void
+cache_fpl_cleanup_cnp(struct componentname *cnp)
+{
+
+   uma_zfree(namei_zone, cnp->cn_pnbuf);
+#ifdef DIAGNOSTIC
+   cnp->cn_pnbuf = NULL;
+   cnp->cn_nameptr = NULL;
+#endif
+}
+
+static void
+cache_fpl_handle_root(struct nameidata *ndp, struct vnode **dpp)
+{
+   struct componentname *cnp;
+
+   cnp = &ndp->ni_cnd;
+   while (*(cnp->cn_nameptr) == '/') {
+   cnp->cn_nameptr++;
+   ndp->ni_pathlen--;
+   }
+
+   *dpp = ndp->ni_rootdir;
+}
+
+/*
+ * Components of nameidata (or objects it can point to) which may
+ * need restoring in case fast path lookup fails.
+ */
+struct nameidata_saved {
+   int cn_flags;
+   long cn_namelen;
+   char *cn_nameptr;
+   size_t ni_pathlen;
+};
+
+struct cache_fpl {
+   int line;
+   enum cache_fpl_status status;
+   bool in_smr;
+   struct nameidata *ndp;
+   struct nameidata_saved snd;
+   struct componentname *cnp;
+   struct vnode *dvp;
+   seqc_t dvp_seqc;
+   struct vnode *tvp;
+   seqc_t tvp_seqc;
+   struct pwd *pwd;
+};
+
+static void
+cache_fpl_checkpoint(struct cache_fpl *fpl, struct nameidata_saved *snd)
+{
+
+   snd->cn_flags = fpl->ndp->ni_cnd.cn_flags;
+   snd->cn_namelen = fpl->ndp->ni_cnd.cn_namelen;
+   snd->cn_nameptr = fpl->ndp->ni_cnd.cn_nameptr;
+   snd->ni_pathlen = fpl->ndp->ni_pathlen;
+}
+
+static void
+cache_fpl_restore(struct cache_fpl *fpl, struct nameidata_saved *snd)
+{
+
+   fpl->ndp->ni_cnd.cn_flags = snd->cn_flags;
+   fpl->ndp->ni_cnd.cn_namelen = snd->cn_namelen;
+   fpl->ndp->ni_cnd.cn_nameptr = snd->cn_nameptr;
+   fpl->ndp->ni_pathlen = snd->ni_pathlen;
+}
+
+#ifdef INVARIANTS
+#define cache_fpl_smr_assert_entered(fpl) ({   \
+   struct cache_fpl *_fpl = (fpl); \
+   MPASS(_fpl->in_smr == true);\
+   VFS_SMR_ASSERT_ENTERED();   \
+})
+#define cache_fpl_smr_assert_not_entered(fpl) ({   \
+   struct cache_fpl *_fpl = (fpl); \
+   MPASS(_fpl->in_smr == false);   \
+   VFS_SMR_ASSERT_NOT_ENTERED();   \
+})
+#else
+#define cache_fpl_smr_assert_entered(fpl) do { } while (0)
+#define cache_fpl_smr_asser

svn commit: r363518 - in head/sys: kern security/mac sys

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 10:32:45 2020
New Revision: 363518
URL: https://svnweb.freebsd.org/changeset/base/363518

Log:
  vfs: add the infrastructure for lockless lookup
  
  Reviewed by:kib
  Tested by:  pho (in a patchset)
  Differential Revision:https://reviews.freebsd.org/D25577

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/kern/vfs_subr.c
  head/sys/kern/vnode_if.src
  head/sys/security/mac/mac_framework.h
  head/sys/sys/filedesc.h
  head/sys/sys/mount.h
  head/sys/sys/vnode.h

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cSat Jul 25 10:31:52 2020
(r363517)
+++ head/sys/kern/kern_descrip.cSat Jul 25 10:32:45 2020
(r363518)
@@ -102,8 +102,8 @@ MALLOC_DECLARE(M_FADVISE);
 
 static __read_mostly uma_zone_t file_zone;
 static __read_mostly uma_zone_t filedesc0_zone;
-static __read_mostly uma_zone_t pwd_zone;
-static __read_mostly smr_t pwd_smr;
+__read_mostly uma_zone_t pwd_zone;
+VFS_SMR_DECLARE;
 
 static int closefp(struct filedesc *fdp, int fd, struct file *fp,
struct thread *td, int holdleaders);
@@ -3343,21 +3343,30 @@ pwd_hold(struct thread *td)
 
fdp = td->td_proc->p_fd;
 
-   smr_enter(pwd_smr);
-   pwd = smr_entered_load(&fdp->fd_pwd, pwd_smr);
+   vfs_smr_enter();
+   pwd = vfs_smr_entered_load(&fdp->fd_pwd);
MPASS(pwd != NULL);
if (__predict_true(refcount_acquire_if_not_zero(&pwd->pwd_refcount))) {
-   smr_exit(pwd_smr);
+   vfs_smr_exit();
return (pwd);
}
-   smr_exit(pwd_smr);
+   vfs_smr_exit();
FILEDESC_SLOCK(fdp);
pwd = pwd_hold_filedesc(fdp);
MPASS(pwd != NULL);
-   FILEDESC_SUNLOCK(fdp);
return (pwd);
 }
 
+struct pwd *
+pwd_get_smr(void)
+{
+   struct pwd *pwd;
+
+   pwd = vfs_smr_entered_load(&curproc->p_fd->fd_pwd);
+   MPASS(pwd != NULL);
+   return (pwd);
+}
+
 static struct pwd *
 pwd_alloc(void)
 {
@@ -4368,7 +4377,11 @@ filelistinit(void *dummy)
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
pwd_zone = uma_zcreate("PWD", sizeof(struct pwd), NULL, NULL,
NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_SMR);
-   pwd_smr = uma_zone_get_smr(pwd_zone);
+   /*
+* XXXMJG this is a temporary hack due to boot ordering issues against
+* the vnode zone.
+*/
+   vfs_smr = uma_zone_get_smr(pwd_zone);
mtx_init(&sigio_lock, "sigio lock", NULL, MTX_DEF);
 }
 SYSINIT(select, SI_SUB_LOCK, SI_ORDER_FIRST, filelistinit, NULL);

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSat Jul 25 10:31:52 2020(r363517)
+++ head/sys/kern/vfs_subr.cSat Jul 25 10:32:45 2020(r363518)
@@ -664,8 +664,8 @@ vntblinit(void *dummy __unused)
vnode_list_reclaim_marker = vn_alloc_marker(NULL);
TAILQ_INSERT_HEAD(&vnode_list, vnode_list_reclaim_marker, v_vnodelist);
vnode_zone = uma_zcreate("VNODE", sizeof (struct vnode), NULL, NULL,
-   vnode_init, vnode_fini, UMA_ALIGN_PTR, UMA_ZONE_SMR);
-   vfs_smr = uma_zone_get_smr(vnode_zone);
+   vnode_init, vnode_fini, UMA_ALIGN_PTR, 0);
+   uma_zone_set_smr(vnode_zone, vfs_smr);
vnodepoll_zone = uma_zcreate("VNODEPOLL", sizeof (struct vpollinfo),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
/*
@@ -2914,6 +2914,22 @@ vget_prep(struct vnode *vp)
return (vs);
 }
 
+void
+vget_abort(struct vnode *vp, enum vgetstate vs)
+{
+
+   switch (vs) {
+   case VGET_USECOUNT:
+   vrele(vp);
+   break;
+   case VGET_HOLDCNT:
+   vdrop(vp);
+   break;
+   default:
+   __assert_unreachable();
+   }
+}
+
 int
 vget(struct vnode *vp, int flags, struct thread *td)
 {
@@ -2925,7 +2941,7 @@ vget(struct vnode *vp, int flags, struct thread *td)
return (vget_finish(vp, flags, vs));
 }
 
-static int __noinline
+static void __noinline
 vget_finish_vchr(struct vnode *vp)
 {
 
@@ -2941,7 +2957,7 @@ vget_finish_vchr(struct vnode *vp)
 #else
refcount_release(&vp->v_holdcnt);
 #endif
-   return (0);
+   return;
}
 
VI_LOCK(vp);
@@ -2953,18 +2969,17 @@ vget_finish_vchr(struct vnode *vp)
refcount_release(&vp->v_holdcnt);
 #endif
VI_UNLOCK(vp);
-   return (0);
+   return;
}
v_incr_devcount(vp);
refcount_acquire(&vp->v_usecount);
VI_UNLOCK(vp);
-   return (0);
 }
 
 int
 vget_finish(struct vnode *vp, int flags, enum vgetstate vs)
 {
-   int error, old;
+   int error;
 
if ((flags & LK_INTERLOCK) != 0)
ASSERT_VI_LOCKED(vp, __func__);
@@ -2976,20 +2991,32 @@ vget_finish(str

svn commit: r363517 - in head/sys: cddl/compat/opensolaris/kern kern sys

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 10:31:52 2020
New Revision: 363517
URL: https://svnweb.freebsd.org/changeset/base/363517

Log:
  vfs: introduce vnode sequence counters
  
  Modified on each permission change and link/unlink.
  
  Reviewed by:  kib
  Tested by:pho (in a patchset)
  Differential Revision:https://reviews.freebsd.org/D25573

Modified:
  head/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
  head/sys/kern/vfs_mount.c
  head/sys/kern/vfs_subr.c
  head/sys/kern/vnode_if.src
  head/sys/sys/vnode.h

Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
==
--- head/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Sat Jul 25 
10:29:48 2020(r363516)
+++ head/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Sat Jul 25 
10:31:52 2020(r363517)
@@ -154,6 +154,7 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const cha
vput(vp);
return (error);
}
+   vn_seqc_write_begin(vp);
VOP_UNLOCK(vp);
 
/*
@@ -206,6 +207,7 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const cha
VI_LOCK(vp);
vp->v_iflag &= ~VI_MOUNT;
VI_UNLOCK(vp);
+   vn_seqc_write_end(vp);
vput(vp);
vfs_unbusy(mp);
vfs_freeopts(mp->mnt_optnew);
@@ -241,6 +243,7 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const cha
vfs_event_signal(NULL, VQ_MOUNT, 0);
if (VFS_ROOT(mp, LK_EXCLUSIVE, &mvp))
panic("mount: lost mount");
+   vn_seqc_write_end(vp);
VOP_UNLOCK(vp);
vfs_op_exit(mp);
vfs_unbusy(mp);

Modified: head/sys/kern/vfs_mount.c
==
--- head/sys/kern/vfs_mount.c   Sat Jul 25 10:29:48 2020(r363516)
+++ head/sys/kern/vfs_mount.c   Sat Jul 25 10:31:52 2020(r363517)
@@ -947,6 +947,7 @@ vfs_domount_first(
vput(vp);
return (error);
}
+   vn_seqc_write_begin(vp);
VOP_UNLOCK(vp);
 
/* Allocate and initialize the filesystem. */
@@ -979,9 +980,11 @@ vfs_domount_first(
VI_LOCK(vp);
vp->v_iflag &= ~VI_MOUNT;
VI_UNLOCK(vp);
+   vn_seqc_write_end(vp);
vrele(vp);
return (error);
}
+   vn_seqc_write_begin(newdp);
VOP_UNLOCK(newdp);
 
if (mp->mnt_opt != NULL)
@@ -1018,6 +1021,8 @@ vfs_domount_first(
EVENTHANDLER_DIRECT_INVOKE(vfs_mounted, mp, newdp, td);
VOP_UNLOCK(newdp);
mountcheckdirs(vp, newdp);
+   vn_seqc_write_end(vp);
+   vn_seqc_write_end(newdp);
vrele(newdp);
if ((mp->mnt_flag & MNT_RDONLY) == 0)
vfs_allocate_syncvnode(mp);
@@ -1094,7 +1099,9 @@ vfs_domount_update(
VOP_UNLOCK(vp);
 
vfs_op_enter(mp);
+   vn_seqc_write_begin(vp);
 
+   rootvp = NULL;
MNT_ILOCK(mp);
if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) {
MNT_IUNLOCK(mp);
@@ -1108,8 +1115,6 @@ vfs_domount_update(
mp->mnt_kern_flag &= ~MNTK_ASYNC;
rootvp = vfs_cache_root_clear(mp);
MNT_IUNLOCK(mp);
-   if (rootvp != NULL)
-   vrele(rootvp);
mp->mnt_optnew = *optlist;
vfs_mergeopts(mp->mnt_optnew, mp->mnt_opt);
 
@@ -1233,6 +1238,11 @@ vfs_domount_update(
vfs_deallocate_syncvnode(mp);
 end:
vfs_op_exit(mp);
+   if (rootvp != NULL) {
+   vn_seqc_write_end(rootvp);
+   vrele(rootvp);
+   }
+   vn_seqc_write_end(vp);
vfs_unbusy(mp);
VI_LOCK(vp);
vp->v_iflag &= ~VI_MOUNT;
@@ -1723,14 +1733,19 @@ dounmount(struct mount *mp, int flags, struct thread *
}
mp->mnt_kern_flag |= MNTK_UNMOUNT;
rootvp = vfs_cache_root_clear(mp);
+   if (coveredvp != NULL)
+   vn_seqc_write_begin(coveredvp);
if (flags & MNT_NONBUSY) {
MNT_IUNLOCK(mp);
error = vfs_check_usecounts(mp);
MNT_ILOCK(mp);
if (error != 0) {
+   vn_seqc_write_end(coveredvp);
dounmount_cleanup(mp, coveredvp, MNTK_UNMOUNT);
-   if (rootvp != NULL)
+   if (rootvp != NULL) {
+   vn_seqc_write_end(rootvp);
vrele(rootvp);
+   }
return (error);
}
}
@@ -1759,22 +1774,19 @@ dounmount(struct mount *mp, int flags, struct thread *
("%s: invalid return value for msleep in the drain path @ %s:%d",
__func__, __FILE__, __LINE__));
 
-   if (rootvp != NULL)
+   /*
+* We want to keep the vnode around so that we can vn_seqc_write_end
+ 

svn commit: r363516 - head/sys/sys

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 10:29:48 2020
New Revision: 363516
URL: https://svnweb.freebsd.org/changeset/base/363516

Log:
  seqc: add a sleepable variant and convert some routines to macros
  
  This temporarily duplicates some code.
  
  Macro conversion convinces clang to carry predicts into consumers.

Added:
  head/sys/sys/_seqc.h   (contents, props changed)
Modified:
  head/sys/sys/seqc.h

Added: head/sys/sys/_seqc.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/sys/_seqc.hSat Jul 25 10:29:48 2020(r363516)
@@ -0,0 +1,11 @@
+/*-
+ * This file is in the public domain.
+ */
+/* $FreeBSD$ */
+
+#ifndef _SYS__SEQC_H_
+#define _SYS__SEQC_H_
+
+typedef uint32_t seqc_t;
+
+#endif /* _SYS__SEQC_H */

Modified: head/sys/sys/seqc.h
==
--- head/sys/sys/seqc.h Sat Jul 25 09:28:38 2020(r363515)
+++ head/sys/sys/seqc.h Sat Jul 25 10:29:48 2020(r363516)
@@ -36,7 +36,7 @@
 /*
  * seqc_t may be included in structs visible to userspace
  */
-typedef uint32_t seqc_t;
+#include 
 
 #ifdef _KERNEL
 
@@ -45,13 +45,15 @@ typedef uint32_t seqc_t;
 
 #include 
 
-static __inline bool
-seqc_in_modify(seqc_t seqcp)
-{
+/*
+ * Predicts from inline functions are not honored by clang.
+ */
+#define seqc_in_modify(seqc)   ({  \
+   seqc_t __seqc = (seqc); \
+   \
+   __predict_false(__seqc & 1);\
+})
 
-   return (seqcp & 1);
-}
-
 static __inline void
 seqc_write_begin(seqc_t *seqcp)
 {
@@ -86,7 +88,7 @@ seqc_read(const seqc_t *seqcp)
 
for (;;) {
ret = seqc_read_any(seqcp);
-   if (__predict_false(seqc_in_modify(ret))) {
+   if (seqc_in_modify(ret)) {
cpu_spinwait();
continue;
}
@@ -96,19 +98,38 @@ seqc_read(const seqc_t *seqcp)
return (ret);
 }
 
-static __inline bool
-seqc_consistent_nomb(const seqc_t *seqcp, seqc_t oldseqc)
+#define seqc_consistent_nomb(seqcp, oldseqc)   ({  \
+   const seqc_t *__seqcp = (seqcp);\
+   seqc_t __oldseqc = (oldseqc);   \
+   \
+   MPASS(!(seqc_in_modify(__oldseqc)));\
+   __predict_true(*__seqcp == __oldseqc);  \
+})
+
+#define seqc_consistent(seqcp, oldseqc)({  \
+   atomic_thread_fence_acq();  \
+   seqc_consistent_nomb(seqcp, oldseqc);   \
+})
+
+/*
+ * Variant which does not critical enter/exit.
+ */
+static __inline void
+seqc_sleepable_write_begin(seqc_t *seqcp)
 {
 
-   return (*seqcp == oldseqc);
+   MPASS(!seqc_in_modify(*seqcp));
+   *seqcp += 1;
+   atomic_thread_fence_rel();
 }
 
-static __inline bool
-seqc_consistent(const seqc_t *seqcp, seqc_t oldseqc)
+static __inline void
+seqc_sleepable_write_end(seqc_t *seqcp)
 {
 
-   atomic_thread_fence_acq();
-   return (seqc_consistent_nomb(seqcp, oldseqc));
+   atomic_thread_fence_rel();
+   *seqcp += 1;
+   MPASS(!seqc_in_modify(*seqcp));
 }
 
 #endif /* _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: r363515 - in head/sys: dev/iommu x86/iommu

2020-07-25 Thread Ruslan Bukin
Author: br
Date: Sat Jul 25 09:28:38 2020
New Revision: 363515
URL: https://svnweb.freebsd.org/changeset/base/363515

Log:
  Split-out the Intel GAS (Guest Address Space) management component
  from Intel DMAR support, so it can be used on other IOMMU systems.
  
  Reviewed by:  kib
  Sponsored by: DARPA/AFRL
  Differential Revision:https://reviews.freebsd.org/D25743

Modified:
  head/sys/dev/iommu/iommu.h
  head/sys/x86/iommu/intel_ctx.c
  head/sys/x86/iommu/intel_dmar.h
  head/sys/x86/iommu/intel_drv.c
  head/sys/x86/iommu/intel_gas.c
  head/sys/x86/iommu/intel_idpgtbl.c
  head/sys/x86/iommu/intel_utils.c

Modified: head/sys/dev/iommu/iommu.h
==
--- head/sys/dev/iommu/iommu.h  Sat Jul 25 07:48:20 2020(r363514)
+++ head/sys/dev/iommu/iommu.h  Sat Jul 25 09:28:38 2020(r363515)
@@ -48,6 +48,10 @@ struct bus_dma_tag_common;
 struct iommu_map_entry;
 TAILQ_HEAD(iommu_map_entries_tailq, iommu_map_entry);
 
+RB_HEAD(iommu_gas_entries_tree, iommu_map_entry);
+RB_PROTOTYPE(iommu_gas_entries_tree, iommu_map_entry, rb_entry,
+iommu_gas_cmp_entries);
+
 struct iommu_qi_genseq {
u_int gen;
uint32_t seq;
@@ -107,6 +111,11 @@ struct iommu_domain {
u_int entries_cnt;  /* (d) */
struct iommu_map_entries_tailq unload_entries; /* (d) Entries to
 unload */
+   struct iommu_gas_entries_tree rb_root; /* (d) */
+   iommu_gaddr_t end;  /* (c) Highest address + 1 in
+  the guest AS */
+   struct iommu_map_entry *first_place, *last_place; /* (d) */
+   u_int flags;/* (u) */
 };
 
 struct iommu_ctx {

Modified: head/sys/x86/iommu/intel_ctx.c
==
--- head/sys/x86/iommu/intel_ctx.c  Sat Jul 25 07:48:20 2020
(r363514)
+++ head/sys/x86/iommu/intel_ctx.c  Sat Jul 25 09:28:38 2020
(r363515)
@@ -132,7 +132,7 @@ device_tag_init(struct dmar_ctx *ctx, device_t dev)
bus_addr_t maxaddr;
 
domain = (struct dmar_domain *)ctx->context.domain;
-   maxaddr = MIN(domain->end, BUS_SPACE_MAXADDR);
+   maxaddr = MIN(domain->iodom.end, BUS_SPACE_MAXADDR);
ctx->context.tag->common.ref_count = 1; /* Prevent free */
ctx->context.tag->common.impl = &bus_dma_iommu_impl;
ctx->context.tag->common.boundary = 0;
@@ -186,7 +186,7 @@ ctx_id_entry_init(struct dmar_ctx *ctx, dmar_ctx_entry
pci_get_function(ctx->context.tag->owner),
ctxp->ctx1, ctxp->ctx2));
 
-   if ((domain->flags & DMAR_DOMAIN_IDMAP) != 0 &&
+   if ((domain->iodom.flags & DMAR_DOMAIN_IDMAP) != 0 &&
(unit->hw_ecap & DMAR_ECAP_PT) != 0) {
KASSERT(domain->pgtbl_obj == NULL,
("ctx %p non-null pgtbl_obj", ctx));
@@ -254,7 +254,7 @@ domain_init_rmrr(struct dmar_domain *domain, device_t 
 * and round as neccesary.
 *
 * We also allow the overlapping RMRR entries, see
-* dmar_gas_alloc_region().
+* iommu_gas_alloc_region().
 */
start = entry->start;
end = entry->end;
@@ -282,7 +282,8 @@ domain_init_rmrr(struct dmar_domain *domain, device_t 
ma[i] = vm_page_getfake(entry->start + PAGE_SIZE * i,
VM_MEMATTR_DEFAULT);
}
-   error1 = dmar_gas_map_region(domain, entry,
+   error1 = iommu_gas_map_region((struct iommu_domain *)domain,
+   entry,
IOMMU_MAP_ENTRY_READ | IOMMU_MAP_ENTRY_WRITE,
IOMMU_MF_CANWAIT | IOMMU_MF_RMRR, ma);
/*
@@ -294,7 +295,7 @@ domain_init_rmrr(struct dmar_domain *domain, device_t 
if (error1 == 0 && entry->end != entry->start) {
IOMMU_LOCK(domain->iodom.iommu);
domain->refs++; /* XXXKIB prevent free */
-   domain->flags |= DMAR_DOMAIN_RMRR;
+   domain->iodom.flags |= DMAR_DOMAIN_RMRR;
IOMMU_UNLOCK(domain->iodom.iommu);
} else {
if (error1 != 0) {
@@ -308,7 +309,8 @@ domain_init_rmrr(struct dmar_domain *domain, device_t 
error = error1;
}
TAILQ_REMOVE(&rmrr_entries, entry, unroll_link);
-   dmar_gas_free_entry(domain, entry);
+   iommu_gas_free_entry((struct iommu_domain *)domain,
+   entry);
}
for (i = 0; i < size; i++)
vm_page_putfake(ma[i]);
@@ -320,6 +322,7 @@ domain_init_rmrr(struct dmar_domain *domain, device_t 
 static struct

svn commit: r363514 - head/sys/sys

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 07:48:20 2020
New Revision: 363514
URL: https://svnweb.freebsd.org/changeset/base/363514

Log:
  Remove duplicated content from _eventhandler.h

Modified:
  head/sys/sys/_eventhandler.h

Modified: head/sys/sys/_eventhandler.h
==
--- head/sys/sys/_eventhandler.hSat Jul 25 07:45:44 2020
(r363513)
+++ head/sys/sys/_eventhandler.hSat Jul 25 07:48:20 2020
(r363514)
@@ -70,75 +70,3 @@ struct eventhandler_entry_ ## name   
\
 struct __hack
 
 #endif
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Michael Smith 
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SYS__EVENTHANDLER_H_
-#define _SYS__EVENTHANDLER_H_
-
-#include 
-
-struct eventhandler_entry {
-   TAILQ_ENTRY(eventhandler_entry) ee_link;
-   int ee_priority;
-#defineEHE_DEAD_PRIORITY   (-1)
-   void*ee_arg;
-};
-
-typedef struct eventhandler_entry  *eventhandler_tag;
-
-/*
- * You can optionally use the EVENTHANDLER_LIST and EVENTHANDLER_DIRECT macros
- * to pre-define a symbol for the eventhandler list. This symbol can be used by
- * EVENTHANDLER_DIRECT_INVOKE, which has the advantage of not needing to do a
- * locked search of the global list of eventhandler lists. At least
- * EVENTHANDLER_LIST_DEFINE must be be used for EVENTHANDLER_DIRECT_INVOKE to
- * work. EVENTHANDLER_LIST_DECLARE is only needed if the call to
- * EVENTHANDLER_DIRECT_INVOKE is in a different compilation unit from
- * EVENTHANDLER_LIST_DEFINE. If the events are even relatively high frequency
- * it is suggested that you directly define a list for them.
- */
-struct eventhandler_list;
-#defineEVENTHANDLER_LIST_DECLARE(name) 
\
-extern struct eventhandler_list *_eventhandler_list_ ## name   \
-
-/*
- * Event handlers need to be declared, but do not need to be defined. The
- * declaration must be in scope wherever the handler is to be invoked.
- */
-#define EVENTHANDLER_DECLARE(name, type)   \
-struct eventhandler_entry_ ## name \
-{  \
-   struct eventhandler_entry   ee; \
-   typeeh_func;\
-}; \
-struct __hack
-
-#endif
___
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: r363513 - head/sys/sys

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 07:45:44 2020
New Revision: 363513
URL: https://svnweb.freebsd.org/changeset/base/363513

Log:
  Remove leftover macros for long gone vmsize mtx

Modified:
  head/sys/sys/resourcevar.h

Modified: head/sys/sys/resourcevar.h
==
--- head/sys/sys/resourcevar.h  Sat Jul 25 07:15:23 2020(r363512)
+++ head/sys/sys/resourcevar.h  Sat Jul 25 07:45:44 2020(r363513)
@@ -109,9 +109,6 @@ struct uidinfo {
 #endif
 };
 
-#defineUIDINFO_VMSIZE_LOCK(ui) mtx_lock(&((ui)->ui_vmsize_mtx))
-#defineUIDINFO_VMSIZE_UNLOCK(ui)   
mtx_unlock(&((ui)->ui_vmsize_mtx))
-
 struct proc;
 struct rusage_ext;
 struct thread;
___
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: r363512 - head/sys/kern

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 07:15:23 2020
New Revision: 363512
URL: https://svnweb.freebsd.org/changeset/base/363512

Log:
  Guard sbcompress_ktls_rx with KERN_TLS
  
  Fixes a compilation warning after r363464

Modified:
  head/sys/kern/uipc_sockbuf.c

Modified: head/sys/kern/uipc_sockbuf.c
==
--- head/sys/kern/uipc_sockbuf.cSat Jul 25 07:14:33 2020
(r363511)
+++ head/sys/kern/uipc_sockbuf.cSat Jul 25 07:15:23 2020
(r363512)
@@ -70,8 +70,10 @@ u_long sb_max_adj =
 
 static u_long sb_efficiency = 8;   /* parameter for sbreserve() */
 
+#ifdef KERN_TLS
 static voidsbcompress_ktls_rx(struct sockbuf *sb, struct mbuf *m,
 struct mbuf *n);
+#endif
 static struct mbuf *sbcut_internal(struct sockbuf *sb, int len);
 static voidsbflush_internal(struct sockbuf *sb);
 
___
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: r363511 - head/sys/kern

2020-07-25 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul 25 07:14:33 2020
New Revision: 363511
URL: https://svnweb.freebsd.org/changeset/base/363511

Log:
  Do a lockless check in kthread_suspend_check
  
  Otherwise an idle system running lockstat sleep 10 reports contention on
  process lock comming from bufdaemon.
  
  While here fix a style nit.

Modified:
  head/sys/kern/kern_kthread.c

Modified: head/sys/kern/kern_kthread.c
==
--- head/sys/kern/kern_kthread.cSat Jul 25 06:32:23 2020
(r363510)
+++ head/sys/kern/kern_kthread.cSat Jul 25 07:14:33 2020
(r363511)
@@ -441,12 +441,15 @@ kthread_suspend_check(void)
panic("%s: curthread is not a valid kthread", __func__);
 
/*
-* As long as the double-lock protection is used when accessing the
-* TDF_KTH_SUSP flag, synchronizing the read operation via proc mutex
-* is fine.
+* Setting the TDF_KTH_SUSP flag is protected by process lock.
+*
+* Do an unlocked read first to avoid serializing with all other threads
+* in the common case of not suspending.
 */
+   if ((td->td_flags & TDF_KTH_SUSP) == 0)
+   return;
PROC_LOCK(p);
-   while (td->td_flags & TDF_KTH_SUSP) {
+   while ((td->td_flags & TDF_KTH_SUSP) != 0) {
wakeup(&td->td_flags);
msleep(&td->td_flags, &p->p_mtx, PPAUSE, "ktsusp", 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"