Re: svn commit: r365640 - in head: share/man/man5 share/man/man7 tools/build/options

2020-09-12 Thread Gordon Bergling
Hi Niclas,

On Sat, Sep 12, 2020 at 09:13:33PM +0200, Niclas Zeising wrote:
> On 2020-09-11 20:09, Gordon Bergling wrote:
> > Author: gbe (doc committer)
> > Date: Fri Sep 11 18:09:49 2020
> > New Revision: 365640
> > URL: https://svnweb.freebsd.org/changeset/base/365640
> > 
> > Log:
> >Improvements for the src.conf(5) and build(7) man pages
> >
> >PR:  203863 (based on)
> >Submitted by:Russell Haley 
> >Reviewed by: bcr, imp
> >Approved by: imp
> >MFC after:   1 week
> >Differential Revision:   https://reviews.freebsd.org/D26343
> > 
> > Modified:
> >head/share/man/man5/src.conf.5
> >head/share/man/man7/build.7
> >head/tools/build/options/makeman
> > 
> > Modified: head/share/man/man5/src.conf.5
> > ==
> > --- head/share/man/man5/src.conf.5  Fri Sep 11 17:05:09 2020
> > (r365639)
> > +++ head/share/man/man5/src.conf.5  Fri Sep 11 18:09:49 2020
> > (r365640)
> > @@ -1,6 +1,6 @@
> >   .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
> 
> As the comment above hints, this file is generated by a tool, and should 
> not be edited directly.  This will be overwritten the next time someone 
> regenerates the manual page.  You have to update the template in 
> tools/build/options/makeman and regenerate the manual from there.

I did updated 'tools/build/options/makeman' with this commit. I justed commited
the newly generated src.conf.5 alongside and not with a separate commit.

> >   .\" $FreeBSD$
> > -.Dd September 8, 2020
> > +.Dd September 11, 2020
> >   .Dt SRC.CONF 5
> >   .Os
> >   .Sh NAME
> > @@ -9,7 +9,8 @@
> >   .Sh DESCRIPTION
> >   The
> >   .Nm
> > -file contains settings that will apply to every build involving the
> > +file contains variables that control what components will be generated 
> > during
> > +the build process of the
> >   .Fx
> >   source tree; see
> >   .Xr build 7 .
> > 
> 
> Regards
> -- 
> Niclas Zeising

-- Gordon
___
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: r365678 - head/sys/powerpc/aim

2020-09-12 Thread Brandon Bergren
Author: bdragon
Date: Sat Sep 12 23:54:57 2020
New Revision: 365678
URL: https://svnweb.freebsd.org/changeset/base/365678

Log:
  [PowerPC] Add PVO_PADDR macro to mmu_oea.c to match mmu_oea64.c changes
  
  Use a PVO_PADDR macro on 32 bit as well, to reduce the difference between
  mmu_oea.c and mmu_oea64.c.
  
  Equivilent to the changes in r363222.

Modified:
  head/sys/powerpc/aim/mmu_oea.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Sat Sep 12 23:49:43 2020
(r365677)
+++ head/sys/powerpc/aim/mmu_oea.c  Sat Sep 12 23:54:57 2020
(r365678)
@@ -157,6 +157,9 @@ __FBSDID("$FreeBSD$");
 #defineVSID_TO_SR(vsid)((vsid) & 0xf)
 #defineVSID_TO_HASH(vsid)  (((vsid) >> 4) & 0xf)
 
+/* Get physical address from PVO. */
+#define PVO_PADDR(pvo) ((pvo)->pvo_pte.pte.pte_lo & PTE_RPGN)
+
 struct ofw_map {
vm_offset_t om_va;
vm_size_t   om_len;
@@ -1265,7 +1268,7 @@ moea_extract(pmap_t pm, vm_offset_t va)
if (pvo == NULL)
pa = 0;
else
-   pa = (pvo->pvo_pte.pte.pte_lo & PTE_RPGN) | (va & ADDR_POFF);
+   pa = PVO_PADDR(pvo) | (va & ADDR_POFF);
PMAP_UNLOCK(pm);
return (pa);
 }
