svn commit: r333594 - head/sys/powerpc/aim

2018-05-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun May 13 23:56:43 2018
New Revision: 333594
URL: https://svnweb.freebsd.org/changeset/base/333594

Log:
  Revert changes to hash table alignment in r333273, which booting on all G5
  systems, pending further analysis.

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

Modified: head/sys/powerpc/aim/moea64_native.c
==
--- head/sys/powerpc/aim/moea64_native.cSun May 13 23:55:11 2018
(r333593)
+++ head/sys/powerpc/aim/moea64_native.cSun May 13 23:56:43 2018
(r333594)
@@ -448,14 +448,18 @@ moea64_bootstrap_native(mmu_t mmup, vm_offset_t kernel
moea64_part_table =
(struct pate *)moea64_bootstrap_alloc(PART_SIZE, PART_SIZE);
if (hw_direct_map)
-   moea64_part_table =
-   (struct pate 
*)PHYS_TO_DMAP((vm_offset_t)moea64_part_table);
+   moea64_part_table = (struct pate *)PHYS_TO_DMAP(
+   (vm_offset_t)moea64_part_table);
}
/*
 * PTEG table must be aligned on a 256k boundary, but can be placed
-* anywhere with that alignment.
+* anywhere with that alignment. Some of our hash calculations,
+* however, assume that the PTEG table is aligned to its own size
+* (low-order bits are zero in an OR). As such, make alignment
+* bigger than strictly necessary for the time being.
 */
-   moea64_pteg_table = (struct lpte *)moea64_bootstrap_alloc(size, 
256*1024);
+   moea64_pteg_table = (struct lpte *)moea64_bootstrap_alloc(size, 
+   MAX(256*1024, size));
if (hw_direct_map)
moea64_pteg_table =
(struct lpte *)PHYS_TO_DMAP((vm_offset_t)moea64_pteg_table);
___
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: r333599 - head/sys/powerpc/aim

2018-05-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon May 14 04:00:52 2018
New Revision: 333599
URL: https://svnweb.freebsd.org/changeset/base/333599

Log:
  Final fix for alignment issues with the page table first patched with
  r333273 and partially reverted with r333594.
  
  Older CPUs implement addition of offsets into the page table by a
  bitwise OR rather than actual addition, which only works if the table is
  aligned at a multiple of its own size (they also require it to be aligned
  at a multiple of 256KB). Newer ones do not have that requirement, but it
  hardly matters to enforce it anyway.
  
  The original code was failing on newer systems with huge amounts of RAM
  (> 512 GB), in which the page table was 4 GB in size. Because the
  bootstrap memory allocator took its alignment parameter as an int, this
  turned into a 0, removing any alignment constraint at all and making
  the MMU fail. The first round of this patch (r333273) fixed this case by
  aligning it at 256 KB, which broke older CPUs. Fix this instead by widening
  the alignment parameter.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/mmu_oea64.h
  head/sys/powerpc/aim/moea64_native.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cMon May 14 01:08:47 2018
(r333598)
+++ head/sys/powerpc/aim/mmu_oea64.cMon May 14 04:00:52 2018
(r333599)
@@ -2446,7 +2446,7 @@ moea64_remove_all(mmu_t mmu, vm_page_t m)
  * calculated.
  */
 vm_offset_t
