svn commit: r343862 - in head/sys/dev/cxgbe: . common

2019-02-06 Thread Navdeep Parhar
Author: np
Date: Thu Feb  7 05:40:51 2019
New Revision: 343862
URL: https://svnweb.freebsd.org/changeset/base/343862

Log:
  cxgbe(4): Auto-dump the CIM block's logic analyzer on a TIMER0 interrupt.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hThu Feb  7 05:06:29 2019
(r343861)
+++ head/sys/dev/cxgbe/adapter.hThu Feb  7 05:40:51 2019
(r343862)
@@ -1164,6 +1164,7 @@ void free_atid(struct adapter *, int);
 void release_tid(struct adapter *, int, struct sge_wrq *);
 int cxgbe_media_change(struct ifnet *);
 void cxgbe_media_status(struct ifnet *, struct ifmediareq *);
+bool t4_os_dump_cimla(struct adapter *, int, bool);
 void t4_os_dump_devlog(struct adapter *);
 
 #ifdef DEV_NETMAP

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Thu Feb  7 05:06:29 2019
(r343861)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Thu Feb  7 05:40:51 2019
(r343862)
@@ -4356,6 +4356,10 @@ static bool sge_intr_handler(struct adapter *adap, int
  */
 static bool cim_intr_handler(struct adapter *adap, int arg, bool verbose)
 {
+   static const struct intr_action cim_host_intr_actions[] = {
+   { F_TIMER0INT, 0, t4_os_dump_cimla },
+   { 0 },
+   };
static const struct intr_details cim_host_intr_details[] = {
/* T6+ */
{ F_PCIE2CIMINTFPARERR, "CIM IBQ PCIe interface parity error" },
@@ -4400,7 +4404,7 @@ static bool cim_intr_handler(struct adapter *adap, int
.enable_reg = A_CIM_HOST_INT_ENABLE,
.fatal = 0,
.details = cim_host_intr_details,
-   .actions = NULL,
+   .actions = cim_host_intr_actions,
};
static const struct intr_details cim_host_upacc_intr_details[] = {
{ F_EEPROMWRINT, "CIM EEPROM came out of busy state" },

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Feb  7 05:06:29 2019
(r343861)
+++ head/sys/dev/cxgbe/t4_main.cThu Feb  7 05:40:51 2019
(r343862)
@@ -648,7 +648,6 @@ static int sysctl_loadavg(SYSCTL_HANDLER_ARGS);
 static int sysctl_cctrl(SYSCTL_HANDLER_ARGS);
 static int sysctl_cim_ibq_obq(SYSCTL_HANDLER_ARGS);
 static int sysctl_cim_la(SYSCTL_HANDLER_ARGS);
-static int sysctl_cim_la_t6(SYSCTL_HANDLER_ARGS);
 static int sysctl_cim_ma_la(SYSCTL_HANDLER_ARGS);
 static int sysctl_cim_pif_la(SYSCTL_HANDLER_ARGS);
 static int sysctl_cim_qcfg(SYSCTL_HANDLER_ARGS);
@@ -6026,8 +6025,7 @@ t4_sysctls(struct adapter *sc)
sysctl_cim_ibq_obq, "A", "CIM IBQ 5 (NCSI)");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cim_la",
-   CTLTYPE_STRING | CTLFLAG_RD, sc, 0,
-   chip_id(sc) <= CHELSIO_T5 ? sysctl_cim_la : sysctl_cim_la_t6,
+   CTLTYPE_STRING | CTLFLAG_RD, sc, 0, sysctl_cim_la,
"A", "CIM logic analyzer");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cim_ma_la",
@@ -7249,36 +7247,11 @@ done:
return (rc);
 }
 
-static int
-sysctl_cim_la(SYSCTL_HANDLER_ARGS)
+static void
+sbuf_cim_la4(struct adapter *sc, struct sbuf *sb, uint32_t *buf, uint32_t cfg)
 {
-   struct adapter *sc = arg1;
-   u_int cfg;
-   struct sbuf *sb;
-   uint32_t *buf, *p;
-   int rc;
+   uint32_t *p;
 
-   MPASS(chip_id(sc) <= CHELSIO_T5);
-
-   rc = -t4_cim_read(sc, A_UP_UP_DBG_LA_CFG, 1, );
-   if (rc != 0)
-   return (rc);
-
-   rc = sysctl_wire_old_buffer(req, 0);
-   if (rc != 0)
-   return (rc);
-
-   sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req);
-   if (sb == NULL)
-   return (ENOMEM);
-
-   buf = malloc(sc->params.cim_la_size * sizeof(uint32_t), M_CXGBE,
-   M_ZERO | M_WAITOK);
-
-   rc = -t4_cim_read_la(sc, buf, NULL);
-   if (rc != 0)
-   goto done;
-
sbuf_printf(sb, "Status   Data  PC%s",
cfg & F_UPDBGLACAPTPCONLY ? "" :
" LS0Stat  LS0Addr LS0Data");
@@ -7302,44 +7275,13 @@ sysctl_cim_la(SYSCTL_HANDLER_ARGS)
p[6], p[7]);
}
}
-
-   rc = sbuf_finish(sb);
-   sbuf_delete(sb);
-done:
-   free(buf, M_CXGBE);
-   return (rc);
 }
 
-static int
-sysctl_cim_la_t6(SYSCTL_HANDLER_ARGS)
+static void
+sbuf_cim_la6(struct adapter *sc, struct sbuf *sb, uint32_t *buf, uint32_t cfg)
 {
-   struct adapter *sc = arg1;
-   u_int cfg;
-   struct sbuf *sb;
-   uint32_t *buf, *p;
-   int rc;
+   uint32_t *p;
 
-   

svn commit: r343861 - in head/sys/dev/cxgbe: . common

2019-02-06 Thread Navdeep Parhar
Author: np
Date: Thu Feb  7 05:06:29 2019
New Revision: 343861
URL: https://svnweb.freebsd.org/changeset/base/343861

Log:
  cxgbe(4): Auto-dump the device log on a mailbox timeout or when the
  firmware reports an error in pcie_fw.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hThu Feb  7 04:50:16 2019
(r343860)
+++ head/sys/dev/cxgbe/adapter.hThu Feb  7 05:06:29 2019
(r343861)
@@ -1164,6 +1164,7 @@ void free_atid(struct adapter *, int);
 void release_tid(struct adapter *, int, struct sge_wrq *);
 int cxgbe_media_change(struct ifnet *);
 void cxgbe_media_status(struct ifnet *, struct ifmediareq *);
+void t4_os_dump_devlog(struct adapter *);
 
 #ifdef DEV_NETMAP
 /* t4_netmap.c */

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Thu Feb  7 04:50:16 2019
(r343860)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Thu Feb  7 05:06:29 2019
(r343861)
@@ -212,9 +212,11 @@ static void t4_report_fw_error(struct adapter *adap)
 
pcie_fw = t4_read_reg(adap, A_PCIE_FW);
if (pcie_fw & F_PCIE_FW_ERR) {
+   adap->flags &= ~FW_OK;
CH_ERR(adap, "firmware reports adapter error: %s (0x%08x)\n",
reason[G_PCIE_FW_EVAL(pcie_fw)], pcie_fw);
-   adap->flags &= ~FW_OK;
+   if (pcie_fw != 0x)
+   t4_os_dump_devlog(adap);
}
 }
 
@@ -488,13 +490,19 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int 
 * the error and also check to see if the firmware reported any
 * errors ...
 */
-   ret = (pcie_fw & F_PCIE_FW_ERR) ? -ENXIO : -ETIMEDOUT;
CH_ERR(adap, "command %#x in mbox %d timed out (0x%08x).\n",
*(const u8 *)cmd, mbox, pcie_fw);
CH_DUMP_MBOX(adap, mbox, 0, "cmdsent", cmd_rpl, true);
CH_DUMP_MBOX(adap, mbox, data_reg, "current", NULL, true);
 