@@ -1287,7 +1290,7 @@ moea_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_
if (pvo != NULL && (pvo->pvo_pte.pte.pte_hi & PTE_VALID) &&
((pvo->pvo_pte.pte.pte_lo & PTE_PP) == PTE_RW ||
 (prot & VM_PROT_WRITE) == 0)) {
-   m = PHYS_TO_VM_PAGE(pvo->pvo_pte.pte.pte_lo & PTE_RPGN);
+   m = PHYS_TO_VM_PAGE(PVO_PADDR(pvo));
if (!vm_page_wire_mapped(m))
m = NULL;
}
@@ -1535,7 +1538,7 @@ moea_kextract(vm_offset_t va)
PMAP_LOCK(kernel_pmap);
pvo = moea_pvo_find_va(kernel_pmap, va & ~ADDR_POFF, NULL);
KASSERT(pvo != NULL, ("moea_kextract: no addr found"));
-   pa = (pvo->pvo_pte.pte.pte_lo & PTE_RPGN) | (va & ADDR_POFF);
+   pa = PVO_PADDR(pvo) | (va & ADDR_POFF);
PMAP_UNLOCK(kernel_pmap);
return (pa);
 }
@@ -2001,7 +2004,7 @@ moea_pvo_enter(pmap_t pm, uma_zone_t zone, struct pvo_
mtx_lock(_table_mutex);
LIST_FOREACH(pvo, _pvo_table[ptegidx], pvo_olink) {
if (pvo->pvo_pmap == pm && PVO_VADDR(pvo) == va) {
-   if ((pvo->pvo_pte.pte.pte_lo & PTE_RPGN) == pa &&
+   if (PVO_PADDR(pvo) == pa &&
(pvo->pvo_pte.pte.pte_lo & PTE_PP) ==
(pte_lo & PTE_PP)) {
/*
@@ -2129,7 +2132,7 @@ moea_pvo_remove(struct pvo_entry *pvo, int pteidx)
if ((pvo->pvo_vaddr & PVO_MANAGED) == PVO_MANAGED) {
struct vm_page *pg;
 
-   pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pte.pte_lo & PTE_RPGN);
+   pg = PHYS_TO_VM_PAGE(PVO_PADDR(pvo));
if (pg != NULL) {
moea_attr_save(pg, pvo->pvo_pte.pte.pte_lo &
(PTE_REF | PTE_CHG));
@@ -2696,8 +2699,7 @@ moea_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t 
len = MIN(lim - va, sz);
pvo = moea_pvo_find_va(pm, va & ~ADDR_POFF, NULL);
if (pvo != NULL) {
-   pa = (pvo->pvo_pte.pte.pte_lo & PTE_RPGN) |
-   (va & ADDR_POFF);
+   pa = PVO_PADDR(pvo) | (va & ADDR_POFF);
moea_syncicache(pa, len);
}
va += len;
___
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: r365677 - head/sys/arm/broadcom/bcm2835

2020-09-12 Thread Mike Karels
Author: karels
Date: Sat Sep 12 23:49:43 2020
New Revision: 365677
URL: https://svnweb.freebsd.org/changeset/base/365677

Log:
  bcm2838_pci.c: Respect DMA limits of controller.
  
  Fixes for Raspberry Pi 4B PCIe / USB:
  - Pass through a DMA tag for the controller.
  - In theory the controller can access the lower 3 GB, but testing found
that unreliable. OpenBSD also restricts DMA to the lowest 960 MiB.
  - Rename some constants to be a bit more meaningful.
  
  Submitted by: Robert Crowston, crowston at protonmail.com
  Reviewed by:  mkarels, outside reviewers
  Differential Revision:https://reviews.freebsd.org/D26344

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2838_pci.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2838_pci.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2838_pci.c Sat Sep 12 23:23:16 2020
(r365676)
+++ head/sys/arm/broadcom/bcm2835/bcm2838_pci.c Sat Sep 12 23:49:43 2020
(r365677)
@@ -57,9 +57,6 @@ __FBSDID("$FreeBSD$");
 #include "pcib_if.h"
 #include "msi_if.h"
 
-extern struct bus_space memmap_bus;
-
-#define BUS_SPACE_3G_MAXADDR   0xc000
 #define PCI_ID_VAL30x43c
 #define CLASS_SHIFT0x10
 #define SUBCLASS_SHIFT 0x8
@@ -69,18 +66,18 @@ extern struct bus_space memmap_bus;
 #define BRIDGE_DISABLE_FLAG0x1
 #define BRIDGE_RESET_FLAG  0x2
 #define REG_BRIDGE_SERDES_MODE 0x4204
-#define REG_BRIDGE_CONFIG  0x4008
-#define REG_BRIDGE_MEM_WINDOW_LOW  0x4034
-#define REG_BRIDGE_MEM_WINDOW_HIGH 0x4038
-#define REG_BRIDGE_MEM_WINDOW_10x403c
+#define REG_DMA_CONFIG 0x4008
+#define REG_DMA_WINDOW_LOW 0x4034
+#define REG_DMA_WINDOW_HIGH0x4038
+#define REG_DMA_WINDOW_1   0x403c
 #define REG_BRIDGE_GISB_WINDOW 0x402c
 #define REG_BRIDGE_STATE   0x4068
 #define REG_BRIDGE_LINK_STATE  0x00bc
-#define REG_BRIDGE_BUS_WINDOW_LOW  0x400c
-#define REG_BRIDGE_BUS_WINDOW_HIGH 0x4010
-#define REG_BRIDGE_CPU_WINDOW_LOW  0x4070
-#define REG_BRIDGE_CPU_WINDOW_START_HIGH   0x4080
-#define REG_BRIDGE_CPU_WINDOW_END_HIGH 0x4084
+#define REG_BUS_WINDOW_LOW 0x400c
+#define REG_BUS_WINDOW_HIGH0x4010
+#define REG_CPU_WINDOW_LOW 0x4070
+#define REG_CPU_WINDOW_START_HIGH  0x4080
+#define REG_CPU_WINDOW_END_HIGH0x4084
 
 #define REG_MSI_ADDR_LOW   0x4044
 #define REG_MSI_ADDR_HIGH  0x4048
@@ -95,12 +92,27 @@ extern struct bus_space memmap_bus;
 #define REG_EP_CONFIG_DATA 0x8000
 
 /*
- * These values were obtained from runtime inspection of a Linux system using a
- * JTAG. The very limited documentation I have obtained from Broadcom does not
- * explain how to compute them.
+ * The system memory controller can address up to 16 GiB of physical memory
+ * (although at time of writing the largest memory size available for purchase
+ * is 8 GiB). However, the system DMA controller is capable of accessing only a
+ * limited portion of the address space. Worse, the PCI-e controller has 
further
+ * constraints for DMA, and those limitations are not wholly clear to the
+ * author. NetBSD and Linux allow DMA on the lower 3 GiB of the physical 
memory,
+ * but experimentation shows DMA performed above 960 MiB results in data
+ * corruption with this driver. The limit of 960 MiB is taken from OpenBSD, but
+ * apparently that value was chosen for satisfying a constraint of an unrelated
+ * peripheral.
+ *
+ * Whatever the true maximum address, 960 MiB works.
  */
-#define REG_VALUE_4GB_WINDOW   0x11
-#define REG_VALUE_4GB_CONFIG   0x88003000
+#define DMA_HIGH_LIMIT 0x3c00
+#define MAX_MEMORY_LOG20x21
+#define REG_VALUE_DMA_WINDOW_LOW   (MAX_MEMORY_LOG2 - 0xf)
+#define REG_VALUE_DMA_WINDOW_HIGH  0x0
+#define DMA_WINDOW_ENABLE  0x3000
+#define REG_VALUE_DMA_WINDOW_CONFIG\
+(((MAX_MEMORY_LOG2 - 0xf) << 0x1b) | DMA_WINDOW_ENABLE)
+
 #define REG_VALUE_MSI_CONFIG   0xffe06540
 
 struct bcm_pcib_irqsrc {
@@ -112,6 +124,7 @@ struct bcm_pcib_irqsrc {
 struct bcm_pcib_softc {
struct generic_pcie_fdt_softc   base;
device_tdev;
+   bus_dma_tag_t   dmat;
struct mtx  config_mtx;
struct mtx  msi_mtx;
struct resource *msi_irq_res;
@@ -142,6 +155,15 @@ bcm_pcib_probe(device_t dev)
return (BUS_PROBE_DEFAULT);
 }
 
+static bus_dma_tag_t
+bcm_pcib_get_dma_tag(device_t dev, device_t child)
+{
+   struct bcm_pcib_softc *sc;
+
+   sc = device_get_softc(dev);
+   return 

Re: svn commit: r365640 - in head: share/man/man5 share/man/man7 tools/build/options

2020-09-12 Thread Niclas Zeising

On 2020-09-11 20:09, Gordon Bergling wrote:

Author: gbe (doc committer)
Date: Fri Sep 11 18:09:49 2020
New Revision: 365640
URL: https://svnweb.freebsd.org/changeset/base/365640

Log:
   Improvements for the src.conf(5) and build(7) man pages
   
   PR:		203863 (based on)

   Submitted by:Russell Haley 
   Reviewed by: bcr, imp
   Approved by: imp
   MFC after:   1 week
   Differential Revision:   https://reviews.freebsd.org/D26343

Modified:
   head/share/man/man5/src.conf.5
   head/share/man/man7/build.7
   head/tools/build/options/makeman

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Fri Sep 11 17:05:09 2020
(r365639)
+++ head/share/man/man5/src.conf.5  Fri Sep 11 18:09:49 2020
(r365640)
@@ -1,6 +1,6 @@
  .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.


As the comment above hints, this file is generated by a tool, and should 
not be edited directly.  This will be overwritten the next time someone 
regenerates the manual page.  You have to update the template in 
tools/build/options/makeman and regenerate the manual from there.



  .\" $FreeBSD$
-.Dd September 8, 2020
+.Dd September 11, 2020
  .Dt SRC.CONF 5
  .Os
  .Sh NAME
@@ -9,7 +9,8 @@
  .Sh DESCRIPTION
  The
  .Nm
-file contains settings that will apply to every build involving the
+file contains variables that control what components will be generated during
+the build process of the
  .Fx
  source tree; see
  .Xr build 7 .



Regards
--
Niclas Zeising
___
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: r365666 - head/contrib/llvm-project/clang/lib/Basic

2020-09-12 Thread Brandon Bergren
Author: bdragon
Date: Sat Sep 12 18:23:27 2020
New Revision: 365666
URL: https://svnweb.freebsd.org/changeset/base/365666

Log:
  [PowerPC64LE] Fix platform definitions for powerpc64le-*-freebsd*
  
  Teach clang that powerpc64le-*-freebsd* is a valid triple.
  
  This is already in upstream clang, but was too late for llvm 11.0.0.
  Apply it directly for now, until it can be backported to llvm 11.0.1.
  
  See upstream https://reviews.llvm.org/D73425 for details.
  
  Reviewed by:  dim (upstream version), emaste
  Approved by:  emaste
  Differential Revision:https://reviews.freebsd.org/D26400

Modified:
  head/contrib/llvm-project/clang/lib/Basic/Targets.cpp

Modified: head/contrib/llvm-project/clang/lib/Basic/Targets.cpp
==
--- head/contrib/llvm-project/clang/lib/Basic/Targets.cpp   Sat Sep 12 
17:24:04 2020(r365665)
+++ head/contrib/llvm-project/clang/lib/Basic/Targets.cpp   Sat Sep 12 
18:23:27 2020(r365666)
@@ -358,6 +358,8 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
 switch (os) {
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
+case llvm::Triple::FreeBSD:
+  return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
___
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: r365665 - head/tools/regression/geom/Ref

2020-09-12 Thread Warner Losh
Author: imp
Date: Sat Sep 12 17:24:04 2020
New Revision: 365665
URL: https://svnweb.freebsd.org/changeset/base/365665

Log:
  Update flp test for new diskinfo output
  
  The floppy test passes with this. The others fail due to 'integrity
  checks' failing in GPART. It's not at all clear those integrity
  checks are legit or if the test samples were bogusly generated
  by FreeBSD.

Modified:
  head/tools/regression/geom/Ref/disk.empty.flp.xml

Modified: head/tools/regression/geom/Ref/disk.empty.flp.xml
==
--- head/tools/regression/geom/Ref/disk.empty.flp.xml   Sat Sep 12 17:24:00 
2020(r365664)
+++ head/tools/regression/geom/Ref/disk.empty.flp.xml   Sat Sep 12 17:24:04 
2020(r365665)
@@ -1,2 +1,2 @@
 $FreeBSD$
-/dev/md34  512 1474560 288080  2   18
+/dev/md34  512 1474560 28800   0   80  2   18
___
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: r365664 - head/tools/regression/geom

2020-09-12 Thread Warner Losh
Author: imp
Date: Sat Sep 12 17:24:00 2020
New Revision: 365664
URL: https://svnweb.freebsd.org/changeset/base/365664

Log:
  Fix trailing whitespace

Modified:
  head/tools/regression/geom/RunTest.t

Modified: head/tools/regression/geom/RunTest.t
==
--- head/tools/regression/geom/RunTest.tSat Sep 12 17:23:51 2020
(r365663)
+++ head/tools/regression/geom/RunTest.tSat Sep 12 17:24:00 2020
(r365664)
@@ -32,11 +32,11 @@ do
fi
MdLoad/MdLoad md${MD} $f
if [ -f Ref/$b ] ; then
-   if diskinfo /dev/md${MD}* | 
-  diff -I '$FreeBSD' -u Ref/$b - > $TMP; then
+   if diskinfo /dev/md${MD}* |
+  diff -I '\$FreeBSD' -u Ref/$b - > $TMP; then
echo "ok - $b"
else
-   echo "not ok - $b" 
+   echo "not ok - $b"
sed 's/^/# /' $TMP
fi
else
___
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: r365663 - head/tools/regression/geom/MdLoad

2020-09-12 Thread Warner Losh
Author: imp
Date: Sat Sep 12 17:23:51 2020
New Revision: 365663
URL: https://svnweb.freebsd.org/changeset/base/365663

Log:
  Make this compile again by fixing err args to have formats
  
  Also, add NO_OBJ=t top the Makefie, since the test-harnest expects to
  run it in place.

Modified:
  head/tools/regression/geom/MdLoad/Makefile
  head/tools/regression/geom/MdLoad/MdLoad.c

Modified: head/tools/regression/geom/MdLoad/Makefile
==
--- head/tools/regression/geom/MdLoad/Makefile  Sat Sep 12 16:50:04 2020
(r365662)
+++ head/tools/regression/geom/MdLoad/Makefile  Sat Sep 12 17:23:51 2020
(r365663)
@@ -2,6 +2,7 @@
 
 PROG=  MdLoad
 LIBADD=sbuf bsdxml
+NO_OBJ=t
 
 MAN=
 

Modified: head/tools/regression/geom/MdLoad/MdLoad.c
==
--- head/tools/regression/geom/MdLoad/MdLoad.c  Sat Sep 12 16:50:04 2020
(r365662)
+++ head/tools/regression/geom/MdLoad/MdLoad.c  Sat Sep 12 17:23:51 2020
(r365663)
@@ -216,7 +216,7 @@ g_simdisk_xml_load(const char *file)
 
fd = open(file, O_RDONLY);
if (fd < 0)
-   err(1, file);
+   err(1, "%s", file);
fstat(fd, );
p = mmap(NULL, st.st_size, PROT_READ, MAP_NOCORE|MAP_PRIVATE, fd, 0);
i = XML_Parse(parser, p, st.st_size, 1);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365658 - head/usr.sbin/traceroute6

2020-09-12 Thread Michael Tuexen
Author: tuexen
Date: Sat Sep 12 11:24:36 2020
New Revision: 365658
URL: https://svnweb.freebsd.org/changeset/base/365658

Log:
  Fix the length of probe packets when using UDP.
  Since https://svnweb.freebsd.org/changeset/base/365378 a raw socket is
  used for sending UDP probe packets instead of a UDP socket. So don't
  compensate for the UDP header anymore.

Modified:
  head/usr.sbin/traceroute6/traceroute6.c

Modified: head/usr.sbin/traceroute6/traceroute6.c
==
--- head/usr.sbin/traceroute6/traceroute6.c Sat Sep 12 11:19:54 2020
(r365657)
+++ head/usr.sbin/traceroute6/traceroute6.c Sat Sep 12 11:24:36 2020
(r365658)
@@ -677,8 +677,6 @@ main(int argc, char *argv[])
minlen, MAXPACKET);
exit(1);
}
-   if (useproto == IPPROTO_UDP)
-   datalen -= sizeof(struct udphdr);
if ((useproto == IPPROTO_SCTP) && (datalen & 3)) {
fprintf(stderr, 
"traceroute6: packet size must be a multiple of 4.\n");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365657 - head/usr.sbin/traceroute6

2020-09-12 Thread Michael Tuexen
Author: tuexen
Date: Sat Sep 12 11:19:54 2020
New Revision: 365657
URL: https://svnweb.freebsd.org/changeset/base/365657

Log:
  Simplify code, no functional change.
  
  Since https://svnweb.freebsd.org/base?view=revision=365378
  UDP is handled the same way as SCTP and TCP (using a raw socket).
  Therefore use the same code path.

Modified:
  head/usr.sbin/traceroute6/traceroute6.c

Modified: head/usr.sbin/traceroute6/traceroute6.c
==
--- head/usr.sbin/traceroute6/traceroute6.c Sat Sep 12 09:47:58 2020
(r365656)
+++ head/usr.sbin/traceroute6/traceroute6.c Sat Sep 12 11:19:54 2020
(r365657)
@@ -568,15 +568,10 @@ main(int argc, char *argv[])
case IPPROTO_ICMPV6:
sndsock = rcvsock;
break;
-   case IPPROTO_UDP:
-   if ((sndsock = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP)) < 0) {
-   perror("socket(SOCK_RAW)");
-   exit(5);
-   }
-   break;
case IPPROTO_NONE:
case IPPROTO_SCTP:
case IPPROTO_TCP:
+   case IPPROTO_UDP:
if ((sndsock = socket(AF_INET6, SOCK_RAW, useproto)) < 0) {
perror("socket(SOCK_RAW)");
exit(5);
___
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: r365652 - in head/sys: sys x86/x86

2020-09-12 Thread Jason A. Harmening
Author: jah
Date: Sat Sep 12 07:04:00 2020
New Revision: 365652
URL: https://svnweb.freebsd.org/changeset/base/365652

Log:
  amd64: prevent KCSan false positives on LAPIC mapping
  
  For configurations without x2APIC support (guests, older hardware), the global
  LAPIC MMIO mapping will trigger false-positive KCSan reports as it will appear
  that multiple CPUs are concurrently reading and writing the same address.
  This isn't actually true, as the underlying physical access will be performed
  on the local CPU's APIC. Additionally, because LAPIC access can happen during
  event timer configuration, the resulting KCSan printf can produce a panic due
  to attempted recursion on event timer resources.
  
  Add a __nosanitizethread preprocessor define to prevent the compiler from
  inserting TSan hooks, and apply it to the x86 LAPIC accessors.
  
  PR:   249149
  Reported by:  gbe
  Reviewed by:  andrew, kib
  Tested by:gbe
  Differential Revision:https://reviews.freebsd.org/D26354

Modified:
  head/sys/sys/cdefs.h
  head/sys/x86/x86/local_apic.c

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hSat Sep 12 01:55:07 2020(r365651)
+++ head/sys/sys/cdefs.hSat Sep 12 07:04:00 2020(r365652)
@@ -880,8 +880,10 @@
  */
 #if __has_attribute(no_sanitize) && defined(__clang__)
 #define __nosanitizeaddress__attribute__((no_sanitize("address")))
+#define __nosanitizethread __attribute__((no_sanitize("thread")))
 #else
 #define __nosanitizeaddress
+#define __nosanitizethread
 #endif
 
 /* Guard variables and structure members by lock. */

Modified: head/sys/x86/x86/local_apic.c
==
--- head/sys/x86/x86/local_apic.c   Sat Sep 12 01:55:07 2020
(r365651)
+++ head/sys/x86/x86/local_apic.c   Sat Sep 12 07:04:00 2020
(r365652)
@@ -215,7 +215,17 @@ SYSCTL_INT(_hw_apic, OID_AUTO, timer_tsc_deadline, CTL
 static void lapic_calibrate_initcount(struct lapic *la);
 static void lapic_calibrate_deadline(struct lapic *la);
 
-static uint32_t
+/*
+ * Use __nosanitizethread to exempt the LAPIC I/O accessors from KCSan
+ * instrumentation.  Otherwise, if x2APIC is not available, use of the global
+ * lapic_map will generate a KCSan false positive.  While the mapping is
+ * shared among all CPUs, the physical access will always take place on the
+ * local CPU's APIC, so there isn't in fact a race here.  Furthermore, the
+ * KCSan warning printf can cause a panic if issued during LAPIC access,
+ * due to attempted recursive use of event timer resources.
+ */
+
+static uint32_t __nosanitizethread
 lapic_read32(enum LAPIC_REGISTERS reg)
 {
uint32_t res;
@@ -228,7 +238,7 @@ lapic_read32(enum LAPIC_REGISTERS reg)
return (res);
 }
 
-static void
+static void __nosanitizethread
 lapic_write32(enum LAPIC_REGISTERS reg, uint32_t val)
 {
 
@@ -241,7 +251,7 @@ lapic_write32(enum LAPIC_REGISTERS reg, uint32_t val)
}
 }
 
-static void
+static void __nosanitizethread
 lapic_write32_nofence(enum LAPIC_REGISTERS reg, uint32_t val)
 {
 
___
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"