-moea64_bootstrap_alloc(vm_size_t size, u_int align)
+moea64_bootstrap_alloc(vm_size_t size, vm_size_t align)
 {
vm_offset_t s, e;
int i, j;

Modified: head/sys/powerpc/aim/mmu_oea64.h
==
--- head/sys/powerpc/aim/mmu_oea64.hMon May 14 01:08:47 2018
(r333598)
+++ head/sys/powerpc/aim/mmu_oea64.hMon May 14 04:00:52 2018
(r333599)
@@ -39,7 +39,7 @@ extern mmu_def_t oea64_mmu;
  */
 
 /* Allocate physical memory for use in moea64_bootstrap. */
-vm_offset_tmoea64_bootstrap_alloc(vm_size_t, u_int);
+vm_offset_tmoea64_bootstrap_alloc(vm_size_t size, vm_size_t align);
 /* Set an LPTE structure to match the contents of a PVO */
 void   moea64_pte_from_pvo(const struct pvo_entry *pvo, struct lpte *lpte);
 

Modified: head/sys/powerpc/aim/moea64_native.c
==
--- head/sys/powerpc/aim/moea64_native.cMon May 14 01:08:47 2018
(r333598)
+++ head/sys/powerpc/aim/moea64_native.cMon May 14 04:00:52 2018
(r333599)
@@ -453,10 +453,11 @@ moea64_bootstrap_native(mmu_t mmup, vm_offset_t kernel
}
/*
 * PTEG table must be aligned on a 256k boundary, but can be placed
-* anywhere with that alignment. Some of our hash calculations,
-* however, assume that the PTEG table is aligned to its own size
-* (low-order bits are zero in an OR). As such, make alignment
-* bigger than strictly necessary for the time being.
+* anywhere with that alignment on POWER ISA 3+ systems. On earlier
+* systems, offset addition is done by the CPU with bitwise OR rather
+* than addition, so the table must also be aligned on a boundary of
+* its own size. Pick the larger of the two, which works on all
+* systems.
 */
moea64_pteg_table = (struct lpte *)moea64_bootstrap_alloc(size, 
MAX(256*1024, 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"


Re: svn commit: r333765 - head/sys/conf

2018-05-17 Thread Nathan Whitehorn



On 05/17/18 14:04, Matt Macy wrote:

Author: mmacy
Date: Thu May 17 21:04:19 2018
New Revision: 333765
URL: https://svnweb.freebsd.org/changeset/base/333765

Log:
   powerpc: fix LINT build
   
   netmap currently doesn't build, take it out of LINT to prevent

   hiding regressions in universe
   
   Reviewed by:	jhibbits

   Approved by: sbruno

Modified:
   head/sys/conf/makeLINT.mk

Modified: head/sys/conf/makeLINT.mk
==
--- head/sys/conf/makeLINT.mk   Thu May 17 21:03:36 2018(r333764)
+++ head/sys/conf/makeLINT.mk   Thu May 17 21:04:19 2018(r333765)
@@ -53,6 +53,7 @@ LINT: ${NOTES} ${MAKELINT_SED}
  .if ${TARGET} == "powerpc"
# cat is available, not sure if cp is?
cat ${.TARGET} > ${.TARGET}64
+   echo "nodevice netmap">> ${.TARGET}
echo "machine  ${TARGET} powerpc" >> ${.TARGET}
echo "machine  ${TARGET} powerpc64" >> ${.TARGET}64
  .endif



The build error is that it is broken on all 32-bit architectures because 
of some integer/pointer type confusion, not just (32-bit) PowerPC. So, 
if we aren't fixing it, it at least it should also be removed from ARM, 
i386, mips, etc.

-Nathan
___
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: r333803 - head/usr.sbin/bsdinstall/partedit

2018-05-18 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri May 18 17:43:15 2018
New Revision: 333803
URL: https://svnweb.freebsd.org/changeset/base/333803

Log:
  Fix math error in the computation of the free space after the last partition
  on a disk. This resulted in one sector always remaining free at the end.
  
  PR:   bin/228322
  Submitted by: Rikiya Yonemoto
  MFC after:2 weeks

Modified:
  head/usr.sbin/bsdinstall/partedit/gpart_ops.c

Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c
==
--- head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Fri May 18 17:29:43 
2018(r333802)
+++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Fri May 18 17:43:15 
2018(r333803)
@@ -856,7 +856,7 @@ gpart_max_free(struct ggeom *geom, intmax_t *npartstar
}
 
if (end - lastend > maxsize) {
-   maxsize = end - lastend - 1;
+   maxsize = end - lastend;
maxstart = lastend + 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: r333804 - head/usr.sbin/bsdinstall

2018-05-18 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri May 18 17:46:40 2018
New Revision: 333804
URL: https://svnweb.freebsd.org/changeset/base/333804

Log:
  Use sysrc(8) in the documentation rather than echoing things to rc.conf
  in order to encourage good habits.
  
  PR:   228325
  Submitted by: Mateusz Piotrowski
  MFC after:2 weeks

Modified:
  head/usr.sbin/bsdinstall/bsdinstall.8

Modified: head/usr.sbin/bsdinstall/bsdinstall.8
==
--- head/usr.sbin/bsdinstall/bsdinstall.8   Fri May 18 17:43:15 2018
(r333803)
+++ head/usr.sbin/bsdinstall/bsdinstall.8   Fri May 18 17:46:40 2018
(r333804)
@@ -333,8 +333,8 @@ PARTITIONS=ada0
 DISTRIBUTIONS="kernel.txz base.txz"
 
 #!/bin/sh
-echo "ifconfig_em0=DHCP" >> /etc/rc.conf
-echo "sshd_enable=YES" >> /etc/rc.conf
+sysrc ifconfig_em0=DHCP
+sysrc sshd_enable=YES
 pkg install puppet
 .Ed
 .Pp
___
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: r333897 - head/sys/dev/vt/hw/ofwfb

2018-05-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat May 19 22:04:54 2018
New Revision: 333897
URL: https://svnweb.freebsd.org/changeset/base/333897

Log:
  Avoid writing to the frame buffer in early boot on PowerPC if the CPU's
  MMU is disabled.
  
  This expands some earlier logic and avoids a number of potential problems:
  1. The CPU may not be able to access the framebuffer in real mode (real
 mode does not necessarily encompass all available memory, especially
 under a hypervisor).
  2. Real mode accesses generally assume cacheability, so it might not
 even have worked.
  3. The difference in cacheability between real mode and later (and
 potentially earlier) points in the boot with the MMU on may cause
 ERAT parity problems, resulting in a machine check.
  
  This fixes real-mode (usefdt=1) early boot on the G5 iMac, which was
  previously broken as a result of issue #3. Late boot will require some
  other fixups.

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

Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c
==
--- head/sys/dev/vt/hw/ofwfb/ofwfb.cSat May 19 21:36:55 2018
(r333896)
+++ head/sys/dev/vt/hw/ofwfb/ofwfb.cSat May 19 22:04:54 2018
(r333897)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #ifdef __sparc64__
 #include 
 #endif
+#include 
 
 #include 
 #include 
@@ -138,6 +139,7 @@ ofwfb_bitblt_bitmap(struct vt_device *vd, const struct
if (pmap_bootstrapped) {
sc->fb_flags &= ~FB_FLAG_NOWRITE;
ofwfb_initialize(vd);
+   vd->vd_driver->vd_blank(vd, TC_BLACK);
} else {
return;
}
@@ -490,11 +492,6 @@ ofwfb_init(struct vt_device *vd)
OF_decode_addr(node, fb_phys, &sc->sc_memt, &sc->fb.fb_vbase,
NULL);
sc->fb.fb_pbase = sc->fb.fb_vbase & ~DMAP_BASE_ADDRESS;
-   #ifdef __powerpc64__
-   /* Real mode under a hypervisor probably doesn't cover FB */
-   if (!(mfmsr() & (PSL_HV | PSL_DR)))
-   sc->fb.fb_flags |= FB_FLAG_NOWRITE;
-   #endif
#else
/* No ability to interpret assigned-addresses otherwise */
return (CN_DEAD);
@@ -502,6 +499,17 @@ ofwfb_init(struct vt_device *vd)
 }
 
 
+   #if defined(__powerpc__)
+   /*
+* If we are running on PowerPC in real mode (supported only on AIM
+* CPUs), the frame buffer may be inaccessible (real mode does not
+* necessarily cover all RAM) and may also be mapped with the wrong
+* cache properties (all real mode accesses are assumed cacheable).
+* Just don't write to it for the time being.
+*/
+   if (!(cpu_features & PPC_FEATURE_BOOKE) && !(mfmsr() & PSL_DR))
+   sc->fb.fb_flags |= FB_FLAG_NOWRITE;
+   #endif
ofwfb_initialize(vd);
vt_fb_init(vd);
 
___
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: r333934 - head/sys/powerpc/pseries

2018-05-20 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun May 20 18:26:09 2018
New Revision: 333934
URL: https://svnweb.freebsd.org/changeset/base/333934

Log:
  Fix build with PSERIES but not POWERNV defined.

Modified:
  head/sys/powerpc/pseries/xics.c

Modified: head/sys/powerpc/pseries/xics.c
==
--- head/sys/powerpc/pseries/xics.c Sun May 20 18:18:56 2018
(r333933)
+++ head/sys/powerpc/pseries/xics.c Sun May 20 18:26:09 2018
(r333934)
@@ -139,7 +139,9 @@ static driver_t xics_driver = {
0
 };
 
+#ifdef POWERNV
 static uint32_t cpu_xirr[MAXCPU];
+#endif
 
 static devclass_t xicp_devclass;
 static devclass_t xics_devclass;
___
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: r334372 - head/sys/dev/vt/hw/ofwfb

2018-05-29 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed May 30 04:15:33 2018
New Revision: 334372
URL: https://svnweb.freebsd.org/changeset/base/334372

Log:
  If linebytes property is missing from the graphics device, assume no
  overscan and synthesize it from the display depth and screen width.
  This may not be right, but it sometimes right and is better than
  returning CN_DEAD.

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

Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c
==
--- head/sys/dev/vt/hw/ofwfb/ofwfb.cWed May 30 04:12:51 2018
(r334371)
+++ head/sys/dev/vt/hw/ofwfb/ofwfb.cWed May 30 04:15:33 2018
(r334372)
@@ -394,8 +394,7 @@ ofwfb_init(struct vt_device *vd)
/* Make sure we have needed properties */
if (OF_getproplen(node, "height") != sizeof(height) ||
OF_getproplen(node, "width") != sizeof(width) ||
-   OF_getproplen(node, "depth") != sizeof(depth) ||
-   OF_getproplen(node, "linebytes") != sizeof(sc->fb.fb_stride))
+   OF_getproplen(node, "depth") != sizeof(depth))
return (CN_DEAD);
 
/* Only support 8 and 32-bit framebuffers */
@@ -406,7 +405,9 @@ ofwfb_init(struct vt_device *vd)
 
OF_getprop(node, "height", &height, sizeof(height));
OF_getprop(node, "width", &width, sizeof(width));
-   OF_getprop(node, "linebytes", &stride, sizeof(stride));
+   if (OF_getprop(node, "linebytes", &stride, sizeof(stride)) !=
+   sizeof(stride))
+   stride = width*depth/8;
 
sc->fb.fb_height = height;
sc->fb.fb_width = width;
___
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: r334365 - head/sys/dev/pci

2018-05-30 Thread Nathan Whitehorn



On 05/30/18 02:42, Peter Grehan wrote:
   PCIe only permits 1 device on an endpoint, so some devices ignore 
the device
   part of B:D:F probing.  Although ARI likely fixes this, not all 
platforms
   support ARI completely or correctly, so some devices end up 
showing up 32

   times on the bus.


 I think this might have broken bhyve - a fake PCIe capability is put 
on the root port so that guests will use MSI/MSI-x, but otherwise it 
looks like parallel PCI. Not exactly spec-compliant, but then neither 
is most of the world of PCI/PCIe.


 It may be worth #ifdef'ing this with powerpc.

later,

Peter.



There are a ton of ARM boards that need this too. You can find one-off 
hacks all through the tree and one of the nice things about this change 
is that all of those can be consolidated/removed now. If we are going to 
have some #ifdef and special cases, it would be better to make them for 
bhyve.

-Nathan
___
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: r335299 - head

2018-06-17 Thread Nathan Whitehorn
As a minor caveat, the default release kernel on powerpc64 is 
"GENERIC64" not "GENERIC".

-Nathan

On 06/17/18 12:44, Eitan Adler wrote:

Author: eadler
Date: Sun Jun 17 19:44:24 2018
New Revision: 335299
URL: https://svnweb.freebsd.org/changeset/base/335299

Log:
   README: add generic notes about GENERIC and NOTES
   
   Inform new users what GENERIC and NOTES are. These are useful for people

   perusing the tree without a great deal of specific fbsd knowledge.
   See discussion of r334073 for further motivation.
   
   Requested by:	jhb


Modified:
   head/README
   head/README.md

Modified: head/README
==
--- head/README Sun Jun 17 19:31:35 2018(r335298)
+++ head/README Sun Jun 17 19:44:24 2018(r335299)
@@ -60,7 +60,9 @@ stand Boot loader sources.
  
  sys		Kernel sources.
  
-sys//conf Kernel configuration file

+sys//conf Kernel configuration files. GENERIC is the configuration
+   used in release builds. NOTES contains documentation of
+   all possible entries.
  
  tests		Regression tests which can be run by Kyua.  See tests/README

for additional information.

Modified: head/README.md
==
--- head/README.md  Sun Jun 17 19:31:35 2018(r335298)
+++ head/README.md  Sun Jun 17 19:44:24 2018(r335299)
@@ -62,7 +62,9 @@ stand Boot loader sources.
  
  sys		Kernel sources.
  
-sys//conf Kernel configuration file

+sys//conf Kernel configuration files. GENERIC is the configuration
+   used in release builds. NOTES contains documentation of
+   all possible entries.
  
  tests		Regression tests which can be run by Kyua.  See tests/README

for additional information.



___
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: r326218 - head/sys/kern

2017-11-27 Thread Nathan Whitehorn



On 11/27/17 10:06, Andrew Turner wrote:

On 26 Nov 2017, at 17:07, Nathan Whitehorn  wrote:



On 11/26/17 01:46, Andrew Turner wrote:

On 25 Nov 2017, at 23:41, Nathan Whitehorn  wrote:

Author: nwhitehorn
Date: Sat Nov 25 23:41:05 2017
New Revision: 326218
URL: https://svnweb.freebsd.org/changeset/base/326218

Log:
  Remove some, but not all, assumptions that the BSP is CPU 0 and that CPUs
  are numbered densely from there to n_cpus.

  MFC after:1 month

Modified:
  head/sys/kern/kern_clock.c
  head/sys/kern/kern_clocksource.c
  head/sys/kern/kern_shutdown.c
  head/sys/kern/kern_timeout.c
  head/sys/kern/sched_ule.c
  head/sys/kern/subr_pcpu.c


...

Modified: head/sys/kern/subr_pcpu.c
==
--- head/sys/kern/subr_pcpu.c   Sat Nov 25 23:23:24 2017(r326217)
+++ head/sys/kern/subr_pcpu.c   Sat Nov 25 23:41:05 2017(r326218)
@@ -279,6 +279,8 @@ pcpu_destroy(struct pcpu *pcpu)
struct pcpu *
pcpu_find(u_int cpuid)
{
+   KASSERT(cpuid_to_pcpu[cpuid] != NULL,
+   ("Getting uninitialized PCPU %d", cpuid));

return (cpuid_to_pcpu[cpuid]);
}

This breaks on one arm64 simulator I have where the device tree lists 8 cpus, 
but only 2 are enabled in the simulation. The ofw_cpu device nodes for these 
are cpu0 and cpu4 so the call to cpu_find in ofw_cpu_attach will hit this 
KASSERT when the CPU has not been enabled.

Andrew

cpu0:  on cpulist0
cpu1:  on cpulist0
panic: Getting uninitialized PCPU 1
cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self() at db_trace_self_wrapper+0x28
 pc = 0x005f03e8  lr = 0x00087048
 sp = 0x000105a0  fp = 0x000107b0

That's unfortunate. Removing the new KASSERT is probably not the right option, 
since all it is doing is indicating a pre-existing bug. Specifically, it is 
preventing ofw_cpu from using a NULL pointer for CPU 4, which I suppose it was 
previously happily doing (it would only get dereferenced if you had cpufreq 
support, hence no previous panic).

I would expect cpu4 to have a non-NULL value as its cpu pointer will have been 
set. It’s cpu1 that is the issue as it’s in the device tree, but doesn’t exist 
in “hardware”. Because of this it fails when we try to enable it so free it’s 
pcpu data clear the pointer.


Yes, I phrased that badly. As you say, the CPU ID that ofw_cpu has is 
"1", which doesn't exist. To fix this, we need to change the CPU ID that 
ofw_cpu has to match what the kernel thinks it is using.





A super quick-and-dirty fix would be to be fail attach on 
CPU_ABSENT(device_get_unit(dev)), which restores the previous buggy behavior 
but without the panic. If you do not actually use ofw_cpu for anything, we 
could also just disable it temporarily on your platform (it's off for some PPC 
systems, you will note, for similar reasons).

We used to use it to find CPUs to start, however this is no longer the case.


OK, so disabling it works fine for now.




A real fix is somewhat complex, since the driver relies on being able to get a 
mapping from platform-specific numbers in the device tree to an entry in pcpu, 
which intrinsically relies on reverse-engineering the platform's mapping 
between some kind of hardware CPU ID and the kernel CPU numbering. I can't 
think of a way to do that internally. We could make some kind of platform 
macro, but the whole concept is even somewhat dubious at the moment since a 
number of IBM systems with SMT don't even have a 1:1 relationship between CPUs 
as FreeBSD defines them and device tree nodes, so it's possible we need a 
serious rearchitecture of the driver.

On arm64 we use the ID from the device tree to assign the cpuid so there is a 
1:1 mapping between the two. In most cases both are identical, the only case 
that’s not correct is when we boot from a non-zero CPU, and I know of only one 
SoC where this is true.


The "ID from the device tree" being the value of "reg"? Or something 
else? I see a lot of variation in the encoding in sys/dts and there does 
not seem to be an obvious single answer. This is making me think that 
the only workable solution is something like a new ofw_machdep function 
that gets the phandle for a given CPU ID.

-Nathan



Andrew




___
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: r326218 - head/sys/kern

2017-11-27 Thread Nathan Whitehorn



On 11/27/17 11:31, John Baldwin wrote:

On Sunday, November 26, 2017 10:06:56 PM Nathan Whitehorn wrote:

On 11/26/17 20:50, John Baldwin wrote:

On Saturday, November 25, 2017 11:41:05 PM Nathan Whitehorn wrote:

Author: nwhitehorn
Date: Sat Nov 25 23:41:05 2017
New Revision: 326218
URL: https://svnweb.freebsd.org/changeset/base/326218

Log:
Remove some, but not all, assumptions that the BSP is CPU 0 and that CPUs
are numbered densely from there to n_cpus.

MFC after:	1 month


Modified:
head/sys/kern/kern_clock.c
head/sys/kern/kern_clocksource.c
head/sys/kern/kern_shutdown.c
head/sys/kern/kern_timeout.c
head/sys/kern/sched_ule.c
head/sys/kern/subr_pcpu.c

Modified: head/sys/kern/kern_clock.c
==
--- head/sys/kern/kern_clock.c  Sat Nov 25 23:23:24 2017(r326217)
+++ head/sys/kern/kern_clock.c  Sat Nov 25 23:41:05 2017(r326218)
@@ -573,7 +573,9 @@ hardclock_cnt(int cnt, int usermode)
   void
   hardclock_sync(int cpu)
   {
-   int *t = DPCPU_ID_PTR(cpu, pcputicks);
+   int *t;
+   KASSERT(!CPU_ABSENT(cpu), ("Absent CPU %d", cpu));

Blank line before the KASSERT() perhaps?


+   t = DPCPU_ID_PTR(cpu, pcputicks);
   
   	*t = ticks;

Probably don't need this blank line though?

Those are both good ideas.


   }

Modified: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Sat Nov 25 23:23:24 2017(r326217)
+++ head/sys/kern/sched_ule.c   Sat Nov 25 23:41:05 2017(r326218)
@@ -2444,6 +2451,7 @@ sched_add(struct thread *td, int flags)
 * Pick the destination cpu and if it isn't ours transfer to the
 * target cpu.
 */
+   td_get_sched(td)->ts_cpu = curcpu; /* Pick something valid to start */
cpu = sched_pickcpu(td, flags);

It is not obvious why every sched_add() needs this once you've fixed thread0.
Shouldn't new threads just inherit from thread0's already-fixed value?  If not,
perhaps fix thread0's value sooner?

That's a fair point. I don't remember the rationale for this now; the
changes are over a year old from the powernv branch. I do remember
setting thread0's CPU early not working, but have forgotten why. I will
try to remember...


tdq = sched_setcpu(td, cpu, flags);
tdq_add(tdq, td, flags);

Modified: head/sys/kern/subr_pcpu.c
==
--- head/sys/kern/subr_pcpu.c   Sat Nov 25 23:23:24 2017(r326217)
+++ head/sys/kern/subr_pcpu.c   Sat Nov 25 23:41:05 2017(r326218)
@@ -279,6 +279,8 @@ pcpu_destroy(struct pcpu *pcpu)
   struct pcpu *
   pcpu_find(u_int cpuid)
   {
+   KASSERT(cpuid_to_pcpu[cpuid] != NULL,
+   ("Getting uninitialized PCPU %d", cpuid));

This KASSERT seems unnecessary?  If the caller uses an invalid one, it will
just fault anyway.

It won't necessarily fault. For example, on PowerPC, NULL is a valid
address that does not trigger faults. It's unfortunately quite
complicated to fix this in a general way. Even if it did fault, this
makes the fault more informative (and has found at least one bug on
arm64 already).

Given the large number of bugs caused by NULL pointers, having NULL pointers
"work" doesn't seem like a long-term tenable solution.  You'd have to go add
explicit KASSERT()'s to every pointer indirection in the kernel which seems
unworkable.  Also, adding the KASSERT() here has broken other places that were
depending on the existing behavior of pcpu_find() (see markj@'s commit to dtrace
today).



Unfortunately, it's unfixable on ppc64. Apologies for breaking dtrace! 
Would you like me to remove the KASSERT() here? I'm happy to do that in 
a few hours (unless you beat me to it first) -- although I do think that 
explicitly checking for CPU_ABSENT is a much better behavior in client 
code than checking the return value of pcpu_find().

-Nathan
___
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: r326308 - head/sys/kern

2017-11-27 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Nov 28 05:39:48 2017
New Revision: 326308
URL: https://svnweb.freebsd.org/changeset/base/326308

Log:
  Remove assertion that a CPU be present before returning a PCPU for it. It
  is up to the caller to check for a NULL return value. The assert was meant
  to catch buggy code that did not check the return value. Some code, however,
  was smart and used the return value to see if a CPU existed, which this
  broke.
  
  Requested by: jhb@

Modified:
  head/sys/kern/subr_pcpu.c

Modified: head/sys/kern/subr_pcpu.c
==
--- head/sys/kern/subr_pcpu.c   Tue Nov 28 01:35:28 2017(r326307)
+++ head/sys/kern/subr_pcpu.c   Tue Nov 28 05:39:48 2017(r326308)
@@ -279,8 +279,6 @@ pcpu_destroy(struct pcpu *pcpu)
 struct pcpu *
 pcpu_find(u_int cpuid)
 {
-   KASSERT(cpuid_to_pcpu[cpuid] != NULL,
-   ("Getting uninitialized PCPU %d", cpuid));
 
return (cpuid_to_pcpu[cpuid]);
 }
___
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: r326310 - in head/sys: dev/ofw powerpc/ofw

2017-11-27 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Nov 28 06:31:39 2017
New Revision: 326310
URL: https://svnweb.freebsd.org/changeset/base/326310

Log:
  Back out OF module installation in the event of failure. PS3 firmware gives
  some ancient FDT version (2) that fails the init check in OFW_FDT. It is
  still possible to make progress, but not while the OF layer is going crazy.

Modified:
  head/sys/dev/ofw/openfirm.c
  head/sys/powerpc/ofw/ofw_machdep.c

Modified: head/sys/dev/ofw/openfirm.c
==
--- head/sys/dev/ofw/openfirm.c Tue Nov 28 06:21:37 2017(r326309)
+++ head/sys/dev/ofw/openfirm.c Tue Nov 28 06:31:39 2017(r326310)
@@ -201,6 +201,12 @@ OF_install(char *name, int prio)
ofw_def_t *ofwp, **ofwpp;
static int curr_prio = 0;
 
+   /* Allow OF layer to be uninstalled */
+   if (name == NULL) {
+   ofw_def_impl = NULL;
+   return (FALSE);
+   }
+
/*
 * Try and locate the OFW kobj corresponding to the name.
 */

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==
--- head/sys/powerpc/ofw/ofw_machdep.c  Tue Nov 28 06:21:37 2017
(r326309)
+++ head/sys/powerpc/ofw/ofw_machdep.c  Tue Nov 28 06:31:39 2017
(r326310)
@@ -393,6 +393,7 @@ boolean_t
 OF_bootstrap()
 {
boolean_t status = FALSE;
+   int err = 0;
 
 #ifdef AIM
if (openfirmware_entry != NULL) {
@@ -409,7 +410,7 @@ OF_bootstrap()
if (status != TRUE)
return status;
 
-   OF_init(openfirmware);
+   err = OF_init(openfirmware);
} else
 #endif
if (fdt != NULL) {
@@ -418,9 +419,15 @@ OF_bootstrap()
if (status != TRUE)
return status;
 
-   OF_init(fdt);
-   OF_interpret("perform-fixup", 0);
+   err = OF_init(fdt);
+   if (err == 0)
+   OF_interpret("perform-fixup", 0);
} 
+
+   if (err != 0) {
+   OF_install(NULL, 0);
+   status = FALSE;
+   }
 
return (status);
 }
___
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: r326203 - head/sys/conf

2017-11-28 Thread Nathan Whitehorn



On 11/28/17 07:27, Justin Hibbits wrote:

On Sat, Nov 25, 2017 at 3:45 PM, Nathan Whitehorn
 wrote:

Author: nwhitehorn
Date: Sat Nov 25 21:45:51 2017
New Revision: 326203
URL: https://svnweb.freebsd.org/changeset/base/326203

Log:
   Avoid emitting a PT_INTERP section for powerpc64 kernels and arrange for
   the first instruction to be at the start of the text segment. This allows
   the kernel to be booted correctly by stock kexec-lite.

   MFC after:2 weeks

Modified:
   head/sys/conf/ldscript.powerpc64

Modified: head/sys/conf/ldscript.powerpc64
==
--- head/sys/conf/ldscript.powerpc64Sat Nov 25 21:44:23 2017
(r326202)
+++ head/sys/conf/ldscript.powerpc64Sat Nov 25 21:45:51 2017
(r326203)
@@ -10,7 +10,7 @@ SECTIONS
  {
/* Read-only sections, merged into text segment: */

-  . = kernbase + SIZEOF_HEADERS;
+  . = kernbase;
PROVIDE (begin = . - SIZEOF_HEADERS);

.text  :
@@ -24,7 +24,10 @@ SECTIONS
_etext = .;
PROVIDE (etext = .);

-  .interp : { *(.interp)   }
+  /* Do not emit PT_INTERP section, which confuses some loaders (kexec-lite) */
+  .interpX: { *(.interp)   } : NONE
+  /DISCARD/   : { *(.interp)   }
+
.hash  : { *(.hash)  }
.dynsym: { *(.dynsym)}
.dynstr: { *(.dynstr)}


This broke powerpc64 Book-E kernels.  It now puts a 1MB blank space
ahead of the kernel data (ELF header + 1MB - sizeof(header) of 0's),
meaning that now the kernel needs to be loaded by uboot 1MB earlier in
memory, rather than straight on the 64MB boundary as it has been.

- Justin



How on Earth? It doesn't do that on my system. What binutils are you using?
-Nathan
___
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: r326203 - head/sys/conf

2017-11-28 Thread Nathan Whitehorn



On 11/28/17 08:23, Justin Hibbits wrote:

On Tue, Nov 28, 2017 at 10:13 AM, Nathan Whitehorn
 wrote:


On 11/28/17 07:27, Justin Hibbits wrote:

On Sat, Nov 25, 2017 at 3:45 PM, Nathan Whitehorn
 wrote:

Author: nwhitehorn
Date: Sat Nov 25 21:45:51 2017
New Revision: 326203
URL: https://svnweb.freebsd.org/changeset/base/326203

Log:
Avoid emitting a PT_INTERP section for powerpc64 kernels and arrange
for
the first instruction to be at the start of the text segment. This
allows
the kernel to be booted correctly by stock kexec-lite.

MFC after:2 weeks

Modified:
head/sys/conf/ldscript.powerpc64

Modified: head/sys/conf/ldscript.powerpc64

==
--- head/sys/conf/ldscript.powerpc64Sat Nov 25 21:44:23 2017
(r326202)
+++ head/sys/conf/ldscript.powerpc64Sat Nov 25 21:45:51 2017
(r326203)
@@ -10,7 +10,7 @@ SECTIONS
   {
 /* Read-only sections, merged into text segment: */

-  . = kernbase + SIZEOF_HEADERS;
+  . = kernbase;
 PROVIDE (begin = . - SIZEOF_HEADERS);

 .text  :
@@ -24,7 +24,10 @@ SECTIONS
 _etext = .;
 PROVIDE (etext = .);

-  .interp : { *(.interp)   }
+  /* Do not emit PT_INTERP section, which confuses some loaders
(kexec-lite) */
+  .interpX: { *(.interp)   } : NONE
+  /DISCARD/   : { *(.interp)   }
+
 .hash  : { *(.hash)  }
 .dynsym: { *(.dynsym)}
 .dynstr: { *(.dynstr)}


This broke powerpc64 Book-E kernels.  It now puts a 1MB blank space
ahead of the kernel data (ELF header + 1MB - sizeof(header) of 0's),
meaning that now the kernel needs to be loaded by uboot 1MB earlier in
memory, rather than straight on the 64MB boundary as it has been.

- Justin


How on Earth? It doesn't do that on my system. What binutils are you using?
-Nathan


This is using base binutils (2.17.50...)  I don't know why it's doing
this, but readelf shows that file offset 0x0010 maps to
0xc000, and it goes from there.

- Justin



Bizarre. Why don't you just revert for now (I need to run) and I can 
figure out what went wrong later?

-Nathan
___
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: r326674 - head/usr.sbin/bsdinstall/partedit

2017-12-07 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Dec  8 00:57:13 2017
New Revision: 326674
URL: https://svnweb.freebsd.org/changeset/base/326674

Log:
  Support mounted boot partitions in the installer. This allows the platform
  layer, for example, to specify that the EFI boot partition should be
  mounted at /efi and formatted normally with newfs_msdos rather than
  splatted to from /boot/boot1.efifat.
  
  This commit adds only the API for this; actual platform use will come later.

Modified:
  head/usr.sbin/bsdinstall/partedit/gpart_ops.c
  head/usr.sbin/bsdinstall/partedit/partedit.h
  head/usr.sbin/bsdinstall/partedit/partedit_arm64.c
  head/usr.sbin/bsdinstall/partedit/partedit_generic.c
  head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
  head/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
  head/usr.sbin/bsdinstall/partedit/partedit_x86.c

Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c
==
--- head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Thu Dec  7 22:36:58 
2017(r326673)
+++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Fri Dec  8 00:57:13 
2017(r326674)
@@ -191,9 +191,7 @@ newfs_command(const char *fstype, char *command, int u
for (i = 0; i < (int)nitems(items); i++) {
if (items[i].state == 0)
continue;
-   if (strcmp(items[i].name, "FAT32") == 0)
-   strcat(command, "-F 32 ");
-   else if (strcmp(items[i].name, "FAT16") == 0)
+   if (strcmp(items[i].name, "FAT16") == 0)
strcat(command, "-F 16 ");
else if (strcmp(items[i].name, "FAT12") == 0)
strcat(command, "-F 12 ");
@@ -675,6 +673,7 @@ set_default_part_metadata(const char *name, const char
 {
struct partition_metadata *md;
char *zpool_name = NULL;
+   const char *default_bootmount = NULL;
int i;
 
/* Set part metadata */
@@ -705,8 +704,12 @@ set_default_part_metadata(const char *name, const char
 
if (strcmp(type, "freebsd-swap") == 0)
mountpoint = "none";
-   if (strcmp(type, bootpart_type(scheme)) == 0)
-   md->bootcode = 1;
+   if (strcmp(type, bootpart_type(scheme, &default_bootmount)) == 0) {
+   if (default_bootmount == NULL)
+   md->bootcode = 1;
+   else if (mountpoint == NULL || strlen(mountpoint) == 0)
+   mountpoint = default_bootmount;
+   }
 
/* VTOC8 needs partcode at the start of partitions */
if (strcmp(scheme, "VTOC8") == 0 && (strcmp(type, "freebsd-ufs") == 0
@@ -886,9 +889,79 @@ gpart_max_free(struct ggeom *geom, intmax_t *npartstar
return (maxsize);
 }
 
+static size_t
+add_boot_partition(struct ggeom *geom, struct gprovider *pp,
+const char *scheme, int interactive)
+{
+   struct gconfig *gc;
+   struct gprovider *ppi;
+   int choice;
+
+   /* Check for existing freebsd-boot partition */
+   LIST_FOREACH(ppi, &geom->lg_provider, lg_provider) {
+   struct partition_metadata *md;
+   const char *bootmount = NULL;
+
+   LIST_FOREACH(gc, &ppi->lg_config, lg_config)
+   if (strcmp(gc->lg_name, "type") == 0)
+   break;
+   if (gc == NULL)
+   continue;
+   if (strcmp(gc->lg_val, bootpart_type(scheme, &bootmount)) != 0)
+   continue;
+
+   /*
+* If the boot partition is not mountable and needs partcode,
+* but doesn't have it, it doesn't satisfy our requirements.
+*/
+   md = get_part_metadata(ppi->lg_name, 0);
+   if (bootmount == NULL && (md == NULL || !md->bootcode))
+   continue;
+
+   /* If it is mountable, but mounted somewhere else, remount */
+   if (bootmount != NULL && md != NULL && md->fstab != NULL
+   && strlen(md->fstab->fs_file) > 0
+   && strcmp(md->fstab->fs_file, bootmount) != 0)
+   continue;
+
+   /* If it is mountable, but mountpoint is not set, mount it */
+   if (bootmount != NULL && md == NULL)
+   set_default_part_metadata(ppi->lg_name, scheme,
+   gc->lg_val, bootmount, NULL);
+   
+   /* Looks good at this point, no added data needed */
+   return (0);
+   }
+
+   if (interactive)
+   choice = dialog_yesno("Boot Partition",
+   "This partition scheme requires a boot partition "
+   "for the disk to be bootable. Would you like to "
+   "make one now?", 0, 0);
+   else
+

Re: svn commit: r326773 - in head/sys: conf dev/syscon

2017-12-11 Thread Nathan Whitehorn
I think this name might confuse people looking for "syscons". Can it be 
renamed? Also, if it is ARM-specific, maybe it belongs in sys/arm?

-Nathan

On 12/11/17 10:04, Kyle Evans wrote:

Author: kevans
Date: Mon Dec 11 18:04:04 2017
New Revision: 326773
URL: https://svnweb.freebsd.org/changeset/base/326773

Log:
   Add generic 'syscon' driver
   
   Upstream dts for allwinner will require a syscon driver, since the emac node

   coming in 4.15 will be using xref to /soc/syscon for configuring the emac
   clock. Add a generic syscon driver to attach to /soc/syscon for use by
   if_awg, providing basic read/write functionality to consumers.
   
   syscon driver will also be used by arm64 at least for A64+H5 emac/if_awg.
   
   Written by:	mmel

   Reviewed by: manu
   Differential Revision:   https://reviews.freebsd.org/D13295

Added:
   head/sys/dev/syscon/
   head/sys/dev/syscon/syscon.c   (contents, props changed)
   head/sys/dev/syscon/syscon_if.m   (contents, props changed)
Modified:
   head/sys/conf/files

Modified: head/sys/conf/files
==
--- head/sys/conf/files Mon Dec 11 16:18:05 2017(r326772)
+++ head/sys/conf/files Mon Dec 11 18:04:04 2017(r326773)
@@ -3109,6 +3109,8 @@ dev/stg/tmc18c30_subr.c   optional stg
  dev/stge/if_stge.coptional stge
  dev/sym/sym_hipd.coptional sym\
dependency  "$S/dev/sym/sym_{conf,defs}.h"
+dev/syscon/syscon.coptional fdt syscon
+dev/syscon/syscon_if.m optional fdt syscon
  dev/syscons/blank/blank_saver.c   optional blank_saver
  dev/syscons/daemon/daemon_saver.c optional daemon_saver
  dev/syscons/dragon/dragon_saver.c optional dragon_saver

Added: head/sys/dev/syscon/syscon.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/syscon/syscon.cMon Dec 11 18:04:04 2017
(r326773)
@@ -0,0 +1,185 @@
+/*-
+ * Copyright (c) 2015 Michal Meloun
+ * 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.
+ */
+
+/*
+ * This is a generic syscon driver, whose purpose is to provide access to
+ * various unrelated bits packed in a single register space. It is usually used
+ * as a fallback to more specific driver, but works well enough for simple
+ * access.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include "syscon_if.h"
+
+#define SYSCON_LOCK(_sc)   mtx_lock(&(_sc)->mtx)
+#defineSYSCON_UNLOCK(_sc)  mtx_unlock(&(_sc)->mtx)
+#define SYSCON_LOCK_INIT(_sc)  mtx_init(&(_sc)->mtx,\
+   device_get_nameunit((_sc)->dev), "syscon", MTX_DEF)
+#define SYSCON_LOCK_DESTROY(_sc)   mtx_destroy(&(_sc)->mtx);
+#define SYSCON_ASSERT_LOCKED(_sc)  mtx_assert(&(_sc)->mtx, MA_OWNED);
+#define SYSCON_ASSERT_UNLOCKED(_sc)mtx_assert(&(_sc)->mtx, MA_NOTOWNED);
+
+struct syscon_softc {
+   device_tdev;
+   struct resource *mem_res;
+   struct mtx  mtx;
+};
+
+static struct ofw_compat_data compat_data[] = {
+   {"syscon",1},
+   {NULL,  0}
+};
+
+static uint32_t
+syscon_read_4(device_t dev, device_t consumer, bus_size_t offset)
+{
+   struct syscon_softc *sc;
+   uint32_t val;
+
+   sc = device_get_softc(dev);
+
+   SYSCON_LOCK(sc);
+   val = bus_read_4(sc->mem_res, offset);
+   SYSCON_UNLOCK(sc);
+   return (val);
+}
+
+static void
+syscon_write_4(device_t dev, device_t consum

svn commit: r326978 - head/sys/conf

2017-12-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Dec 19 15:50:46 2017
New Revision: 326978
URL: https://svnweb.freebsd.org/changeset/base/326978

Log:
  Make __startkernel line up with KERNBASE, so that the math to compute the
  applied relocation offset in link_elf.c works as intended. We may want to
  revisit how that works in future, for example by having elf_reloc_self()
  actually store the numbers it is using rather than computing them later,
  but this fixes symbol lookup after r326203.
  
  Reported by:  andreast@
  Pointy hat to:me

Modified:
  head/sys/conf/ldscript.powerpc64

Modified: head/sys/conf/ldscript.powerpc64
==
--- head/sys/conf/ldscript.powerpc64Tue Dec 19 14:11:41 2017
(r326977)
+++ head/sys/conf/ldscript.powerpc64Tue Dec 19 15:50:46 2017
(r326978)
@@ -11,7 +11,7 @@ SECTIONS
   /* Read-only sections, merged into text segment: */
 
   . = kernbase;
-  PROVIDE (begin = . - SIZEOF_HEADERS);
+  PROVIDE (begin = .);
 
   .text  :
   {
___
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: r326981 - in head/sys/powerpc: booke powerpc

2017-12-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Dec 19 16:45:40 2017
New Revision: 326981
URL: https://svnweb.freebsd.org/changeset/base/326981

Log:
  The highest-order bit of the bootloader cookie is 1, with the result that
  the 32-bit cookie can be sign-extended on its way out of the loader and
  through Open Firmware. If sign-extended, the in-kernel check of its value
  would fail on 64-bit systems, resulting in a mountroot prompt. Solve this
  by telling the kernel to ignore the high-order bits.
  
  PR:   kern/224437
  Submitted by: Gustavo Romero

Modified:
  head/sys/powerpc/booke/booke_machdep.c
  head/sys/powerpc/powerpc/machdep.c

Modified: head/sys/powerpc/booke/booke_machdep.c
==
--- head/sys/powerpc/booke/booke_machdep.c  Tue Dec 19 16:20:13 2017
(r326980)
+++ head/sys/powerpc/booke/booke_machdep.c  Tue Dec 19 16:45:40 2017
(r326981)
@@ -201,7 +201,7 @@ extern void *int_performance_counter;
mtspr(ivor, (uintptr_t)(&handler) & 0xUL);
 
 uintptr_t powerpc_init(vm_offset_t fdt, vm_offset_t, vm_offset_t, void *mdp,
-vm_offset_t mdp_cookie);
+uint32_t mdp_cookie);
 void booke_cpu_init(void);
 
 void

Modified: head/sys/powerpc/powerpc/machdep.c
==
--- head/sys/powerpc/powerpc/machdep.c  Tue Dec 19 16:20:13 2017
(r326980)
+++ head/sys/powerpc/powerpc/machdep.c  Tue Dec 19 16:45:40 2017
(r326981)
@@ -155,7 +155,7 @@ SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size,
   CTLFLAG_RD, &cacheline_size, 0, "");
 
 uintptr_t  powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *,
-   vm_offset_t);
+   uint32_t);
 
 long   Maxmem = 0;
 long   realmem = 0;
@@ -234,7 +234,7 @@ void booke_cpu_init(void);
 
 uintptr_t
 powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp,
-vm_offset_t mdp_cookie)
+uint32_t mdp_cookie)
 {
struct  pcpu *pc;
struct cpuref   bsp;
___
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: r326758 - in head/sys/i386: conf include

2017-12-19 Thread Nathan Whitehorn



On 12/12/17 11:32, John Baldwin wrote:

On 12/11/17 5:26 AM, Eugene Grosbein wrote:

On 11.12.2017 16:19, Konstantin Belousov wrote:

On Mon, Dec 11, 2017 at 04:32:37AM +, Conrad Meyer wrote:

Author: cem
Date: Mon Dec 11 04:32:37 2017
New Revision: 326758
URL: https://svnweb.freebsd.org/changeset/base/326758

Log:
   i386: Bump KSTACK_PAGES default to match amd64

i386 is not amd64, the change is wrong.

i386 has the word size two times smaller than amd64, which makes typical
frame smaller by 30-40% over same code on amd64. Also i386 has much
smaller available KVA size (tens of MB) and KVA fragmentation is both
more severe and more fatal due to this. I expect that your change will
make any non-trivial load which creates enough threads to either fail
randomly or deadlock.

If somebody tries to fit large load onto i386 machine, he must know what to
do and how to configure the kernel to adapt to the load (which does not
require the recompilation).

Its very easy to get kernel stack overflow with 11-STABLE/i386
without any significant load due to abuse of kernel stack in many kernel 
subsystems
as shown in the https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219476

Contrary, "enough threads" seems to be very non-trivial number of threads
and pretty unusual load pattern for i386 as I run several such systems
with kern.kstack_pages=4 for quite long time and have no problems.
No random fails, no deadlocks. And with 2 pages only 11-STABLE/i386 is just 
unusable
if one utilizes SCTP, IPv6, some WiFi connectivity, IPSEC or even very small 
ZFS pool.

I still wonder if there is really such load pattern that creates "enough 
threads"
for i386 to make 4-pages stack troublesome.

I suspect two things are at play in running out of stack in 10.x and later.
1) Usage of XSAVE for AVX, etc. state uses more of the kstack (as kib@ alludes
to), and 2) clang.  Certainly for MIPS I have found that compiling with clang
instead of gcc for mips64 gives a kernel that panics for stack overflow for any
use of NFS.  It might be that this is due to something MIPS-specific, but it
might be worthwhile retesting with kstack_pages=2 and building the kernel
with CROSS_TOOLCHAIN=i386-gcc after installing the appropriate package.


For what it's worth, I see the same NFS-related stack overflows on 
mips64 with in-tree GCC 4.2.1.

-Nathan

___
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: r326758 - in head/sys/i386: conf include

2017-12-20 Thread Nathan Whitehorn



On 12/20/17 09:14, John Baldwin wrote:

On Wednesday, December 20, 2017 09:59:26 AM David Chisnall wrote:

On 16 Dec 2017, at 18:05, John Baldwin  wrote:

When I build a FreeBSD/mips64 kernel with clang,
_any_ simple NFS op triggers a kernel stack overflow.  Kernels compiled
with GCC do not.

That is not my experience.  I haven’t tried a MIPS64 kernel built with clang, 
but with in-tree gcc I get kernel panics as soon as I try to use NFS, unless I 
use Stacey’s patches that increase the kernel stack size.

I have primarily been using modern GCC for GCC once that was working, but at
least when running a MALTA64 kernel under qemu I was not triggering panics
even with old GCC.  With the in-tree clang 5.0 or with CHERI clang, just
doing an 'ls' of a NFS directory or even a tab-complete of a path that
is on NFS reliably triggers a kernel stack overflow for MALTA64 in qemu.

With Stacey's kstack pages, a clang kernel does survive, but those are not
in stock FreeBSD which is where I have been testing this.



With GCC 4, it takes a little while, but trying to build ports over NFS 
is a sure-fire way to bring down the kernel. I haven't tried any other 
compilers.

-Nathan
___
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: r327258 - head/usr.sbin/bsdinstall/partedit

2017-12-27 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Dec 28 01:21:30 2017
New Revision: 327258
URL: https://svnweb.freebsd.org/changeset/base/327258

Log:
  Fix bug introduced in r326674, in which efi boot partitions created by
  the installer but not mounted (i.e. with boot1.efifat dd'ed to them
  rather than the forthcoming proper filesystem) would get newfs_msdos run
  on them immediately after the boot code was copied. This would overwrite
  the bootstrap code, causing the EFI system partition to be blanked and
  resulting in an unbootable system.
  
  PR:   224562

Modified:
  head/usr.sbin/bsdinstall/partedit/gpart_ops.c

Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c
==
--- head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Thu Dec 28 01:20:30 
2017(r327257)
+++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Thu Dec 28 01:21:30 
2017(r327258)
@@ -942,7 +942,9 @@ add_boot_partition(struct ggeom *geom, struct gprovide
choice = 0;
 
if (choice == 0) { /* yes */
+   struct partition_metadata *md;
const char *bootmount = NULL;
+   char *bootpartname = NULL;
char sizestr[7];
 
humanize_number(sizestr, 7,
@@ -950,7 +952,21 @@ add_boot_partition(struct ggeom *geom, struct gprovide
HN_NOSPACE | HN_DECIMAL);
 
gpart_create(pp, bootpart_type(scheme, &bootmount),
-   sizestr, bootmount, NULL, 0);
+   sizestr, bootmount, &bootpartname, 0);
+
+   if (bootpartname == NULL) /* Error reported to user already */
+   return 0;
+
+   /* If the part is not mountable, make sure newfs isn't set */
+   if (bootmount == NULL) {
+   md = get_part_metadata(bootpartname, 0);
+   if (md != NULL && md->newfs != NULL) {
+   free(md->newfs);
+   md->newfs = NULL;
+   }
+   }
+
+   free(bootpartname);
 
return (bootpart_size(scheme));
}
___
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: r327318 - in head/sys: conf powerpc/ofw

2017-12-28 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Dec 28 23:49:53 2017
New Revision: 327318
URL: https://svnweb.freebsd.org/changeset/base/327318

Log:
  Remove ELF note for Open Firmware. It is marked optional in a single 1996
  draft of a never-finalized standard (CHRP) and is irrelevant in practice
  on FreeBSD since we load the kernel with loader(8) on Open Firmware
  platforms anyway. Moreover, loader(8), which is directly loaded by Open
  Firmware, has never had an equivalent note.
  
  MFC after:2 weeks

Deleted:
  head/sys/powerpc/ofw/ofwmagic.S
Modified:
  head/sys/conf/files.powerpc

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Thu Dec 28 22:57:34 2017(r327317)
+++ head/sys/conf/files.powerpc Thu Dec 28 23:49:53 2017(r327318)
@@ -158,7 +158,6 @@ powerpc/ofw/ofw_real.c  optionalaim
 powerpc/ofw/ofw_syscons.c  optionalsc aim
 powerpc/ofw/ofwcall32.Soptionalaim powerpc
 powerpc/ofw/ofwcall64.Soptionalaim powerpc64
-powerpc/ofw/ofwmagic.S optionalaim
 powerpc/ofw/openpic_ofw.c  optionalaim | fdt
 powerpc/ofw/rtas.c optionalaim
 powerpc/powermac/ata_kauai.c   optionalpowermac ata | powermac atamacio
___
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: r327357 - head/sys/powerpc/aim

2017-12-29 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Dec 29 20:25:15 2017
New Revision: 327357
URL: https://svnweb.freebsd.org/changeset/base/327357

Log:
  Maintain alignment of in-code 64-bit quantities by design rather than luck.
  If these are not aligned, the linker has to emit a different type of
  relocation that the early boot self-relocation code cannot handle, even
  in principle, resulting in them being set to zero and the kernel crashing.
  
  MFC after:1 week

Modified:
  head/sys/powerpc/aim/trap_subr64.S

Modified: head/sys/powerpc/aim/trap_subr64.S
==
--- head/sys/powerpc/aim/trap_subr64.S  Fri Dec 29 20:00:19 2017
(r327356)
+++ head/sys/powerpc/aim/trap_subr64.S  Fri Dec 29 20:25:15 2017
(r327357)
@@ -297,7 +297,8 @@ dtrace_invop_calltrap_addr:
  * not still hanging around in the trap handling region
  * once the MMU is turned on.
  */
-   .globl  CNAME(rstcode), CNAME(rstcodeend)
+   .globl  CNAME(rstcode), CNAME(rstcodeend), CNAME(cpu_reset_handler)
+   .p2align 3
 CNAME(rstcode):
/* Explicitly set MSR[SF] */
mfmsr   %r9
@@ -305,8 +306,9 @@ CNAME(rstcode):
insrdi  %r9,%r8,1,0
mtmsrd  %r9
isync
+
bl  1f
-   .llong  cpu_reset
+   .llong  cpu_reset_handler /* Make sure to maintain 8-byte alignment */
 1: mflr%r9
ld  %r9,0(%r9)
mtlr%r9
@@ -314,7 +316,7 @@ CNAME(rstcode):
blr
 CNAME(rstcodeend):
 
-cpu_reset:
+cpu_reset_handler:
GET_TOCBASE(%r2)
 
ld  %r1,TOC_REF(tmpstk)(%r2)/* get new SP */
@@ -569,6 +571,7 @@ CNAME(aliend):
  * Has to handle standard pagetable spills
  */
.globl  CNAME(dsitrap),CNAME(dsiend)
+   .p2align 3
 CNAME(dsitrap):
mtsprg1 %r1 /* save SP */
GET_CPUINFO(%r1)
@@ -831,6 +834,7 @@ dbleave:
  * In case of KDB we want a separate trap catcher for it
  */
.globl  CNAME(dblow),CNAME(dbend)
+   .p2align 3
 CNAME(dblow):
mtsprg1 %r1 /* save SP */
mtsprg2 %r29/* save r29 */
@@ -859,6 +863,7 @@ CNAME(dblow):
 std%r30,(PC_DBSAVE+CPUSAVE_R30)(%r1)   /* free r30 */
 std%r31,(PC_DBSAVE+CPUSAVE_R31)(%r1)   /* free r31 */
 mflr   %r28/* save LR */
+   nop /* alignment */
bl  9f  /* Begin branch */
.llong  dbtrap
 9: mflr%r1
___
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: r327358 - in head/sys: conf powerpc/aim powerpc/include

2017-12-29 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Dec 29 20:30:10 2017
New Revision: 327358
URL: https://svnweb.freebsd.org/changeset/base/327358

Log:
  Add support for 64-bit PowerPC kernels to be directly loaded by kexec, which
  is used as the bootloader on a number of PPC64 platforms. This involves the
  following pieces:
  - Making the first instruction a valid kernel entry point, since kexec
ignores the ELF entry value. This requires a separate section and linker
magic to prevent the linker from filling the beginning of the section
with stubs.
  - Adding an entry point at 0x60 past the first instruction for systems
lacking firmware CPU shutdown support (notably PS3).
  - Linker script changes to support the above.
  
  MFC after:1 month

Modified:
  head/sys/conf/ldscript.powerpc64
  head/sys/powerpc/aim/locore64.S
  head/sys/powerpc/include/vmparam.h

Modified: head/sys/conf/ldscript.powerpc64
==
--- head/sys/conf/ldscript.powerpc64Fri Dec 29 20:25:15 2017
(r327357)
+++ head/sys/conf/ldscript.powerpc64Fri Dec 29 20:30:10 2017
(r327358)
@@ -8,8 +8,12 @@ SEARCH_DIR(/usr/lib);
 PROVIDE (__stack = 0);
 SECTIONS
 {
-  /* Read-only sections, merged into text segment: */
 
+  /* Low-address wrapper for bootloaders (kexec/kboot) that can't parse ELF */
+  . = kernbase - 0x100;
+  .kboot : { *(.text.kboot) }
+
+  /* Read-only sections, merged into text segment: */
   . = kernbase;
   PROVIDE (begin = .);
 
@@ -27,6 +31,9 @@ SECTIONS
   /* Do not emit PT_INTERP section, which confuses some loaders (kexec-lite) */
   .interpX: { *(.interp)   } : NONE
   /DISCARD/   : { *(.interp)   } 
+
+  /* Also delete notes */
+  /DISCARD/   : { *(.note.*)   } 
 
   .hash  : { *(.hash)  }
   .dynsym: { *(.dynsym)}

Modified: head/sys/powerpc/aim/locore64.S
==
--- head/sys/powerpc/aim/locore64.S Fri Dec 29 20:25:15 2017
(r327357)
+++ head/sys/powerpc/aim/locore64.S Fri Dec 29 20:30:10 2017
(r327358)
@@ -61,6 +61,47 @@ GLOBAL(tmpstk)
 
 TOC_ENTRY(tmpstk)
 
+/*
+ * Entry point for bootloaders that do not fully implement ELF and start
+ * at the beginning of the image (kexec, notably). In its own section so
+ * that it ends up before any linker-generated call stubs and actually at
+ * the beginning of the image. kexec on some systems also enters at
+ * (start of image) + 0x60, so put a spin loop there.
+ */
+   .section ".text.kboot", "x", @progbits
+kbootentry:
+   b __start
+. = kbootentry + 0x40  /* Magic address used in platform layer */
+   .global smp_spin_sem
+ap_kexec_spin_sem:
+   .long   -1
+. = kbootentry + 0x60  /* Entry point for kexec APs */
+ap_kexec_start:/* At 0x60 past start, copied to 0x60 by kexec 
*/
+   /* r3 set to CPU ID by kexec */
+
+   /* Invalidate icache for low-memory copy and jump there */
+   li  %r0,0x80
+   dcbst   0,%r0
+   sync
+   icbi0,%r0
+   isync
+   ba  0x78/* Absolute branch to next inst */
+
+1: or  31,31,31/* yield */
+   sync
+   lwz %r1,0x40(0) /* Spin on ap_kexec_spin_sem */
+   cmpw%r1,%r3 /* Until it equals our CPU ID */
+   bne 1b
+   
+   /* Released */
+   or  2,2,2   /* unyield */
+   ba  EXC_RST
+
+
+/*
+ * Now start the real text section
+ */
+
.text
.globl  btext
 btext:

Modified: head/sys/powerpc/include/vmparam.h
==
--- head/sys/powerpc/include/vmparam.h  Fri Dec 29 20:25:15 2017
(r327357)
+++ head/sys/powerpc/include/vmparam.h  Fri Dec 29 20:30:10 2017
(r327358)
@@ -108,7 +108,7 @@
 #endif
 
 #ifdef AIM
-#defineKERNBASE0x0010UL/* start of kernel 
virtual */
+#defineKERNBASE0x00100100UL/* start of kernel 
virtual */
 
 #ifndef __powerpc64__
 #defineVM_MIN_KERNEL_ADDRESS   ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
___
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: r327360 - head/sys/powerpc/pseries

2017-12-29 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Dec 29 21:09:17 2017
New Revision: 327360
URL: https://svnweb.freebsd.org/changeset/base/327360

Log:
  Enhance the CHRP/pSeries platform layer:
  - Densely number CPUs to avoid systems with CPUs with very high ID numbers
  - Always have the BSP be CPU 0 to avoid remnant brokenness with non-0 BSPs
in other parts of the kernel.
  - Improve parsing of the device tree CPU listings on SMT systems.
  - Allow reboot via RTAS as well as OF for pSeries systems booted by FDT
without functioning Open Firmware.
  
  Obtained from:projects/powernv
  MFC after:3 weeks

Modified:
  head/sys/powerpc/pseries/platform_chrp.c

Modified: head/sys/powerpc/pseries/platform_chrp.c
==
--- head/sys/powerpc/pseries/platform_chrp.cFri Dec 29 20:33:56 2017
(r327359)
+++ head/sys/powerpc/pseries/platform_chrp.cFri Dec 29 21:09:17 2017
(r327360)
@@ -114,6 +114,8 @@ static platform_def_t chrp_platform = {
 
 PLATFORM_DEF(chrp_platform);
 
+#define BSP_MUST_BE_CPU_ZERO
+
 static int
 chrp_probe(platform_t plat)
 {
@@ -279,13 +281,31 @@ chrp_real_maxaddr(platform_t plat)
 static u_long
 chrp_timebase_freq(platform_t plat, struct cpuref *cpuref)
 {
-   phandle_t phandle;
+   char buf[8];
+   phandle_t cpu, dev, root;
+   int res;
int32_t ticks = -1;
 
-   phandle = cpuref->cr_hwref;
+   root = OF_peer(0);
 
-   OF_getencprop(phandle, "timebase-frequency", &ticks, sizeof(ticks));
+   dev = OF_child(root);
+   while (dev != 0) {
+   res = OF_getprop(dev, "name", buf, sizeof(buf));
+   if (res > 0 && strcmp(buf, "cpus") == 0)
+   break;
+   dev = OF_peer(dev);
+   }
 
+   for (cpu = OF_child(dev); cpu != 0; cpu = OF_peer(cpu)) {
+   res = OF_getprop(cpu, "device_type", buf, sizeof(buf));
+   if (res > 0 && strcmp(buf, "cpu") == 0)
+   break;
+   }
+   if (cpu == 0)
+   return (51200);
+
+   OF_getencprop(cpu, "timebase-frequency", &ticks, sizeof(ticks));
+
if (ticks <= 0)
panic("Unable to determine timebase frequency!");
 
@@ -293,11 +313,11 @@ chrp_timebase_freq(platform_t plat, struct cpuref *cpu
 }
 
 static int
-chrp_smp_first_cpu(platform_t plat, struct cpuref *cpuref)
+chrp_cpuref_for_server(struct cpuref *cpuref, int cpu_n, int server)
 {
char buf[8];
phandle_t cpu, dev, root;
-   int res, cpuid;
+   int res, cpuid, i, j;
 
root = OF_peer(0);
 
@@ -318,71 +338,84 @@ chrp_smp_first_cpu(platform_t plat, struct cpuref *cpu
return (ENOENT);
}
 
-   cpu = OF_child(dev);
-
-   while (cpu != 0) {
+   i = 0;
+   for (cpu = OF_child(dev); cpu != 0; cpu = OF_peer(cpu)) {
res = OF_getprop(cpu, "device_type", buf, sizeof(buf));
-   if (res > 0 && strcmp(buf, "cpu") == 0)
-   break;
-   cpu = OF_peer(cpu);
+   if (res <= 0 || strcmp(buf, "cpu") != 0)
+   continue;
+
+   res = OF_getproplen(cpu, "ibm,ppc-interrupt-server#s");
+   if (res > 0) {
+   cell_t interrupt_servers[res/sizeof(cell_t)];
+   OF_getencprop(cpu, "ibm,ppc-interrupt-server#s",
+   interrupt_servers, res);
+   for (j = 0; j < res/sizeof(cell_t); j++) {
+   cpuid = interrupt_servers[j];
+   if (server != -1 && cpuid == server)
+   break;
+   if (cpu_n != -1 && cpu_n == i)
+   break;
+   i++;
+   }
+
+   if (j != res/sizeof(cell_t))
+   break;
+   } else {
+   res = OF_getencprop(cpu, "reg", &cpuid, sizeof(cpuid));
+   if (res <= 0)
+   cpuid = 0;
+   if (server != -1 && cpuid == server)
+   break;
+   if (cpu_n != -1 && cpu_n == i)
+   break;
+   i++;
+   }
}
+
if (cpu == 0)
return (ENOENT);
 
-   cpuref->cr_hwref = cpu;
-   res = OF_getencprop(cpu, "ibm,ppc-interrupt-server#s", &cpuid,
-   sizeof(cpuid));
-   if (res <= 0)
-   res = OF_getencprop(cpu, "reg", &cpuid, sizeof(cpuid));
-   if (res <= 0)
-   cpuid = 0;
-   cpuref->cr_cpuid = cpuid;
+   cpuref->cr_hwref = cpuid;
+   cpuref->cr_cpuid = i;
 
return (0);
 }
 
 static int
+chrp_smp_first_cpu(platform_t plat, struct cpuref *cpuref)
+{
+#ifdef BSP_MUST_BE_

svn commit: r327387 - head/sys/dev/vt/hw/ofwfb

2017-12-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 30 20:23:14 2017
New Revision: 327387
URL: https://svnweb.freebsd.org/changeset/base/327387

Log:
  Check more aggressively for whether the desired properties actually exist.
  If they don't, the code would look up some random part of the device tree
  and seize the console inappropriately.
  
  MFC after:2 weeks

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

Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c
==
--- head/sys/dev/vt/hw/ofwfb/ofwfb.cSat Dec 30 19:49:40 2017
(r327386)
+++ head/sys/dev/vt/hw/ofwfb/ofwfb.cSat Dec 30 20:23:14 2017
(r327387)
@@ -94,8 +94,13 @@ ofwfb_probe(struct vt_device *vd)
char type[64];
 
chosen = OF_finddevice("/chosen");
-   OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
-   node = OF_instance_to_package(stdout);
+   if (chosen == -1)
+   return (CN_DEAD);
+
+   node = -1;
+   if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) ==
+   sizeof(stdout))
+   node = OF_instance_to_package(stdout);
if (node == -1) {
/*
 * The "/chosen/stdout" does not exist try
___
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: r327388 - head/sys/powerpc/ps3

2017-12-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 30 20:24:33 2017
New Revision: 327388
URL: https://svnweb.freebsd.org/changeset/base/327388

Log:
  Change the way SMP startup works to match the new multi-AP features in
  locore64.S introduced in r327358.
  
  MFC after:3 weeks

Modified:
  head/sys/powerpc/ps3/platform_ps3.c

Modified: head/sys/powerpc/ps3/platform_ps3.c
==
--- head/sys/powerpc/ps3/platform_ps3.c Sat Dec 30 20:23:14 2017
(r327387)
+++ head/sys/powerpc/ps3/platform_ps3.c Sat Dec 30 20:24:33 2017
(r327388)
@@ -103,6 +103,8 @@ static platform_def_t ps3_platform = {
 
 PLATFORM_DEF(ps3_platform);
 
+static int ps3_boot_pir = 0;
+
 static int
 ps3_probe(platform_t plat)
 {
@@ -129,6 +131,9 @@ ps3_attach(platform_t plat)
/* Set a breakpoint to make NULL an invalid address */
lv1_set_dabr(0x7 /* read and write, MMU on */, 2 /* kernel accesses */);
 
+   /* Record our PIR at boot for later */
+   ps3_boot_pir = mfspr(SPR_PIR);
+
return (0);
 }
 
@@ -189,7 +194,7 @@ ps3_smp_first_cpu(platform_t plat, struct cpuref *cpur
 {
 
cpuref->cr_cpuid = 0;
-   cpuref->cr_hwref = cpuref->cr_cpuid;
+   cpuref->cr_hwref = ps3_boot_pir;
 
return (0);
 }
@@ -202,7 +207,7 @@ ps3_smp_next_cpu(platform_t plat, struct cpuref *cpure
return (ENOENT);
 
cpuref->cr_cpuid++;
-   cpuref->cr_hwref = cpuref->cr_cpuid;
+   cpuref->cr_hwref = !ps3_boot_pir;
 
return (0);
 }
@@ -212,7 +217,7 @@ ps3_smp_get_bsp(platform_t plat, struct cpuref *cpuref
 {
 
cpuref->cr_cpuid = 0;
-   cpuref->cr_hwref = cpuref->cr_cpuid;
+   cpuref->cr_hwref = ps3_boot_pir;
 
return (0);
 }
@@ -220,21 +225,21 @@ ps3_smp_get_bsp(platform_t plat, struct cpuref *cpuref
 static int
 ps3_smp_start_cpu(platform_t plat, struct pcpu *pc)
 {
-   /* loader(8) is spinning on 0x40 == 0 right now */
-   uint32_t *secondary_spin_sem = (uint32_t *)(0x40);
+   /* kernel is spinning on 0x40 == -1 right now */
+   volatile uint32_t *secondary_spin_sem = (uint32_t *)(0x40);
+   int remote_pir = pc->pc_hwref;
int timeout;
 
-   if (pc->pc_hwref != 1)
-   return (ENXIO);
-
ap_pcpu = pc;
-   *secondary_spin_sem = 1;
-   powerpc_sync();
-   DELAY(1);
 
+   /* Try both PIR values, looping a few times: the HV likes moving us */
timeout = 1;
-   while (!pc->pc_awake && timeout--)
+   while (!pc->pc_awake && timeout--) {
+   *secondary_spin_sem = remote_pir;
+   powerpc_sync();
DELAY(100);
+   remote_pir = !remote_pir;
+   }
 
return ((pc->pc_awake) ? 0 : EBUSY);
 }
___
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: r327389 - head/sys/powerpc/ps3

2017-12-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 30 20:25:33 2017
New Revision: 327389
URL: https://svnweb.freebsd.org/changeset/base/327389

Log:
  Remove logic for early console with loader.ps3 now that loader.ps3 is dead.

Modified:
  head/sys/powerpc/ps3/mmu_ps3.c

Modified: head/sys/powerpc/ps3/mmu_ps3.c
==
--- head/sys/powerpc/ps3/mmu_ps3.c  Sat Dec 30 20:24:33 2017
(r327388)
+++ head/sys/powerpc/ps3/mmu_ps3.c  Sat Dec 30 20:25:33 2017
(r327389)
@@ -100,12 +100,18 @@ mps3_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm
 
moea64_early_bootstrap(mmup, kernelstart, kernelend);
 
+   /* In case we had a page table already */
+   lv1_destruct_virtual_address_space(0);
+
+   /* Allocate new hardware page table */
lv1_construct_virtual_address_space(
20 /* log_2(moea64_pteg_count) */, 2 /* n page sizes */,
(24UL << 56) | (16UL << 48) /* page sizes 16 MB + 64 KB */,
&mps3_vas_id, &final_pteg_count
);
 
+   lv1_select_virtual_address_space(mps3_vas_id);
+
moea64_pteg_count = final_pteg_count / sizeof(struct lpteg);
 
moea64_mid_bootstrap(mmup, kernelstart, kernelend);
@@ -122,14 +128,9 @@ mps3_cpu_bootstrap(mmu_t mmup, int ap)
mtmsr(mfmsr() & ~PSL_DR & ~PSL_IR);
 
/*
-* Destroy the loader's address space if we are coming up for
-* the first time, and redo the FB mapping so we can continue
-* having a console.
+* Select the page table we configured above and set up the FB mapping
+* so we can have a console.
 */
-
-   if (!ap)
-   lv1_destruct_virtual_address_space(0);
-
lv1_select_virtual_address_space(mps3_vas_id);
 
if (!ap)
___
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: r327390 - head/stand/powerpc/ps3

2017-12-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 30 20:27:13 2017
New Revision: 327390
URL: https://svnweb.freebsd.org/changeset/base/327390

Log:
  Garbage-collect loader.ps3. It is currently disconnected from the build and
  is superseded by either direct loading of the kernel by petitboot (soon to
  become the installer default) or loader.kboot.

Deleted:
  head/stand/powerpc/ps3/
___
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: r327391 - head/sys/dev/ofw

2017-12-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 30 20:28:29 2017
New Revision: 327391
URL: https://svnweb.freebsd.org/changeset/base/327391

Log:
  Avoid use of the fdt_get_property_*() API, which is intrinsically
  incompatible with FDT versions < 16. This also simplifies the code a bit.
  
  MFC after:1 month

Modified:
  head/sys/dev/ofw/ofw_fdt.c

Modified: head/sys/dev/ofw/ofw_fdt.c
==
--- head/sys/dev/ofw/ofw_fdt.c  Sat Dec 30 20:27:13 2017(r327390)
+++ head/sys/dev/ofw/ofw_fdt.c  Sat Dec 30 20:28:29 2017(r327391)
@@ -248,7 +248,7 @@ ofw_fdt_instance_to_package(ofw_t ofw, ihandle_t insta
 static ssize_t
 ofw_fdt_getproplen(ofw_t ofw, phandle_t package, const char *propname)
 {
-   const struct fdt_property *prop;
+   const void *prop;
int offset, len;
 
offset = fdt_phandle_offset(package);
@@ -256,7 +256,7 @@ ofw_fdt_getproplen(ofw_t ofw, phandle_t package, const
return (-1);
 
len = -1;
-   prop = fdt_get_property(fdtp, offset, propname, &len);
+   prop = fdt_getprop(fdtp, offset, propname, &len);
 
if (prop == NULL && strcmp(propname, "name") == 0) {
/* Emulate the 'name' property */
@@ -333,7 +333,7 @@ static int
 ofw_fdt_nextprop(ofw_t ofw, phandle_t package, const char *previous, char *buf,
 size_t size)
 {
-   const struct fdt_property *prop;
+   const void *prop;
const char *name;
int offset;
 
@@ -348,7 +348,7 @@ ofw_fdt_nextprop(ofw_t ofw, phandle_t package, const c
 
if (previous != NULL) {
while (offset >= 0) {
-   prop = fdt_get_property_by_offset(fdtp, offset, NULL);
+   prop = fdt_getprop_by_offset(fdtp, offset, &name, NULL);
if (prop == NULL)
return (-1); /* Internal error */
 
@@ -357,17 +357,16 @@ ofw_fdt_nextprop(ofw_t ofw, phandle_t package, const c
return (0); /* No more properties */
 
/* Check if the last one was the one we wanted */
-   name = fdt_string(fdtp, fdt32_to_cpu(prop->nameoff));
if (strcmp(name, previous) == 0)
break;
}
}
 
-   prop = fdt_get_property_by_offset(fdtp, offset, &offset);
+   prop = fdt_getprop_by_offset(fdtp, offset, &name, &offset);
if (prop == NULL)
return (-1); /* Internal error */
 
-   strncpy(buf, fdt_string(fdtp, fdt32_to_cpu(prop->nameoff)), size);
+   strncpy(buf, name, size);
 
return (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: r327417 - head/sys/powerpc/aim

2017-12-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 31 05:38:19 2017
New Revision: 327417
URL: https://svnweb.freebsd.org/changeset/base/327417

Log:
  Make sure the first instruction of the low-memory spinloop is in the
  cacheline being invalidated.
  
  MFC after:1 month

Modified:
  head/sys/powerpc/aim/locore64.S

Modified: head/sys/powerpc/aim/locore64.S
==
--- head/sys/powerpc/aim/locore64.S Sun Dec 31 05:22:26 2017
(r327416)
+++ head/sys/powerpc/aim/locore64.S Sun Dec 31 05:38:19 2017
(r327417)
@@ -85,8 +85,9 @@ ap_kexec_start:   /* At 0x60 past start, copied 
to 0x60
sync
icbi0,%r0
isync
-   ba  0x78/* Absolute branch to next inst */
+   ba  0x80/* Absolute branch to next inst */
 
+. = kbootentry + 0x80  /* Aligned to cache line */
 1: or  31,31,31/* yield */
sync
lwz %r1,0x40(0) /* Spin on ap_kexec_spin_sem */
___
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: r327405 - head/usr.sbin/bsdinstall/partedit

2017-12-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 31 03:13:45 2017
New Revision: 327405
URL: https://svnweb.freebsd.org/changeset/base/327405

Log:
  Teach bsdinstall partedit/sade how to format FAT partitions on GPT, which
  have the partition type code "ms-basic-data".
  
  MFC after:2 weeks

Modified:
  head/usr.sbin/bsdinstall/partedit/gpart_ops.c

Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c
==
--- head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Sun Dec 31 03:06:29 
2017(r327404)
+++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Sun Dec 31 03:13:45 
2017(r327405)
@@ -167,7 +167,8 @@ newfs_command(const char *fstype, char *command, int u
else if (strcmp(items[i].name, "atime") == 0)
strcat(command, "-O atime=off ");
}
-   } else if (strcmp(fstype, "fat32") == 0 || strcmp(fstype, "efi") == 0) {
+   } else if (strcmp(fstype, "fat32") == 0 || strcmp(fstype, "efi") == 0 ||
+strcmp(fstype, "ms-basic-data") == 0) {
int i;
DIALOG_LISTITEM items[] = {
{"FAT32", "FAT Type 32",
@@ -747,7 +748,8 @@ set_default_part_metadata(const char *name, const char
/* Get VFS from text after freebsd-, if possible */
if (strncmp("freebsd-", type, 8) == 0)
md->fstab->fs_vfstype = strdup(&type[8]);
-   else if (strcmp("fat32", type) == 0 || strcmp("efi", type) == 0)
+   else if (strcmp("fat32", type) == 0 || strcmp("efi", type) == 0
+   || strcmp("ms-basic-data", type) == 0)
md->fstab->fs_vfstype = strdup("msdosfs");
else
md->fstab->fs_vfstype = strdup(type); /* Guess */
___
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: r327418 - head/sys/powerpc/ps3

2017-12-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 31 06:10:07 2017
New Revision: 327418
URL: https://svnweb.freebsd.org/changeset/base/327418

Log:
  Use data from the boot loader to pick the appropriate output graphics mode
  instead of hard-coding a default. This information is passed implicitly by
  the PS3 firmware and can be relied upon. Also adjust the default mode, if
  somehow firmware doesn't pass one, to 1920x1080 from 720x480 since it is
  2017.
  
  MFC after:2 weeks

Modified:
  head/sys/powerpc/ps3/ps3_syscons.c

Modified: head/sys/powerpc/ps3/ps3_syscons.c
==
--- head/sys/powerpc/ps3/ps3_syscons.c  Sun Dec 31 05:38:19 2017
(r327417)
+++ head/sys/powerpc/ps3/ps3_syscons.c  Sun Dec 31 06:10:07 2017
(r327418)
@@ -159,16 +159,62 @@ static int
 ps3fb_init(struct vt_device *vd)
 {
struct ps3fb_softc *sc;
+   char linux_video_mode[24];
+   int linux_video_mode_num = 0;
 
/* Init softc */
vd->vd_softc = sc = &ps3fb_softc;
 
-   /* XXX: get from HV repository */
sc->fb_info.fb_depth = 32;
-   sc->fb_info.fb_height = 480;
-   sc->fb_info.fb_width = 720;
+   sc->fb_info.fb_height = 1080;
+   sc->fb_info.fb_width = 1920;
+
+   /* See if the bootloader has passed a graphics mode to use */
+   bzero(linux_video_mode, sizeof(linux_video_mode));
+   TUNABLE_STR_FETCH("video", linux_video_mode, sizeof(linux_video_mode));
+   sscanf(linux_video_mode, "ps3fb:mode:%d", &linux_video_mode_num);
+   
+   switch (linux_video_mode_num) {
+   case 1:
+   case 2:
+   sc->fb_info.fb_height = 480;
+   sc->fb_info.fb_width = 720;
+   break;
+   case 3:
+   case 8:
+   sc->fb_info.fb_height = 720;
+   sc->fb_info.fb_width = 1280;
+   break;
+   case 4:
+   case 5:
+   case 9:
+   case 10:
+   sc->fb_info.fb_height = 1080;
+   sc->fb_info.fb_width = 1920;
+   break;
+   case 6:
+   case 7:
+   sc->fb_info.fb_height = 576;
+   sc->fb_info.fb_width = 720;
+   break;
+   case 11:
+   sc->fb_info.fb_height = 768;
+   sc->fb_info.fb_width = 1024;
+   break;
+   case 12:
+   sc->fb_info.fb_height = 1024;
+   sc->fb_info.fb_width = 1280;
+   break;
+   case 13:
+   sc->fb_info.fb_height = 1200;
+   sc->fb_info.fb_width = 1920;
+   break;
+   }
+   
+   /* Allow explicitly-specified values for us to override everything */
TUNABLE_INT_FETCH("hw.ps3fb.height", &sc->fb_info.fb_height);
TUNABLE_INT_FETCH("hw.ps3fb.width", &sc->fb_info.fb_width);
+
sc->fb_info.fb_stride = sc->fb_info.fb_width*4;
sc->fb_info.fb_size = sc->fb_info.fb_height * sc->fb_info.fb_stride;
sc->fb_info.fb_bpp = sc->fb_info.fb_stride / sc->fb_info.fb_width * 8;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327441 - head/sys/powerpc/powerpc

2017-12-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 31 20:08:16 2017
New Revision: 327441
URL: https://svnweb.freebsd.org/changeset/base/327441

Log:
  Provide relative, as well as absolute, addresses in trap panic panics. This
  makes it easier to cross-correlate them with instruction listings without
  worrying about where the kernel was relocated to.
  
  MFC after:1 week

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

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Sun Dec 31 19:24:13 2017
(r327440)
+++ head/sys/powerpc/powerpc/trap.c Sun Dec 31 20:08:16 2017
(r327441)
@@ -97,6 +97,8 @@ static inthandle_user_slb_spill(pmap_t pm, vm_offset_
 extern int n_slbs;
 #endif
 
+extern vm_offset_t __startkernel;
+
 #ifdef KDB
 int db_trap_glue(struct trapframe *);  /* Called from trap_subr.S */
 #endif
@@ -123,6 +125,7 @@ static struct powerpc_exception powerpc_exceptions[] =
{ EXC_EXI,  "external interrupt" },
{ EXC_ALI,  "alignment" },
{ EXC_PGM,  "program" },
+   { EXC_HEA,  "hypervisor emulation assistance" },
{ EXC_FPU,  "floating-point unavailable" },
{ EXC_APU,  "auxiliary proc unavailable" },
{ EXC_DECR, "decrementer" },
@@ -484,9 +487,11 @@ printtrap(u_int vector, struct trapframe *frame, int i
printf("   esr = 0x%b\n",
(int)frame->cpu.booke.esr, ESR_BITMASK);
 #endif
-   printf("   srr0= 0x%" PRIxPTR "\n", frame->srr0);
+   printf("   srr0= 0x%" PRIxPTR " (0x%" PRIxPTR ")\n",
+   frame->srr0, frame->srr0 - (__startkernel - KERNBASE));
printf("   srr1= 0x%lx\n", (u_long)frame->srr1);
-   printf("   lr  = 0x%" PRIxPTR "\n", frame->lr);
+   printf("   lr  = 0x%" PRIxPTR " (0x%" PRIxPTR ")\n",
+   frame->lr, frame->lr - (__startkernel - KERNBASE));
printf("   curthread   = %p\n", curthread);
if (curthread != NULL)
printf("  pid = %d, comm = %s\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: r327442 - head/sys/powerpc/powerpc

2017-12-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 31 20:10:08 2017
New Revision: 327442
URL: https://svnweb.freebsd.org/changeset/base/327442

Log:
  Make newer binutils happy by using a bl-type branch instead of b, which
  displeases it for some reason. LR is not relevant in this code, so just
  do what it wants.

Modified:
  head/sys/powerpc/powerpc/swtch64.S

Modified: head/sys/powerpc/powerpc/swtch64.S
==
--- head/sys/powerpc/powerpc/swtch64.S  Sun Dec 31 20:08:16 2017
(r327441)
+++ head/sys/powerpc/powerpc/swtch64.S  Sun Dec 31 20:10:08 2017
(r327442)
@@ -280,5 +280,5 @@ ENTRY_NOPROF(fork_trampoline)
   trapframe to simulate FRAME_SETUP
   does when allocating space for
   a frame pointer/saved LR */
-   b   trapexit
+   bl  trapexit
nop
___
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: r327443 - head/sys/powerpc/powerpc

2017-12-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 31 20:20:55 2017
New Revision: 327443
URL: https://svnweb.freebsd.org/changeset/base/327443

Log:
  Fix 32-bit build.

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

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Sun Dec 31 20:10:08 2017
(r327442)
+++ head/sys/powerpc/powerpc/trap.c Sun Dec 31 20:20:55 2017
(r327443)
@@ -488,10 +488,10 @@ printtrap(u_int vector, struct trapframe *frame, int i
(int)frame->cpu.booke.esr, ESR_BITMASK);
 #endif
printf("   srr0= 0x%" PRIxPTR " (0x%" PRIxPTR ")\n",
-   frame->srr0, frame->srr0 - (__startkernel - KERNBASE));
+   frame->srr0, frame->srr0 - (register_t)(__startkernel - KERNBASE));
printf("   srr1= 0x%lx\n", (u_long)frame->srr1);
printf("   lr  = 0x%" PRIxPTR " (0x%" PRIxPTR ")\n",
-   frame->lr, frame->lr - (__startkernel - KERNBASE));
+   frame->lr, frame->lr - (register_t)(__startkernel - KERNBASE));
printf("   curthread   = %p\n", curthread);
if (curthread != NULL)
printf("  pid = %d, comm = %s\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: r327445 - in head/sys/powerpc: include powerpc

2017-12-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 31 20:23:39 2017
New Revision: 327445
URL: https://svnweb.freebsd.org/changeset/base/327445

Log:
  Remove PIR from PCPU data. It has an implementation-defined meaning that
  is of limited utility outside of platform-specific code and can vary
  at runtime when running as a hypervisor guest, so does not even have the
  virtue of being a static identifier.
  
  Reviewed by:  jhibbits

Modified:
  head/sys/powerpc/include/pcpu.h
  head/sys/powerpc/powerpc/db_interface.c
  head/sys/powerpc/powerpc/machdep.c
  head/sys/powerpc/powerpc/mp_machdep.c

Modified: head/sys/powerpc/include/pcpu.h
==
--- head/sys/powerpc/include/pcpu.h Sun Dec 31 20:21:05 2017
(r327444)
+++ head/sys/powerpc/include/pcpu.h Sun Dec 31 20:23:39 2017
(r327445)
@@ -46,7 +46,6 @@ struct pvo_entry;
struct thread   *pc_fputhread;  /* current fpu user */  \
struct thread   *pc_vecthread;  /* current vec user */  \
uintptr_t   pc_hwref;   \
-   uint32_tpc_pir; \
int pc_bsp; \
volatile intpc_awake;   \
uint32_tpc_ipimask; \

Modified: head/sys/powerpc/powerpc/db_interface.c
==
--- head/sys/powerpc/powerpc/db_interface.c Sun Dec 31 20:21:05 2017
(r327444)
+++ head/sys/powerpc/powerpc/db_interface.c Sun Dec 31 20:23:39 2017
(r327445)
@@ -91,5 +91,4 @@ db_show_mdpcpu(struct pcpu *pc)
 
db_printf("PPC: hwref   = %#zx\n", pc->pc_hwref);
db_printf("PPC: ipimask = %#x\n", pc->pc_ipimask);
-   db_printf("PPC: pir = %#x\n", pc->pc_pir);
 }

Modified: head/sys/powerpc/powerpc/machdep.c
==
--- head/sys/powerpc/powerpc/machdep.c  Sun Dec 31 20:21:05 2017
(r327444)
+++ head/sys/powerpc/powerpc/machdep.c  Sun Dec 31 20:23:39 2017
(r327445)
@@ -368,7 +368,6 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs
thread0.td_oncpu = bsp.cr_cpuid;
pc->pc_cpuid = bsp.cr_cpuid;
pc->pc_hwref = bsp.cr_hwref;
-   pc->pc_pir = mfspr(SPR_PIR);
__asm __volatile("mtsprg 0, %0" :: "r"(pc));
 
/*

Modified: head/sys/powerpc/powerpc/mp_machdep.c
==
--- head/sys/powerpc/powerpc/mp_machdep.c   Sun Dec 31 20:21:05 2017
(r327444)
+++ head/sys/powerpc/powerpc/mp_machdep.c   Sun Dec 31 20:23:39 2017
(r327445)
@@ -74,8 +74,6 @@ void
 machdep_ap_bootstrap(void)
 {
 
-   /* Set PIR */
-   PCPU_SET(pir, mfspr(SPR_PIR));
PCPU_SET(awake, 1);
__asm __volatile("msync; isync");
 
@@ -224,13 +222,13 @@ cpu_mp_unleash(void *dummy)
DELAY(1000);
 
} else {
-   PCPU_SET(pir, mfspr(SPR_PIR));
pc->pc_awake = 1;
}
if (pc->pc_awake) {
if (bootverbose)
-   printf("Adding CPU %d, pir=%x, awake=%x\n",
-   pc->pc_cpuid, pc->pc_pir, pc->pc_awake);
+   printf("Adding CPU %d, hwref=%jx, awake=%x\n",
+   pc->pc_cpuid, (uintmax_t)pc->pc_hwref,
+   pc->pc_awake);
smp_cpus++;
} else
CPU_SET(pc->pc_cpuid, &stopped_cpus);
___
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: r327456 - head/release/powerpc

2017-12-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Jan  1 03:33:01 2018
New Revision: 327456
URL: https://svnweb.freebsd.org/changeset/base/327456

Log:
  After removal of loader.ps3, change petitboot configuration in release media
  to directly kexec the kernel. Unlike the old loader.ps3 code, this also works
  on PowerNV systems, which also use petitboot.
  
  MFC after:1 month

Modified:
  head/release/powerpc/mkisoimages.sh

Modified: head/release/powerpc/mkisoimages.sh
==
--- head/release/powerpc/mkisoimages.sh Mon Jan  1 00:20:35 2018
(r327455)
+++ head/release/powerpc/mkisoimages.sh Mon Jan  1 03:33:01 2018
(r327456)
@@ -23,20 +23,38 @@
 # extra-bits-dir, if provided, contains additional files to be merged
 # into base-bits-dir as part of making the image.
 
+
 if [ "$1" = "-b" ]; then
+   bootable=1
+   shift
+else
+   bootable=""
+fi
+
+if [ $# -lt 3 ]; then
+   echo "Usage: $0 [-b] image-label image-name base-bits-dir 
[extra-bits-dir]"
+   exit 1
+fi
+
+LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
+NAME="$1"; shift
+
+if [ -n "$bootable" ]; then
+   echo "Building bootable disc"
+
# Apple boot code
uudecode -o /tmp/hfs-boot-block.bz2 "`dirname "$0"`/hfs-boot.bz2.uu"
bzip2 -d /tmp/hfs-boot-block.bz2
OFFSET=$(hd /tmp/hfs-boot-block | grep 'Loader START' | cut -f 1 -d ' ')
OFFSET=0x$(echo 0x$OFFSET | awk '{printf("%x\n",$1/512);}')
-   dd if="$4/boot/loader" of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc
+   dd if="$1/boot/loader" of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc
 
bootable="-o bootimage=macppc;/tmp/hfs-boot-block -o no-emul-boot"
 
# pSeries/PAPR boot code
-   mkdir -p "$4/ppc/chrp"
-   cp "$4/boot/loader" "$4/ppc/chrp"
-   cat > "$4/ppc/bootinfo.txt" << EOF
+   mkdir -p "$1/ppc/chrp"
+   cp "$1/boot/loader" "$1/ppc/chrp"
+   cat > "$1/ppc/bootinfo.txt" << EOF
 
 FreeBSD Install
 FreeBSD
@@ -45,21 +63,9 @@ if [ "$1" = "-b" ]; then
 EOF
bootable="$bootable -o chrp-boot"
 
-   # Playstation 3 boot code
-   echo "FreeBSD Install='/boot/loader.ps3'" > "$4/etc/kboot.conf"
-
-   shift
-else
-   bootable=""
+   # Petitboot config for PS3/PowerNV
+   echo FreeBSD Install=\'/boot/kernel/kernel 
vfs.root.mountfrom=cd9660:/dev/iso9660/$LABEL\' > "$1/etc/kboot.conf"
 fi
-
-if [ $# -lt 3 ]; then
-   echo "Usage: $0 [-b] image-label image-name base-bits-dir 
[extra-bits-dir]"
-   exit 1
-fi
-
-LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
-NAME="$1"; shift
 
 publisher="The FreeBSD Project.  https://www.FreeBSD.org/";
 echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab"
___
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: r327484 - head/sys/powerpc/ps3

2018-01-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Jan  2 03:59:46 2018
New Revision: 327484
URL: https://svnweb.freebsd.org/changeset/base/327484

Log:
  Fix reversed endianness that crept in at some point. Blue is now blue
  instead of pink.
  
  MFC after:3 days

Modified:
  head/sys/powerpc/ps3/ps3_syscons.c

Modified: head/sys/powerpc/ps3/ps3_syscons.c
==
--- head/sys/powerpc/ps3/ps3_syscons.c  Tue Jan  2 01:48:11 2018
(r327483)
+++ head/sys/powerpc/ps3/ps3_syscons.c  Tue Jan  2 03:59:46 2018
(r327484)
@@ -229,7 +229,7 @@ ps3fb_init(struct vt_device *vd)
 
/* 32-bit VGA palette */
vt_generate_cons_palette(sc->fb_info.fb_cmap, COLOR_FORMAT_RGB,
-   255, 0, 255, 8, 255, 16);
+   255, 16, 255, 8, 255, 0);
 
/* Set correct graphics context */
lv1_gpu_context_attribute(sc->sc_fbcontext,
___
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: r327486 - head/usr.sbin/bsdinstall/distextract

2018-01-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Jan  2 05:22:54 2018
New Revision: 327486
URL: https://svnweb.freebsd.org/changeset/base/327486

Log:
  Skip errors from being unable to set modification and creation times. If
  one of the directories in the filesystem hierarchy is a FAT mountpoint,
  settings its times will fail, which would cause installation to abort.
  Instead, make this a best-effort thing.
  
  Handling this error is a hack and a better internal scheme for handling
  this should be added to libarchive.

Modified:
  head/usr.sbin/bsdinstall/distextract/distextract.c

Modified: head/usr.sbin/bsdinstall/distextract/distextract.c
==
--- head/usr.sbin/bsdinstall/distextract/distextract.c  Tue Jan  2 04:35:56 
2018(r327485)
+++ head/usr.sbin/bsdinstall/distextract/distextract.c  Tue Jan  2 05:22:54 
2018(r327486)
@@ -310,7 +310,15 @@ extract_files(struct dpv_file_node *file, int out __un
archive = NULL;
file->status = DPV_STATUS_DONE;
return (100);
-   } else if (retval != ARCHIVE_OK) {
+   } else if (retval != ARCHIVE_OK &&
+   !(retval == ARCHIVE_WARN &&
+   strcmp(archive_error_string(archive), "Can't restore time") == 0)) {
+   /*
+* Print any warning/error messages except inability to set
+* ctime/mtime, which is not fatal, or even interesting,
+* for our purposes. Would be nice if this were a libarchive
+* option.
+*/
snprintf(errormsg, sizeof(errormsg),
"Error while extracting %s: %s\n", file->name,
archive_error_string(archive));
___
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: r327487 - in head/usr.sbin/bsdinstall: partedit scripts

2018-01-01 Thread Nathan Whitehorn
  if (strcmp(platform, "chrp") == 0)
return ("/boot/boot1.elf");
return (NULL);
 }

Modified: head/usr.sbin/bsdinstall/scripts/Makefile
==
--- head/usr.sbin/bsdinstall/scripts/Makefile   Tue Jan  2 05:22:54 2018
(r327486)
+++ head/usr.sbin/bsdinstall/scripts/Makefile   Tue Jan  2 05:27:24 2018
(r327487)
@@ -1,8 +1,9 @@
 # $FreeBSD$
 
-SCRIPTS= auto adduser checksum config docsinstall entropy hardening hostname 
jail \
-keymap mirrorselect mount netconfig netconfig_ipv4 netconfig_ipv6 \
-rootpass script services time umount wlanconfig zfsboot
+SCRIPTS= auto adduser bootconfig checksum config docsinstall entropy hardening 
\
+hostname jail keymap mirrorselect mount netconfig netconfig_ipv4 \
+netconfig_ipv6 rootpass script services time umount wlanconfig \
+zfsboot
 BINDIR= ${LIBEXECDIR}/bsdinstall
 
 MAN=

Modified: head/usr.sbin/bsdinstall/scripts/auto
==
--- head/usr.sbin/bsdinstall/scripts/auto   Tue Jan  2 05:22:54 2018
(r327486)
+++ head/usr.sbin/bsdinstall/scripts/auto   Tue Jan  2 05:27:24 2018
(r327487)
@@ -377,6 +377,10 @@ fi
 
 bsdinstall checksum || error "Distribution checksum failed"
 bsdinstall distextract || error "Distribution extract failed"
+
+# Set up boot loader
+bsdinstall bootconfig || error "Failed to configure bootloader"
+
 bsdinstall rootpass || error "Could not set root password"
 
 trap true SIGINT   # This section is optional

Added: head/usr.sbin/bsdinstall/scripts/bootconfig
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/bsdinstall/scripts/bootconfig Tue Jan  2 05:27:24 2018
(r327487)
@@ -0,0 +1,40 @@
+#!/bin/sh
+#-
+# Copyright (c) 2017 Nathan Whitehorn
+# 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$
+
+if [ `uname -m` == powerpc ]; then
+   platform=`sysctl -n hw.platform`
+   if [ "$platform" == ps3 -o "$platform" == powernv ]; then
+   rootpart=$(awk '{ if($2 == "/") printf("%s:%s\n", $3, $1); }' 
$PATH_FSTAB)
+   mkdir -p $BSDINSTALL_CHROOT/boot/etc/
+   echo FreeBSD=\'/kernel/kernel vfs.root.mountfrom=${rootpart}\' 
> $BSDINSTALL_CHROOT/boot/etc/kboot.conf
+   fi
+fi
+
+# For new-style EFI booting, add code here
+# Add boot0cfg for MBR BIOS booting?
+

Modified: head/usr.sbin/bsdinstall/scripts/script
==
--- head/usr.sbin/bsdinstall/scripts/script Tue Jan  2 05:22:54 2018
(r327486)
+++ head/usr.sbin/bsdinstall/scripts/script Tue Jan  2 05:27:24 2018
(r327487)
@@ -116,8 +116,15 @@ fi
 bsdinstall checksum
 for set in $DISTRIBUTIONS; do
f_dprintf "Extracting $BSDINSTALL_DISTDIR/$set"
+   # XXX: this will fail if any mountpoints are FAT, due to inability to
+   # set ctime/mtime on the root of FAT partitions. tar has no option to
+   # ignore this. We probably need to switch back to distextract here
+   # to properly support EFI.
tar -xf "$BSDINSTALL_DISTDIR/$set" -C $BSDINSTALL_CHROOT
 done
+
+# Configure bootloader if needed
+bsdinstall bootconfig
 
 # Finalize install
 bsdinstall config
___
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: r327566 - head/sys/powerpc/pseries

2018-01-04 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Jan  4 23:07:51 2018
New Revision: 327566
URL: https://svnweb.freebsd.org/changeset/base/327566

Log:
  Revert r327360, which can cause boot problems on high-CPU-count (>60)
  POWER8 and POWER9 systems, pending further analysis.
  
  PR:   224841

Modified:
  head/sys/powerpc/pseries/platform_chrp.c

Modified: head/sys/powerpc/pseries/platform_chrp.c
==
--- head/sys/powerpc/pseries/platform_chrp.cThu Jan  4 22:59:24 2018
(r327565)
+++ head/sys/powerpc/pseries/platform_chrp.cThu Jan  4 23:07:51 2018
(r327566)
@@ -114,8 +114,6 @@ static platform_def_t chrp_platform = {
 
 PLATFORM_DEF(chrp_platform);
 
-#define BSP_MUST_BE_CPU_ZERO
-
 static int
 chrp_probe(platform_t plat)
 {
@@ -281,31 +279,13 @@ chrp_real_maxaddr(platform_t plat)
 static u_long
 chrp_timebase_freq(platform_t plat, struct cpuref *cpuref)
 {
-   char buf[8];
-   phandle_t cpu, dev, root;
-   int res;
+   phandle_t phandle;
int32_t ticks = -1;
 
-   root = OF_peer(0);
+   phandle = cpuref->cr_hwref;
 
-   dev = OF_child(root);
-   while (dev != 0) {
-   res = OF_getprop(dev, "name", buf, sizeof(buf));
-   if (res > 0 && strcmp(buf, "cpus") == 0)
-   break;
-   dev = OF_peer(dev);
-   }
+   OF_getencprop(phandle, "timebase-frequency", &ticks, sizeof(ticks));
 
-   for (cpu = OF_child(dev); cpu != 0; cpu = OF_peer(cpu)) {
-   res = OF_getprop(cpu, "device_type", buf, sizeof(buf));
-   if (res > 0 && strcmp(buf, "cpu") == 0)
-   break;
-   }
-   if (cpu == 0)
-   return (51200);
-
-   OF_getencprop(cpu, "timebase-frequency", &ticks, sizeof(ticks));
-
if (ticks <= 0)
panic("Unable to determine timebase frequency!");
 
@@ -313,11 +293,11 @@ chrp_timebase_freq(platform_t plat, struct cpuref *cpu
 }
 
 static int
-chrp_cpuref_for_server(struct cpuref *cpuref, int cpu_n, int server)
+chrp_smp_first_cpu(platform_t plat, struct cpuref *cpuref)
 {
char buf[8];
phandle_t cpu, dev, root;
-   int res, cpuid, i, j;
+   int res, cpuid;
 
root = OF_peer(0);
 
@@ -338,84 +318,71 @@ chrp_cpuref_for_server(struct cpuref *cpuref, int cpu_
return (ENOENT);
}
 
-   i = 0;
-   for (cpu = OF_child(dev); cpu != 0; cpu = OF_peer(cpu)) {
-   res = OF_getprop(cpu, "device_type", buf, sizeof(buf));
-   if (res <= 0 || strcmp(buf, "cpu") != 0)
-   continue;
+   cpu = OF_child(dev);
 
-   res = OF_getproplen(cpu, "ibm,ppc-interrupt-server#s");
-   if (res > 0) {
-   cell_t interrupt_servers[res/sizeof(cell_t)];
-   OF_getencprop(cpu, "ibm,ppc-interrupt-server#s",
-   interrupt_servers, res);
-   for (j = 0; j < res/sizeof(cell_t); j++) {
-   cpuid = interrupt_servers[j];
-   if (server != -1 && cpuid == server)
-   break;
-   if (cpu_n != -1 && cpu_n == i)
-   break;
-   i++;
-   }
-
-   if (j != res/sizeof(cell_t))
-   break;
-   } else {
-   res = OF_getencprop(cpu, "reg", &cpuid, sizeof(cpuid));
-   if (res <= 0)
-   cpuid = 0;
-   if (server != -1 && cpuid == server)
-   break;
-   if (cpu_n != -1 && cpu_n == i)
-   break;
-   i++;
-   }
+   while (cpu != 0) {
+   res = OF_getprop(cpu, "device_type", buf, sizeof(buf));
+   if (res > 0 && strcmp(buf, "cpu") == 0)
+   break;
+   cpu = OF_peer(cpu);
}
-
if (cpu == 0)
return (ENOENT);
 
-   cpuref->cr_hwref = cpuid;
-   cpuref->cr_cpuid = i;
+   cpuref->cr_hwref = cpu;
+   res = OF_getencprop(cpu, "ibm,ppc-interrupt-server#s", &cpuid,
+   sizeof(cpuid));
+   if (res <= 0)
+   res = OF_getencprop(cpu, "reg", &cpuid, sizeof(cpuid));
+   if (res <= 0)
+   cpuid = 0;
+   cpuref->cr_cpuid = cpuid;
 
return (0);
 }
 
 static int
-chrp_smp_first_cpu(platform_t plat, struct cpuref *cpuref)
-{
-#ifdef BSP_MUST_BE_CPU_ZERO
-   return (chrp_smp_get_bsp(plat, cpuref));
-#else
-   return (chrp_cpuref_for_server(cpuref, 0, -1));
-#endif
-}
-
-static int
 chrp_smp_next_cpu(platform_t plat, struct cpuref *cpuref)
 {
-#ifdef BSP_MUST_BE_CPU_ZERO
-   int bsp, ncp

svn commit: r327736 - head/sys/powerpc/conf

2018-01-09 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Jan  9 19:41:10 2018
New Revision: 327736
URL: https://svnweb.freebsd.org/changeset/base/327736

Log:
  Add XHCI support to powerpc64 GENERIC. This is useful to get input devices
  supported on newer POWER hardware and in graphical VMs run on the same,
  which are typically XHCI-only. The 32-bit GENERIC kernel, which
  does not run on hardware made in the last decade and is unlikely to
  encounter XHCI devices, is left unchanged.
  
  PR:   kern/224940
  Submitted by: Gustavo Romero
  MFC after:1 week

Modified:
  head/sys/powerpc/conf/GENERIC64

Modified: head/sys/powerpc/conf/GENERIC64
==
--- head/sys/powerpc/conf/GENERIC64 Tue Jan  9 19:02:42 2018
(r327735)
+++ head/sys/powerpc/conf/GENERIC64 Tue Jan  9 19:41:10 2018
(r327736)
@@ -173,6 +173,7 @@ options USB_DEBUG   # enable debug msgs
 device uhci# UHCI PCI->USB interface
 device ohci# OHCI PCI->USB interface
 device ehci# EHCI PCI->USB interface
+device xhci# XHCI PCI->USB interface
 device usb # USB Bus (required)
 device uhid# "Human Interface Devices"
 device ukbd# Keyboard
___
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: r327908 - head/sys/powerpc/ofw

2018-01-12 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Jan 13 03:09:05 2018
New Revision: 327908
URL: https://svnweb.freebsd.org/changeset/base/327908

Log:
  Chase removal of FDT fixup code on PowerPC in r327907.

Modified:
  head/sys/powerpc/ofw/ofw_machdep.c

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==
--- head/sys/powerpc/ofw/ofw_machdep.c  Sat Jan 13 02:56:09 2018
(r327907)
+++ head/sys/powerpc/ofw/ofw_machdep.c  Sat Jan 13 03:09:05 2018
(r327908)
@@ -420,8 +420,6 @@ OF_bootstrap()
return status;
 
err = OF_init(fdt);
-   if (err == 0)
-   OF_interpret("perform-fixup", 0);
} 
 
if (err != 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"


Re: svn commit: r327907 - in head/sys: conf dev/fdt dev/ofw

2018-01-12 Thread Nathan Whitehorn
Thanks, Justin! Since the fixup stuff is now only defined for 
FDT_MARVELL, it would be great if it could move to sys/arm/mv now 
instead of being in MI code.

-Nathan

On 01/12/18 18:56, Justin Hibbits wrote:

Author: jhibbits
Date: Sat Jan 13 02:56:09 2018
New Revision: 327907
URL: https://svnweb.freebsd.org/changeset/base/327907

Log:
   Remove fdt fixups for powerpc, they are no longer needed.
   
   If a fixup really is needed, it should be fixed in u-boot, not in FreeBSD.
   
   Suggested by:	nwhitehorn


Deleted:
   head/sys/dev/fdt/fdt_powerpc.c
Modified:
   head/sys/conf/files.powerpc
   head/sys/dev/ofw/ofw_fdt.c

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Sat Jan 13 01:36:37 2018(r327906)
+++ head/sys/conf/files.powerpc Sat Jan 13 02:56:09 2018(r327907)
@@ -31,7 +31,6 @@ dev/adb/adb_if.m  optionaladb
  dev/adb/adb_buttons.c optionaladb
  dev/agp/agp_apple.c   optionalagp powermac
  dev/fb/fb.c   optionalsc
-dev/fdt/fdt_powerpc.c  optionalfdt
  # ofwbus depends on simplebus.
  dev/fdt/simplebus.c   optionalaim | fdt
  dev/hwpmc/hwpmc_e500.coptionalhwpmc

Modified: head/sys/dev/ofw/ofw_fdt.c
==
--- head/sys/dev/ofw/ofw_fdt.c  Sat Jan 13 01:36:37 2018(r327906)
+++ head/sys/dev/ofw/ofw_fdt.c  Sat Jan 13 02:56:09 2018(r327907)
@@ -430,7 +430,7 @@ ofw_fdt_package_to_path(ofw_t ofw, phandle_t package,
return (-1);
  }
  
-#if defined(FDT_MARVELL) || defined(__powerpc__)

+#if defined(FDT_MARVELL)
  static int
  ofw_fdt_fixup(ofw_t ofw)
  {
@@ -477,7 +477,7 @@ ofw_fdt_fixup(ofw_t ofw)
  static int
  ofw_fdt_interpret(ofw_t ofw, const char *cmd, int nret, cell_t *retvals)
  {
-#if defined(FDT_MARVELL) || defined(__powerpc__)
+#if defined(FDT_MARVELL)
int rv;
  
  	/*




___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Jan 13 23:14:53 2018
New Revision: 327950
URL: https://svnweb.freebsd.org/changeset/base/327950

Log:
  Document places we assume that physical memory is direct-mapped at zero by
  using a new macro PHYS_TO_DMAP, which deliberately has the same name as the
  equivalent macro on amd64. This also sets the stage for moving the direct
  map to another base address.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/include/vmparam.h
  head/sys/powerpc/powerpc/uma_machdep.c
  head/sys/powerpc/ps3/platform_ps3.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cSat Jan 13 22:30:30 2018
(r327949)
+++ head/sys/powerpc/aim/mmu_oea64.cSat Jan 13 23:14:53 2018
(r327950)
@@ -540,7 +540,8 @@ moea64_add_ofw_mappings(mmu_t mmup, phandle_t mmu, siz
DISABLE_TRANS(msr);
for (off = 0; off < translations[i].om_len; off += PAGE_SIZE) {
/* If this address is direct-mapped, skip remapping */
-   if (hw_direct_map && translations[i].om_va == pa_base &&
+   if (hw_direct_map &&
+   translations[i].om_va == PHYS_TO_DMAP(pa_base) &&
moea64_calc_wimg(pa_base + off, VM_MEMATTR_DEFAULT) 
== LPTE_M)
continue;
 
@@ -633,7 +634,7 @@ moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernel
 
pvo = alloc_pvo_entry(1 /* bootstrap */);
pvo->pvo_vaddr |= PVO_WIRED | PVO_LARGE;
-   init_pvo_entry(pvo, kernel_pmap, pa);
+   init_pvo_entry(pvo, kernel_pmap, PHYS_TO_DMAP(pa));
 
/*
 * Set memory access as guarded if prefetch within
@@ -,7 +1112,8 @@ moea64_copy_page(mmu_t mmu, vm_page_t msrc, vm_page_t 
src = VM_PAGE_TO_PHYS(msrc);
 
if (hw_direct_map) {
-   bcopy((void *)src, (void *)dst, PAGE_SIZE);
+   bcopy((void *)PHYS_TO_DMAP(src), (void *)PHYS_TO_DMAP(dst),
+   PAGE_SIZE);
} else {
mtx_lock(&moea64_scratchpage_mtx);
 
@@ -1136,11 +1138,13 @@ moea64_copy_pages_dmap(mmu_t mmu, vm_page_t *ma, vm_of
while (xfersize > 0) {
a_pg_offset = a_offset & PAGE_MASK;
cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
-   a_cp = (char *)VM_PAGE_TO_PHYS(ma[a_offset >> PAGE_SHIFT]) +
+   a_cp = (char *)PHYS_TO_DMAP(
+   VM_PAGE_TO_PHYS(ma[a_offset >> PAGE_SHIFT])) +
a_pg_offset;
b_pg_offset = b_offset & PAGE_MASK;
cnt = min(cnt, PAGE_SIZE - b_pg_offset);
-   b_cp = (char *)VM_PAGE_TO_PHYS(mb[b_offset >> PAGE_SHIFT]) +
+   b_cp = (char *)PHYS_TO_DMAP(
+   VM_PAGE_TO_PHYS(mb[b_offset >> PAGE_SHIFT])) +
b_pg_offset;
bcopy(a_cp, b_cp, cnt);
a_offset += cnt;
@@ -1200,7 +1204,7 @@ moea64_zero_page_area(mmu_t mmu, vm_page_t m, int off,
panic("moea64_zero_page: size + off > PAGE_SIZE");
 
if (hw_direct_map) {
-   bzero((caddr_t)pa + off, size);
+   bzero((caddr_t)PHYS_TO_DMAP(pa) + off, size);
} else {
mtx_lock(&moea64_scratchpage_mtx);
moea64_set_scratchpage_pa(mmu, 0, pa);
@@ -1224,7 +1228,7 @@ moea64_zero_page(mmu_t mmu, vm_page_t m)
moea64_set_scratchpage_pa(mmu, 0, pa);
va = moea64_scratchpage_va[0];
} else {
-   va = pa;
+   va = PHYS_TO_DMAP(pa);
}
 
for (off = 0; off < PAGE_SIZE; off += cacheline_size)
@@ -1241,7 +1245,7 @@ moea64_quick_enter_page(mmu_t mmu, vm_page_t m)
vm_paddr_t pa = VM_PAGE_TO_PHYS(m);
 
if (hw_direct_map)
-   return (pa);
+   return (PHYS_TO_DMAP(pa));
 
/*
 * MOEA64_PTE_REPLACE does some locking, so we can't just grab
@@ -1402,7 +1406,7 @@ moea64_syncicache(mmu_t mmu, pmap_t pmap, vm_offset_t 
} else if (pmap == kernel_pmap) {
__syncicache((void *)va, sz);
} else if (hw_direct_map) {
-   __syncicache((void *)pa, sz);
+   __syncicache((void *)PHYS_TO_DMAP(pa), sz);
} else {
/* Use the scratch page to set up a temp mapping */
 
@@ -1565,7 +1569,7 @@ moea64_init(mmu_t mmu)
 
if (!hw_direct_map) {
installed_mmu = mmu;
-   uma_zone_set_allocf(moea64_pvo_zone,moea64_uma_page_alloc);
+   uma_zone_set_allocf(moea64_pvo_zone, moea64_uma_page_alloc);
}
 
 #ifdef COMPAT_FREEBSD32
@@ -1855,7 +1859,7 @@ moea64_map(mmu_t mmu, vm_offset_t *virt, vm_paddr_t pa
   

Re: svn commit: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-13 Thread Nathan Whitehorn



On 01/13/18 15:24, Konstantin Belousov wrote:

On Sat, Jan 13, 2018 at 11:14:53PM +, Nathan Whitehorn wrote:

+/*
+ * We (usually) have a direct map of all physical memory. All
+ * uses of this macro must be gated by a check on hw_direct_map!
+ * The location of the direct map may not be 1:1 in future, so use
+ * of the macro is recommended; it may also grow an assert that hw_direct_map
+ * is set.
+ */
+#define PHYS_TO_DMAP(x) x
+#define DMAP_TO_PHYS(x) x

Take a look at the sys/vm/vm_page.c:vm_page_free_prep() function.



I think the checks in there should work as designed, unless I'm missing 
something. Am I?

-Nathan
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-13 Thread Nathan Whitehorn



On 01/13/18 15:28, Nathan Whitehorn wrote:



On 01/13/18 15:24, Konstantin Belousov wrote:

On Sat, Jan 13, 2018 at 11:14:53PM +, Nathan Whitehorn wrote:

+/*
+ * We (usually) have a direct map of all physical memory. All
+ * uses of this macro must be gated by a check on hw_direct_map!
+ * The location of the direct map may not be 1:1 in future, so use
+ * of the macro is recommended; it may also grow an assert that 
hw_direct_map

+ * is set.
+ */
+#define PHYS_TO_DMAP(x) x
+#define DMAP_TO_PHYS(x) x

Take a look at the sys/vm/vm_page.c:vm_page_free_prep() function.



I think the checks in there should work as designed, unless I'm 
missing something. Am I?

-Nathan



Actually, wait, this is broken if hw_direct_map is not set. I can do an 
#ifdef __powerpc__ hack, but do you have opinions for a better MI flag 
for "yes, the macro is defined but, no, the direct map may not be 
available"?

-Nathan
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-14 Thread Nathan Whitehorn



On 01/14/18 00:30, Konstantin Belousov wrote:

On Sat, Jan 13, 2018 at 08:31:40PM -0800, Nathan Whitehorn wrote:


On 01/13/18 15:28, Nathan Whitehorn wrote:


On 01/13/18 15:24, Konstantin Belousov wrote:

On Sat, Jan 13, 2018 at 11:14:53PM +, Nathan Whitehorn wrote:

+/*
+ * We (usually) have a direct map of all physical memory. All
+ * uses of this macro must be gated by a check on hw_direct_map!
+ * The location of the direct map may not be 1:1 in future, so use
+ * of the macro is recommended; it may also grow an assert that
hw_direct_map
+ * is set.
+ */
+#define PHYS_TO_DMAP(x) x
+#define DMAP_TO_PHYS(x) x

Take a look at the sys/vm/vm_page.c:vm_page_free_prep() function.


I think the checks in there should work as designed, unless I'm
missing something. Am I?
-Nathan


Actually, wait, this is broken if hw_direct_map is not set. I can do an
#ifdef __powerpc__ hack, but do you have opinions for a better MI flag
for "yes, the macro is defined but, no, the direct map may not be
available"?

Exactly.  You explicitly noted the need to check for the hw_direct_map
in the comment, so I did not see a need to explain further.

We intended that PHYS_TO_DMAP/DMAP_TO_PHYS become MI KPI.  If the symbols
are present, their semantic is the unconditional presence and usability of
the direct map.

sf bufs were rototiled with things like SFBUF_OPTIONAL_DIRECT_MAP, but I
dislike it and hope that PHYS_TO_DMAP would be not damaged this way.



That's unfortunate. Is there any reason you need this to be certain at 
compile time? That seems to be quite restrictive and not to add a huge 
amount of performance. Given the exciting variety of MMU modes on 
PowerPC, there is not any way to guarantee the presence of a direct map 
at compile time, so the alternative is to invent a whole new kernel 
signalling mechanism for "direct map is almost certainly available, but 
might not be", which seems strictly worse, or to have a standard API 
that PowerPC can't use, which also seems worse.

-Nathan
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-14 Thread Nathan Whitehorn



On 01/14/18 09:05, Konstantin Belousov wrote:

On Sun, Jan 14, 2018 at 08:06:19AM -0800, Nathan Whitehorn wrote:


On 01/14/18 00:30, Konstantin Belousov wrote:

On Sat, Jan 13, 2018 at 08:31:40PM -0800, Nathan Whitehorn wrote:

On 01/13/18 15:28, Nathan Whitehorn wrote:

On 01/13/18 15:24, Konstantin Belousov wrote:

On Sat, Jan 13, 2018 at 11:14:53PM +, Nathan Whitehorn wrote:

+/*
+ * We (usually) have a direct map of all physical memory. All
+ * uses of this macro must be gated by a check on hw_direct_map!
+ * The location of the direct map may not be 1:1 in future, so use
+ * of the macro is recommended; it may also grow an assert that
hw_direct_map
+ * is set.
+ */
+#define PHYS_TO_DMAP(x) x
+#define DMAP_TO_PHYS(x) x

Take a look at the sys/vm/vm_page.c:vm_page_free_prep() function.


I think the checks in there should work as designed, unless I'm
missing something. Am I?
-Nathan


Actually, wait, this is broken if hw_direct_map is not set. I can do an
#ifdef __powerpc__ hack, but do you have opinions for a better MI flag
for "yes, the macro is defined but, no, the direct map may not be
available"?

Exactly.  You explicitly noted the need to check for the hw_direct_map
in the comment, so I did not see a need to explain further.

We intended that PHYS_TO_DMAP/DMAP_TO_PHYS become MI KPI.  If the symbols
are present, their semantic is the unconditional presence and usability of
the direct map.

sf bufs were rototiled with things like SFBUF_OPTIONAL_DIRECT_MAP, but I
dislike it and hope that PHYS_TO_DMAP would be not damaged this way.


That's unfortunate. Is there any reason you need this to be certain at
compile time? That seems to be quite restrictive and not to add a huge
amount of performance.

We tend to start using PHYS_TO_DMAP in MI code.  Both amd64 and arm64 do not
need a qualification.



Given the exciting variety of MMU modes on
PowerPC, there is not any way to guarantee the presence of a direct map
at compile time, so the alternative is to invent a whole new kernel
signalling mechanism for "direct map is almost certainly available, but
might not be", which seems strictly worse, or to have a standard API
that PowerPC can't use, which also seems worse.

Why not use a slight variation of the symbol name, to not confuse MI code ?
E.g. PPC_PHYS_TO_DMAP (only as an example, it is not hard to construct a
better name).



The immediate consequence of that is that no MI code that knows about 
direct maps can possibly take advantage of the direct map on this 
platform. Do we really want that to save some conditional logic that 
would get optimized out on amd64 and arm64 anyway? I really do not see 
the benefit here.

-Nathan
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-14 Thread Nathan Whitehorn



On 01/14/18 09:52, Konstantin Belousov wrote:

On Sun, Jan 14, 2018 at 09:30:53AM -0800, Nathan Whitehorn wrote:

The immediate consequence of that is that no MI code that knows about
direct maps can possibly take advantage of the direct map on this
platform. Do we really want that to save some conditional logic that
would get optimized out on amd64 and arm64 anyway? I really do not see
the benefit here.

It is not clear what do you mean.  Are you saying that there is no benefit
of providing the conditional logic, or that it is not benefit of exclusing
powerpc ?


Sorry, that was poorly stated. Let me try again:

If we make a PPC_PHYS_TO_DMAP(), but there is an MI PHYS_TO_DMAP() API, 
consumer code in the MI parts of the kernel won't be able to benefit 
from the PPC direct map, which seems unfortunate. The cost from a code 
perspective of having an if (direct_map_available) seems low, since on 
systems where direct_map_available is defined to be 1, the compiler will 
optimize it to the same code as if gated by #ifdef. It might be more 
cumbersome to write the code, however.



I do not object against adding the conditional, but it should not be
too clumsy to use.



OK. Let me try to draft something in the next couple days and see how 
much of a pain it is in practice.

-Nathan
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-14 Thread Nathan Whitehorn



On 01/14/18 09:57, Nathan Whitehorn wrote:



On 01/14/18 09:52, Konstantin Belousov wrote:

On Sun, Jan 14, 2018 at 09:30:53AM -0800, Nathan Whitehorn wrote:

The immediate consequence of that is that no MI code that knows about
direct maps can possibly take advantage of the direct map on this
platform. Do we really want that to save some conditional logic that
would get optimized out on amd64 and arm64 anyway? I really do not see
the benefit here.
It is not clear what do you mean.  Are you saying that there is no 
benefit
of providing the conditional logic, or that it is not benefit of 
exclusing

powerpc ?


Sorry, that was poorly stated. Let me try again:

If we make a PPC_PHYS_TO_DMAP(), but there is an MI PHYS_TO_DMAP() 
API, consumer code in the MI parts of the kernel won't be able to 
benefit from the PPC direct map, which seems unfortunate. The cost 
from a code perspective of having an if (direct_map_available) seems 
low, since on systems where direct_map_available is defined to be 1, 
the compiler will optimize it to the same code as if gated by #ifdef. 
It might be more cumbersome to write the code, however.



I do not object against adding the conditional, but it should not be
too clumsy to use.



OK. Let me try to draft something in the next couple days and see how 
much of a pain it is in practice.

-Nathan



How about the attached? It makes PHYS_TO_DMAP() return 0 if no mapping 
exists. This is straightforward, does not introduce extra macros, and 
can pretty easily replace SFBUF_OPTIONAL_DIRECT_MAP on the assumption 
that PHYS_TO_DMAP() is cheap. I've modified the other MI-ish consumers 
in the tree accordingly; compat/linuxkpi/common/src/linux_page.c already 
does the right thing and needed no modifications.

-Nathan
Index: powerpc/include/vmparam.h
===
--- powerpc/include/vmparam.h	(revision 327952)
+++ powerpc/include/vmparam.h	(working copy)
@@ -240,13 +240,12 @@
 #define	SFBUF_PHYS_DMAP(x)		(x)
 
 /*
- * We (usually) have a direct map of all physical memory. All
- * uses of this macro must be gated by a check on hw_direct_map!
- * The location of the direct map may not be 1:1 in future, so use
- * of the macro is recommended; it may also grow an assert that hw_direct_map
- * is set.
+ * We (usually) have a direct map of all physical memory, so provide
+ * a macro to use to get the kernel VA address for a given PA. Returns
+ * 0 if the direct map is unavailable. The location of the direct map
+ * may not be 1:1 in future, so use of the macro is recommended.
  */
-#define PHYS_TO_DMAP(x) x
-#define DMAP_TO_PHYS(x) x
+#define PHYS_TO_DMAP(x) (hw_direct_map ? 0 : (x))
+#define DMAP_TO_PHYS(x) (hw_direct_map ? 0 : (x))
  
 #endif /* _MACHINE_VMPARAM_H_ */
Index: vm/vm_page.c
===
--- vm/vm_page.c	(revision 327952)
+++ vm/vm_page.c	(working copy)
@@ -2937,7 +2937,8 @@
 {
 
 #if defined(DIAGNOSTIC) && defined(PHYS_TO_DMAP)
-	if ((m->flags & PG_ZERO) != 0) {
+	if ((m->flags & PG_ZERO) != 0 &&
+	PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)) != 0) {
 		uint64_t *p;
 		int i;
 		p = (uint64_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m));
Index: dev/efidev/efirt.c
===
--- dev/efidev/efirt.c	(revision 327952)
+++ dev/efidev/efirt.c	(working copy)
@@ -115,6 +115,11 @@
 		return (0);
 	}
 	efi_systbl = (struct efi_systbl *)PHYS_TO_DMAP(efi_systbl_phys);
+	if (efi_systbl == NULL) {
+		if (bootverbose)
+			printf("EFI systbl not mapped in kernel VA\n");
+		return (0);
+	}
 	if (efi_systbl->st_hdr.th_sig != EFI_SYSTBL_SIG) {
 		efi_systbl = NULL;
 		if (bootverbose)
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-14 Thread Nathan Whitehorn



On 01/14/18 15:42, Nathan Whitehorn wrote:



On 01/14/18 09:57, Nathan Whitehorn wrote:



On 01/14/18 09:52, Konstantin Belousov wrote:

On Sun, Jan 14, 2018 at 09:30:53AM -0800, Nathan Whitehorn wrote:

The immediate consequence of that is that no MI code that knows about
direct maps can possibly take advantage of the direct map on this
platform. Do we really want that to save some conditional logic that
would get optimized out on amd64 and arm64 anyway? I really do not see
the benefit here.
It is not clear what do you mean.  Are you saying that there is no 
benefit
of providing the conditional logic, or that it is not benefit of 
exclusing

powerpc ?


Sorry, that was poorly stated. Let me try again:

If we make a PPC_PHYS_TO_DMAP(), but there is an MI PHYS_TO_DMAP() 
API, consumer code in the MI parts of the kernel won't be able to 
benefit from the PPC direct map, which seems unfortunate. The cost 
from a code perspective of having an if (direct_map_available) seems 
low, since on systems where direct_map_available is defined to be 1, 
the compiler will optimize it to the same code as if gated by #ifdef. 
It might be more cumbersome to write the code, however.



I do not object against adding the conditional, but it should not be
too clumsy to use.



OK. Let me try to draft something in the next couple days and see how 
much of a pain it is in practice.

-Nathan



How about the attached? It makes PHYS_TO_DMAP() return 0 if no mapping 
exists. This is straightforward, does not introduce extra macros, and 
can pretty easily replace SFBUF_OPTIONAL_DIRECT_MAP on the assumption 
that PHYS_TO_DMAP() is cheap. I've modified the other MI-ish consumers 
in the tree accordingly; compat/linuxkpi/common/src/linux_page.c 
already does the right thing and needed no modifications.

-Nathan


Sorry, this is the patch I meant to send.
-Nathan
Index: powerpc/include/vmparam.h
===
--- powerpc/include/vmparam.h	(revision 327952)
+++ powerpc/include/vmparam.h	(working copy)
@@ -240,13 +240,12 @@
 #define	SFBUF_PHYS_DMAP(x)		(x)
 
 /*
- * We (usually) have a direct map of all physical memory. All
- * uses of this macro must be gated by a check on hw_direct_map!
- * The location of the direct map may not be 1:1 in future, so use
- * of the macro is recommended; it may also grow an assert that hw_direct_map
- * is set.
+ * We (usually) have a direct map of all physical memory, so provide
+ * a macro to use to get the kernel VA address for a given PA. Returns
+ * 0 if the direct map is unavailable. The location of the direct map
+ * may not be 1:1 in future, so use of the macro is recommended.
  */
-#define PHYS_TO_DMAP(x) x
-#define DMAP_TO_PHYS(x) x
+#define PHYS_TO_DMAP(x) (hw_direct_map ? (x) : 0)
+#define DMAP_TO_PHYS(x) (hw_direct_map ? (x) : 0)
  
 #endif /* _MACHINE_VMPARAM_H_ */
Index: vm/vm_page.c
===
--- vm/vm_page.c	(revision 327952)
+++ vm/vm_page.c	(working copy)
@@ -2937,7 +2937,8 @@
 {
 
 #if defined(DIAGNOSTIC) && defined(PHYS_TO_DMAP)
-	if ((m->flags & PG_ZERO) != 0) {
+	if ((m->flags & PG_ZERO) != 0 &&
+	PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)) != 0) {
 		uint64_t *p;
 		int i;
 		p = (uint64_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m));
Index: dev/efidev/efirt.c
===
--- dev/efidev/efirt.c	(revision 327952)
+++ dev/efidev/efirt.c	(working copy)
@@ -115,6 +115,11 @@
 		return (0);
 	}
 	efi_systbl = (struct efi_systbl *)PHYS_TO_DMAP(efi_systbl_phys);
+	if (efi_systbl == NULL) {
+		if (bootverbose)
+			printf("EFI systbl not mapped in kernel VA\n");
+		return (0);
+	}
 	if (efi_systbl->st_hdr.th_sig != EFI_SYSTBL_SIG) {
 		efi_systbl = NULL;
 		if (bootverbose)
___
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: r327992 - in head/sys/powerpc: aim booke include powerpc

2018-01-14 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Jan 15 06:46:33 2018
New Revision: 327992
URL: https://svnweb.freebsd.org/changeset/base/327992

Log:
  Move the pmap-specific code in copyinout.c that gets pointers to userland
  buffers into a new pmap-module function pmap_map_user_ptr() that can
  be implemented by the respective modules. This is required to implement
  non-segment-based AIM-ish MMU systems such as the radix-tree page tables
  introduced by POWER ISA 3.0 and present on POWER9.
  
  Reviewed by:  jhibbits

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/booke/pmap.c
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/powerpc/copyinout.c
  head/sys/powerpc/powerpc/mmu_if.m
  head/sys/powerpc/powerpc/pmap_dispatch.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Mon Jan 15 05:00:26 2018
(r327991)
+++ head/sys/powerpc/aim/mmu_oea.c  Mon Jan 15 06:46:33 2018
(r327992)
@@ -320,7 +320,10 @@ void moea_dumpsys_map(mmu_t mmu, vm_paddr_t pa, size_t
 void moea_scan_init(mmu_t mmu);
 vm_offset_t moea_quick_enter_page(mmu_t mmu, vm_page_t m);
 void moea_quick_remove_page(mmu_t mmu, vm_offset_t addr);
+static int moea_map_user_ptr(mmu_t mmu, pmap_t pm,
+volatile const void *uaddr, void **kaddr, size_t ulen, size_t *klen);
 
+
 static mmu_method_t moea_methods[] = {
MMUMETHOD(mmu_clear_modify, moea_clear_modify),
MMUMETHOD(mmu_copy_page,moea_copy_page),
@@ -370,6 +373,7 @@ static mmu_method_t moea_methods[] = {
MMUMETHOD(mmu_dev_direct_mapped,moea_dev_direct_mapped),
MMUMETHOD(mmu_scan_init,moea_scan_init),
MMUMETHOD(mmu_dumpsys_map,  moea_dumpsys_map),
+   MMUMETHOD(mmu_map_user_ptr, moea_map_user_ptr),
 
{ 0, 0 }
 };
@@ -1542,6 +1546,45 @@ moea_kremove(mmu_t mmu, vm_offset_t va)
 {
 
moea_remove(mmu, kernel_pmap, va, va + PAGE_SIZE);
+}
+
+/*
+ * Provide a kernel pointer corresponding to a given userland pointer.
+ * The returned pointer is valid until the next time this function is
+ * called in this thread. This is used internally in copyin/copyout.
+ */
+int
+moea_map_user_ptr(mmu_t mmu, pmap_t pm, volatile const void *uaddr,
+void **kaddr, size_t ulen, size_t *klen)
+{
+   size_t l;
+   register_t vsid;
+
+   *kaddr = (char *)USER_ADDR + ((uintptr_t)uaddr & ~SEGMENT_MASK);
+   l = ((char *)USER_ADDR + SEGMENT_LENGTH) - (char *)(*kaddr);
+   if (l > ulen)
+   l = ulen;
+   if (klen)
+   *klen = l;
+   else if (l != ulen)
+   return (EFAULT);
+
+   vsid = va_to_vsid(pm, (vm_offset_t)uaddr);
+ 
+   /* Mark segment no-execute */
+   vsid |= SR_N;
+ 
+   /* If we have already set this VSID, we can just return */
+   if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == vsid)
+   return (0);
+ 
+   __asm __volatile("isync");
+   curthread->td_pcb->pcb_cpu.aim.usr_segm =
+   (uintptr_t)uaddr >> ADDR_SR_SHFT;
+   curthread->td_pcb->pcb_cpu.aim.usr_vsid = vsid;
+   __asm __volatile("mtsr %0,%1; isync" :: "n"(USER_SR), "r"(vsid));
+
+   return (0);
 }
 
 /*

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cMon Jan 15 05:00:26 2018
(r327991)
+++ head/sys/powerpc/aim/mmu_oea64.cMon Jan 15 06:46:33 2018
(r327992)
@@ -284,7 +284,10 @@ void moea64_dumpsys_map(mmu_t mmu, vm_paddr_t pa, size
 void moea64_scan_init(mmu_t mmu);
 vm_offset_t moea64_quick_enter_page(mmu_t mmu, vm_page_t m);
 void moea64_quick_remove_page(mmu_t mmu, vm_offset_t addr);
+static int moea64_map_user_ptr(mmu_t mmu, pmap_t pm,
+volatile const void *uaddr, void **kaddr, size_t ulen, size_t *klen);
 
+
 static mmu_method_t moea64_methods[] = {
MMUMETHOD(mmu_clear_modify, moea64_clear_modify),
MMUMETHOD(mmu_copy_page,moea64_copy_page),
@@ -333,6 +336,7 @@ static mmu_method_t moea64_methods[] = {
MMUMETHOD(mmu_dev_direct_mapped,moea64_dev_direct_mapped),
MMUMETHOD(mmu_scan_init,moea64_scan_init),
MMUMETHOD(mmu_dumpsys_map,  moea64_dumpsys_map),
+   MMUMETHOD(mmu_map_user_ptr, moea64_map_user_ptr),
 
{ 0, 0 }
 };
@@ -1831,6 +1835,70 @@ void
 moea64_kremove(mmu_t mmu, vm_offset_t va)
 {
moea64_remove(mmu, kernel_pmap, va, va + PAGE_SIZE);
+}
+
+/*
+ * Provide a kernel pointer corresponding to a given userland pointer.
+ * The returned pointer is valid until the next time this function is
+ * called in this thread. This is used internally in copyin/copyout.
+ */
+static int
+moea64_map_user_ptr(mmu_t mmu, pmap_t pm, volatile const void *uaddr,
+void **kaddr, size_t ulen, size_t *klen)
+{
+   size_t l;
+#ifdef __powerpc64__
+   struct slb *slb;
+#e

Re: svn commit: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-15 Thread Nathan Whitehorn



On 01/15/18 03:18, Konstantin Belousov wrote:

On Sun, Jan 14, 2018 at 03:46:38PM -0800, Nathan Whitehorn wrote:


On 01/14/18 15:42, Nathan Whitehorn wrote:


On 01/14/18 09:57, Nathan Whitehorn wrote:


On 01/14/18 09:52, Konstantin Belousov wrote:

On Sun, Jan 14, 2018 at 09:30:53AM -0800, Nathan Whitehorn wrote:

The immediate consequence of that is that no MI code that knows about
direct maps can possibly take advantage of the direct map on this
platform. Do we really want that to save some conditional logic that
would get optimized out on amd64 and arm64 anyway? I really do not see
the benefit here.

It is not clear what do you mean.  Are you saying that there is no
benefit
of providing the conditional logic, or that it is not benefit of
exclusing
powerpc ?

Sorry, that was poorly stated. Let me try again:

If we make a PPC_PHYS_TO_DMAP(), but there is an MI PHYS_TO_DMAP()
API, consumer code in the MI parts of the kernel won't be able to
benefit from the PPC direct map, which seems unfortunate. The cost
from a code perspective of having an if (direct_map_available) seems
low, since on systems where direct_map_available is defined to be 1,
the compiler will optimize it to the same code as if gated by #ifdef.
It might be more cumbersome to write the code, however.


I do not object against adding the conditional, but it should not be
too clumsy to use.


OK. Let me try to draft something in the next couple days and see how
much of a pain it is in practice.
-Nathan


How about the attached? It makes PHYS_TO_DMAP() return 0 if no mapping
exists. This is straightforward, does not introduce extra macros, and
can pretty easily replace SFBUF_OPTIONAL_DIRECT_MAP on the assumption
that PHYS_TO_DMAP() is cheap. I've modified the other MI-ish consumers
in the tree accordingly; compat/linuxkpi/common/src/linux_page.c
already does the right thing and needed no modifications.
-Nathan

I think that this is fine from the PoV of code complexity.

We now require MI (but not amd64 and arm64 MD) code to check for
PHYS_TO_DMAP() return value, which is redundand for a*64. I am not sure
if this is good choice from the PoV of possible microoptimizations.
You promised something which is trivially detectable by compiler as
an excess code.


Fair enough -- the logic was that a lot of code already checks for NULL 
pointers (the linux_page.c for instance required no changes to do the 
right thing). If we want it to be fully compiler-transparent, we could 
also add a flag, but that would add more code complexity. Do you have a 
preference? I would be happy to draft that too.





Sorry, this is the patch I meant to send.

Do you plan to convert sf buf code on powerpc ?


Yes, once this is finalized.
-Nathan




-Nathan
Index: powerpc/include/vmparam.h
===
--- powerpc/include/vmparam.h   (revision 327952)
+++ powerpc/include/vmparam.h   (working copy)
@@ -240,13 +240,12 @@
  #define   SFBUF_PHYS_DMAP(x)  (x)
  
  /*

- * We (usually) have a direct map of all physical memory. All
- * uses of this macro must be gated by a check on hw_direct_map!
- * The location of the direct map may not be 1:1 in future, so use
- * of the macro is recommended; it may also grow an assert that hw_direct_map
- * is set.
+ * We (usually) have a direct map of all physical memory, so provide
+ * a macro to use to get the kernel VA address for a given PA. Returns
+ * 0 if the direct map is unavailable. The location of the direct map
+ * may not be 1:1 in future, so use of the macro is recommended.
   */
-#define PHYS_TO_DMAP(x) x
-#define DMAP_TO_PHYS(x) x
+#define PHYS_TO_DMAP(x) (hw_direct_map ? (x) : 0)
+#define DMAP_TO_PHYS(x) (hw_direct_map ? (x) : 0)
   
  #endif /* _MACHINE_VMPARAM_H_ */

Index: vm/vm_page.c
===
--- vm/vm_page.c(revision 327952)
+++ vm/vm_page.c(working copy)
@@ -2937,7 +2937,8 @@
  {
  
  #if defined(DIAGNOSTIC) && defined(PHYS_TO_DMAP)

-   if ((m->flags & PG_ZERO) != 0) {
+   if ((m->flags & PG_ZERO) != 0 &&
+   PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)) != 0) {
uint64_t *p;
int i;
p = (uint64_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m));
Index: dev/efidev/efirt.c
===
--- dev/efidev/efirt.c  (revision 327952)
+++ dev/efidev/efirt.c  (working copy)
@@ -115,6 +115,11 @@
return (0);
}
efi_systbl = (struct efi_systbl *)PHYS_TO_DMAP(efi_systbl_phys);
+   if (efi_systbl == NULL) {
+   if (bootverbose)
+   printf("EFI systbl not mapped in kernel VA\n");
+   return (0);
+   }
if (efi_systbl->st_hdr.th_sig != EFI_SYSTBL_SIG) {
efi_systbl = NULL;
if (bootverbose)



svn commit: r328004 - head/sys/powerpc/aim

2018-01-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Jan 15 16:08:34 2018
New Revision: 328004
URL: https://svnweb.freebsd.org/changeset/base/328004

Log:
  Install the SLB miss trap-handling code in the SLB-based MMU driver set up,
  to which it is specific, rather than in the generic AIM startup code. This
  will be required to support the radix-table-based MMU introduced with POWER9.

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

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Mon Jan 15 14:56:47 2018
(r328003)
+++ head/sys/powerpc/aim/aim_machdep.c  Mon Jan 15 16:08:34 2018
(r328004)
@@ -150,7 +150,6 @@ extern Elf_Addr _GLOBAL_OFFSET_TABLE_[];
 extern void*rstcode, *rstcodeend;
 extern void*trapcode, *trapcodeend;
 extern void*generictrap, *generictrap64;
-extern void*slbtrap, *slbtrapend;
 extern void*alitrap, *aliend;
 extern void*dsitrap, *dsiend;
 extern void*decrint, *decrsize;
@@ -332,9 +331,6 @@ aim_cpu_init(vm_offset_t toc)
/* Set TOC base so that the interrupt code can get at it */
*((void **)TRAP_GENTRAP) = &generictrap;
*((register_t *)TRAP_TOCBASE) = toc;
-
-   bcopy(&slbtrap, (void *)EXC_DSE,(size_t)&slbtrapend - (size_t)&slbtrap);
-   bcopy(&slbtrap, (void *)EXC_ISE,(size_t)&slbtrapend - (size_t)&slbtrap);
#else
/* Set branch address for trap code */
if (cpu_features & PPC_FEATURE_64)

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cMon Jan 15 14:56:47 2018
(r328003)
+++ head/sys/powerpc/aim/mmu_oea64.cMon Jan 15 16:08:34 2018
(r328004)
@@ -140,6 +140,8 @@ struct ofw_map {
 extern unsigned char _etext[];
 extern unsigned char _end[];
 
+extern void *slbtrap, *slbtrapend;
+
 /*
  * Map of physical memory regions.
  */
@@ -712,6 +714,12 @@ moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernels
hw_direct_map = 1;
else
hw_direct_map = 0;
+
+   /* Install trap handlers for SLBs */
+   bcopy(&slbtrap, (void *)EXC_DSE,(size_t)&slbtrapend - (size_t)&slbtrap);
+   bcopy(&slbtrap, (void *)EXC_ISE,(size_t)&slbtrapend - (size_t)&slbtrap);
+   __syncicache((void *)EXC_DSE, 0x80);
+   __syncicache((void *)EXC_ISE, 0x80);
 #endif
 
/* Get physical memory regions from firmware */
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-15 Thread Nathan Whitehorn



On 01/15/18 09:06, Konstantin Belousov wrote:

On Mon, Jan 15, 2018 at 07:33:01AM -0800, Nathan Whitehorn wrote:


On 01/15/18 03:18, Konstantin Belousov wrote:

On Sun, Jan 14, 2018 at 03:46:38PM -0800, Nathan Whitehorn wrote:

On 01/14/18 15:42, Nathan Whitehorn wrote:

On 01/14/18 09:57, Nathan Whitehorn wrote:

On 01/14/18 09:52, Konstantin Belousov wrote:

On Sun, Jan 14, 2018 at 09:30:53AM -0800, Nathan Whitehorn wrote:

The immediate consequence of that is that no MI code that knows about
direct maps can possibly take advantage of the direct map on this
platform. Do we really want that to save some conditional logic that
would get optimized out on amd64 and arm64 anyway? I really do not see
the benefit here.

It is not clear what do you mean.  Are you saying that there is no
benefit
of providing the conditional logic, or that it is not benefit of
exclusing
powerpc ?

Sorry, that was poorly stated. Let me try again:

If we make a PPC_PHYS_TO_DMAP(), but there is an MI PHYS_TO_DMAP()
API, consumer code in the MI parts of the kernel won't be able to
benefit from the PPC direct map, which seems unfortunate. The cost
from a code perspective of having an if (direct_map_available) seems
low, since on systems where direct_map_available is defined to be 1,
the compiler will optimize it to the same code as if gated by #ifdef.
It might be more cumbersome to write the code, however.


I do not object against adding the conditional, but it should not be
too clumsy to use.


OK. Let me try to draft something in the next couple days and see how
much of a pain it is in practice.
-Nathan


How about the attached? It makes PHYS_TO_DMAP() return 0 if no mapping
exists. This is straightforward, does not introduce extra macros, and
can pretty easily replace SFBUF_OPTIONAL_DIRECT_MAP on the assumption
that PHYS_TO_DMAP() is cheap. I've modified the other MI-ish consumers
in the tree accordingly; compat/linuxkpi/common/src/linux_page.c
already does the right thing and needed no modifications.
-Nathan

I think that this is fine from the PoV of code complexity.

We now require MI (but not amd64 and arm64 MD) code to check for
PHYS_TO_DMAP() return value, which is redundand for a*64. I am not sure
if this is good choice from the PoV of possible microoptimizations.
You promised something which is trivially detectable by compiler as
an excess code.

Fair enough -- the logic was that a lot of code already checks for NULL
pointers (the linux_page.c for instance required no changes to do the
right thing).

Most likely this is an accidental feature of the linux code and not the
specific decision by the freebsd emulation of it.


If we want it to be fully compiler-transparent, we could
also add a flag, but that would add more code complexity. Do you have a
preference? I would be happy to draft that too.

I think I am fine with amd64 doing
#define PMAP_HAS_DMAP   1
in machine/param.h.  I do not insist on the name.

Then ppc could define its version as a reference to the variable.  I thought
that might be you can create less clumsy model of propagating this to the
MI VM level.


That seems fine to me. I don't think a less-clumsy way that does not 
involve extra indirection is possible. The PHYS_TO_DMAP() returning NULL 
is about the best thing I can come up with from a clumsiness standpoint 
since plenty of code checks for null pointers already, but doesn't 
cleanly handle the rarer case where you want to test for the existence 
of direct maps in general without testing some potemkin address.


My one reservation about PMAP_HAS_DMAP or the like as a selector is that 
it does not encode the full shape of the problem: one could imagine 
having a direct map that only covers a limited range of RAM (I am not 
sure whether the existence of dmaplimit on amd64 implies this can happen 
with non-device memory in real life), for example. These cases are 
currently covered by an assert() in PHYS_TO_DMAP(), whereas having 
PHYS_TO_DMAP() return NULL allows a more flexible signalling and the 
potential for the calling code to do something reasonable to handle the 
error. A single global flag can't convey information at this kind of 
granularity. Is this a reasonable concern? Or am I overthinking things?

-Nathan
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-15 Thread Nathan Whitehorn



On 01/15/18 09:53, Konstantin Belousov wrote:

On Mon, Jan 15, 2018 at 09:32:56AM -0800, Nathan Whitehorn wrote:

That seems fine to me. I don't think a less-clumsy way that does not
involve extra indirection is possible. The PHYS_TO_DMAP() returning NULL
is about the best thing I can come up with from a clumsiness standpoint
since plenty of code checks for null pointers already, but doesn't
cleanly handle the rarer case where you want to test for the existence
of direct maps in general without testing some potemkin address.

My one reservation about PMAP_HAS_DMAP or the like as a selector is that
it does not encode the full shape of the problem: one could imagine
having a direct map that only covers a limited range of RAM (I am not
sure whether the existence of dmaplimit on amd64 implies this can happen
with non-device memory in real life), for example. These cases are
currently covered by an assert() in PHYS_TO_DMAP(), whereas having
PHYS_TO_DMAP() return NULL allows a more flexible signalling and the
potential for the calling code to do something reasonable to handle the
error. A single global flag can't convey information at this kind of
granularity. Is this a reasonable concern? Or am I overthinking things?

IMO it is overreaction.  amd64 assumes that all normal memory is covered
by DMAP.  It must never fail.   See, for instance, the implementation
of the sf bufs for it.

If device memory not covered by DMAP can exists, it is the driver problem.
For instance, for NVDIMMs I wrote specific mapping code which establishes
kernel mapping for it, when not covered by EFI memory map and correspondingly
not included into DMAP.



Fair enough. Here's a patch with a new flag (DIRECT_MAP_AVAILABLE). I've 
also retooled the sfbuf code to use this rather than its own flags that 
mean the same things. The sparc64 part of the patch is untested.

-Nathan
Index: amd64/include/vmparam.h
===
--- amd64/include/vmparam.h	(revision 328006)
+++ amd64/include/vmparam.h	(working copy)
@@ -190,6 +190,7 @@
  * because the result is not actually accessed until later, but the early
  * vt fb startup needs to be reworked.
  */
+#define	DIRECT_MAP_AVAILABLE	1
 #define	PHYS_TO_DMAP(x)	({		\
 	KASSERT(dmaplimit == 0 || (x) < dmaplimit,			\
 	("physical address %#jx not covered by the DMAP",		\
Index: arm64/include/vmparam.h
===
--- arm64/include/vmparam.h	(revision 328006)
+++ arm64/include/vmparam.h	(working copy)
@@ -176,6 +176,7 @@
 #define	VIRT_IN_DMAP(va)	((va) >= DMAP_MIN_ADDRESS && \
 (va) < (dmap_max_addr))
 
+#define	DIRECT_MAP_AVAILABLE
 #define	PHYS_TO_DMAP(pa)		\
 ({	\
 	KASSERT(PHYS_IN_DMAP(pa),	\
Index: dev/efidev/efirt.c
===
--- dev/efidev/efirt.c	(revision 328006)
+++ dev/efidev/efirt.c	(working copy)
@@ -115,6 +115,11 @@
 		return (0);
 	}
 	efi_systbl = (struct efi_systbl *)PHYS_TO_DMAP(efi_systbl_phys);
+	if (efi_systbl == NULL) {
+		if (bootverbose)
+			printf("EFI systbl not mapped in kernel VA\n");
+		return (0);
+	}
 	if (efi_systbl->st_hdr.th_sig != EFI_SYSTBL_SIG) {
 		efi_systbl = NULL;
 		if (bootverbose)
Index: kern/subr_sfbuf.c
===
--- kern/subr_sfbuf.c	(revision 328006)
+++ kern/subr_sfbuf.c	(working copy)
@@ -88,8 +88,8 @@
 	vm_offset_t sf_base;
 	int i;
 
-#ifdef SFBUF_OPTIONAL_DIRECT_MAP
-	if (SFBUF_OPTIONAL_DIRECT_MAP)
+#ifdef DIRECT_MAP_AVAILABLE
+	if (DIRECT_MAP_AVAILABLE)
 		return;
 #endif
 
@@ -119,8 +119,8 @@
 	struct sf_buf *sf;
 	int error;
 
-#ifdef SFBUF_OPTIONAL_DIRECT_MAP
-	if (SFBUF_OPTIONAL_DIRECT_MAP)
+#ifdef DIRECT_MAP_AVAILABLE
+	if (DIRECT_MAP_AVAILABLE)
 		return ((struct sf_buf *)m);
 #endif
 
@@ -181,8 +181,8 @@
 sf_buf_free(struct sf_buf *sf)
 {
 
-#ifdef SFBUF_OPTIONAL_DIRECT_MAP
-	if (SFBUF_OPTIONAL_DIRECT_MAP)
+#ifdef DIRECT_MAP_AVAILABLE
+	if (DIRECT_MAP_AVAILABLE)
 		return;
 #endif
 
@@ -205,8 +205,8 @@
 sf_buf_ref(struct sf_buf *sf)
 {
 
-#ifdef SFBUF_OPTIONAL_DIRECT_MAP
-	if (SFBUF_OPTIONAL_DIRECT_MAP)
+#ifdef DIRECT_MAP_AVAILABLE
+	if (DIRECT_MAP_AVAILABLE)
 		return;
 #endif
 
Index: powerpc/include/vmparam.h
===
--- powerpc/include/vmparam.h	(revision 328006)
+++ powerpc/include/vmparam.h	(working copy)
@@ -37,6 +37,10 @@
 #ifndef _MACHINE_VMPARAM_H_
 #define	_MACHINE_VMPARAM_H_
 
+#ifndef LOCORE
+#include 
+#endif
+
 #define	USRSTACK	SHAREDPAGE
 
 #ifndef	MAXTSIZ
@@ -236,17 +240,21 @@
  */
 #define	SFBUF
 #define	SFBUF_NOMD
-#define	SFBUF_OPTIONAL_DIRECT_MAP	hw_direct_map
-#define	SFBUF_PHYS_DMAP(x)		(x)
 
 /*
- * We (usually) have a direct map of all physical memory. All
- * uses of this macro must be gated by a check on hw_direct_map!
- * The location of th

Re: svn commit: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-15 Thread Nathan Whitehorn



On 01/15/18 15:42, Konstantin Belousov wrote:

On Mon, Jan 15, 2018 at 03:20:49PM -0800, Nathan Whitehorn wrote:

Fair enough. Here's a patch with a new flag (DIRECT_MAP_AVAILABLE). I've
also retooled the sfbuf code to use this rather than its own flags that
mean the same things. The sparc64 part of the patch is untested.
-Nathan
Index: amd64/include/vmparam.h
===
--- amd64/include/vmparam.h (revision 328006)
+++ amd64/include/vmparam.h (working copy)
@@ -190,6 +190,7 @@
   * because the result is not actually accessed until later, but the early
   * vt fb startup needs to be reworked.
   */
+#defineDIRECT_MAP_AVAILABLE1
  #define   PHYS_TO_DMAP(x) ({  
\
KASSERT(dmaplimit == 0 || (x) < dmaplimit,   \
("physical address %#jx not covered by the DMAP", \
Index: arm64/include/vmparam.h
===
--- arm64/include/vmparam.h (revision 328006)
+++ arm64/include/vmparam.h (working copy)
@@ -176,6 +176,7 @@
  #define   VIRT_IN_DMAP(va)((va) >= DMAP_MIN_ADDRESS && \
  (va) < (dmap_max_addr))
  
+#define	DIRECT_MAP_AVAILABLE

Just define, or define it to 1 ?


Yes, sorry for typo.




  #define   PHYS_TO_DMAP(pa)
\
  ({\
KASSERT(PHYS_IN_DMAP(pa),   \
Index: dev/efidev/efirt.c
===
--- dev/efidev/efirt.c  (revision 328006)
+++ dev/efidev/efirt.c  (working copy)
@@ -115,6 +115,11 @@
return (0);
}
efi_systbl = (struct efi_systbl *)PHYS_TO_DMAP(efi_systbl_phys);
+   if (efi_systbl == NULL) {
+   if (bootverbose)
+   printf("EFI systbl not mapped in kernel VA\n");
+   return (0);
+   }

Is this chunk still needed ?


The existing code is a bit of an awkward superposition of the "return 
NULL" idea and having the flag. Since you think there will never be 
intermediate cases -- which seems reasonable -- I will rip the 
conditional logic out and add a KASSERT matching the ones on arm64 and 
amd64 to the powerpc version.





if (efi_systbl->st_hdr.th_sig != EFI_SYSTBL_SIG) {
efi_systbl = NULL;
if (bootverbose)
Index: kern/subr_sfbuf.c
===
--- kern/subr_sfbuf.c   (revision 328006)
+++ kern/subr_sfbuf.c   (working copy)
@@ -88,8 +88,8 @@
vm_offset_t sf_base;
int i;
  
-#ifdef SFBUF_OPTIONAL_DIRECT_MAP

-   if (SFBUF_OPTIONAL_DIRECT_MAP)
+#ifdef DIRECT_MAP_AVAILABLE
+   if (DIRECT_MAP_AVAILABLE)
return;

Would it make sense to define the symbol on all other arches as 0 then,
and remove #ifdef ? Returning to your initial proposal of relying on the
compiler optimiing if (0) block; out.


That is a good idea.


Also, just curious, why did you spelled DMAP as DIRECT_MAP ?



DMAP without the PHYS_TO_ seemed lacking in context and I was worried 
there might be a collision on DMAP. PMAP_HAS_DMAP would also work; I 
don't have a preference.


Thanks for your patience working this out in real time with me.
-Nathan
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-16 Thread Nathan Whitehorn



On 01/16/18 11:32, Marius Strobl wrote:

On Mon, Jan 15, 2018 at 03:20:49PM -0800, Nathan Whitehorn wrote:


On 01/15/18 09:53, Konstantin Belousov wrote:

On Mon, Jan 15, 2018 at 09:32:56AM -0800, Nathan Whitehorn wrote:

That seems fine to me. I don't think a less-clumsy way that does not
involve extra indirection is possible. The PHYS_TO_DMAP() returning NULL
is about the best thing I can come up with from a clumsiness standpoint
since plenty of code checks for null pointers already, but doesn't
cleanly handle the rarer case where you want to test for the existence
of direct maps in general without testing some potemkin address.

My one reservation about PMAP_HAS_DMAP or the like as a selector is that
it does not encode the full shape of the problem: one could imagine
having a direct map that only covers a limited range of RAM (I am not
sure whether the existence of dmaplimit on amd64 implies this can happen
with non-device memory in real life), for example. These cases are
currently covered by an assert() in PHYS_TO_DMAP(), whereas having
PHYS_TO_DMAP() return NULL allows a more flexible signalling and the
potential for the calling code to do something reasonable to handle the
error. A single global flag can't convey information at this kind of
granularity. Is this a reasonable concern? Or am I overthinking things?

IMO it is overreaction.  amd64 assumes that all normal memory is covered
by DMAP.  It must never fail.   See, for instance, the implementation
of the sf bufs for it.

If device memory not covered by DMAP can exists, it is the driver problem.
For instance, for NVDIMMs I wrote specific mapping code which establishes
kernel mapping for it, when not covered by EFI memory map and correspondingly
not included into DMAP.


Fair enough. Here's a patch with a new flag (DIRECT_MAP_AVAILABLE). I've
also retooled the sfbuf code to use this rather than its own flags that
mean the same things. The sparc64 part of the patch is untested.
-Nathan
Index: sparc64/include/vmparam.h
===
--- sparc64/include/vmparam.h   (revision 328006)
+++ sparc64/include/vmparam.h   (working copy)
@@ -240,10 +240,12 @@
   */
  #define   ZERO_REGION_SIZEPAGE_SIZE
  
+#include 

+
  #define   SFBUF
  #define   SFBUF_MAP
-#defineSFBUF_OPTIONAL_DIRECT_MAP   dcache_color_ignore
-#include 
-#defineSFBUF_PHYS_DMAP(x)  TLB_PHYS_TO_DIRECT(x)
  
+#define DIRECT_MAP_AVAILABLE	dcache_color_ignore

+#definePHYS_TO_DMAP(x) (DIRECT_MAP_AVAILABLE ? (TLB_PHYS_TO_DIRECT(x) 
: 0)

What dcache_color_ignore actually indicates is the presence of
hardware unaliasing support, in other words the ability to enter
duplicate cacheable mappings into the MMU. While a direct map is
available and used by MD code on all supported CPUs down to US-I,
the former feature is only implemented in the line of Fujitsu SPARC64
processors. IIRC, the sfbuf(9) code can't guarantee that there isn't
already a cacheable mapping from a different VA to the same PA,
which is why it employs dcache_color_ignore. Is that a general
constraint of all MI PHYS_TO_DMAP users or are there consumers
which can guarantee that they are the only users of a mapping
to the same PA?

Marius



With the patch, there are four uses of this in the kernel: the sfbuf 
code, a diagnostic check on page zeroing, part of the EFI runtime code, 
and part of the Linux KBI compat. The second looks safe from this 
perspective and at least some of the others (EFI runtime) are irrelevant 
on sparc64. But I really have no idea what was intended for the 
semantics of this API -- I didn't even know it *was* an MI API until 
this commit. Maybe kib can comment? If this is outside the semantics of 
PHYS_TO_DMAP, then we need to keep the existing sfbuf code.

-Nathan

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

2018-01-17 Thread Nathan Whitehorn
Please revert the AHCI removal. It works just fine on big-endian 
hardware and has for a long time -- I think the problem may be limited 
to you specific hardware.

-Nathan

On 01/17/18 01:33, Wojciech Macek wrote:

Author: wma
Date: Wed Jan 17 09:33:16 2018
New Revision: 328078
URL: https://svnweb.freebsd.org/changeset/base/328078

Log:
   PPC64: add CXGBE and remove AHCI from GENERIC64
   
   Add CXGBE driver which is required for PowerNV system.

   Also, remove AHCI which does not work in BigEndian.
   
   Created by:Wojciech Macek 

   Obtained from: Semihalf
   Sponsored by:  QCM Technologies

Modified:
   head/sys/powerpc/conf/GENERIC64

Modified: head/sys/powerpc/conf/GENERIC64
==
--- head/sys/powerpc/conf/GENERIC64 Wed Jan 17 08:01:51 2018
(r328077)
+++ head/sys/powerpc/conf/GENERIC64 Wed Jan 17 09:33:16 2018
(r328078)
@@ -107,7 +107,7 @@ options PCI_HP  # PCI-Express native 
HotPlug
  deviceagp
  
  # ATA controllers

-device ahci# AHCI-compatible SATA controllers
+#deviceahci# AHCI-compatible SATA controllers
  deviceata # Legacy ATA/SATA controllers
  devicemvs # Marvell 
88SX50XX/88SX60XX/88SX70XX/SoC SATA
  devicesiis# SiliconImage SiI3124/SiI3132/SiI3531 
SATA
@@ -143,6 +143,7 @@ device  ix  # Intel PRO/10GbE PCIE 
PF Ethernet Family
  deviceixv # Intel PRO/10GbE PCIE VF Ethernet 
Family
  deviceglc # Sony Playstation 3 Ethernet
  devicellan# IBM pSeries Virtual Ethernet
+device cxgbe   # Chelsio 10/25G NIC
  
  # PCI Ethernet NICs that use the common MII bus controller code.

  devicemiibus  # MII bus support



___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-18 Thread Nathan Whitehorn



On 01/17/18 01:44, Konstantin Belousov wrote:

On Tue, Jan 16, 2018 at 09:30:29PM -0800, Nathan Whitehorn wrote:


On 01/16/18 11:32, Marius Strobl wrote:

On Mon, Jan 15, 2018 at 03:20:49PM -0800, Nathan Whitehorn wrote:

On 01/15/18 09:53, Konstantin Belousov wrote:

On Mon, Jan 15, 2018 at 09:32:56AM -0800, Nathan Whitehorn wrote:

That seems fine to me. I don't think a less-clumsy way that does not
involve extra indirection is possible. The PHYS_TO_DMAP() returning NULL
is about the best thing I can come up with from a clumsiness standpoint
since plenty of code checks for null pointers already, but doesn't
cleanly handle the rarer case where you want to test for the existence
of direct maps in general without testing some potemkin address.

My one reservation about PMAP_HAS_DMAP or the like as a selector is that
it does not encode the full shape of the problem: one could imagine
having a direct map that only covers a limited range of RAM (I am not
sure whether the existence of dmaplimit on amd64 implies this can happen
with non-device memory in real life), for example. These cases are
currently covered by an assert() in PHYS_TO_DMAP(), whereas having
PHYS_TO_DMAP() return NULL allows a more flexible signalling and the
potential for the calling code to do something reasonable to handle the
error. A single global flag can't convey information at this kind of
granularity. Is this a reasonable concern? Or am I overthinking things?

IMO it is overreaction.  amd64 assumes that all normal memory is covered
by DMAP.  It must never fail.   See, for instance, the implementation
of the sf bufs for it.

If device memory not covered by DMAP can exists, it is the driver problem.
For instance, for NVDIMMs I wrote specific mapping code which establishes
kernel mapping for it, when not covered by EFI memory map and correspondingly
not included into DMAP.


Fair enough. Here's a patch with a new flag (DIRECT_MAP_AVAILABLE). I've
also retooled the sfbuf code to use this rather than its own flags that
mean the same things. The sparc64 part of the patch is untested.
-Nathan
Index: sparc64/include/vmparam.h
===
--- sparc64/include/vmparam.h   (revision 328006)
+++ sparc64/include/vmparam.h   (working copy)
@@ -240,10 +240,12 @@
*/
   #define  ZERO_REGION_SIZEPAGE_SIZE
   
+#include 

+
   #define  SFBUF
   #define  SFBUF_MAP
-#defineSFBUF_OPTIONAL_DIRECT_MAP   dcache_color_ignore
-#include 
-#defineSFBUF_PHYS_DMAP(x)  TLB_PHYS_TO_DIRECT(x)
   
+#define DIRECT_MAP_AVAILABLE	dcache_color_ignore

+#definePHYS_TO_DMAP(x) (DIRECT_MAP_AVAILABLE ? (TLB_PHYS_TO_DIRECT(x) 
: 0)

What dcache_color_ignore actually indicates is the presence of
hardware unaliasing support, in other words the ability to enter
duplicate cacheable mappings into the MMU. While a direct map is
available and used by MD code on all supported CPUs down to US-I,
the former feature is only implemented in the line of Fujitsu SPARC64
processors. IIRC, the sfbuf(9) code can't guarantee that there isn't
already a cacheable mapping from a different VA to the same PA,
which is why it employs dcache_color_ignore. Is that a general
constraint of all MI PHYS_TO_DMAP users or are there consumers
which can guarantee that they are the only users of a mapping
to the same PA?

Marius


With the patch, there are four uses of this in the kernel: the sfbuf
code, a diagnostic check on page zeroing, part of the EFI runtime code,
and part of the Linux KBI compat. The second looks safe from this
perspective and at least some of the others (EFI runtime) are irrelevant
on sparc64. But I really have no idea what was intended for the
semantics of this API -- I didn't even know it *was* an MI API until
this commit. Maybe kib can comment? If this is outside the semantics of
PHYS_TO_DMAP, then we need to keep the existing sfbuf code.

sfbufs cannot guarantee that there is no other mapping of the page when
the sfbuf is created.  For instance, one of the use of sfbufs is to map
the image page 0 to read ELF headers when doing the image activation.
The image might be mapped by other processes, and we do not control the
address at which it mapped.

So the direct map accesses must work regardless of the presence of other
page mappings, and the check for dcache_color_ignore is needed to allow
MI code to take advantage of DMAP.



So: what do you want to happen with PHYS_TO_DMAP()? Do we want to claim 
to MI that a direct map is "available" in such circumstances, or 
"unavailable"? Should sfbuf retain a separate API? I have no preferences 
here and just want to close out this issue.

-Nathan
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-18 Thread Nathan Whitehorn



On 01/18/18 07:35, Konstantin Belousov wrote:

On Thu, Jan 18, 2018 at 07:24:11AM -0800, Nathan Whitehorn wrote:


On 01/17/18 01:44, Konstantin Belousov wrote:

On Tue, Jan 16, 2018 at 09:30:29PM -0800, Nathan Whitehorn wrote:

On 01/16/18 11:32, Marius Strobl wrote:

On Mon, Jan 15, 2018 at 03:20:49PM -0800, Nathan Whitehorn wrote:

On 01/15/18 09:53, Konstantin Belousov wrote:

On Mon, Jan 15, 2018 at 09:32:56AM -0800, Nathan Whitehorn wrote:

That seems fine to me. I don't think a less-clumsy way that does not
involve extra indirection is possible. The PHYS_TO_DMAP() returning NULL
is about the best thing I can come up with from a clumsiness standpoint
since plenty of code checks for null pointers already, but doesn't
cleanly handle the rarer case where you want to test for the existence
of direct maps in general without testing some potemkin address.

My one reservation about PMAP_HAS_DMAP or the like as a selector is that
it does not encode the full shape of the problem: one could imagine
having a direct map that only covers a limited range of RAM (I am not
sure whether the existence of dmaplimit on amd64 implies this can happen
with non-device memory in real life), for example. These cases are
currently covered by an assert() in PHYS_TO_DMAP(), whereas having
PHYS_TO_DMAP() return NULL allows a more flexible signalling and the
potential for the calling code to do something reasonable to handle the
error. A single global flag can't convey information at this kind of
granularity. Is this a reasonable concern? Or am I overthinking things?

IMO it is overreaction.  amd64 assumes that all normal memory is covered
by DMAP.  It must never fail.   See, for instance, the implementation
of the sf bufs for it.

If device memory not covered by DMAP can exists, it is the driver problem.
For instance, for NVDIMMs I wrote specific mapping code which establishes
kernel mapping for it, when not covered by EFI memory map and correspondingly
not included into DMAP.


Fair enough. Here's a patch with a new flag (DIRECT_MAP_AVAILABLE). I've
also retooled the sfbuf code to use this rather than its own flags that
mean the same things. The sparc64 part of the patch is untested.
-Nathan
Index: sparc64/include/vmparam.h
===
--- sparc64/include/vmparam.h   (revision 328006)
+++ sparc64/include/vmparam.h   (working copy)
@@ -240,10 +240,12 @@
 */
#define ZERO_REGION_SIZEPAGE_SIZE

+#include 

+
#define SFBUF
#define SFBUF_MAP
-#defineSFBUF_OPTIONAL_DIRECT_MAP   dcache_color_ignore
-#include 
-#defineSFBUF_PHYS_DMAP(x)  TLB_PHYS_TO_DIRECT(x)

+#define DIRECT_MAP_AVAILABLE	dcache_color_ignore

+#definePHYS_TO_DMAP(x) (DIRECT_MAP_AVAILABLE ? (TLB_PHYS_TO_DIRECT(x) 
: 0)

What dcache_color_ignore actually indicates is the presence of
hardware unaliasing support, in other words the ability to enter
duplicate cacheable mappings into the MMU. While a direct map is
available and used by MD code on all supported CPUs down to US-I,
the former feature is only implemented in the line of Fujitsu SPARC64
processors. IIRC, the sfbuf(9) code can't guarantee that there isn't
already a cacheable mapping from a different VA to the same PA,
which is why it employs dcache_color_ignore. Is that a general
constraint of all MI PHYS_TO_DMAP users or are there consumers
which can guarantee that they are the only users of a mapping
to the same PA?

Marius


With the patch, there are four uses of this in the kernel: the sfbuf
code, a diagnostic check on page zeroing, part of the EFI runtime code,
and part of the Linux KBI compat. The second looks safe from this
perspective and at least some of the others (EFI runtime) are irrelevant
on sparc64. But I really have no idea what was intended for the
semantics of this API -- I didn't even know it *was* an MI API until
this commit. Maybe kib can comment? If this is outside the semantics of
PHYS_TO_DMAP, then we need to keep the existing sfbuf code.

sfbufs cannot guarantee that there is no other mapping of the page when
the sfbuf is created.  For instance, one of the use of sfbufs is to map
the image page 0 to read ELF headers when doing the image activation.
The image might be mapped by other processes, and we do not control the
address at which it mapped.

So the direct map accesses must work regardless of the presence of other
page mappings, and the check for dcache_color_ignore is needed to allow
MI code to take advantage of DMAP.


So: what do you want to happen with PHYS_TO_DMAP()? Do we want to claim
to MI that a direct map is "available" in such circumstances, or
"unavailable"? Should sfbuf retain a separate API? I have no preferences
here and just want to close out this issue.

Perhaps DMAP should be conditionally available to the MI layer, same as
on powerpc ? I.e. your patch cited above lo

svn commit: r328168 - in head/sys: amd64/include arm/include arm64/include compat/linuxkpi/common/src dev/efidev i386/include kern mips/include powerpc/include riscv/include sparc64/include sys vm

2018-01-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Jan 19 17:46:31 2018
New Revision: 328168
URL: https://svnweb.freebsd.org/changeset/base/328168

Log:
  Remove SFBUF_OPTIONAL_DIRECT_MAP and such hacks, replacing them across the
  kernel by PHYS_TO_DMAP() as previously present on amd64, arm64, riscv, and
  powerpc64. This introduces a new MI macro (PMAP_HAS_DMAP) that can be
  evaluated at runtime to determine if the architecture has a direct map;
  if it does not (or does) unconditionally and PMAP_HAS_DMAP is either 0 or
  1, the compiler can remove the conditional logic.
  
  As part of this, implement PHYS_TO_DMAP() on sparc64 and mips64, which had
  similar things but spelled differently. 32-bit MIPS has a partial direct-map
  that maps poorly to this concept and is unchanged.
  
  Reviewed by:  kib
  Suggestions from: marius, alc, kib
  Runtime tested on:amd64, powerpc64, powerpc, mips64

Modified:
  head/sys/amd64/include/vmparam.h
  head/sys/arm/include/vmparam.h
  head/sys/arm64/include/vmparam.h
  head/sys/compat/linuxkpi/common/src/linux_page.c
  head/sys/dev/efidev/efirt.c
  head/sys/i386/include/vmparam.h
  head/sys/kern/subr_sfbuf.c
  head/sys/mips/include/vmparam.h
  head/sys/powerpc/include/vmparam.h
  head/sys/riscv/include/vmparam.h
  head/sys/sparc64/include/vmparam.h
  head/sys/sys/sf_buf.h
  head/sys/vm/vm_page.c

Modified: head/sys/amd64/include/vmparam.h
==
--- head/sys/amd64/include/vmparam.hFri Jan 19 16:06:52 2018
(r328167)
+++ head/sys/amd64/include/vmparam.hFri Jan 19 17:46:31 2018
(r328168)
@@ -190,6 +190,7 @@
  * because the result is not actually accessed until later, but the early
  * vt fb startup needs to be reworked.
  */
+#definePMAP_HAS_DMAP   1
 #definePHYS_TO_DMAP(x) ({  
\
KASSERT(dmaplimit == 0 || (x) < dmaplimit,  \
("physical address %#jx not covered by the DMAP",   \

Modified: head/sys/arm/include/vmparam.h
==
--- head/sys/arm/include/vmparam.h  Fri Jan 19 16:06:52 2018
(r328167)
+++ head/sys/arm/include/vmparam.h  Fri Jan 19 17:46:31 2018
(r328168)
@@ -187,6 +187,8 @@ extern vm_offset_t vm_max_kernel_address;
 #defineSFBUF
 #defineSFBUF_MAP
 
+#definePMAP_HAS_DMAP   0
+
 #defineDEVMAP_MAX_VADDRARM_VECTORS_HIGH
 
 #endif /* _MACHINE_VMPARAM_H_ */

Modified: head/sys/arm64/include/vmparam.h
==
--- head/sys/arm64/include/vmparam.hFri Jan 19 16:06:52 2018
(r328167)
+++ head/sys/arm64/include/vmparam.hFri Jan 19 17:46:31 2018
(r328168)
@@ -176,6 +176,7 @@
 #defineVIRT_IN_DMAP(va)((va) >= DMAP_MIN_ADDRESS && \
 (va) < (dmap_max_addr))
 
+#definePMAP_HAS_DMAP   1
 #definePHYS_TO_DMAP(pa)
\
 ({ \
KASSERT(PHYS_IN_DMAP(pa),   \

Modified: head/sys/compat/linuxkpi/common/src/linux_page.c
==
--- head/sys/compat/linuxkpi/common/src/linux_page.cFri Jan 19 16:06:52 
2018(r328167)
+++ head/sys/compat/linuxkpi/common/src/linux_page.cFri Jan 19 17:46:31 
2018(r328168)
@@ -63,19 +63,14 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#if defined(__amd64__) || defined(__aarch64__) || defined(__riscv)
-#defineLINUXKPI_HAVE_DMAP
-#else
-#undef LINUXKPI_HAVE_DMAP
-#endif
-
 void *
 linux_page_address(struct page *page)
 {
 
if (page->object != kmem_object && page->object != kernel_object) {
-#ifdef LINUXKPI_HAVE_DMAP
-   return ((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page)));
+#ifdef PHYS_TO_DMAP
+   return (PMAP_HAS_DMAP ?
+   ((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page))) : NULL);
 #else
return (NULL);
 #endif
@@ -87,7 +82,8 @@ linux_page_address(struct page *page)
 vm_page_t
 linux_alloc_pages(gfp_t flags, unsigned int order)
 {
-#ifdef LINUXKPI_HAVE_DMAP
+#ifdef PHYS_TO_DMAP
+   KASSERT(PMAP_HAS_DMAP, ("Direct map unavailable"));
unsigned long npages = 1UL << order;
int req = (flags & M_ZERO) ? (VM_ALLOC_ZERO | VM_ALLOC_NOOBJ |
VM_ALLOC_NORMAL) : (VM_ALLOC_NOOBJ | VM_ALLOC_NORMAL);
@@ -145,23 +141,27 @@ retry:
 void
 linux_free_pages(vm_page_t page, unsigned int order)
 {
-#ifdef LINUXKPI_HAVE_DMAP
-   unsigned long npages = 1UL << order;
-   unsigned long x;
+#ifdef PHYS_TO_DMAP
+   if (PMAP_HAS_DMAP) {
+   unsigned long npages = 1UL << order;
+   unsigned long x;
 
-   for (x = 0; x != npages; x++) {
-

svn commit: r328178 - in head/sys: arm/include compat/linuxkpi/common/src i386/include sys

2018-01-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Jan 19 22:17:13 2018
New Revision: 328178
URL: https://svnweb.freebsd.org/changeset/base/328178

Log:
  Define PHYS_TO_DMAP() and DMAP_TO_PHYS() as panics on the architectures
  (i386 and arm) that never implement them. This allows the removal of
  #ifdef PHYS_TO_DMAP on code otherwise protected by a runtime check on
  PMAP_HAS_DMAP. It also fixes the build on ARM and i386 after I forgot an
  #ifdef in r328168.
  
  Reported by:  Milan Obuch
  Pointy hat to:me

Modified:
  head/sys/arm/include/vmparam.h
  head/sys/compat/linuxkpi/common/src/linux_page.c
  head/sys/i386/include/vmparam.h
  head/sys/sys/sf_buf.h

Modified: head/sys/arm/include/vmparam.h
==
--- head/sys/arm/include/vmparam.h  Fri Jan 19 22:10:29 2018
(r328177)
+++ head/sys/arm/include/vmparam.h  Fri Jan 19 22:17:13 2018
(r328178)
@@ -188,6 +188,8 @@ extern vm_offset_t vm_max_kernel_address;
 #defineSFBUF_MAP
 
 #definePMAP_HAS_DMAP   0
+#definePHYS_TO_DMAP(x) ({ panic("No direct map exists"); 0; })
+#defineDMAP_TO_PHYS(x) ({ panic("No direct map exists"); 0; })
 
 #defineDEVMAP_MAX_VADDRARM_VECTORS_HIGH
 

Modified: head/sys/compat/linuxkpi/common/src/linux_page.c
==
--- head/sys/compat/linuxkpi/common/src/linux_page.cFri Jan 19 22:10:29 
2018(r328177)
+++ head/sys/compat/linuxkpi/common/src/linux_page.cFri Jan 19 22:17:13 
2018(r328178)
@@ -68,12 +68,8 @@ linux_page_address(struct page *page)
 {
 
if (page->object != kmem_object && page->object != kernel_object) {
-#ifdef PHYS_TO_DMAP
return (PMAP_HAS_DMAP ?
((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page))) : NULL);
-#else
-   return (NULL);
-#endif
}
return ((void *)(uintptr_t)(VM_MIN_KERNEL_ADDRESS +
IDX_TO_OFF(page->pindex)));
@@ -82,66 +78,65 @@ linux_page_address(struct page *page)
 vm_page_t
 linux_alloc_pages(gfp_t flags, unsigned int order)
 {
-#ifdef PHYS_TO_DMAP
-   KASSERT(PMAP_HAS_DMAP, ("Direct map unavailable"));
-   unsigned long npages = 1UL << order;
-   int req = (flags & M_ZERO) ? (VM_ALLOC_ZERO | VM_ALLOC_NOOBJ |
-   VM_ALLOC_NORMAL) : (VM_ALLOC_NOOBJ | VM_ALLOC_NORMAL);
vm_page_t page;
 
-   if (order == 0 && (flags & GFP_DMA32) == 0) {
-   page = vm_page_alloc(NULL, 0, req);
-   if (page == NULL)
-   return (NULL);
-   } else {
-   vm_paddr_t pmax = (flags & GFP_DMA32) ?
-   BUS_SPACE_MAXADDR_32BIT : BUS_SPACE_MAXADDR;
-retry:
-   page = vm_page_alloc_contig(NULL, 0, req,
-   npages, 0, pmax, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+   if (PMAP_HAS_DMAP) {
+   unsigned long npages = 1UL << order;
+   int req = (flags & M_ZERO) ? (VM_ALLOC_ZERO | VM_ALLOC_NOOBJ |
+   VM_ALLOC_NORMAL) : (VM_ALLOC_NOOBJ | VM_ALLOC_NORMAL);
 
-   if (page == NULL) {
-   if (flags & M_WAITOK) {
-   if (!vm_page_reclaim_contig(req,
-   npages, 0, pmax, PAGE_SIZE, 0)) {
-   VM_WAIT;
+   if (order == 0 && (flags & GFP_DMA32) == 0) {
+   page = vm_page_alloc(NULL, 0, req);
+   if (page == NULL)
+   return (NULL);
+   } else {
+   vm_paddr_t pmax = (flags & GFP_DMA32) ?
+   BUS_SPACE_MAXADDR_32BIT : BUS_SPACE_MAXADDR;
+   retry:
+   page = vm_page_alloc_contig(NULL, 0, req,
+   npages, 0, pmax, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+
+   if (page == NULL) {
+   if (flags & M_WAITOK) {
+   if (!vm_page_reclaim_contig(req,
+   npages, 0, pmax, PAGE_SIZE, 0)) {
+   VM_WAIT;
+   }
+   flags &= ~M_WAITOK;
+   goto retry;
}
-   flags &= ~M_WAITOK;
-   goto retry;
+   return (NULL);
}
-   return (NULL);
}
-   }
-   if (flags & M_ZERO) {
-   unsigned long x;
+   if (flags & M_ZERO) {
+   unsigned long x;
 
-   for (x = 0; x != npages; x++) {
-   vm_page_t pgo = page + x;
+   for (x = 0; x != npages; x++) {
+   

svn commit: r328179 - head/sys/powerpc/aim

2018-01-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Jan 19 22:19:50 2018
New Revision: 328179
URL: https://svnweb.freebsd.org/changeset/base/328179

Log:
  On AIM systems without a software-managed SLB, such as POWER9 systems using
  either hardware segment tables or radix-tree-based page tables, do not try
  to install SLB entries at trap boundaries.

Modified:
  head/sys/powerpc/aim/trap_subr64.S

Modified: head/sys/powerpc/aim/trap_subr64.S
==
--- head/sys/powerpc/aim/trap_subr64.S  Fri Jan 19 22:17:13 2018
(r328178)
+++ head/sys/powerpc/aim/trap_subr64.S  Fri Jan 19 22:19:50 2018
(r328179)
@@ -58,6 +58,9 @@
 restore_usersrs:
GET_CPUINFO(%r28)
ld  %r28,PC_USERSLB(%r28)
+   cmpdi   %r28, 0 /* If user SLB pointer NULL, exit */
+   beqlr
+
li  %r29, 0 /* Set the counter to zero */
 
slbia
@@ -83,6 +86,12 @@ restore_usersrs:
 restore_kernsrs:
GET_CPUINFO(%r28)
addi%r28,%r28,PC_KERNSLB
+   ld  %r29,16(%r28)   /* One past USER_SLB_SLOT */
+   cmpdi   %r28,0
+   beqlr   /* If first kernel entry is invalid,
+* SLBs not in use, so exit early */
+
+   /* Otherwise, set up SLBs */
li  %r29, 0 /* Set the counter to zero */
 
slbia
___
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: r328408 - head/sys/powerpc/powerpc

2018-01-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Jan 25 18:09:26 2018
New Revision: 328408
URL: https://svnweb.freebsd.org/changeset/base/328408

Log:
  Treat DSE exceptions like DSI exceptions when generating signinfo.
  Both can generate SIGSEGV, but DSEs would have put the wrong address
  into the siginfo structure when the signal was delivered.
  
  MFC after:1 week

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

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==
--- head/sys/powerpc/powerpc/exec_machdep.c Thu Jan 25 18:08:56 2018
(r328407)
+++ head/sys/powerpc/powerpc/exec_machdep.c Thu Jan 25 18:09:26 2018
(r328408)
@@ -154,7 +154,8 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask
 * Fill siginfo structure.
 */
ksi->ksi_info.si_signo = ksi->ksi_signo;
-   ksi->ksi_info.si_addr = (void *)((tf->exc == EXC_DSI) ? 
+   ksi->ksi_info.si_addr =
+   (void *)((tf->exc == EXC_DSI || tf->exc == EXC_DSE) ? 
tf->dar : tf->srr0);
 
#ifdef COMPAT_FREEBSD32
___
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: r328409 - head/sys/powerpc/powerpc

2018-01-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Jan 25 18:10:33 2018
New Revision: 328409
URL: https://svnweb.freebsd.org/changeset/base/328409

Log:
  Avoid all SLB operations in trap handling if the process is not using a
  software-managed SLB.

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

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Thu Jan 25 18:09:26 2018
(r328408)
+++ head/sys/powerpc/powerpc/trap.c Thu Jan 25 18:10:33 2018
(r328409)
@@ -629,8 +629,9 @@ syscall(struct trapframe *frame)
 * Speculatively restore last user SLB segment, which we know is
 * invalid already, since we are likely to do copyin()/copyout().
 */
-   __asm __volatile ("slbmte %0, %1; isync" ::
-"r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
+   if (td->td_pcb->pcb_cpu.aim.usr_vsid != 0)
+   __asm __volatile ("slbmte %0, %1; isync" ::
+   "r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
 #endif
 
error = syscallenter(td);
@@ -690,6 +691,9 @@ handle_user_slb_spill(pmap_t pm, vm_offset_t addr)
struct slb *user_entry;
uint64_t esid;
int i;
+
+   if (pm->pm_slb == NULL)
+   return (-1);
 
esid = (uintptr_t)addr >> ADDR_SR_SHFT;
 
___
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: r328519 - head/sys/powerpc/include

2018-01-28 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Jan 28 21:30:57 2018
New Revision: 328519
URL: https://svnweb.freebsd.org/changeset/base/328519

Log:
  Remove some unused AIM register declarations that existed to support some
  CPUs we have never run on. As a side-effect, removes some #ifdef AIM/#else.

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

Modified: head/sys/powerpc/include/spr.h
==
--- head/sys/powerpc/include/spr.h  Sun Jan 28 20:35:48 2018
(r328518)
+++ head/sys/powerpc/include/spr.h  Sun Jan 28 21:30:57 2018
(r328519)
@@ -667,19 +667,7 @@
 #definePMC970N_CYCLES  0xf /* Processor cycles */
 #definePMC970N_ICOMP   0x9 /* Instructions completed */
 
-#if defined(AIM)
-
-#defineSPR_ESR 0x3d4   /* 4.. Exception Syndrome 
Register */
-#define  ESR_MCI 0x8000 /* Machine check - 
instruction */
-#define  ESR_PIL 0x0800 /* Program interrupt - 
illegal */
-#define  ESR_PPR 0x0400 /* Program interrupt - 
privileged */
-#define  ESR_PTR 0x0200 /* Program interrupt - 
trap */
-#define  ESR_ST  0x0100 /* Store operation */
-#define  ESR_DST 0x0080 /* Data storage interrupt 
- store fault */
-#define  ESR_DIZ 0x0080 /* Data/instruction 
storage interrupt - zone fault */
-#define  ESR_U0F 0x8000 /* Data storage interrupt 
- U0 fault */
-
-#elif defined(BOOKE)
+#if defined(BOOKE)
 
 #defineSPR_MCARU   0x239   /* ..8 Machine Check Address 
register upper bits */
 #defineSPR_MCSR0x23c   /* ..8 Machine Check Syndrome 
register */
___
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: r328530 - in head/sys/powerpc: aim booke include powerpc

2018-01-28 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Jan 29 04:33:41 2018
New Revision: 328530
URL: https://svnweb.freebsd.org/changeset/base/328530

Log:
  Remove hard-coded trap-handling logic involving the segmented memory model
  used with hashed page tables on AIM and place it into a new, modular pmap
  function called pmap_decode_kernel_ptr(). This function is the inverse
  of pmap_map_user_ptr(). With POWER9 radix tables, which mapping to use
  becomes more complex than just AIM/BOOKE and it is best to have it in
  the same place as pmap_map_user_ptr().
  
  Reviewed by:  jhibbits

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/booke/pmap.c
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/powerpc/mmu_if.m
  head/sys/powerpc/powerpc/pmap_dispatch.c
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Mon Jan 29 04:04:52 2018
(r328529)
+++ head/sys/powerpc/aim/mmu_oea.c  Mon Jan 29 04:33:41 2018
(r328530)
@@ -322,6 +322,8 @@ vm_offset_t moea_quick_enter_page(mmu_t mmu, vm_page_t
 void moea_quick_remove_page(mmu_t mmu, vm_offset_t addr);
 static int moea_map_user_ptr(mmu_t mmu, pmap_t pm,
 volatile const void *uaddr, void **kaddr, size_t ulen, size_t *klen);
+static int moea_decode_kernel_ptr(mmu_t mmu, vm_offset_t addr,
+int *is_user, vm_offset_t *decoded_addr);
 
 
 static mmu_method_t moea_methods[] = {
@@ -374,6 +376,7 @@ static mmu_method_t moea_methods[] = {
MMUMETHOD(mmu_scan_init,moea_scan_init),
MMUMETHOD(mmu_dumpsys_map,  moea_dumpsys_map),
MMUMETHOD(mmu_map_user_ptr, moea_map_user_ptr),
+   MMUMETHOD(mmu_decode_kernel_ptr, moea_decode_kernel_ptr),
 
{ 0, 0 }
 };
@@ -1583,6 +1586,31 @@ moea_map_user_ptr(mmu_t mmu, pmap_t pm, volatile const
(uintptr_t)uaddr >> ADDR_SR_SHFT;
curthread->td_pcb->pcb_cpu.aim.usr_vsid = vsid;
__asm __volatile("mtsr %0,%1; isync" :: "n"(USER_SR), "r"(vsid));
+
+   return (0);
+}
+
+/*
+ * Figure out where a given kernel pointer (usually in a fault) points
+ * to from the VM's perspective, potentially remapping into userland's
+ * address space.
+ */
+static int
+moea_decode_kernel_ptr(mmu_t mmu, vm_offset_t addr, int *is_user,
+vm_offset_t *decoded_addr)
+{
+   vm_offset_t user_sr;
+
+   if ((addr >> ADDR_SR_SHFT) == (USER_ADDR >> ADDR_SR_SHFT)) {
+   user_sr = curthread->td_pcb->pcb_cpu.aim.usr_segm;
+   addr &= ADDR_PIDX | ADDR_POFF;
+   addr |= user_sr << ADDR_SR_SHFT;
+   *decoded_addr = addr;
+   *is_user = 1;
+   } else {
+   *decoded_addr = addr;
+   *is_user = 0;
+   }
 
return (0);
 }

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cMon Jan 29 04:04:52 2018
(r328529)
+++ head/sys/powerpc/aim/mmu_oea64.cMon Jan 29 04:33:41 2018
(r328530)
@@ -288,6 +288,8 @@ vm_offset_t moea64_quick_enter_page(mmu_t mmu, vm_page
 void moea64_quick_remove_page(mmu_t mmu, vm_offset_t addr);
 static int moea64_map_user_ptr(mmu_t mmu, pmap_t pm,
 volatile const void *uaddr, void **kaddr, size_t ulen, size_t *klen);
+static int moea64_decode_kernel_ptr(mmu_t mmu, vm_offset_t addr,
+int *is_user, vm_offset_t *decoded_addr);
 
 
 static mmu_method_t moea64_methods[] = {
@@ -339,6 +341,7 @@ static mmu_method_t moea64_methods[] = {
MMUMETHOD(mmu_scan_init,moea64_scan_init),
MMUMETHOD(mmu_dumpsys_map,  moea64_dumpsys_map),
MMUMETHOD(mmu_map_user_ptr, moea64_map_user_ptr),
+   MMUMETHOD(mmu_decode_kernel_ptr, moea64_decode_kernel_ptr),
 
{ 0, 0 }
 };
@@ -1905,6 +1908,31 @@ moea64_map_user_ptr(mmu_t mmu, pmap_t pm, volatile con
 #else
__asm __volatile("mtsr %0,%1; isync" :: "n"(USER_SR), "r"(slbv));
 #endif
+
+   return (0);
+}
+
+/*
+ * Figure out where a given kernel pointer (usually in a fault) points
+ * to from the VM's perspective, potentially remapping into userland's
+ * address space.
+ */
+static int
+moea64_decode_kernel_ptr(mmu_t mmu, vm_offset_t addr, int *is_user,
+vm_offset_t *decoded_addr)
+{
+   vm_offset_t user_sr;
+
+   if ((addr >> ADDR_SR_SHFT) == (USER_ADDR >> ADDR_SR_SHFT)) {
+   user_sr = curthread->td_pcb->pcb_cpu.aim.usr_segm;
+   addr &= ADDR_PIDX | ADDR_POFF;
+   addr |= user_sr << ADDR_SR_SHFT;
+   *decoded_addr = addr;
+   *is_user = 1;
+   } else {
+   *decoded_addr = addr;
+   *is_user = 0;
+   }
 
return (0);
 }

Modified: head/sys/powerpc/booke/pmap.c
==
--- head/sys/powerpc/book

Re: svn commit: r328537 - in head/sys/powerpc: aim powernv

2018-01-29 Thread Nathan Whitehorn
Can you explain why this is necessary? Both functions are run in the 
same context and this way of doing things breaks important abstraction 
barriers.


Since it also breaks booting on pHyp systems, I would appreciate it if 
you could revert this pending review.

-Nathan

On 01/29/18 01:27, Wojciech Macek wrote:

Author: wma
Date: Mon Jan 29 09:27:02 2018
New Revision: 328537
URL: https://svnweb.freebsd.org/changeset/base/328537

Log:
   PowerNV: move LPCR and LPID altering to cpudep_ap_early_bootstrap
   
   It turns out that under some circumstances we can get DSI or DSE before we set

   LPCR and LPID so we should set it as early as possible.
   
   Authored by:   Patryk Duda 

   Submitted by:  Wojciech Macek 
   Obtained from: Semihalf
   Sponsored by:  IBM, QCM Technologies

Modified:
   head/sys/powerpc/aim/mp_cpudep.c
   head/sys/powerpc/powernv/platform_powernv.c

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cMon Jan 29 09:24:28 2018
(r328536)
+++ head/sys/powerpc/aim/mp_cpudep.cMon Jan 29 09:27:02 2018
(r328537)
@@ -64,9 +64,6 @@ cpudep_ap_early_bootstrap(void)
register_t reg;
  #endif
  
-	__asm __volatile("mtsprg 0, %0" :: "r"(ap_pcpu));

-   powerpc_sync();
-
switch (mfpvr() >> 16) {
case IBM970:
case IBM970FX:
@@ -86,7 +83,20 @@ cpudep_ap_early_bootstrap(void)
  #endif
powerpc_sync();
break;
+   case IBMPOWER8:
+   case IBMPOWER8E:
+   isync();
+   /* Direct interrupts to SRR instead of HSRR and reset LPCR 
otherwise */
+   mtspr(SPR_LPID, 0);
+   isync();
+
+   mtspr(SPR_LPCR, LPCR_LPES);
+   isync();
+   break;
}
+
+   __asm __volatile("mtsprg 0, %0" :: "r"(ap_pcpu));
+   powerpc_sync();
  }
  
  uintptr_t


Modified: head/sys/powerpc/powernv/platform_powernv.c
==
--- head/sys/powerpc/powernv/platform_powernv.c Mon Jan 29 09:24:28 2018
(r328536)
+++ head/sys/powerpc/powernv/platform_powernv.c Mon Jan 29 09:27:02 2018
(r328537)
@@ -128,6 +128,7 @@ powernv_attach(platform_t plat)
pcell_t prop;
phandle_t cpu;
int res, len, node, idx;
+   register_t msr;
  
  	/* Ping OPAL again just to make sure */

opal_check();
@@ -141,6 +142,19 @@ powernv_attach(platform_t plat)
cpu_idle_hook = powernv_cpu_idle;
powernv_boot_pir = mfspr(SPR_PIR);
  
+	/* LPID must not be altered when PSL_DR or PSL_IR is set */

+   msr = mfmsr();
+   mtmsr(msr & ~(PSL_DR | PSL_IR));
+
+   /* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */
+   mtspr(SPR_LPID, 0);
+   isync();
+
+   mtmsr(msr);
+
+   mtspr(SPR_LPCR, LPCR_LPES);
+   isync();
+
/* Init CPU bits */
powernv_smp_ap_init(plat);
  
@@ -444,21 +458,6 @@ powernv_reset(platform_t platform)

  static void
  powernv_smp_ap_init(platform_t platform)
  {
-   register_t msr;
-
-   /* LPID must not be altered when PSL_DR or PSL_IR is set */
-   msr = mfmsr();
-   mtmsr(msr & ~(PSL_DR | PSL_IR));
-
-   isync();
-   /* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */
-   mtspr(SPR_LPID, 0);
-   isync();
-
-   mtmsr(msr);
-
-   mtspr(SPR_LPCR, LPCR_LPES);
-   isync();
  }
  
  static void




___
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: r328537 - in head/sys/powerpc: aim powernv

2018-01-30 Thread Nathan Whitehorn



On 01/30/18 01:04, Wojciech Macek wrote:
The LPCR register must be set very early. The best is to do it in 
cpudep_bootstrap as this is the first function being run on the AP 
after start.
As soon as the AP completes pmap_cpu_bootstrap, we must guarantee that 
DSI exceptions are working fine. We can't do this with LPCR set 
incorrectly, this it contains a base addres of an exception table.


Hmm, yes. I had forgotten this ran after pmap_cpu_bootstrap(). Thanks 
for the explanation!


The code from powernv_smp_ap_init was moved to attach, as we don't set 
LPCR twice during AP startup - it's not an error of course, but I like 
to have this in one place only.


I can revert this patch if you insist, but to fix non-powernv boards 
we can just add "if (mfmsr() & PSL_HV)" check to early_bootstrap. What 
do you think?


Let's just add the PSL_HV check. We could add another platform_early() 
method, but I don't see much point in it here.

-Nathan



Regards,
Wojtek

2018-01-29 16:46 GMT+01:00 Nathan Whitehorn <mailto:nwhiteh...@freebsd.org>>:


Can you explain why this is necessary? Both functions are run in
the same context and this way of doing things breaks important
abstraction barriers.

Since it also breaks booting on pHyp systems, I would appreciate
it if you could revert this pending review.
-Nathan


On 01/29/18 01:27, Wojciech Macek wrote:

Author: wma
Date: Mon Jan 29 09:27:02 2018
New Revision: 328537
URL: https://svnweb.freebsd.org/changeset/base/328537
<https://svnweb.freebsd.org/changeset/base/328537>

Log:
   PowerNV: move LPCR and LPID altering to
cpudep_ap_early_bootstrap
      It turns out that under some circumstances we can get
DSI or DSE before we set
   LPCR and LPID so we should set it as early as possible.
      Authored by:           Patryk Duda mailto:p...@semihalf.com>>
   Submitted by:          Wojciech Macek mailto:w...@semihalf.com>>
   Obtained from:         Semihalf
   Sponsored by:          IBM, QCM Technologies

Modified:
   head/sys/powerpc/aim/mp_cpudep.c
   head/sys/powerpc/powernv/platform_powernv.c

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

==
--- head/sys/powerpc/aim/mp_cpudep.c    Mon Jan 29 09:24:28
2018        (r328536)
+++ head/sys/powerpc/aim/mp_cpudep.c    Mon Jan 29 09:27:02
2018        (r328537)
@@ -64,9 +64,6 @@ cpudep_ap_early_bootstrap(void)
        register_t reg;
  #endif
  -     __asm __volatile("mtsprg 0, %0" :: "r"(ap_pcpu));
-       powerpc_sync();
-
        switch (mfpvr() >> 16) {
        case IBM970:
        case IBM970FX:
@@ -86,7 +83,20 @@ cpudep_ap_early_bootstrap(void)
  #endif
                powerpc_sync();
                break;
+       case IBMPOWER8:
+       case IBMPOWER8E:
+               isync();
+               /* Direct interrupts to SRR instead of HSRR
and reset LPCR otherwise */
+               mtspr(SPR_LPID, 0);
+               isync();
+
+               mtspr(SPR_LPCR, LPCR_LPES);
+               isync();
+               break;
        }
+
+       __asm __volatile("mtsprg 0, %0" :: "r"(ap_pcpu));
+       powerpc_sync();
  }
    uintptr_t

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

==
--- head/sys/powerpc/powernv/platform_powernv.c Mon Jan 29
09:24:28 2018        (r328536)
+++ head/sys/powerpc/powernv/platform_powernv.c Mon Jan 29
09:27:02 2018        (r328537)
@@ -128,6 +128,7 @@ powernv_attach(platform_t plat)
        pcell_t prop;
        phandle_t cpu;
        int res, len, node, idx;
+       register_t msr;
        /* Ping OPAL again just to make sure */
        opal_check();
@@ -141,6 +142,19 @@ powernv_attach(platform_t plat)
        cpu_idle_hook = powernv_cpu_idle;
        powernv_boot_pir = mfspr(SPR_PIR);
  +     /* LPID must not be altered when PSL_DR or PSL_IR is
set */
+       msr = mfmsr();
+       mtmsr(msr & ~(PSL_DR | PSL_IR));
+
+       /* Direct interrupts to SRR instead of HSRR and reset
LPCR otherwise */
+       mtspr(SPR_LPID, 0);
+       isync();
+
+       mtmsr(msr);
+
+       mtspr(SPR_LPCR, LPCR_LPES);
+       isync();
+
   

svn commit: r332788 - head/sys/powerpc/aim

2018-04-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Apr 19 18:34:38 2018
New Revision: 332788
URL: https://svnweb.freebsd.org/changeset/base/332788

Log:
  Fix detection of memory overlap with the kernel in the case where a memory
  region marked "available" by firmware is contained entirely in the kernel.
  
  This had a tendency to happen with FDTs passed by loader, though could for
  other reasons as well, and would result in the kernel slowly cannibalizing
  itself for other purposes, eventually resulting in a crash.
  
  A similar fix is needed for mmu_oea.c and should probably just be rolled
  at that point into some generic code in platform.c for taking a mem_region
  list and removing chunks.
  
  PR:   226974
  Submitted by: leandro.lup...@gmail.com
  Reviewed by:  jhibbits
  Differential Revision:D15121

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

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cThu Apr 19 18:10:44 2018
(r332787)
+++ head/sys/powerpc/aim/mmu_oea64.cThu Apr 19 18:34:38 2018
(r332788)
@@ -695,12 +695,27 @@ moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernel
unmapped_buf_allowed = hw_direct_map;
 }
 
+/* Quick sort callout for comparing physical addresses. */
+static int
+pa_cmp(const void *a, const void *b)
+{
+   const vm_paddr_t *pa = a, *pb = b;
+
+   if (*pa < *pb)
+   return (-1);
+   else if (*pa > *pb)
+   return (1);
+   else
+   return (0);
+}
+
 void
 moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t 
kernelend)
 {
int i, j;
vm_size_t   physsz, hwphyssz;
vm_paddr_t  kernelphysstart, kernelphysend;
+   int rm_pavail;
 
 #ifndef __powerpc64__
/* We don't have a direct map since there is no BAT */
@@ -763,10 +778,18 @@ moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernels
}
 
/* Check for overlap with the kernel and exception vectors */
+   rm_pavail = 0;
for (j = 0; j < 2*phys_avail_count; j+=2) {
if (phys_avail[j] < EXC_LAST)
phys_avail[j] += EXC_LAST;
 
+   if (phys_avail[j] >= kernelphysstart &&
+   phys_avail[j+1] <= kernelphysend) {
+   phys_avail[j] = phys_avail[j+1] = ~0;
+   rm_pavail++;
+   continue;
+   }
+
if (kernelphysstart >= phys_avail[j] &&
kernelphysstart < phys_avail[j+1]) {
if (kernelphysend < phys_avail[j+1]) {
@@ -792,6 +815,16 @@ moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernels
phys_avail[j] = (kernelphysend & ~PAGE_MASK) +
PAGE_SIZE;
}
+   }
+
+   /* Remove physical available regions marked for removal (~0) */
+   if (rm_pavail) {
+   qsort(phys_avail, 2*phys_avail_count, sizeof(phys_avail[0]),
+   pa_cmp);
+   phys_avail_count -= rm_pavail;
+   for (i = 2*phys_avail_count;
+i < 2*(phys_avail_count + rm_pavail); i+=2)
+   phys_avail[i] = phys_avail[i+1] = 0;
}
 
physmem = btoc(physsz);
___
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: r333124 - head/sys/powerpc/powermac

2018-04-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Apr 30 19:37:32 2018
New Revision: 333124
URL: https://svnweb.freebsd.org/changeset/base/333124

Log:
  Fix null pointer dereference on nodes without a "compatible" property.
  
  MFC after:1 week

Modified:
  head/sys/powerpc/powermac/macio.c

Modified: head/sys/powerpc/powermac/macio.c
==
--- head/sys/powerpc/powermac/macio.c   Mon Apr 30 19:21:20 2018
(r333123)
+++ head/sys/powerpc/powermac/macio.c   Mon Apr 30 19:37:32 2018
(r333124)
@@ -399,7 +399,8 @@ macio_attach(device_t dev)
continue;
 
if (strcmp(ofw_bus_get_name(cdev), "bmac") == 0 ||
-   strcmp(ofw_bus_get_compat(cdev), "bmac+") == 0) {
+   (ofw_bus_get_compat(cdev) != NULL &&
+   strcmp(ofw_bus_get_compat(cdev), "bmac+") == 0)) {
uint32_t fcr;
 
fcr = bus_read_4(sc->sc_memr, HEATHROW_FCR);
___
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: r333134 - head/sys/kern

2018-04-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue May  1 04:06:59 2018
New Revision: 333134
URL: https://svnweb.freebsd.org/changeset/base/333134

Log:
  Report the kernel base address properly in kldstat when using PowerPC kernels
  loaded at addresses other than their link address.

Modified:
  head/sys/kern/link_elf.c

Modified: head/sys/kern/link_elf.c
==
--- head/sys/kern/link_elf.cTue May  1 00:53:46 2018(r333133)
+++ head/sys/kern/link_elf.cTue May  1 04:06:59 2018(r333134)
@@ -383,7 +383,7 @@ link_elf_link_common_finish(linker_file_t lf)
return (0);
 }
 
-extern vm_offset_t __startkernel;
+extern vm_offset_t __startkernel, __endkernel;
 
 static void
 link_elf_init(void* arg)
@@ -424,8 +424,13 @@ link_elf_init(void* arg)
 
if (dp != NULL)
parse_dynamic(ef);
+#ifdef __powerpc__
+   linker_kernel_file->address = (caddr_t)__startkernel;
+   linker_kernel_file->size = (intptr_t)(__endkernel - __startkernel);
+#else
linker_kernel_file->address += KERNBASE;
linker_kernel_file->size = -(intptr_t)linker_kernel_file->address;
+#endif
 
if (modptr != NULL) {
ef->modptr = modptr;
___
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: r333436 - in head/etc: etc.aarch64 etc.amd64 etc.arm etc.i386 etc.powerpc etc.riscv etc.sparc64

2018-05-09 Thread Nathan Whitehorn

Thanks!

At this point, these files only differ from each other in white space, 
comments, and whether they have video console lines at all, which is 
made unnecessary by this commit --- with the exception of sparc64, which 
has a few extra off-by-default console options. Any reason not to unify 
them? Or is that a follow-up commit?

-Nathan

On 05/09/18 13:49, Warner Losh wrote:

Author: imp
Date: Wed May  9 20:49:00 2018
New Revision: 333436
URL: https://svnweb.freebsd.org/changeset/base/333436

Log:
   For video consoles, only launch a getty if the device exists.
   
   Differential Revision: https://reviews.freebsd.org/D15169


Modified:
   head/etc/etc.aarch64/ttys
   head/etc/etc.amd64/ttys
   head/etc/etc.arm/ttys
   head/etc/etc.i386/ttys
   head/etc/etc.powerpc/ttys
   head/etc/etc.riscv/ttys
   head/etc/etc.sparc64/ttys

Modified: head/etc/etc.aarch64/ttys
==
--- head/etc/etc.aarch64/ttys   Wed May  9 20:41:03 2018(r333435)
+++ head/etc/etc.aarch64/ttys   Wed May  9 20:49:00 2018(r333436)
@@ -29,16 +29,16 @@
  # when going to single-user mode.
  console   noneunknown off secure
  #
-ttyv0  "/usr/libexec/getty Pc"   xterm   onifconsole  secure
+ttyv0  "/usr/libexec/getty Pc"   xterm   onifexists secure
  # Virtual terminals
-ttyv1  "/usr/libexec/getty Pc"   xterm   off  secure
-ttyv2  "/usr/libexec/getty Pc"   xterm   off  secure
-ttyv3  "/usr/libexec/getty Pc"   xterm   off  secure
-ttyv4  "/usr/libexec/getty Pc"   xterm   off  secure
-ttyv5  "/usr/libexec/getty Pc"   xterm   off  secure
-ttyv6  "/usr/libexec/getty Pc"   xterm   off  secure
-ttyv7  "/usr/libexec/getty Pc"   xterm   off  secure
-#ttyv8 "/usr/local/bin/xdm -nodaemon"xterm   off secure
+ttyv1  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv2  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv3  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv4  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv5  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv6  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv7  "/usr/libexec/getty Pc"   xterm   onifexists secure
+#ttyv8 "/usr/local/bin/xdm -nodaemon"xterm   onifexists secure
  # Serial terminals
  # The 'dialup' keyword identifies dialin lines to login, fingerd etc.
  ttyu0 "/usr/libexec/getty 3wire"vt100   onifconsole  secure

Modified: head/etc/etc.amd64/ttys
==
--- head/etc/etc.amd64/ttys Wed May  9 20:41:03 2018(r333435)
+++ head/etc/etc.amd64/ttys Wed May  9 20:49:00 2018(r333436)
@@ -29,15 +29,15 @@
  # when going to single-user mode.
  console   noneunknown off secure
  #
-ttyv0  "/usr/libexec/getty Pc"   xterm   on  secure
+ttyv0  "/usr/libexec/getty Pc"   xterm   onifexists secure
  # Virtual terminals
-ttyv1  "/usr/libexec/getty Pc"   xterm   on  secure
-ttyv2  "/usr/libexec/getty Pc"   xterm   on  secure
-ttyv3  "/usr/libexec/getty Pc"   xterm   on  secure
-ttyv4  "/usr/libexec/getty Pc"   xterm   on  secure
-ttyv5  "/usr/libexec/getty Pc"   xterm   on  secure
-ttyv6  "/usr/libexec/getty Pc"   xterm   on  secure
-ttyv7  "/usr/libexec/getty Pc"   xterm   on  secure
+ttyv1  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv2  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv3  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv4  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv5  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv6  "/usr/libexec/getty Pc"   xterm   onifexists secure
+ttyv7  "/usr/libexec/getty Pc"   xterm   onifexists secure
  ttyv8 "/usr/local/bin/xdm -nodaemon"xterm   off secure
  # Serial terminals
  # The 'dialup' keyword identifies dialin lines to login, fingerd etc.

Modified: head/etc/etc.arm/ttys
==
--- head/etc/etc.arm/ttys   Wed May  9 20:41:03 2018(r333435)
+++ head/etc/etc.arm/ttys   Wed May  9 20:49:00 2018(r333436)
@@ -29,15 +29,15 @@
  # when going to single-user mode.
  console   noneunknown off secure
  #
-ttyv0  "/usr/libexec/getty Pc"   xterm   onifconsole  secure
+ttyv0  "/usr/libexec/getty Pc"   xterm   onifexists secure
  # Virtual terminals
-ttyv1  "/usr/libexec/getty Pc"   xterm   off  secure
-ttyv2  "/usr/libexec/getty Pc"   xte

svn commit: r349121 - head/sys/powerpc/ofw

2019-06-16 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Jun 16 21:56:45 2019
New Revision: 349121
URL: https://svnweb.freebsd.org/changeset/base/349121

Log:
  Fix bug on newbus device deletion: we should delete the child's devinfo
  on deletion, not the parent's.
  
  MFC after:3 weeks

Modified:
  head/sys/powerpc/ofw/ofw_pcibus.c

Modified: head/sys/powerpc/ofw/ofw_pcibus.c
==
--- head/sys/powerpc/ofw/ofw_pcibus.c   Sun Jun 16 20:01:45 2019
(r349120)
+++ head/sys/powerpc/ofw/ofw_pcibus.c   Sun Jun 16 21:56:45 2019
(r349121)
@@ -294,7 +294,7 @@ ofw_pcibus_child_deleted(device_t dev, device_t child)
 {
struct ofw_pcibus_devinfo *dinfo;
 
-   dinfo = device_get_ivars(dev);
+   dinfo = device_get_ivars(child);
ofw_bus_gen_destroy_devinfo(&dinfo->opd_obdinfo);
pci_child_deleted(dev, child);
 }
___
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: r364379 - head/sys/dev/usb/controller

2020-08-20 Thread Nathan Whitehorn
Either this or r364347 has broken Yubikeys (at least Yubikey 4) plugged
into XHCI ports, which are completely invisible to the USB stack after
the change. I'm going to try to debug further, but wanted to give you a
heads-up in case you can get there first.
-Nathan

On 2020-08-19 07:50, Hans Petter Selasky wrote:
> Author: hselasky
> Date: Wed Aug 19 11:50:12 2020
> New Revision: 364379
> URL: https://svnweb.freebsd.org/changeset/base/364379
>
> Log:
>   Avoid evaluating the XHCI control endpoint context.
>   
>   The XHCI specification says that the XHCI controller should detect
>   reception of the USB device descriptors, and automatically update
>   the max packet size in the control endpoint context.
>   
>   Differential Revision:  https://reviews.freebsd.org/D26104
>   Reviewed by:kp@
>   MFC after:  1 week
>   Sponsored by:   Mellanox Technologies
>
> Modified:
>   head/sys/dev/usb/controller/xhci.c
>   head/sys/dev/usb/controller/xhci.h
>
> Modified: head/sys/dev/usb/controller/xhci.c
> ==
> --- head/sys/dev/usb/controller/xhci.cWed Aug 19 10:40:02 2020
> (r364378)
> +++ head/sys/dev/usb/controller/xhci.cWed Aug 19 11:50:12 2020
> (r364379)
> @@ -2398,8 +2398,6 @@ xhci_configure_endpoint(struct usb_device *udev,
>  
>   /* store endpoint mode */
>   pepext->trb_ep_mode = ep_mode;
> - /* store bMaxPacketSize for control endpoints */
> - pepext->trb_ep_maxp = edesc->wMaxPacketSize[0];
>   usb_pc_cpu_flush(pepext->page_cache);
>  
>   if (ep_mode == USB_EP_MODE_STREAMS) {
> @@ -2929,17 +2927,6 @@ xhci_transfer_insert(struct usb_xfer *xfer)
>   return (USB_ERR_NOMEM);
>   }
>  
> - /* check if bMaxPacketSize changed */
> - if (xfer->flags_int.control_xfr != 0 &&
> - pepext->trb_ep_maxp != xfer->endpoint->edesc->wMaxPacketSize[0]) {
> -
> - DPRINTFN(8, "Reconfigure control endpoint\n");
> -
> - /* force driver to reconfigure endpoint */
> - pepext->trb_halted = 1;
> - pepext->trb_running = 0;
> - }
> -
>   /* check for stopped condition, after putting transfer on interrupt 
> queue */
>   if (pepext->trb_running == 0) {
>   struct xhci_softc *sc = XHCI_BUS2SC(xfer->xroot->bus);
> @@ -3917,8 +3904,10 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer)
>   if (!(sc->sc_hw.devs[index].ep_configured & mask)) {
>   sc->sc_hw.devs[index].ep_configured |= mask;
>   err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index);
> - } else {
> + } else if (epno != 1) {
>   err = xhci_cmd_evaluate_ctx(sc, buf_inp.physaddr, index);
> + } else {
> + err = 0;
>   }
>  
>   if (err != 0) {
>
> Modified: head/sys/dev/usb/controller/xhci.h
> ==
> --- head/sys/dev/usb/controller/xhci.hWed Aug 19 10:40:02 2020
> (r364378)
> +++ head/sys/dev/usb/controller/xhci.hWed Aug 19 11:50:12 2020
> (r364379)
> @@ -393,7 +393,6 @@ struct xhci_endpoint_ext {
>   uint8_t trb_halted;
>   uint8_t trb_running;
>   uint8_t trb_ep_mode;
> - uint8_t trb_ep_maxp;
>  };
>  
>  enum {
>

___
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: r364379 - head/sys/dev/usb/controller

2020-08-20 Thread Nathan Whitehorn



On 2020-08-20 13:47, Hans Petter Selasky wrote:
> On 2020-08-20 18:21, Hans Petter Selasky wrote:
>> On 2020-08-20 18:14, Hans Petter Selasky wrote:
>>> On 2020-08-20 17:51, Nathan Whitehorn wrote:
>>>> Either this or r364347 has broken Yubikeys (at least Yubikey 4)
>>>> plugged
>>>> into XHCI ports, which are completely invisible to the USB stack after
>>>> the change. I'm going to try to debug further, but wanted to give
>>>> you a
>>>> heads-up in case you can get there first.
>>>> -Nathan
>>>>
>>>
>>> Let me know if you can isolate the commit. There has been two
>>> commits recently in the XHCI code.
>>
>> I'm on it. Let me run some test here.
>>
>
> See:
> https://svnweb.freebsd.org/changeset/base/364433
>
> Thanks to Ed Maste who quickly tested my patch.
>
> --HPS
>

That was incredibly fast! Everything works fine again. Thanks much!
-Nathan
___
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: r366723 - head/sys/dev/iicbus

2020-10-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Oct 15 13:43:43 2020
New Revision: 366723
URL: https://svnweb.freebsd.org/changeset/base/366723

Log:
  Provide a slightly more-tolerant set of thermal parameters for PowerMac
  motherboard temperatures. In particular, the U4 northbridge die is very
  hard to cool or heat effectively with fans and is not responsive to load.
  It generally sits around 64C, where it seems happy, so (like Linux) just
  declare that to be its target temperature.
  
  This makes the PowerMac G5 much less loud, with no change in the
  temperatures of any system components.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/iicbus/max6690.c

Modified: head/sys/dev/iicbus/max6690.c
==
--- head/sys/dev/iicbus/max6690.c   Thu Oct 15 12:48:30 2020
(r366722)
+++ head/sys/dev/iicbus/max6690.c   Thu Oct 15 13:43:43 2020
(r366723)
@@ -213,8 +213,17 @@ max6690_fill_sensor_prop(device_t dev)
for (j = 0; j < i; j++) {
sc->sc_sensors[j].dev = dev;
 
-   sc->sc_sensors[j].therm.target_temp = 400 + ZERO_C_TO_K;
-   sc->sc_sensors[j].therm.max_temp = 800 + ZERO_C_TO_K;
+   /*
+* Target value for "KODIAK DIODE" (= northbridge die) should
+* be 64C (value from Linux). It operates fine at that
+* temperature and has limited responsivity to the fan aimed at
+* it, so no point in trying to cool it to 40C.
+*/
+   if (strcmp(sc->sc_sensors[j].therm.name, "KODIAK DIODE") == 0)
+   sc->sc_sensors[j].therm.target_temp = 640 + ZERO_C_TO_K;
+   else
+   sc->sc_sensors[j].therm.target_temp = 400 + ZERO_C_TO_K;
+   sc->sc_sensors[j].therm.max_temp = 850 + ZERO_C_TO_K;
 
sc->sc_sensors[j].therm.read =
(int (*)(struct pmac_therm *))(max6690_sensor_read);
___
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: r368718 - head/sys/modules/if_wg

2020-12-17 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Dec 17 14:20:36 2020
New Revision: 368718
URL: https://svnweb.freebsd.org/changeset/base/368718

Log:
  Make non-debug kernels installable.
  
  Setting DEBUG_FLAGS results in make installkernel trying to install debug
  information that doesn't exist if the kernel was built without it.

Modified:
  head/sys/modules/if_wg/Makefile

Modified: head/sys/modules/if_wg/Makefile
==
--- head/sys/modules/if_wg/Makefile Thu Dec 17 13:17:26 2020
(r368717)
+++ head/sys/modules/if_wg/Makefile Thu Dec 17 14:20:36 2020
(r368718)
@@ -15,8 +15,6 @@ CFLAGS+= -I${INCDIR}
 
 CFLAGS+= -D__KERNEL__
 
-DEBUG_FLAGS=-g
-
 SRCS= opt_inet.h opt_inet6.h device_if.h bus_if.h ifdi_if.h
 
 SRCS+= if_wg_session.c module.c
___
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: r356758 - in head/usr.sbin/bsdinstall: . scripts

2020-01-15 Thread Nathan Whitehorn
I agree -- this seems like a really big change, especially with no
discussion.
-Nathan

On 2020-01-15 10:57, Oliver Pinter wrote:
>
>
> On Wednesday, January 15, 2020, Ben Woods  > wrote:
>
> Author: woodsb02 (ports committer)
> Date: Wed Jan 15 07:47:52 2020
> New Revision: 356758
> URL: https://svnweb.freebsd.org/changeset/base/356758
> 
>
> Log:
>   bsdinstall: Change "default" (first) Partitioning method to ZFS
>
>   Reported by:  Ruben Schade (during his talk at linux.conf.au
> )
>   Approved by:  philip
>   Differential Revision:        https://reviews.freebsd.org/D23173
> 
>
>
> What's the justification behind this change? 
> Plus I miss from here the relontes tag. 
>
>  
>
>
> Modified:
>   head/usr.sbin/bsdinstall/bsdinstall.8
>   head/usr.sbin/bsdinstall/scripts/auto
>
> Modified: head/usr.sbin/bsdinstall/bsdinstall.8
> 
> ==
> --- head/usr.sbin/bsdinstall/bsdinstall.8       Wed Jan 15
> 06:18:32 2020        (r356757)
> +++ head/usr.sbin/bsdinstall/bsdinstall.8       Wed Jan 15
> 07:47:52 2020        (r356758)
> @@ -119,7 +119,7 @@ Provides the installer's interactive guided
> disk parti
>  installations.
>  Defaults to UFS.
>  .It Cm zfsboot
> -Provides an alternative ZFS-only automatic interactive disk
> partitioner.
> +Provides a ZFS-only automatic interactive disk partitioner.
>  Creates a single
>  .Ic zpool
>  with separate datasets for
>
> Modified: head/usr.sbin/bsdinstall/scripts/auto
> 
> ==
> --- head/usr.sbin/bsdinstall/scripts/auto       Wed Jan 15
> 06:18:32 2020        (r356757)
> +++ head/usr.sbin/bsdinstall/scripts/auto       Wed Jan 15
> 07:47:52 2020        (r356758)
> @@ -289,7 +289,7 @@ Shell \"Open a shell and partition by hand\""
>  CURARCH=$( uname -m )
>  case $CURARCH in
>         amd64|arm64|i386)       # Booting ZFS Supported
> -               PMODES="$PMODES \"Auto (ZFS)\" \"Guided Root-on-ZFS\""
> +               PMODES="\"Auto (ZFS)\" \"Guided Root-on-ZFS\" $PMODES"
>                 ;;
>         *)              # Booting ZFS Unspported
>                 ;;
> @@ -303,6 +303,10 @@ PARTMODE=`echo $PMODES | xargs dialog
> --backtitle "Fre
>  exec 3>&-
>
>  case "$PARTMODE" in
> +"Auto (ZFS)")  # ZFS
> +       bsdinstall zfsboot || error "ZFS setup failed"
> +       bsdinstall mount || error "Failed to mount filesystem"
> +       ;;
>  "Auto (UFS)")  # Guided
>         bsdinstall autopart || error "Partitioning error"
>         bsdinstall mount || error "Failed to mount filesystem"
> @@ -319,10 +323,6 @@ case "$PARTMODE" in
>         else
>                 bsdinstall partedit || error "Partitioning error"
>         fi
> -       bsdinstall mount || error "Failed to mount filesystem"
> -       ;;
> -"Auto (ZFS)")  # ZFS
> -       bsdinstall zfsboot || error "ZFS setup failed"
>         bsdinstall mount || error "Failed to mount filesystem"
>         ;;
>  *)
> ___
> 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-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: r324732 - head/usr.sbin/jail

2017-10-18 Thread Nathan Whitehorn
Is this even true? Don't you want to run bsdconfig? We split that 
functionality out from the installer when sysinstall was replaced.

-Nathan

On 10/18/17 15:56, Benjamin Kaduk wrote:

Author: bjk (doc committer)
Date: Wed Oct 18 22:56:46 2017
New Revision: 324732
URL: https://svnweb.freebsd.org/changeset/base/324732

Log:
   Adopt jail.8 to our brave new bsdinstall world
   
   Submitted by:	Steve Kargl

   MFC after:   3 days

Modified:
   head/usr.sbin/jail/jail.8

Modified: head/usr.sbin/jail/jail.8
==
--- head/usr.sbin/jail/jail.8   Wed Oct 18 22:00:44 2017(r324731)
+++ head/usr.sbin/jail/jail.8   Wed Oct 18 22:56:46 2017(r324732)
@@ -1006,7 +1006,7 @@ jail -c path=/data/jail/testjail mount.devfs \\
  .Pp
  Assuming no errors, you will end up with a shell prompt within the jail.
  You can now run
-.Pa /usr/sbin/sysinstall
+.Pa /usr/sbin/bsdinstall
  and do the post-install configuration to set various configuration options,
  or perform these actions manually by editing
  .Pa /etc/rc.conf ,



___
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: r325688 - head/sys/boot/powerpc/ps3

2017-11-10 Thread Nathan Whitehorn
The PS3 port *does* support FDT, though not through this loader. On a 
related note, I'm planning to just svn rm loader.ps3 in the next few weeks.

-Nathan

On 11/10/17 15:54, Warner Losh wrote:

Author: imp
Date: Fri Nov 10 23:54:18 2017
New Revision: 325688
URL: https://svnweb.freebsd.org/changeset/base/325688

Log:
   FDT support doesn't make sense for ps3. There's no support in the ps3
   port for FDT, and it's unlikely to grow support for that anytime soon.
   When it does, support can be added back easily enough.
   
   Supported by: Netflix


Modified:
   head/sys/boot/powerpc/ps3/Makefile

Modified: head/sys/boot/powerpc/ps3/Makefile
==
--- head/sys/boot/powerpc/ps3/Makefile  Fri Nov 10 23:54:13 2017
(r325687)
+++ head/sys/boot/powerpc/ps3/Makefile  Fri Nov 10 23:54:18 2017
(r325688)
@@ -7,7 +7,6 @@ LOADER_NET_SUPPORT?=yes
  LOADER_NFS_SUPPORT?=  yes
  LOADER_TFTP_SUPPORT?= no
  LOADER_GZIP_SUPPORT?= yes
-LOADER_FDT_SUPPORT?=   no
  LOADER_BZIP2_SUPPORT?=no
  
  .include 

@@ -24,12 +23,6 @@ SRCS+=   lv1call.S ps3cons.c font.h ps3mmu.c 
ps3net.c p
ps3stor.c ps3disk.c ps3cdrom.c
  SRCS+=ucmpdi2.c
  
-.if ${LOADER_FDT_SUPPORT} == "yes"

-CFLAGS+=   -I${FDTSRC}
-CFLAGS+=   -DLOADER_FDT_SUPPORT
-LIBFDT=${BOOTOBJ}/fdt/libfdt.a
-.endif
-
  CFLAGS+=  -mcpu=powerpc64
  
  # Always add MI sources

@@ -55,7 +48,7 @@ SC_DFLT_FONT=cp437
  font.h:
uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < 
${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char 
dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt 
&& file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h
  
-loader.help: help.common ${FDTSRC}/help.fdt

+loader.help: help.common
cat ${.ALLSRC} | \
awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
  



___
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: r326171 - in head/sys: arm/xscale/ixp425 contrib/dev/npe

2017-11-24 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 24 15:48:17 2017
New Revision: 326171
URL: https://svnweb.freebsd.org/changeset/base/326171

Log:
  Switch the default firmware for npe(4) from the QOS_VLAN one to the
  plain-vanilla ETH microcode. The QOS_VLAN firmware added support in microcode
  for handling IEEE 802.1q tags, but the npe(4) driver did not actually
  support the relevant signalling. As a result, it was impossible to use
  VLANs with npe(4). Switching to the more basic microcode (same license)
  removes the on-NIC promisisng and makes vlan(4) work on both NPE interfaces.
  
  Ref: https://lists.freebsd.org/pipermail/freebsd-arm/2012-August/003826.html

Modified:
  head/sys/arm/xscale/ixp425/ixp425_npevar.h
  head/sys/contrib/dev/npe/IxNpeMicrocode.dat.uu

Modified: head/sys/arm/xscale/ixp425/ixp425_npevar.h
==
--- head/sys/arm/xscale/ixp425/ixp425_npevar.h  Fri Nov 24 14:52:27 2017
(r326170)
+++ head/sys/arm/xscale/ixp425/ixp425_npevar.h  Fri Nov 24 15:48:17 2017
(r326171)
@@ -102,8 +102,8 @@
 #defineNPE_MAX (NPE_C+1)
 
 #defineIXP425_NPE_A_IMAGEID0x10820200
-#defineIXP425_NPE_B_IMAGEID0x01020201
-#defineIXP425_NPE_C_IMAGEID0x02050201
+#defineIXP425_NPE_B_IMAGEID0x01000201
+#defineIXP425_NPE_C_IMAGEID0x02000201
 
 struct ixpnpe_softc;
 struct ixpnpe_softc *ixpnpe_attach(device_t, int npeid);

Modified: head/sys/contrib/dev/npe/IxNpeMicrocode.dat.uu
==
--- head/sys/contrib/dev/npe/IxNpeMicrocode.dat.uu  Fri Nov 24 14:52:27 
2017(r326170)
+++ head/sys/contrib/dev/npe/IxNpeMicrocode.dat.uu  Fri Nov 24 15:48:17 
2017(r326171)
@@ -1,170 +1,127 @@
 begin 644 IxNpeMicrocode.dat
-M_NWP#1""`@])``\!```'1`$```[-`0``#MT`
-M```!```.]0$```]"`0``#T4/!S,0`'X0$`#\\!``
-M=*`03KX!!:C\@```^=```';P$`!T`!`"O@$0`H@0$`*"`A`"__X`6(```%B"
-M```ZQ?L0``0`$``$$A``18P0`$2'$`*\`A`"__D0`L7T$`+%\Q`"Q?(&,O_Q
-M"6R*(`^0P!`/J$`0$`*^`!!$``L!U,```$V'"``MAP0`-8<$`!F'!``AAP0`
-M48<$`%V'!!!$?G`!V,``$`&+$1`!DQ$0`9L1!02*4`4H$(`%.!*0!404H`5`
-M%K`%;!C`!6@:T!``?A(0`OWU$$@`"PP`P``$`,0`"0R"$`DH2$`0`KX!"01W
-M0!`#/@$)C((0":A(0!`"O@$)A'=0$`,^`1!$=/`!Y.``$`*^`1`!O=$0`;G1
-M$`$WT1`!/]$0`'02$`+]^Q``-9`0`KX!$$1^@`>$_``01KX!`?#@`!`!@]$0
-M`8O1$`&:P1!%D](`"/PA$`!^$A`"^?H02.H``@#@```(<8`0`>O/$$P`"P6H
-M_(```'X``!!V`!`#?Z$0`H+$$6*"0`$=D`0`,H'$`,V
-M!A!$``L`!'8>"37N"!``V@<0
-M`K@&$`&:"A!%R@L``'=@`#':#!"7/A8)*&B`"0VN``DER@@0`9`,$`#D``DD
-MHQ`)!)$1$`'0#!``T4`0`=`.$`&*$Q`#/U801``+``!W8!"7/@$%%(0@$`&:
-M!Q`!DB$0`8H@$``$L!""OT<%%(0@$`'*"!`!DB$0`8H@$(%4!!`!5@T0`4@%
-M$`!(`!`!T`40`9IB$`&281`!V@\0`9I@$`'2#A`!K&80`=H-$$24D!`@[`<0
-M`K9A$$1J``#`[`<0`&L>$`$H#1`!:@<0`&E&$`*X01`!I`@0`,2`$`/`X!`!
-MJB$0`:(@$`"55Q``FQT0`K94$`#$3Q``Q!H0`:HA$`&B(!``E5<0`)L=$`*V
-M31``Q$\0`,0:$`&J(1`!HB`0`)57$`";'1`"MD80`,1/$`#$&A`!JB$0`:(@
-M$`"55Q``FQT0`K8_$`#$3Q``Q!H0`:HA$`&B(!``E5<0`)L=$`*V.!``Q$\0
-M`,0:$`&J(1`!HB`0`)57$`";'1`"MC$0`,1/$`#$&A`!JB$0`:(@$`"55Q``
-MFQT0`K8J$`#$3Q``Q!H0`:HA$`&B(!``E5<0`)L=$`*V(Q``Q$\0`,0:$`&J
-M(1`!HB`0`)57$`";'1`"MAP01``+`!QI\!`!:`00`%-`$`%2!A`!$@T0```+
-M$`!3(Q`!4@P0`.P`$`'L!Q``4``0`5`)$`*^W1``4``0`5`)$`!N)A`"N`,0
-M`6P$$`+_\A`!$@80```+$`!2A!`!4@80`O_M$`&L:!`"_Y\0`%-`$`%2!A``
-M;D80`OGP$`&;8Q!$12`0(-@'$$:XQ?_\U<`0`9MA$`!$`!`!$``0`&Z&$`*V
-M!1``4!80`K@#$`!%(!``U$$0`40,$`':'Q`!$@801``+``!2C!`!4@801$0`
-M$!S9-Q!&MK`0)-EW$$:VK@#`V`<01KJH``A28!!$$'``!%'S$``2@A``4``0
-M`=`)$`':'Q`!1!L0`%'P$``1@0$`&2#A`!F@\0`)"P$`"4T!`!TAH01=P6`XCD`!``4``0`!-@$`#0
-M.A``I)$0`:K@$`&:X1``D7`0`>@1$`!K(!``E-`0`=(9$`%X($`!W0!`!!@D01$0```!'@0D'
-M/D(``-6!$`'4!Q`!XAH0`>@6$`&2!1L0`-`4$$72%@-@Y``0`%``$``3
-M8!``T#H0`*21$`&2X!`!J.(0`=(7$$7H$`.(Y``0`%``$``38!``T#H0`*21
-M$`&JX!`!FN$0`)%P$`'H$1``E-`0`5P$$`'2&1`!D@X0`9H/$`"0L!``E-`0
-M`=(<$`'<&A``:S`016H'``1W,!`#``$011`)``!IX`DH*($3":X("26V&`DE
-MMAP));X`"26^!`DEO@@));X,"26^$!`!F!H0`-P`"22:T!``4`<0`K8%$`!1
-MZA``4`D0`#"`"23:``D][@@0`'=`$`$&"1!$1$>!"0<^`1`!(`P01:@)
-M`]SEH!``A5$0`<0."2@K4`D-K@@0`$V&$):X$PDX("0<^)@DP,
-M$`%H!Q`!H@L)*&A`$`!F!!,)IB`))*,0"01W0!`#?B8#]-'`$`&B@!`!*`80
-M`.(1$`'B@!``Z@`0`8H+$`'J"Q`![`P0`6@'$`+^(1``1400`KY&$):@RP40
-MC"`0`$0`$`!!A!`!B&$0`08(!C7'1`8TDB`&-)H@$`'341`!D!\0`=M1$`!1
-M^A``$*80`KBJ$$6@`@-`T(`0`\#`$`&J@1`!HH`0`)M7$`"5/1`"MB(0`-!/
-M$$30&@-`T`(0`:J!$`&B@!``FU<0`)4]$`*V&A``T$\01-`:`T#0`A`!JH$0
-M`:*`$`";5Q``E3T0`K82$`#03Q!$T!H#0-`"$`&J@1`!HH`0`)M7$`"5/1`"
-MM@H0`-!/$$30&@-`T`(0`:J!$`&B@!``FU<0`)4]$`*V`A``8AP0`9`?$`&:
-M71``(H40`&(6$`*X?A`!E%P03``+`##8!QA`W`T``-0-$`+WO!``4A80`KA[
-M!C2:(!`!HAT0`*K0$$0;/!`@V`<0`\#`$`*V=A`!H!D0`>M1$`'@8A``U``0
-M`'#`!C7'1!`"OC`0`K9N$`!%)!`!FAP0`-1`$`'<8A`!VU$0`>M1$`!PL`8U
-MQT00`KXF$`+Y[Q`"N&,0`&?Z$``E7A``U#@0`'#0!C7'1!`!JE,0`KX,$`+Y
-MYA`"^>T0`KA9$`!%)!``9_H0`"5>$`#4`!`!VU$0`'#`!C7'1!`!JE00`=QB
-M$$6@``'\W?80`K@#$`"@]!`!X&(02*#P`@#0``'\W8,0`-WJ$`"0\1`!)H`0
-M`&)S$`!B0A``

svn commit: r326182 - in head/stand: ofw/libofw powerpc/kboot powerpc/ps3

2017-11-24 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 24 23:41:04 2017
New Revision: 326182
URL: https://svnweb.freebsd.org/changeset/base/326182

Log:
  Modify all FreeBSD bootloaders on PowerPC AIM (Book-S) systems to pass a
  magic number to the kernel in r7 rather than the (currently unused and
  irrelevant) width of the metadata pointer, which I believe was intended
  for a never-used approach to the 64-bit port. This enables the kernel,
  in a future commit, to switch on the cookie to distinguish a real
  metadata pointer from loader(8) from garbage left in r6 by some other
  boot loader.
  
  MFC after:3 weeks

Modified:
  head/stand/ofw/libofw/elf_freebsd.c
  head/stand/ofw/libofw/ppc64_elf_freebsd.c
  head/stand/powerpc/kboot/ppc64_elf_freebsd.c
  head/stand/powerpc/ps3/ppc64_elf_freebsd.c

Modified: head/stand/ofw/libofw/elf_freebsd.c
==
--- head/stand/ofw/libofw/elf_freebsd.c Fri Nov 24 19:57:13 2017
(r326181)
+++ head/stand/ofw/libofw/elf_freebsd.c Fri Nov 24 23:41:04 2017
(r326182)
@@ -91,7 +91,7 @@ __elfN(ofw_exec)(struct preloaded_file *fp)
mdp, sizeof(mdp));
} else {
OF_chain((void *)reloc, end - (char *)reloc, (void *)entry,
-   (void *)mdp, sizeof(mdp));
+   (void *)mdp, 0xfb5d104d);
}
 
panic("exec returned");

Modified: head/stand/ofw/libofw/ppc64_elf_freebsd.c
==
--- head/stand/ofw/libofw/ppc64_elf_freebsd.c   Fri Nov 24 19:57:13 2017
(r326181)
+++ head/stand/ofw/libofw/ppc64_elf_freebsd.c   Fri Nov 24 23:41:04 2017
(r326182)
@@ -93,11 +93,11 @@ ppc64_ofw_elf_exec(struct preloaded_file *fp)
 
if (dtbp != 0) {
OF_quiesce();
-   ((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, 
0, 0,
-   mdp, sizeof(mdp));
+   ((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp,
+   0, 0, mdp, 0xfb5d104d);
} else {
OF_chain((void *)reloc, end - (char *)reloc, (void *)entry,
-   (void *)mdp, sizeof(mdp));
+   (void *)mdp, 0xfb5d104d);
}
 
panic("exec returned");

Modified: head/stand/powerpc/kboot/ppc64_elf_freebsd.c
==
--- head/stand/powerpc/kboot/ppc64_elf_freebsd.cFri Nov 24 19:57:13 
2017(r326181)
+++ head/stand/powerpc/kboot/ppc64_elf_freebsd.cFri Nov 24 23:41:04 
2017(r326182)
@@ -96,7 +96,7 @@ ppc64_elf_exec(struct preloaded_file *fp)
 
trampoline[3] = dtb;
trampoline[6] = mdp;
-   trampoline[7] = sizeof(mdp);
+   trampoline[7] = 0xfb5d104d;
printf("Kernel entry at %#jx (%#x) ...\n", e->e_entry, trampoline[2]);
printf("DTB at %#x, mdp at %#x\n", dtb, mdp);
 

Modified: head/stand/powerpc/ps3/ppc64_elf_freebsd.c
==
--- head/stand/powerpc/ps3/ppc64_elf_freebsd.c  Fri Nov 24 19:57:13 2017
(r326181)
+++ head/stand/powerpc/ps3/ppc64_elf_freebsd.c  Fri Nov 24 23:41:04 2017
(r326182)
@@ -89,7 +89,7 @@ ppc64_elf_exec(struct preloaded_file *fp)
dev_cleanup();
 
entry(0 /* FDT */, 0 /* Phys. mem offset */, 0 /* OF entry */,
-(void *)mdp, sizeof(mdp));
+(void *)mdp, 0xfb5d104d);
 
panic("exec returned");
 }
___
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: r326202 - head/sys/conf

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 21:44:23 2017
New Revision: 326202
URL: https://svnweb.freebsd.org/changeset/base/326202

Log:
  Automatically use the ELFv2 ABI on powerpc64 if supported by the compiler.
  This has the same effects on DDB working as -mcall=aixdesc, but also is
  supported by clang and marginally improves kernel performance.
  
  MFC after:2 weeks

Modified:
  head/sys/conf/kern.mk

Modified: head/sys/conf/kern.mk
==
--- head/sys/conf/kern.mk   Sat Nov 25 21:29:07 2017(r326201)
+++ head/sys/conf/kern.mk   Sat Nov 25 21:44:23 2017(r326202)
@@ -172,10 +172,16 @@ CFLAGS.gcc+=  -mno-spe
 .endif
 
 #
-# Use dot symbols on powerpc64 to make ddb happy
+# Use dot symbols (or, better, the V2 ELF ABI) on powerpc64 to make
+# DDB happy. ELFv2, if available, has some other efficiency benefits.
 #
 .if ${MACHINE_ARCH} == "powerpc64"
+.if ${COMPILER_VERSION} >= 40900
+CFLAGS.gcc+=   -mabi=elfv2
+.else
 CFLAGS.gcc+=   -mcall-aixdesc
+.endif
+CFLAGS.clang+= -mabi=elfv2
 .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: r326203 - head/sys/conf

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 21:45:51 2017
New Revision: 326203
URL: https://svnweb.freebsd.org/changeset/base/326203

Log:
  Avoid emitting a PT_INTERP section for powerpc64 kernels and arrange for
  the first instruction to be at the start of the text segment. This allows
  the kernel to be booted correctly by stock kexec-lite.
  
  MFC after:2 weeks

Modified:
  head/sys/conf/ldscript.powerpc64

Modified: head/sys/conf/ldscript.powerpc64
==
--- head/sys/conf/ldscript.powerpc64Sat Nov 25 21:44:23 2017
(r326202)
+++ head/sys/conf/ldscript.powerpc64Sat Nov 25 21:45:51 2017
(r326203)
@@ -10,7 +10,7 @@ SECTIONS
 {
   /* Read-only sections, merged into text segment: */
 
-  . = kernbase + SIZEOF_HEADERS;
+  . = kernbase;
   PROVIDE (begin = . - SIZEOF_HEADERS);
 
   .text  :
@@ -24,7 +24,10 @@ SECTIONS
   _etext = .;
   PROVIDE (etext = .);
 
-  .interp : { *(.interp)   }
+  /* Do not emit PT_INTERP section, which confuses some loaders (kexec-lite) */
+  .interpX: { *(.interp)   } : NONE
+  /DISCARD/   : { *(.interp)   } 
+
   .hash  : { *(.hash)  }
   .dynsym: { *(.dynsym)}
   .dynstr: { *(.dynstr)}
___
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: r326204 - head/sys/dev/ofw

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 21:46:51 2017
New Revision: 326204
URL: https://svnweb.freebsd.org/changeset/base/326204

Log:
  Do not bind to CPUs with SMT, which use a different CPU numbering convention
  that does not play well with this driver.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/ofw/ofw_cpu.c

Modified: head/sys/dev/ofw/ofw_cpu.c
==
--- head/sys/dev/ofw/ofw_cpu.c  Sat Nov 25 21:45:51 2017(r326203)
+++ head/sys/dev/ofw/ofw_cpu.c  Sat Nov 25 21:46:51 2017(r326204)
@@ -191,6 +191,10 @@ ofw_cpu_probe(device_t dev)
if (type == NULL || strcmp(type, "cpu") != 0)
return (ENXIO);
 
+   /* Skip SMT CPUs, which we can't reasonably represent with this code */
+   if (OF_hasprop(ofw_bus_get_node(dev), "ibm,ppc-interrupt-server#s"))
+   return (ENXIO);
+
device_set_desc(dev, "Open Firmware CPU");
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: r326205 - in head/sys/powerpc: aim include mpc85xx powermac powerpc

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 21:59:59 2017
New Revision: 326205
URL: https://svnweb.freebsd.org/changeset/base/326205

Log:
  Whether you can use mttb() or not is more complicated than whether PSL_HV
  is set and the right thing to do may be platform-dependent (it requires
  firmware on PowerNV, for instance). Make it a new platform method called
  platform_smp_timebase_sync().
  
  MFC after:3 weeks

Modified:
  head/sys/powerpc/aim/mp_cpudep.c
  head/sys/powerpc/include/platform.h
  head/sys/powerpc/mpc85xx/platform_mpc85xx.c
  head/sys/powerpc/powermac/platform_powermac.c
  head/sys/powerpc/powerpc/mp_machdep.c
  head/sys/powerpc/powerpc/platform.c
  head/sys/powerpc/powerpc/platform_if.m

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cSat Nov 25 21:46:51 2017
(r326204)
+++ head/sys/powerpc/aim/mp_cpudep.cSat Nov 25 21:59:59 2017
(r326205)
@@ -281,13 +281,8 @@ cpudep_ap_setup()
vers = mfpvr() >> 16;
 
/* The following is needed for restoring from sleep. */
-#ifdef __powerpc64__
-   /* Writing to the time base register is hypervisor-privileged */
-   if (mfmsr() & PSL_HV)
-   mttb(0);
-#else
-   mttb(0);
-#endif
+   platform_smp_timebase_sync(0, 1);
+
switch(vers) {
case IBM970:
case IBM970FX:

Modified: head/sys/powerpc/include/platform.h
==
--- head/sys/powerpc/include/platform.h Sat Nov 25 21:46:51 2017
(r326204)
+++ head/sys/powerpc/include/platform.h Sat Nov 25 21:59:59 2017
(r326205)
@@ -45,6 +45,8 @@ struct mem_region {
uint64_tmr_size;
 };
 
+/* Documentation for these functions is in platform_if.m */
+
 void   mem_regions(struct mem_region **, int *, struct mem_region **, int *);
 vm_offset_t platform_real_maxaddr(void);
 
@@ -54,6 +56,7 @@ int   platform_smp_first_cpu(struct cpuref *);
 intplatform_smp_next_cpu(struct cpuref *);
 intplatform_smp_get_bsp(struct cpuref *);
 intplatform_smp_start_cpu(struct pcpu *);
+void   platform_smp_timebase_sync(u_long tb, int ap);
 void   platform_smp_ap_init(void);
   
 const char *installed_platform(void);

Modified: head/sys/powerpc/mpc85xx/platform_mpc85xx.c
==
--- head/sys/powerpc/mpc85xx/platform_mpc85xx.c Sat Nov 25 21:46:51 2017
(r326204)
+++ head/sys/powerpc/mpc85xx/platform_mpc85xx.c Sat Nov 25 21:59:59 2017
(r326205)
@@ -92,6 +92,7 @@ static int mpc85xx_smp_first_cpu(platform_t, struct cp
 static int mpc85xx_smp_next_cpu(platform_t, struct cpuref *cpuref);
 static int mpc85xx_smp_get_bsp(platform_t, struct cpuref *cpuref);
 static int mpc85xx_smp_start_cpu(platform_t, struct pcpu *cpu);
+static void mpc85xx_smp_timebase_sync(platform_t, u_long tb, int ap);
 static void mpc85xx_idle(platform_t, int cpu);
 static int mpc85xx_idle_wakeup(platform_t plat, int cpu);
 
@@ -107,6 +108,7 @@ static platform_method_t mpc85xx_methods[] = {
PLATFORMMETHOD(platform_smp_next_cpu,   mpc85xx_smp_next_cpu),
PLATFORMMETHOD(platform_smp_get_bsp,mpc85xx_smp_get_bsp),
PLATFORMMETHOD(platform_smp_start_cpu,  mpc85xx_smp_start_cpu),
+   PLATFORMMETHOD(platform_smp_timebase_sync, mpc85xx_smp_timebase_sync),
 
PLATFORMMETHOD(platform_reset,  mpc85xx_reset),
PLATFORMMETHOD(platform_idle,   mpc85xx_idle),
@@ -526,6 +528,13 @@ mpc85xx_reset(platform_t plat)
printf("Reset failed...\n");
while (1)
;
+}
+
+static void
+mpc85xx_smp_timebase_sync(platform_t plat, u_long tb, int ap)
+{
+
+   mttb(tb);
 }
 
 static void

Modified: head/sys/powerpc/powermac/platform_powermac.c
==
--- head/sys/powerpc/powermac/platform_powermac.c   Sat Nov 25 21:46:51 
2017(r326204)
+++ head/sys/powerpc/powermac/platform_powermac.c   Sat Nov 25 21:59:59 
2017(r326205)
@@ -64,6 +64,7 @@ static int powermac_smp_first_cpu(platform_t, struct c
 static int powermac_smp_next_cpu(platform_t, struct cpuref *cpuref);
 static int powermac_smp_get_bsp(platform_t, struct cpuref *cpuref);
 static int powermac_smp_start_cpu(platform_t, struct pcpu *cpu);
+static void powermac_smp_timebase_sync(platform_t, u_long tb, int ap);
 static void powermac_reset(platform_t);
 static void powermac_sleep(platform_t);
 
@@ -77,6 +78,7 @@ static platform_method_t powermac_methods[] = {
PLATFORMMETHOD(platform_smp_next_cpu,   powermac_smp_next_cpu),
PLATFORMMETHOD(platform_smp_get_bsp,powermac_smp_get_bsp),
PLATFORMMETHOD(platform_smp_start_cpu,  powermac_smp_start_cpu),
+   PLATFORMMETHOD(platform_smp_timebase_sync, powermac_smp_timebase_sync),
 
PLATFORMMETHOD(platform_rese

svn commit: r326206 - head/sys/powerpc/powerpc

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 22:01:55 2017
New Revision: 326206
URL: https://svnweb.freebsd.org/changeset/base/326206

Log:
  Yield while spinning on APs and avoid announcing all CPUs unless bootverbose
  is set. These improve startup performance on massively multithreaded systems
  with 8-way SMT and dozens to hundreds of CPUs.
  
  MFC after:3 weeks

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

Modified: head/sys/powerpc/powerpc/mp_machdep.c
==
--- head/sys/powerpc/powerpc/mp_machdep.c   Sat Nov 25 21:59:59 2017
(r326205)
+++ head/sys/powerpc/powerpc/mp_machdep.c   Sat Nov 25 22:01:55 2017
(r326206)
@@ -78,7 +78,8 @@ machdep_ap_bootstrap(void)
__asm __volatile("msync; isync");
 
while (ap_letgo == 0)
-   ;
+   __asm __volatile("or 27,27,27");
+   __asm __volatile("or 6,6,6");
 
/* Initialize DEC and TB, sync with the BSP values */
platform_smp_timebase_sync(ap_timebase, 1);
@@ -176,6 +177,9 @@ cpu_mp_announce(void)
 {
struct pcpu *pc;
int i;
+
+   if (!bootverbose)
+   return;
 
CPU_FOREACH(i) {
pc = pcpu_find(i);
___
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: r326207 - head/sys/powerpc/aim

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 22:03:25 2017
New Revision: 326207
URL: https://svnweb.freebsd.org/changeset/base/326207

Log:
  Preserve the LPCR on new-ish (POWER7 and POWER8) CPUs, preventing exceptions
  and such from ending on the wrong CPU on SMP systems. It would be good to
  have this be more generic somehow as POWER9s appear, but PPC does not
  have features bits, unfortunately.
  
  MFC after:3 weeks

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

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cSat Nov 25 22:01:55 2017
(r326206)
+++ head/sys/powerpc/aim/mp_cpudep.cSat Nov 25 22:03:25 2017
(r326207)
@@ -374,6 +374,13 @@ cpudep_ap_setup()
reg = mpc74xx_l1i_enable();
 
break;
+   case IBMPOWER7:
+   case IBMPOWER7PLUS:
+   case IBMPOWER8:
+   case IBMPOWER8E:
+   if (mfmsr() & PSL_HV)
+   mtspr(SPR_LPCR, mfspr(SPR_LPCR) | LPCR_LPES);
+   break;
default:
 #ifdef __powerpc64__
if (!(mfmsr() & PSL_HV)) /* Rely on HV to have set things up */
___
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: r326208 - head/sys/powerpc/aim

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 22:05:05 2017
New Revision: 326208
URL: https://svnweb.freebsd.org/changeset/base/326208

Log:
  Make n_slbs public in a more straightforward way. Some platforms (like
  PowerNV) use firmware-assisted mechanisms to discover it and need access
  to the variable.
  
  MFC after:3 weeks

Modified:
  head/sys/powerpc/aim/aim_machdep.c
  head/sys/powerpc/aim/mmu_oea64.h

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Sat Nov 25 22:03:25 2017
(r326207)
+++ head/sys/powerpc/aim/aim_machdep.c  Sat Nov 25 22:05:05 2017
(r326208)
@@ -130,7 +130,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #ifdef __powerpc64__
-extern int n_slbs;
+#include "mmu_oea64.h"
 #endif
 
 #ifndef __powerpc64__

Modified: head/sys/powerpc/aim/mmu_oea64.h
==
--- head/sys/powerpc/aim/mmu_oea64.hSat Nov 25 22:03:25 2017
(r326207)
+++ head/sys/powerpc/aim/mmu_oea64.hSat Nov 25 22:05:05 2017
(r326208)
@@ -81,6 +81,7 @@ extern intmoea64_large_page_shift;
 extern uint64_tmoea64_large_page_size;
 extern u_int   moea64_pteg_count;
 extern u_int   moea64_pteg_mask;
+extern int n_slbs;
 
 #endif /* _POWERPC_AIM_MMU_OEA64_H */
 
___
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: r326209 - head/sys/powerpc/aim

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 22:06:40 2017
New Revision: 326209
URL: https://svnweb.freebsd.org/changeset/base/326209

Log:
  Missed platform_smp_timebase_sync() in r326205.
  
  MFC after:3 weeks
  X-MFC-With:   r326205

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

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Sat Nov 25 22:05:05 2017
(r326208)
+++ head/sys/powerpc/aim/aim_machdep.c  Sat Nov 25 22:06:40 2017
(r326209)
@@ -595,7 +595,7 @@ cpu_sleep()
while (1)
mtmsr(msr);
}
-   mttb(timebase);
+   platform_smp_timebase_sync(timebase, 0);
PCPU_SET(curthread, curthread);
PCPU_SET(curpcb, curthread->td_pcb);
pmap_activate(curthread);
___
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: r326210 - head/sys/powerpc/include

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 22:08:40 2017
New Revision: 326210
URL: https://svnweb.freebsd.org/changeset/base/326210

Log:
  Definitions for registers and trap types found on new POWER CPUs.
  
  MFC after:3 weeks

Modified:
  head/sys/powerpc/include/spr.h
  head/sys/powerpc/include/trap.h

Modified: head/sys/powerpc/include/spr.h
==
--- head/sys/powerpc/include/spr.h  Sat Nov 25 22:06:40 2017
(r326209)
+++ head/sys/powerpc/include/spr.h  Sat Nov 25 22:08:40 2017
(r326210)
@@ -210,6 +210,11 @@
 #define  EPCR_DMIUH  0x0040
 #define  EPCR_PMGS   0x0020
 #defineSPR_SPEFSCR 0x200   /* ..8 Signal Processing Engine 
FSCR. */
+
+#defineSPR_LPCR0x13e   /* Logical Partitioning Control 
*/
+#define  LPCR_LPES 0x008   /* Bit 60 */
+#defineSPR_LPID0x13f   /* Logical Partitioning Control 
*/
+
 #defineSPR_IBAT0U  0x210   /* .68 Instruction BAT Reg 0 
Upper */
 #defineSPR_IBAT0U  0x210   /* .6. Instruction BAT Reg 0 
Upper */
 #defineSPR_IBAT0L  0x211   /* .6. Instruction BAT Reg 0 
Lower */

Modified: head/sys/powerpc/include/trap.h
==
--- head/sys/powerpc/include/trap.h Sat Nov 25 22:06:40 2017
(r326209)
+++ head/sys/powerpc/include/trap.h Sat Nov 25 22:08:40 2017
(r326210)
@@ -77,6 +77,7 @@
 #defineEXC_DSMISS  0x1200  /* Data store translation miss 
*/
 
 /* Power ISA 2.06+: */
+#defineEXC_HEA 0x0e40  /* Hypervisor Emulation 
Assistance */
 #defineEXC_VSX 0x0f40  /* VSX Unavailable */
 
 /* The following are available on 4xx and 85xx */
___
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: r326211 - head/sys/powerpc/aim

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 22:10:10 2017
New Revision: 326211
URL: https://svnweb.freebsd.org/changeset/base/326211

Log:
  Invalidate TLB at boot using the correct IS settings on newer-than-POWER5
  CPUs.
  
  MFC after:3 weeks

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

Modified: head/sys/powerpc/aim/moea64_native.c
==
--- head/sys/powerpc/aim/moea64_native.cSat Nov 25 22:08:40 2017
(r326210)
+++ head/sys/powerpc/aim/moea64_native.cSat Nov 25 22:10:10 2017
(r326211)
@@ -382,7 +382,7 @@ moea64_cpu_bootstrap_native(mmu_t mmup, int ap)
__asm __volatile ("slbmfee %0,%1; slbie %0;" : "=r"(seg0) :
"r"(0));
 
-   for (i = 0; i < 64; i++) {
+   for (i = 0; i < n_slbs; i++) {
if (!(slb[i].slbe & SLBE_VALID))
continue;
 
@@ -465,9 +465,23 @@ tlbia(void)
register_t msr, scratch;
#endif
 
+   i = 0xc00; /* IS = 11 */
+   switch (mfpvr() >> 16) {
+   case IBM970:
+   case IBM970FX:
+   case IBM970MP:
+   case IBM970GX:
+   case IBMPOWER4:
+   case IBMPOWER4PLUS:
+   case IBMPOWER5:
+   case IBMPOWER5PLUS:
+   i = 0; /* IS not supported */
+   break;
+   }
+
TLBSYNC();
 
-   for (i = 0; i < 0xFF000; i += 0x1000) {
+   for (; i < 0x20; i += 0x1000) {
#ifdef __powerpc64__
__asm __volatile("tlbiel %0" :: "r"(i));
#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: r326212 - head/sys/powerpc/aim

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 22:13:19 2017
New Revision: 326212
URL: https://svnweb.freebsd.org/changeset/base/326212

Log:
  Allow platform modules to set the size of large pizes, as potentially
  discovered from firmware, and better handle highly-discontiguous memory
  and CPU maps.
  
  MFC after:3 weeks

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

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cSat Nov 25 22:10:10 2017
(r326211)
+++ head/sys/powerpc/aim/mmu_oea64.cSat Nov 25 22:13:19 2017
(r326212)
@@ -572,8 +572,10 @@ moea64_probe_large_page(void)

/* FALLTHROUGH */
default:
-   moea64_large_page_size = 0x100; /* 16 MB */
-   moea64_large_page_shift = 24;
+   if (moea64_large_page_size == 0) {
+   moea64_large_page_size = 0x100; /* 16 MB */
+   moea64_large_page_shift = 24;
+   }
}
 
moea64_large_page_mask = moea64_large_page_size - 1;
@@ -873,9 +875,9 @@ moea64_late_bootstrap(mmu_t mmup, vm_offset_t kernelst
/*
 * Calculate the last available physical address.
 */
+   Maxmem = 0;
for (i = 0; phys_avail[i + 2] != 0; i += 2)
-   ;
-   Maxmem = powerpc_btop(phys_avail[i + 1]);
+   Maxmem = max(Maxmem, powerpc_btop(phys_avail[i + 1]));
 
/*
 * Initialize MMU and remap early physical mappings
@@ -956,7 +958,7 @@ moea64_late_bootstrap(mmu_t mmup, vm_offset_t kernelst
pa += PAGE_SIZE;
va += PAGE_SIZE;
}
-   dpcpu_init(dpcpu, 0);
+   dpcpu_init(dpcpu, curcpu);
 
/*
 * Allocate some things for page zeroing. We put this directly
___
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: r326213 - head/sys/powerpc/ofw

2017-11-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 25 22:14:30 2017
New Revision: 326213
URL: https://svnweb.freebsd.org/changeset/base/326213

Log:
  When booting from an FDT, make sure the FDT itself isn't included the range
  of available memory. Boot loaders are supposed to add a reserved entry for
  it, but not all do.
  
  MFC after:2 weeks

Modified:
  head/sys/powerpc/ofw/ofw_machdep.c

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==
--- head/sys/powerpc/ofw/ofw_machdep.c  Sat Nov 25 22:13:19 2017
(r326212)
+++ head/sys/powerpc/ofw/ofw_machdep.c  Sat Nov 25 22:14:30 2017
(r326213)
@@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 static void*fdt;
 intofw_real_mode;
 
@@ -233,8 +235,17 @@ excise_fdt_reserved(struct mem_region *avail, int asz)
fdtmapsize = OF_getprop(chosen, "fdtmemreserv", fdtmap, sizeof(fdtmap));
 
for (j = 0; j < fdtmapsize/sizeof(fdtmap[0]); j++) {
-   fdtmap[j].address = be64toh(fdtmap[j].address);
-   fdtmap[j].size = be64toh(fdtmap[j].size);
+   fdtmap[j].address = be64toh(fdtmap[j].address) & ~PAGE_MASK;
+   fdtmap[j].size = round_page(be64toh(fdtmap[j].size));
+   }
+
+   KASSERT(j*sizeof(fdtmap[0]) < sizeof(fdtmap),
+   ("Exceeded number of FDT reservations"));
+   /* Add a virtual entry for the FDT itself */
+   if (fdt != NULL) {
+   fdtmap[j].address = (vm_offset_t)fdt & ~PAGE_MASK;
+   fdtmap[j].size = round_page(fdt_totalsize(fdt));
+   fdtmapsize += sizeof(fdtmap[0]);
}
 
for (i = 0; i < asz; i++) {
___
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"


  1   2   3   4   5   6   7   8   9   10   >