-   t4_report_fw_error(adap);
+   if (pcie_fw & F_PCIE_FW_ERR) {
+   ret = -ENXIO;
+   t4_report_fw_error(adap);
+   } else {
+   ret = -ETIMEDOUT;
+   t4_os_dump_devlog(adap);
+   }
+
t4_fatal_err(adap, true);
return ret;
 }

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Feb  7 04:50:16 2019
(r343860)
+++ head/sys/dev/cxgbe/t4_main.cThu Feb  7 05:06:29 2019
(r343861)
@@ -7625,19 +7625,18 @@ static const char * const devlog_facility_strings[] = 
 };
 
 static int
-sysctl_devlog(SYSCTL_HANDLER_ARGS)
+sbuf_devlog(struct adapter *sc, struct sbuf *sb, int flags)
 {
-   struct adapter *sc = arg1;
+   int i, j, rc, nentries, first = 0;
struct devlog_params *dparams = >params.devlog;
struct fw_devlog_e *buf, *e;
-   int i, j, rc, nentries, first = 0;
-   struct sbuf *sb;
uint64_t ftstamp = UINT64_MAX;
 
if (dparams->addr == 0)
return (ENXIO);
 
-   buf = malloc(dparams->size, M_CXGBE, M_NOWAIT);
+   MPASS(flags == M_WAITOK || flags == M_NOWAIT);
+   buf = malloc(dparams->size, M_CXGBE, M_ZERO | flags);
if (buf == NULL)
return (ENOMEM);
 
@@ -7666,15 +7665,6 @@ sysctl_devlog(SYSCTL_HANDLER_ARGS)
if (buf[first].timestamp == 0)
goto done;  /* nothing in the log */
 
-   rc = sysctl_wire_old_buffer(req, 0);
-   if (rc != 0)
-   goto done;
-
-   sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req);
-   if (sb == NULL) {
-   rc = ENOMEM;
-   goto done;
-   }
sbuf_printf(sb, "%10s  %15s  %8s  %8s  %s\n",
"Seq#", "Tstamp", "Level", "Facility", "Message");
 
@@ -7697,12 +7687,49 @@ sysctl_devlog(SYSCTL_HANDLER_ARGS)
if (++i == nentries)
i = 0;
} while (i != first);
-
-   rc = sbuf_finish(sb);
-   sbuf_delete(sb);
 done:
free(buf, M_CXGBE);
return (rc);
+}
+
+static int
+sysctl_devlog(SYSCTL_HANDLER_ARGS)
+{
+   struct adapter *sc = arg1;
+   int rc;
+   struct sbuf *sb;
+
+   rc = sysctl_wire_old_buffer(req, 0);
+   if (rc != 0)
+   return (rc);
+   sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req);
+   if (sb == NULL)
+   return (ENOMEM);
+
+   rc = sbuf_devlog(sc, sb, M_WAITOK);
+   if (rc == 0)
+   rc = sbuf_finish(sb);
+   sbuf_delete(sb);
+   return (rc);
+}
+
+void
+t4_os_dump_devlog(struct adapter *sc)
+{
+   int rc;
+   struct sbuf sb;
+
+

svn commit: r343860 - head/sys/dev/pci

2019-02-06 Thread Jayachandran C.
Author: jchandra
Date: Thu Feb  7 04:50:16 2019
New Revision: 343860
URL: https://svnweb.freebsd.org/changeset/base/343860

Log:
  pci_host_generic_acpi: use IORT data for MSI/MSI-X
  
  Use the information from IORT parsing to translate the PCI RID to
  GIC ITS device ID. And similarly, use the information to find the
  PIC XREF identifier to be used for PCI devices.
  
  Reviewed by:  andrew
  Differential Revision:https://reviews.freebsd.org/D18004

Modified:
  head/sys/dev/pci/pci_host_generic_acpi.c

Modified: head/sys/dev/pci/pci_host_generic_acpi.c
==
--- head/sys/dev/pci/pci_host_generic_acpi.cThu Feb  7 03:58:29 2019
(r343859)
+++ head/sys/dev/pci/pci_host_generic_acpi.cThu Feb  7 04:50:16 2019
(r343860)
@@ -348,14 +348,52 @@ generic_pcie_acpi_route_interrupt(device_t bus, device
return (acpi_pcib_route_interrupt(bus, dev, pin, >ap_prt));
 }
 
+static u_int
+generic_pcie_get_xref(device_t pci, device_t child)
+{
+   struct generic_pcie_acpi_softc *sc;
+   uintptr_t rid;
+   u_int xref, devid;
+   int err;
+
+   sc = device_get_softc(pci);
+   err = pcib_get_id(pci, child, PCI_ID_RID, );
+   if (err != 0)
+   return (ACPI_MSI_XREF);
+   err = acpi_iort_map_pci_msi(sc->base.ecam, rid, , );
+   if (err != 0)
+   return (ACPI_MSI_XREF);
+   return (xref);
+}
+
+static u_int
+generic_pcie_map_id(device_t pci, device_t child, uintptr_t *id)
+{
+   struct generic_pcie_acpi_softc *sc;
+   uintptr_t rid;
+   u_int xref, devid;
+   int err;
+
+   sc = device_get_softc(pci);
+   err = pcib_get_id(pci, child, PCI_ID_RID, );
+   if (err != 0)
+   return (err);
+err = acpi_iort_map_pci_msi(sc->base.ecam, rid, , );
+   if (err == 0)
+   *id = devid;
+   else
+   *id = rid;  /* RID not in IORT, likely FW bug, ignore */
+   return (0);
+}
+
 static int
 generic_pcie_acpi_alloc_msi(device_t pci, device_t child, int count,
 int maxcount, int *irqs)
 {
 
 #if defined(INTRNG)
-   return (intr_alloc_msi(pci, child, ACPI_MSI_XREF, count, maxcount,
-   irqs));
+   return (intr_alloc_msi(pci, child, generic_pcie_get_xref(pci, child),
+   count, maxcount, irqs));
 #else
return (ENXIO);
 #endif
@@ -367,7 +405,8 @@ generic_pcie_acpi_release_msi(device_t pci, device_t c
 {
 
 #if defined(INTRNG)
-   return (intr_release_msi(pci, child, ACPI_MSI_XREF, count, irqs));
+   return (intr_release_msi(pci, child, generic_pcie_get_xref(pci, child),
+   count, irqs));
 #else
return (ENXIO);
 #endif
@@ -379,7 +418,8 @@ generic_pcie_acpi_map_msi(device_t pci, device_t child
 {
 
 #if defined(INTRNG)
-   return (intr_map_msi(pci, child, ACPI_MSI_XREF, irq, addr, data));
+   return (intr_map_msi(pci, child, generic_pcie_get_xref(pci, child), irq,
+   addr, data));
 #else
return (ENXIO);
 #endif
@@ -390,7 +430,8 @@ generic_pcie_acpi_alloc_msix(device_t pci, device_t ch
 {
 
 #if defined(INTRNG)
-   return (intr_alloc_msix(pci, child, ACPI_MSI_XREF, irq));
+   return (intr_alloc_msix(pci, child, generic_pcie_get_xref(pci, child),
+   irq));
 #else
return (ENXIO);
 #endif
@@ -401,7 +442,8 @@ generic_pcie_acpi_release_msix(device_t pci, device_t 
 {
 
 #if defined(INTRNG)
-   return (intr_release_msix(pci, child, ACPI_MSI_XREF, irq));
+   return (intr_release_msix(pci, child, generic_pcie_get_xref(pci, child),
+   irq));
 #else
return (ENXIO);
 #endif
@@ -412,14 +454,8 @@ generic_pcie_acpi_get_id(device_t pci, device_t child,
 uintptr_t *id)
 {
 
-   /*
-* Use the PCI RID to find the MSI ID for now, we support only 1:1
-* mapping
-*
-* On aarch64, more complex mapping would come from IORT table
-*/
if (type == PCI_ID_MSI)
-   return (pcib_get_id(pci, child, PCI_ID_RID, id));
+   return (generic_pcie_map_id(pci, child, id));
else
return (pcib_get_id(pci, child, type, id));
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343859 - head/lib/libc/x86/sys

2019-02-06 Thread Konstantin Belousov
Author: kib
Date: Thu Feb  7 03:58:29 2019
New Revision: 343859
URL: https://svnweb.freebsd.org/changeset/base/343859

Log:
  Add comment noting that the strange spelling of GenuineIntel is for reason.
  
  Requested by: rpokala
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/lib/libc/x86/sys/__vdso_gettc.c

Modified: head/lib/libc/x86/sys/__vdso_gettc.c
==
--- head/lib/libc/x86/sys/__vdso_gettc.cThu Feb  7 03:55:05 2019
(r343858)
+++ head/lib/libc/x86/sys/__vdso_gettc.cThu Feb  7 03:58:29 2019
(r343859)
@@ -100,6 +100,7 @@ rdtsc_mb_none(void)
 DEFINE_UIFUNC(static, void, rdtsc_mb, (void), static)
 {
u_int p[4];
+   /* Not a typo, string matches our cpuidp() registers use. */
static const char intel_id[] = "GenuntelineI";
 
if ((cpu_feature & CPUID_SSE2) == 0)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343858 - head/sys/vm

2019-02-06 Thread Gleb Smirnoff
Author: glebius
Date: Thu Feb  7 03:55:05 2019
New Revision: 343858
URL: https://svnweb.freebsd.org/changeset/base/343858

Log:
  Now that there is only one way to allocate a slab, remove uz_slab method.
  
  Discussed with:   jeff

Modified:
  head/sys/vm/uma_core.c
  head/sys/vm/uma_int.h

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Thu Feb  7 03:32:45 2019(r343857)
+++ head/sys/vm/uma_core.c  Thu Feb  7 03:55:05 2019(r343858)
@@ -1746,7 +1746,6 @@ zone_ctor(void *mem, int size, void *udata, int flags)
zone->uz_name = arg->name;
zone->uz_ctor = arg->ctor;
zone->uz_dtor = arg->dtor;
-   zone->uz_slab = zone_fetch_slab;
zone->uz_init = NULL;
zone->uz_fini = NULL;
zone->uz_sleeps = 0;
@@ -2797,7 +2796,7 @@ zone_import(uma_zone_t zone, void **bucket, int max, i
keg = NULL;
/* Try to keep the buckets totally full */
for (i = 0; i < max; ) {
-   if ((slab = zone->uz_slab(zone, keg, domain, flags)) == NULL)
+   if ((slab = zone_fetch_slab(zone, keg, domain, flags)) == NULL)
break;
keg = slab->us_keg;
 #ifdef NUMA

Modified: head/sys/vm/uma_int.h
==
--- head/sys/vm/uma_int.h   Thu Feb  7 03:32:45 2019(r343857)
+++ head/sys/vm/uma_int.h   Thu Feb  7 03:55:05 2019(r343858)
@@ -304,7 +304,6 @@ struct uma_slab {
 #endif
 
 typedef struct uma_slab * uma_slab_t;
-typedef uma_slab_t (*uma_slaballoc)(uma_zone_t, uma_keg_t, int, int);
 
 struct uma_zone_domain {
LIST_HEAD(,uma_bucket)  uzd_buckets;/* full buckets */
@@ -345,7 +344,7 @@ struct uma_zone {
void*uz_arg;/* Import/release argument. */
uma_inituz_init;/* Initializer for each item */
uma_finiuz_fini;/* Finalizer for each item. */
-   uma_slaballoc   uz_slab;/* Allocate a slab from the backend. */
+   void*uz_spare;
uint64_tuz_bkt_count;/* Items in bucket cache */
uint64_tuz_bkt_max; /* Maximum bucket cache size */
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343857 - head/sys/vm

2019-02-06 Thread Gleb Smirnoff
Author: glebius
Date: Thu Feb  7 03:32:45 2019
New Revision: 343857
URL: https://svnweb.freebsd.org/changeset/base/343857

Log:
  Report cache zones in UMA stats sysctl, that 'vmstat -z' uses. This
  should had been part of r251826.

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Thu Feb  7 03:01:54 2019(r343856)
+++ head/sys/vm/uma_core.c  Thu Feb  7 03:32:45 2019(r343857)
@@ -3874,19 +3874,61 @@ sysctl_vm_zone_count(SYSCTL_HANDLER_ARGS)
LIST_FOREACH(z, >uk_zones, uz_link)
count++;
}
+   LIST_FOREACH(z, _cachezones, uz_link)
+   count++;
+
rw_runlock(_rwlock);
return (sysctl_handle_int(oidp, , 0, req));
 }
 
+static void
+uma_vm_zone_stats(struct uma_type_header *uth, uma_zone_t z, struct sbuf *sbuf,
+struct uma_percpu_stat *ups, bool internal)
+{
+   uma_zone_domain_t zdom;
+   uma_cache_t cache;
+   int i;
+
+
+   for (i = 0; i < vm_ndomains; i++) {
+   zdom = >uz_domain[i];
+   uth->uth_zone_free += zdom->uzd_nitems;
+   }
+   uth->uth_allocs = counter_u64_fetch(z->uz_allocs);
+   uth->uth_frees = counter_u64_fetch(z->uz_frees);
+   uth->uth_fails = counter_u64_fetch(z->uz_fails);
+   uth->uth_sleeps = z->uz_sleeps;
+   /*
+* While it is not normally safe to access the cache
+* bucket pointers while not on the CPU that owns the
+* cache, we only allow the pointers to be exchanged
+* without the zone lock held, not invalidated, so
+* accept the possible race associated with bucket
+* exchange during monitoring.
+*/
+   for (i = 0; i < mp_maxid + 1; i++) {
+   bzero([i], sizeof(*ups));
+   if (internal || CPU_ABSENT(i))
+   continue;
+   cache = >uz_cpu[i];
+   if (cache->uc_allocbucket != NULL)
+   ups[i].ups_cache_free +=
+   cache->uc_allocbucket->ub_cnt;
+   if (cache->uc_freebucket != NULL)
+   ups[i].ups_cache_free +=
+   cache->uc_freebucket->ub_cnt;
+   ups[i].ups_allocs = cache->uc_allocs;
+   ups[i].ups_frees = cache->uc_frees;
+   }
+}
+
 static int
 sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS)
 {
struct uma_stream_header ush;
struct uma_type_header uth;
struct uma_percpu_stat *ups;
-   uma_zone_domain_t zdom;
struct sbuf sbuf;
-   uma_cache_t cache;
uma_keg_t kz;
uma_zone_t z;
int count, error, i;
@@ -3905,6 +3947,9 @@ sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS)
count++;
}
 
+   LIST_FOREACH(z, _cachezones, uz_link)
+   count++;
+
/*
 * Insert stream header.
 */
@@ -3939,44 +3984,26 @@ sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS)
if ((z->uz_flags & UMA_ZONE_SECONDARY) &&
(LIST_FIRST(>uk_zones) != z))
uth.uth_zone_flags = UTH_ZONE_SECONDARY;
-
-   for (i = 0; i < vm_ndomains; i++) {
-   zdom = >uz_domain[i];
-   uth.uth_zone_free += zdom->uzd_nitems;
-   }
-   uth.uth_allocs = counter_u64_fetch(z->uz_allocs);
-   uth.uth_frees = counter_u64_fetch(z->uz_frees);
-   uth.uth_fails = counter_u64_fetch(z->uz_fails);
-   uth.uth_sleeps = z->uz_sleeps;
-   /*
-* While it is not normally safe to access the cache
-* bucket pointers while not on the CPU that owns the
-* cache, we only allow the pointers to be exchanged
-* without the zone lock held, not invalidated, so
-* accept the possible race associated with bucket
-* exchange during monitoring.
-*/
-   for (i = 0; i < mp_maxid + 1; i++) {
-   bzero([i], sizeof(*ups));
-   if (kz->uk_flags & UMA_ZFLAG_INTERNAL ||
-   CPU_ABSENT(i))
-   continue;
-   cache = >uz_cpu[i];
-   if (cache->uc_allocbucket != NULL)
-   ups[i].ups_cache_free +=
-   cache->uc_allocbucket->ub_cnt;
-   if (cache->uc_freebucket != NULL)
-   ups[i].ups_cache_free +=
-   

svn commit: r343856 - head/sys/arm64/arm64

2019-02-06 Thread Jayachandran C.
Author: jchandra
Date: Thu Feb  7 03:01:54 2019
New Revision: 343856
URL: https://svnweb.freebsd.org/changeset/base/343856

Log:
  arm64 gicv3: add IORT and NUMA support
  
  acpi_iort.c has added support to query GIC proximity and MSI XREF
  ID for GIC ITS blocks. Use this when GIC ITS blocks are initialized
  from ACPI.
  
  Reviewed by:  andrew
  Differential Revision:https://reviews.freebsd.org/D18003

Modified:
  head/sys/arm64/arm64/gic_v3_acpi.c
  head/sys/arm64/arm64/gic_v3_var.h
  head/sys/arm64/arm64/gicv3_its.c

Modified: head/sys/arm64/arm64/gic_v3_acpi.c
==
--- head/sys/arm64/arm64/gic_v3_acpi.c  Thu Feb  7 02:56:10 2019
(r343855)
+++ head/sys/arm64/arm64/gic_v3_acpi.c  Thu Feb  7 03:01:54 2019
(r343856)
@@ -305,6 +305,8 @@ gic_v3_add_children(ACPI_SUBTABLE_HEADER *entry, void 
struct gic_v3_acpi_devinfo *di;
struct gic_v3_softc *sc;
device_t child, dev;
+   u_int xref;
+   int err, pxm;
 
if (entry->Type == ACPI_MADT_TYPE_GENERIC_TRANSLATOR) {
/* We have an ITS, add it as a child */
@@ -321,7 +323,14 @@ gic_v3_add_children(ACPI_SUBTABLE_HEADER *entry, void 
resource_list_add(>di_rl, SYS_RES_MEMORY, 0,
gict->BaseAddress, gict->BaseAddress + 128 * 1024 - 1,
128 * 1024);
-   di->di_gic_dinfo.gic_domain = -1;
+   err = acpi_iort_its_lookup(gict->TranslationId, , );
+   if (err == 0) {
+   di->di_gic_dinfo.gic_domain = pxm;
+   di->di_gic_dinfo.msi_xref = xref;
+   } else {
+   di->di_gic_dinfo.gic_domain = -1;
+   di->di_gic_dinfo.msi_xref = ACPI_MSI_XREF;
+   }
sc->gic_nchildren++;
device_set_ivars(child, di);
}

Modified: head/sys/arm64/arm64/gic_v3_var.h
==
--- head/sys/arm64/arm64/gic_v3_var.h   Thu Feb  7 02:56:10 2019
(r343855)
+++ head/sys/arm64/arm64/gic_v3_var.h   Thu Feb  7 03:01:54 2019
(r343856)
@@ -87,6 +87,7 @@ struct gic_v3_softc {
 
 struct gic_v3_devinfo {
int gic_domain;
+   int msi_xref;
 };
 
 #define GIC_INTR_ISRC(sc, irq) (>gic_irqs[irq].gi_isrc)

Modified: head/sys/arm64/arm64/gicv3_its.c
==
--- head/sys/arm64/arm64/gicv3_its.cThu Feb  7 02:56:10 2019
(r343855)
+++ head/sys/arm64/arm64/gicv3_its.cThu Feb  7 03:01:54 2019
(r343856)
@@ -1722,6 +1722,7 @@ static int
 gicv3_its_acpi_attach(device_t dev)
 {
struct gicv3_its_softc *sc;
+   struct gic_v3_devinfo *di;
int err;
 
sc = device_get_softc(dev);
@@ -1729,13 +1730,13 @@ gicv3_its_acpi_attach(device_t dev)
if (err != 0)
return (err);
 
-   sc->sc_pic = intr_pic_register(dev,
-   device_get_unit(dev) + ACPI_MSI_XREF);
+   di = device_get_ivars(dev);
+   sc->sc_pic = intr_pic_register(dev, di->msi_xref);
intr_pic_add_handler(device_get_parent(dev), sc->sc_pic,
gicv3_its_intr, sc, sc->sc_irq_base, sc->sc_irq_length);
 
/* Register this device to handle MSI interrupts */
-   intr_msi_register(dev, device_get_unit(dev) + ACPI_MSI_XREF);
+   intr_msi_register(dev, di->msi_xref);
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343855 - head/lib/libc/x86/sys

2019-02-06 Thread Konstantin Belousov
Author: kib
Date: Thu Feb  7 02:56:10 2019
New Revision: 343855
URL: https://svnweb.freebsd.org/changeset/base/343855

Log:
  Use ifunc to select the barrier instruction for RDTSC.
  
  This optimizes out runtime switch and removes yet another cpuid from
  libc.
  
  Note that this is the first use of ifunc in i386 libc, so
  ifunc-capable toolchain is required for building runnable userspace on
  i386, same as on amd64.
  
  Discussed with:   emaste
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/lib/libc/x86/sys/__vdso_gettc.c

Modified: head/lib/libc/x86/sys/__vdso_gettc.c
==
--- head/lib/libc/x86/sys/__vdso_gettc.cThu Feb  7 02:36:59 2019
(r343854)
+++ head/lib/libc/x86/sys/__vdso_gettc.cThu Feb  7 02:56:10 2019
(r343855)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2012 Konstantin Belousov 
- * Copyright (c) 2016, 2017 The FreeBSD Foundation
+ * Copyright (c) 2016, 2017, 2019 The FreeBSD Foundation
  * All rights reserved.
  *
  * Portions of this software were developed by Konstantin Belousov
@@ -50,15 +50,9 @@ __FBSDID("$FreeBSD$");
 #ifdef WANT_HYPERV
 #include 
 #endif
+#include 
 #include "libc_private.h"
 
-static enum LMB {
-   LMB_UNKNOWN,
-   LMB_NONE,
-   LMB_MFENCE,
-   LMB_LFENCE
-} lfence_works = LMB_UNKNOWN;
-
 static void
 cpuidp(u_int leaf, u_int p[4])
 {
@@ -84,68 +78,35 @@ cpuidp(u_int leaf, u_int p[4])
:  "0" (leaf));
 }
 
-static enum LMB
-select_lmb(void)
+static void
+rdtsc_mb_lfence(void)
 {
-   u_int p[4];
-   static const char intel_id[] = "GenuntelineI";
 
-   cpuidp(0, p);
-   return (memcmp(p + 1, intel_id, sizeof(intel_id) - 1) == 0 ?
-   LMB_LFENCE : LMB_MFENCE);
+   lfence();
 }
 
 static void
-init_fence(void)
+rdtsc_mb_mfence(void)
 {
-#if defined(__i386__)
-   u_int cpuid_supported, p[4];
 
-   lfence_works = LMB_NONE;
-   __asm __volatile(
-   "   pushfl\n"
-   "   popl%%eax\n"
-   "   movl%%eax,%%ecx\n"
-   "   xorl$0x20,%%eax\n"
-   "   pushl   %%eax\n"
-   "   popfl\n"
-   "   pushfl\n"
-   "   popl%%eax\n"
-   "   xorl%%eax,%%ecx\n"
-   "   je  1f\n"
-   "   movl$1,%0\n"
-   "   jmp 2f\n"
-   "1: movl$0,%0\n"
-   "2:\n"
-   : "=r" (cpuid_supported) : : "eax", "ecx", "cc");
-   if (cpuid_supported) {
-   cpuidp(0x1, p);
-   if ((p[3] & CPUID_SSE2) != 0)
-   lfence_works = select_lmb();
-   }
-#elif defined(__amd64__)
-   lfence_works = select_lmb();
-#else
-#error "Arch"
-#endif
+   mfence();
 }
 
 static void
-rdtsc_mb(void)
+rdtsc_mb_none(void)
 {
+}
 
-again:
-   if (__predict_true(lfence_works == LMB_LFENCE)) {
-   lfence();
-   return;
-   } else if (lfence_works == LMB_MFENCE) {
-   mfence();
-   return;
-   } else if (lfence_works == LMB_NONE) {
-   return;
-   }
-   init_fence();
-   goto again;
+DEFINE_UIFUNC(static, void, rdtsc_mb, (void), static)
+{
+   u_int p[4];
+   static const char intel_id[] = "GenuntelineI";
+
+   if ((cpu_feature & CPUID_SSE2) == 0)
+   return (rdtsc_mb_none);
+   cpuidp(0, p);
+   return (memcmp(p + 1, intel_id, sizeof(intel_id) - 1) == 0 ?
+   rdtsc_mb_lfence : rdtsc_mb_mfence);
 }
 
 static u_int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343853 - in head/sys: arm64/acpica conf dev/acpica

2019-02-06 Thread Jayachandran C.
Author: jchandra
Date: Thu Feb  7 02:30:33 2019
New Revision: 343853
URL: https://svnweb.freebsd.org/changeset/base/343853

Log:
  arm64 acpi: Add support for IORT table
  
  Add new file arm64/acpica/acpi_iort.c to support the "IO Remapping
  Table" (IORT). The table is specified in ARM document "ARM DEN 0049D"
  titled "IO Remapping Table Platform Design Document".  The IORT table
  has information on the associations between PCI root complexes, SMMU
  blocks and GIC ITS blocks in the system.
  
  The changes are to parse and save the information in the IORT table.
  The API to use this information is added to sys/dev/acpica/acpivar.h.
  
  The acpi_iort.c also has code to check the GIC ITS nodes seen in the
  IORT table with corresponding entries in MADT table (for validity)
  and with entries in SRAT table (for proximity information).
  
  Reviewed by:  andrew
  Differential Revision:https://reviews.freebsd.org/D18002

Added:
  head/sys/arm64/acpica/acpi_iort.c   (contents, props changed)
Modified:
  head/sys/conf/files.arm64
  head/sys/dev/acpica/acpivar.h

Added: head/sys/arm64/acpica/acpi_iort.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm64/acpica/acpi_iort.c   Thu Feb  7 02:30:33 2019
(r343853)
@@ -0,0 +1,502 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * Author: Jayachandran C Nair 
+ *
+ * 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 "opt_acpi.h"
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+/*
+ * Track next XREF available for ITS groups.
+ */
+static u_int acpi_its_xref = ACPI_MSI_XREF;
+
+/*
+ * Some types of IORT nodes have a set of mappings.  Each of them map
+ * a range of device IDs [base..end] from the current node to another
+ * node. The corresponding device IDs on destination node starts at
+ * outbase.
+ */
+struct iort_map_entry {
+   u_int   base;
+   u_int   end;
+   u_int   outbase;
+   u_int   flags;
+   u_int   out_node_offset;
+   struct iort_node*out_node;
+};
+
+/*
+ * The ITS group node does not have any outgoing mappings. It has a
+ * of a list of GIC ITS blocks which can handle the device ID. We
+ * will store the PIC XREF used by the block and the blocks proximity
+ * data here, so that it can be retrieved together.
+ */
+struct iort_its_entry {
+   u_int   its_id;
+   u_int   xref;
+   int pxm;
+};
+
+/*
+ * IORT node. Each node has some device specific data depending on the
+ * type of the node. The node can also have a set of mappings, OR in
+ * case of ITS group nodes a set of ITS entries.
+ * The nodes are kept in a TAILQ by type.
+ */
+struct iort_node {
+   TAILQ_ENTRY(iort_node)  next;   /* next entry with same type */
+   enum AcpiIortNodeType   type;   /* ACPI type */
+   u_int   node_offset;/* offset in IORT - node ID */
+   u_int   nentries;   /* items in array below */
+   u_int   usecount;   /* for bookkeeping */
+   union {
+   ACPI_IORT_ROOT_COMPLEX  pci_rc; /* PCI root complex */
+   ACPI_IORT_SMMU  smmu;
+   ACPI_IORT_SMMU_V3   smmu_v3;
+   } data;
+   union {
+   struct iort_map_entry   *mappings;  /* node mappings  */
+   struct 

svn commit: r343852 - in head/sys: i386/i386 kern x86/include

2019-02-06 Thread Konstantin Belousov
Author: kib
Date: Thu Feb  7 02:17:34 2019
New Revision: 343852
URL: https://svnweb.freebsd.org/changeset/base/343852

Log:
  Port sysctl kern.elf32.read_exec from amd64 to i386.
  
  Make it more comprehensive on i386, by not setting nx bit for any
  mapping, not just adding PF_X to all kernel-loaded ELF segments.  This
  is needed for the compatibility with older i386 programs that assume
  that read access implies exec, e.g. old X servers with hand-rolled
  module loader.
  
  Reported and tested by:   bde
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/i386/i386/pmap.c
  head/sys/kern/imgact_elf.c
  head/sys/x86/include/x86_var.h

Modified: head/sys/i386/i386/pmap.c
==
--- head/sys/i386/i386/pmap.c   Thu Feb  7 02:09:34 2019(r343851)
+++ head/sys/i386/i386/pmap.c   Thu Feb  7 02:17:34 2019(r343852)
@@ -3247,7 +3247,7 @@ retry:
if ((prot & VM_PROT_WRITE) == 0)
newpde &= ~(PG_RW | PG_M);
 #ifdef PMAP_PAE_COMP
-   if ((prot & VM_PROT_EXECUTE) == 0)
+   if ((prot & VM_PROT_EXECUTE) == 0 && !i386_read_exec)
newpde |= pg_nx;
 #endif
if (newpde != oldpde) {
@@ -3389,7 +3389,7 @@ retry:
pbits &= ~(PG_RW | PG_M);
}
 #ifdef PMAP_PAE_COMP
-   if ((prot & VM_PROT_EXECUTE) == 0)
+   if ((prot & VM_PROT_EXECUTE) == 0 && !i386_read_exec)
pbits |= pg_nx;
 #endif
 
@@ -3604,7 +3604,7 @@ __CONCAT(PMTYPE, enter)(pmap_t pmap, vm_offset_t va, v
KASSERT((newpte & (PG_M | PG_RW)) != PG_M,
("pmap_enter: flags includes VM_PROT_WRITE but prot doesn't"));
 #ifdef PMAP_PAE_COMP
-   if ((prot & VM_PROT_EXECUTE) == 0)
+   if ((prot & VM_PROT_EXECUTE) == 0 && !i386_read_exec)
newpte |= pg_nx;
 #endif
if ((flags & PMAP_ENTER_WIRED) != 0)
@@ -3841,7 +3841,7 @@ pmap_enter_4mpage(pmap_t pmap, vm_offset_t va, vm_page
if ((m->oflags & VPO_UNMANAGED) == 0)
newpde |= PG_MANAGED;
 #ifdef PMAP_PAE_COMP
-   if ((prot & VM_PROT_EXECUTE) == 0)
+   if ((prot & VM_PROT_EXECUTE) == 0 && !i386_read_exec)
newpde |= pg_nx;
 #endif
if (pmap != kernel_pmap)
@@ -4099,7 +4099,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v
if ((m->oflags & VPO_UNMANAGED) == 0)
newpte |= PG_MANAGED;
 #ifdef PMAP_PAE_COMP
-   if ((prot & VM_PROT_EXECUTE) == 0)
+   if ((prot & VM_PROT_EXECUTE) == 0 && !i386_read_exec)
newpte |= pg_nx;
 #endif
if (pmap != kernel_pmap)

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Thu Feb  7 02:09:34 2019(r343851)
+++ head/sys/kern/imgact_elf.c  Thu Feb  7 02:17:34 2019(r343852)
@@ -130,13 +130,11 @@ SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_A
 nxstack, CTLFLAG_RW, &__elfN(nxstack), 0,
 __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": enable non-executable stack");
 
-#if __ELF_WORD_SIZE == 32
-#if defined(__amd64__)
+#if __ELF_WORD_SIZE == 32 && (defined(__amd64__) || defined(__i386__))
 int i386_read_exec = 0;
 SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_RW, _read_exec, 0,
 "enable execution from readable segments");
 #endif
-#endif
 
 static Elf_Brandinfo *elf_brand_list[MAX_BRANDS];
 
@@ -2516,11 +2514,9 @@ __elfN(trans_prot)(Elf_Word flags)
prot |= VM_PROT_WRITE;
if (flags & PF_R)
prot |= VM_PROT_READ;
-#if __ELF_WORD_SIZE == 32
-#if defined(__amd64__)
+#if __ELF_WORD_SIZE == 32 && (defined(__amd64__) || defined(__i386__))
if (i386_read_exec && (flags & PF_R))
prot |= VM_PROT_EXECUTE;
-#endif
 #endif
return (prot);
 }

Modified: head/sys/x86/include/x86_var.h
==
--- head/sys/x86/include/x86_var.h  Thu Feb  7 02:09:34 2019
(r343851)
+++ head/sys/x86/include/x86_var.h  Thu Feb  7 02:17:34 2019
(r343852)
@@ -83,6 +83,7 @@ externint _ugssel;
 extern int use_xsave;
 extern uint64_t xsave_mask;
 extern u_int   max_apic_id;
+extern int i386_read_exec;
 extern int pti;
 extern int hw_ibrs_active;
 extern int hw_ssb_active;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343851 - in head/sys: i386/acpica x86/acpica

2019-02-06 Thread Konstantin Belousov
Author: kib
Date: Thu Feb  7 02:09:34 2019
New Revision: 343851
URL: https://svnweb.freebsd.org/changeset/base/343851

Log:
  Fix resume on i386 PAE.
  
  It was broken before PAE/no-PAE merge, but since now PAE is the
  default, resume is apparently becomes for all machines.
  
  The corrected issues:
  - the trampoline page is not mapped executable, so machine faults when
paging is on;
  - MSR.EFER and %cr4 both should be loaded before paging is enabled,
otherwise paging structures are invalid (cr4.PAE and EFER.NX).
  - MSR.EFER and %cr4 should be only loaded if present.  I attempt to handle
this by not touching the registers if the value is zero.
  
  There are some more bits still not quite correct, e.g. unconditional
  access to %cr4 in resumectx.
  
  Reported and debugging help by:   bde
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/i386/acpica/acpi_wakecode.S
  head/sys/x86/acpica/acpi_wakeup.c

Modified: head/sys/i386/acpica/acpi_wakecode.S
==
--- head/sys/i386/acpica/acpi_wakecode.SThu Feb  7 02:00:23 2019
(r343850)
+++ head/sys/i386/acpica/acpi_wakecode.SThu Feb  7 02:09:34 2019
(r343851)
@@ -143,16 +143,26 @@ wakeup_32:
mov $bootdata32 - bootgdt, %eax
mov %ax, %ds
 
-   /* Get PCB and return address. */
-   movlwakeup_pcb - wakeup_start(%ebx), %ecx
-   movlwakeup_ret - wakeup_start(%ebx), %edx
-
-   /* Restore CR4 and CR3. */
-   movlwakeup_cr4 - wakeup_start(%ebx), %eax
+   /* Restore EFER, CR4 and CR3. */
+   movlwakeup_efer - wakeup_start(%ebx), %eax
+   movlwakeup_efer - wakeup_start + 4(%ebx), %edx
+   cmpl$0, %eax
+   jne 1f
+   cmpl$0, %edx
+   je  2f
+1: movl$MSR_EFER, %ecx
+   wrmsr
+2: movlwakeup_cr4 - wakeup_start(%ebx), %eax
+   cmpl$0, %eax
+   je  3f
mov %eax, %cr4
-   movlwakeup_cr3 - wakeup_start(%ebx), %eax
+3: movlwakeup_cr3 - wakeup_start(%ebx), %eax
mov %eax, %cr3
 
+   /* Get PCB and return address. */
+   movlwakeup_ret - wakeup_start(%ebx), %edx
+   movlwakeup_pcb - wakeup_start(%ebx), %ecx
+
/* Enable paging. */
mov %cr0, %eax
orl $CR0_PG, %eax
@@ -187,6 +197,9 @@ bootgdtdesc:
.long   bootgdt - wakeup_start  /* Offset plus %ds << 4 */
 
ALIGN_DATA
+wakeup_efer:
+   .long   0
+   .long   0
 wakeup_cr4:
.long   0
 wakeup_cr3:

Modified: head/sys/x86/acpica/acpi_wakeup.c
==
--- head/sys/x86/acpica/acpi_wakeup.c   Thu Feb  7 02:00:23 2019
(r343850)
+++ head/sys/x86/acpica/acpi_wakeup.c   Thu Feb  7 02:09:34 2019
(r343851)
@@ -260,6 +260,8 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
WAKECODE_FIXUP(wakeup_efer, uint64_t, rdmsr(MSR_EFER) &
~(EFER_LMA));
 #else
+   if ((amd_feature & AMDID_NX) != 0)
+   WAKECODE_FIXUP(wakeup_efer, uint64_t, rdmsr(MSR_EFER));
WAKECODE_FIXUP(wakeup_cr4, register_t, pcb->pcb_cr4);
 #endif
WAKECODE_FIXUP(wakeup_pcb, struct pcb *, pcb);
@@ -375,8 +377,12 @@ acpi_alloc_wakeup_handler(void *wakepages[ACPI_WAKEPAG
 * page-aligned.
 */
for (i = 0; i < ACPI_WAKEPAGES; i++) {
-   wakepages[i] = contigmalloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT,
-   0x500, 0xa, PAGE_SIZE, 0ul);
+   wakepages[i] = contigmalloc(PAGE_SIZE, M_DEVBUF,
+   M_NOWAIT
+#ifdef __i386__
+| M_EXEC
+#endif
+   , 0x500, 0xa, PAGE_SIZE, 0ul);
if (wakepages[i] == NULL) {
printf("%s: can't alloc wake memory\n", __func__);
goto freepages;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343850 - head/sys/vm

2019-02-06 Thread Konstantin Belousov
Author: kib
Date: Thu Feb  7 02:00:23 2019
New Revision: 343850
URL: https://svnweb.freebsd.org/changeset/base/343850

Log:
  contigmalloc: handle M_EXEC.
  
  Reviewed by:  alc, markj
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D19092

Modified:
  head/sys/vm/vm_kern.c

Modified: head/sys/vm/vm_kern.c
==
--- head/sys/vm/vm_kern.c   Thu Feb  7 01:55:11 2019(r343849)
+++ head/sys/vm/vm_kern.c   Thu Feb  7 02:00:23 2019(r343850)
@@ -184,6 +184,7 @@ kmem_alloc_attr_domain(int domain, vm_size_t size, int
vm_offset_t addr, i, offset;
vm_page_t m;
int pflags, tries;
+   vm_prot_t prot;
 
size = round_page(size);
vmem = vm_dom[domain].vmd_kernel_arena;
@@ -193,6 +194,7 @@ kmem_alloc_attr_domain(int domain, vm_size_t size, int
pflags = malloc2vm_flags(flags) | VM_ALLOC_NOBUSY | VM_ALLOC_WIRED;
pflags &= ~(VM_ALLOC_NOWAIT | VM_ALLOC_WAITOK | VM_ALLOC_WAITFAIL);
pflags |= VM_ALLOC_NOWAIT;
+   prot = (flags & M_EXEC) != 0 ? VM_PROT_ALL : VM_PROT_RW;
VM_OBJECT_WLOCK(object);
for (i = 0; i < size; i += PAGE_SIZE) {
tries = 0;
@@ -220,8 +222,8 @@ retry:
if ((flags & M_ZERO) && (m->flags & PG_ZERO) == 0)
pmap_zero_page(m);
m->valid = VM_PAGE_BITS_ALL;
-   pmap_enter(kernel_pmap, addr + i, m, VM_PROT_RW,
-   VM_PROT_RW | PMAP_ENTER_WIRED, 0);
+   pmap_enter(kernel_pmap, addr + i, m, prot,
+   prot | PMAP_ENTER_WIRED, 0);
}
VM_OBJECT_WUNLOCK(object);
return (addr);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343845 - head/share/mk

2019-02-06 Thread Enji Cooper
Author: ngie
Date: Wed Feb  6 21:24:44 2019
New Revision: 343845
URL: https://svnweb.freebsd.org/changeset/base/343845

Log:
  Clean up all directories created by `make hier`
  
  The logic I introduced in r322511 unfortunately left chflags schg'ed
  directories behind created by `make hier` (in the stock /etc/mtree
  files, this is limited to /var/empty).
  
  The proposed change calls `chflags -R 0` and `rm -Rf ...` to clean all
  of the directories that could not be removed by `${MAKE} clean`.
  `${MAKE} clean` in bsd.obj.mk calls `cleandir`/`cleanobj`, which handles
  the first directory tree walk/removal.
  
  Approved by:  emaste (mentor)
  MFC after:1 week
  Differential Revision: https://reviews.freebsd.org/D18641

Modified:
  head/share/mk/suite.test.mk

Modified: head/share/mk/suite.test.mk
==
--- head/share/mk/suite.test.mk Wed Feb  6 20:18:22 2019(r343844)
+++ head/share/mk/suite.test.mk Wed Feb  6 21:24:44 2019(r343845)
@@ -120,5 +120,7 @@ beforecheck:
 #   etc.
 aftercheck:
@cd ${.CURDIR} && ${MAKE} clean
+   @chflags -R 0 "${DESTDIR}"
+   @rm -Rf "${DESTDIR}"
 
 .endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343844 - in head/sys/dev/usb: . net

2019-02-06 Thread Gavin Atkinson
Author: gavin
Date: Wed Feb  6 20:18:22 2019
New Revision: 343844
URL: https://svnweb.freebsd.org/changeset/base/343844

Log:
  Support the Lenovo OneLink in ure(4).
  
  MFC after:1 week

Modified:
  head/sys/dev/usb/net/if_ure.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/net/if_ure.c
==
--- head/sys/dev/usb/net/if_ure.c   Wed Feb  6 19:22:15 2019
(r343843)
+++ head/sys/dev/usb/net/if_ure.c   Wed Feb  6 20:18:22 2019
(r343844)
@@ -69,6 +69,7 @@ static const STRUCT_USB_HOST_ID ure_devs[] = {
 #defineURE_DEV(v,p,i)  { USB_VPI(USB_VENDOR_##v, 
USB_PRODUCT_##v##_##p, i) }
URE_DEV(LENOVO, RTL8153, 0),
URE_DEV(LENOVO, TBT3LAN, 0),
+   URE_DEV(LENOVO, ONELINK, 0),
URE_DEV(LENOVO, USBCLAN, 0),
URE_DEV(NVIDIA, RTL8153, 0),
URE_DEV(REALTEK, RTL8152, URE_FLAG_8152),

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsWed Feb  6 19:22:15 2019(r343843)
+++ head/sys/dev/usb/usbdevsWed Feb  6 20:18:22 2019(r343844)
@@ -2782,6 +2782,7 @@ product LEADTEK 9531  0x2101  9531 GPS
 product LENOVO GIGALAN 0x304b  USB 3.0 Ethernet
 product LENOVO ETHERNET0x7203  USB 2.0 Ethernet
 product LENOVO RTL8153 0x7205  USB 3.0 Ethernet
+product LENOVO ONELINK 0x720a  USB 3.0 Ethernet
 product LENOVO TBT3LAN 0x3069  LAN port in Thinkpad TB3 dock
 product LENOVO USBCLAN 0x3062  LAN port in Thinkpad USB-C dock
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2019-02-06 Thread Ed Maste
Author: emaste
Date: Wed Feb  6 19:22:15 2019
New Revision: 343843
URL: https://svnweb.freebsd.org/changeset/base/343843

Log:
  riscv: default to non-executable stack
  
  There's no need to worry about potential backwards compatibility issues
  in a brand-new architecture, so avoid stack PROT_EXEC as with arm64.
  
  Discussed with:   br

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

Modified: head/sys/riscv/riscv/elf_machdep.c
==
--- head/sys/riscv/riscv/elf_machdep.c  Wed Feb  6 18:50:48 2019
(r343842)
+++ head/sys/riscv/riscv/elf_machdep.c  Wed Feb  6 19:22:15 2019
(r343843)
@@ -77,7 +77,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_maxuser = VM_MAXUSER_ADDRESS,
.sv_usrstack= USRSTACK,
.sv_psstrings   = PS_STRINGS,
-   .sv_stackprot   = VM_PROT_ALL,
+   .sv_stackprot   = VM_PROT_READ | VM_PROT_WRITE,
.sv_copyout_strings = exec_copyout_strings,
.sv_setregs = exec_setregs,
.sv_fixlimit= NULL,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343842 - head/usr.bin/vtfontcvt

2019-02-06 Thread Ed Maste
Author: emaste
Date: Wed Feb  6 18:50:48 2019
New Revision: 343842
URL: https://svnweb.freebsd.org/changeset/base/343842

Log:
  vtfontcvt: whitespace cleanup
  
  PR:   205707
  Submitted by: Dmitry Wagin

Modified:
  head/usr.bin/vtfontcvt/vtfontcvt.c

Modified: head/usr.bin/vtfontcvt/vtfontcvt.c
==
--- head/usr.bin/vtfontcvt/vtfontcvt.c  Wed Feb  6 18:43:30 2019
(r343841)
+++ head/usr.bin/vtfontcvt/vtfontcvt.c  Wed Feb  6 18:50:48 2019
(r343842)
@@ -63,10 +63,10 @@ struct glyph {
 TAILQ_HEAD(glyph_list, glyph);
 static SLIST_HEAD(, glyph) glyph_hash[FONTCVT_NHASH];
 static struct glyph_list glyphs[VFNT_MAPS] = {
-TAILQ_HEAD_INITIALIZER(glyphs[0]),
-TAILQ_HEAD_INITIALIZER(glyphs[1]),
-TAILQ_HEAD_INITIALIZER(glyphs[2]),
-TAILQ_HEAD_INITIALIZER(glyphs[3]),
+   TAILQ_HEAD_INITIALIZER(glyphs[0]),
+   TAILQ_HEAD_INITIALIZER(glyphs[1]),
+   TAILQ_HEAD_INITIALIZER(glyphs[2]),
+   TAILQ_HEAD_INITIALIZER(glyphs[3]),
 };
 static unsigned int glyph_total, glyph_count[4], glyph_unique, glyph_dupe;
 
@@ -79,10 +79,10 @@ struct mapping {
 
 TAILQ_HEAD(mapping_list, mapping);
 static struct mapping_list maps[VFNT_MAPS] = {
-TAILQ_HEAD_INITIALIZER(maps[0]),
-TAILQ_HEAD_INITIALIZER(maps[1]),
-TAILQ_HEAD_INITIALIZER(maps[2]),
-TAILQ_HEAD_INITIALIZER(maps[3]),
+   TAILQ_HEAD_INITIALIZER(maps[0]),
+   TAILQ_HEAD_INITIALIZER(maps[1]),
+   TAILQ_HEAD_INITIALIZER(maps[2]),
+   TAILQ_HEAD_INITIALIZER(maps[3]),
 };
 static unsigned int mapping_total, map_count[4], map_folded_count[4],
 mapping_unique, mapping_dupe;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325728 - head/lib/libkvm

2019-02-06 Thread Will Andrews
On Tue, Feb 5, 2019 at 10:25 AM Bruce Evans  wrote:

> Signed kp_offset seems wrong.  Apart from it not reaching the top of 64-
> bit address spaces, adding unsigned kp_len to it gives an unsigned type.
>

It's appropriate, because in this context, we return page information
including addresses that would be valid pointer references, but are not
included in the core file.  Minidumps omit large numbers of physical pages,
so calls to kvm_walk_pages() will generate large numbers of kvm_page
instances that have an offset of -1.

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


svn commit: r343839 - in head/sys: amd64/conf conf i386/conf

2019-02-06 Thread Ed Maste
Author: emaste
Date: Wed Feb  6 17:21:25 2019
New Revision: 343839
URL: https://svnweb.freebsd.org/changeset/base/343839

Log:
  Retire SPX_HACK option unused after r342244

Modified:
  head/sys/amd64/conf/NOTES
  head/sys/conf/options
  head/sys/i386/conf/NOTES

Modified: head/sys/amd64/conf/NOTES
==
--- head/sys/amd64/conf/NOTES   Wed Feb  6 16:30:08 2019(r343838)
+++ head/sys/amd64/conf/NOTES   Wed Feb  6 17:21:25 2019(r343839)
@@ -612,9 +612,6 @@ options EFIRT
 # Enable 32-bit runtime support for FreeBSD/i386 binaries.
 optionsCOMPAT_FREEBSD32
 
-# Emulate spx device for client side of SVR3 local X interface
-#XXX#options   SPX_HACK
-
 # Enable (32-bit) a.out binary support
 optionsCOMPAT_AOUT
 

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Wed Feb  6 16:30:08 2019(r343838)
+++ head/sys/conf/options   Wed Feb  6 17:21:25 2019(r343839)
@@ -201,7 +201,6 @@ SCHED_STATS opt_sched.h
 SCHED_ULE  opt_sched.h
 SLEEPQUEUE_PROFILING
 SLHCI_DEBUGopt_slhci.h
-SPX_HACK
 STACK  opt_stack.h
 SUIDDIR
 MSGMNB opt_sysvipc.h

Modified: head/sys/i386/conf/NOTES
==
--- head/sys/i386/conf/NOTESWed Feb  6 16:30:08 2019(r343838)
+++ head/sys/i386/conf/NOTESWed Feb  6 17:21:25 2019(r343839)
@@ -885,9 +885,6 @@ options NKPT=31
 #
 # ABI Emulation
 
-# Emulate spx device for client side of SVR3 local X interface
-optionsSPX_HACK
-
 # Enable (32-bit) a.out binary support
 optionsCOMPAT_AOUT
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343838 - head/share/mk

2019-02-06 Thread Ed Maste
Author: emaste
Date: Wed Feb  6 16:30:08 2019
New Revision: 343838
URL: https://svnweb.freebsd.org/changeset/base/343838

Log:
  Retire CTM option after r342126

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

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed Feb  6 13:01:21 2019(r343837)
+++ head/share/mk/src.opts.mk   Wed Feb  6 16:30:08 2019(r343838)
@@ -83,7 +83,6 @@ __DEFAULT_YES_OPTIONS = \
 CPP \
 CROSS_COMPILER \
 CRYPT \
-CTM \
 CUSE \
 CXX \
 CXGBETOOL \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r343837 - head/sys/net80211

2019-02-06 Thread Andriy Voskoboinyk
Author: avos
Date: Wed Feb  6 13:01:21 2019
New Revision: 343837
URL: https://svnweb.freebsd.org/changeset/base/343837

Log:
  net80211(4): validate supplied roam:rate values from ifconfig(8)
  
  MFC after:4 days

Modified:
  head/sys/net80211/ieee80211_ioctl.c

Modified: head/sys/net80211/ieee80211_ioctl.c
==
--- head/sys/net80211/ieee80211_ioctl.c Wed Feb  6 12:31:07 2019
(r343836)
+++ head/sys/net80211/ieee80211_ioctl.c Wed Feb  6 13:01:21 2019
(r343837)
@@ -2204,18 +2204,6 @@ ieee80211_ioctl_setregdomain(struct ieee80211vap *vap,
 }
 
 static int
-ieee80211_ioctl_setroam(struct ieee80211vap *vap,
-   const struct ieee80211req *ireq)
-{
-   if (ireq->i_len != sizeof(vap->iv_roamparms))
-   return EINVAL;
-   /* XXX validate params */
-   /* XXX? ENETRESET to push to device? */
-   return copyin(ireq->i_data, vap->iv_roamparms,
-   sizeof(vap->iv_roamparms));
-}
-
-static int
 checkrate(const struct ieee80211_rateset *rs, int rate)
 {
int i;
@@ -2242,6 +2230,73 @@ checkmcs(const struct ieee80211_htrateset *rs, int mcs
if (IEEE80211_RV(rs->rs_rates[i]) == rate_val)
return 1;
return 0;
+}
+
+static int
+ieee80211_ioctl_setroam(struct ieee80211vap *vap,
+const struct ieee80211req *ireq)
+{
+   struct ieee80211com *ic = vap->iv_ic;
+   struct ieee80211_roamparams_req *parms;
+   struct ieee80211_roamparam *src, *dst;
+   const struct ieee80211_htrateset *rs_ht;
+   const struct ieee80211_rateset *rs;
+   int changed, error, mode, is11n, nmodes;
+
+   if (ireq->i_len != sizeof(vap->iv_roamparms))
+   return EINVAL;
+
+   parms = IEEE80211_MALLOC(sizeof(*parms), M_TEMP,
+   IEEE80211_M_NOWAIT | IEEE80211_M_ZERO);
+   if (parms == NULL)
+   return ENOMEM;
+
+   error = copyin(ireq->i_data, parms, ireq->i_len);
+   if (error != 0)
+   goto fail;
+
+   changed = 0;
+   nmodes = IEEE80211_MODE_MAX;
+
+   /* validate parameters and check if anything changed */
+   for (mode = IEEE80211_MODE_11A; mode < nmodes; mode++) {
+   if (isclr(ic->ic_modecaps, mode))
+   continue;
+   src = >params[mode];
+   dst = >iv_roamparms[mode];
+   rs = >ic_sup_rates[mode];   /* NB: 11n maps to legacy */
+   rs_ht = >ic_sup_htrates;
+   is11n = (mode == IEEE80211_MODE_11NA ||
+mode == IEEE80211_MODE_11NG);
+   /* XXX TODO: 11ac */
+   if (src->rate != dst->rate) {
+   if (!checkrate(rs, src->rate) &&
+   (!is11n || !checkmcs(rs_ht, src->rate))) {
+   error = EINVAL;
+   goto fail;
+   }
+   changed++;
+   }
+   if (src->rssi != dst->rssi)
+   changed++;
+   }
+   if (changed) {
+   /*
+* Copy new parameters in place and notify the
+* driver so it can push state to the device.
+*/
+   /* XXX locking? */
+   for (mode = IEEE80211_MODE_11A; mode < nmodes; mode++) {
+   if (isset(ic->ic_modecaps, mode))
+   vap->iv_roamparms[mode] = parms->params[mode];
+   }
+
+   if (vap->iv_roaming == IEEE80211_ROAMING_DEVICE)
+   error = ERESTART;
+   }
+
+fail:  IEEE80211_FREE(parms, M_TEMP);
+   return error;
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r342634 - in head/sys: arm/broadcom/bcm2835 arm/nvidia arm/ti dev/sdhci

2019-02-06 Thread Marius Strobl
On Tue, Feb 05, 2019 at 05:45:06PM -0500, Ed Maste wrote:
> On Sun, 30 Dec 2018 at 18:08, Marius Strobl  wrote:
> >
> > Author: marius
> > Date: Sun Dec 30 23:08:06 2018
> > New Revision: 342634
> > URL: https://svnweb.freebsd.org/changeset/base/342634
> >
> > Log:
> >   o Don't allocate resources for SDMA in sdhci(4) if the controller or the
> ...
> 
> It seems this change introduced a panic on boot on the Jetson TK1
> platform, see PR 235542. Can you please take a look at the PR and
> suggest next steps for debugging?

Done, however, to the best of my knowledge, that panic is due to a
bug in the ARMv6 bus_dma(9) implementation an ARM maintainer needs
to look at.

Marius

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