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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-h...@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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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(>opd_obdinfo);
pci_child_deleted(dev, child);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343969 - head/sys/mips/cavium/octe

2019-02-10 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Feb 10 20:13:59 2019
New Revision: 343969
URL: https://svnweb.freebsd.org/changeset/base/343969

Log:
  Performance improvements for octe(4):
  - Distribute RX load across multiple cores, if present. This reverts
r217212, which is no longer relevant (I think because of the newer
SDK).
  - Use newer APIs for pinning taskqueue entries to specific cores.
  - Deepen RX buffers.
  
  This more than doubles NAT forwarding throughput on my EdgeRouter Lite from,
  with typical packet mixture, 90 Mbps to over 200 Mbps. The result matches
  forwarding throughput in Linux without the UBNT hardware offload on the same
  hardware, and thus likely reflects hardware limits.
  
  Reviewed by:  jhibbits

Modified:
  head/sys/mips/cavium/octe/ethernet-defines.h
  head/sys/mips/cavium/octe/ethernet-rx.c
  head/sys/mips/cavium/octe/ethernet.c

Modified: head/sys/mips/cavium/octe/ethernet-defines.h
==
--- head/sys/mips/cavium/octe/ethernet-defines.hSun Feb 10 19:20:03 
2019(r343968)
+++ head/sys/mips/cavium/octe/ethernet-defines.hSun Feb 10 20:13:59 
2019(r343969)
@@ -38,14 +38,14 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS MAKES NO PROM
  *  the driver uses the default from below.
  */
 
-#define INTERRUPT_LIMIT 1   /* Max interrupts per second per 
core */
+#define INTERRUPT_LIMIT 1000   /* Max interrupts per second per 
core */
 /*#define INTERRUPT_LIMIT 0 *//* Don't limit the number of 
interrupts */
 #define USE_RED 1  /* Enable Random Early Dropping under 
load */
 #define USE_10MBPS_PREAMBLE_WORKAROUND 1/* Allow SW based preamble removal 
at 10Mbps to workaround PHYs giving us bad preambles */
 #define DONT_WRITEBACK(x)   (x) /* Use this to have all FPA frees also 
tell the L2 not to write data to memory */
 /*#define DONT_WRITEBACK(x) 0   *//* Use this to not have FPA frees 
control L2 */
 
-#define MAX_RX_PACKETS 120 /* Maximum number of packets to process per 
interrupt. */
+#define MAX_RX_PACKETS 1024 /* Maximum number of packets to process per 
interrupt. */
 #define MAX_OUT_QUEUE_DEPTH 1000
 
 #define FAU_NUM_PACKET_BUFFERS_TO_FREE (CVMX_FAU_REG_END - sizeof(uint32_t))

Modified: head/sys/mips/cavium/octe/ethernet-rx.c
==
--- head/sys/mips/cavium/octe/ethernet-rx.c Sun Feb 10 19:20:03 2019
(r343968)
+++ head/sys/mips/cavium/octe/ethernet-rx.c Sun Feb 10 20:13:59 2019
(r343969)
@@ -57,8 +57,6 @@ extern struct ifnet *cvm_oct_device[];
 static struct task cvm_oct_task;
 static struct taskqueue *cvm_oct_taskq;
 
-static int cvm_oct_rx_active;
-
 /**
  * Interrupt handler. The interrupt occurs whenever the POW
  * transitions from 0->1 packets in our group.
@@ -77,10 +75,9 @@ int cvm_oct_do_interrupt(void *dev_id)
cvmx_write_csr(CVMX_POW_WQ_INT, 0x10001

Re: svn commit: r340653 - in head/sys/powerpc: fpu include powerpc

2018-11-19 Thread Nathan Whitehorn
Is this reasonable? What if the junk in the cache happened to be a
*valid* instruction? Won't this approach result in silent corruption and
later failure?
-Nathan

On 11/19/18 3:54 PM, Justin Hibbits wrote:
> Author: jhibbits
> Date: Mon Nov 19 23:54:49 2018
> New Revision: 340653
> URL: https://svnweb.freebsd.org/changeset/base/340653
>
> Log:
>   powerpc: Sync icache on SIGILL, in case of cache issues
>   
>   The update of jemalloc to 5.1.0 exposed a cache syncing issue on a Freescale
>   e500 base system.  There was already code in the FPU emulator to address
>   this, but it was limited to a single static variable, and did not attempt to
>   sync the cache.  This pulls that out to the higher level program exception
>   handler, and syncs the cache.
>   
>   If a SIGILL is hit a second time at the same address, it will be treated as
>   a real illegal instruction, and handled accordingly.
>
> Modified:
>   head/sys/powerpc/fpu/fpu_emu.c
>   head/sys/powerpc/include/pcb.h
>   head/sys/powerpc/powerpc/exec_machdep.c
>
> Modified: head/sys/powerpc/fpu/fpu_emu.c
> ==
> --- head/sys/powerpc/fpu/fpu_emu.cMon Nov 19 22:18:18 2018
> (r340652)
> +++ head/sys/powerpc/fpu/fpu_emu.cMon Nov 19 23:54:49 2018
> (r340653)
> @@ -189,7 +189,6 @@ fpu_emulate(struct trapframe *frame, struct fpu *fpf)
>  {
>   union instr insn;
>   struct fpemu fe;
> - static int lastill = 0;
>   int sig;
>  
>   /* initialize insn.is_datasize to tell it is *not* initialized */
> @@ -243,17 +242,11 @@ fpu_emulate(struct trapframe *frame, struct fpu *fpf)
>   opc_disasm(frame->srr0, insn.i_int);
>   }
>  #endif
> - /*
> - *  retry an illegal insn once due to cache issues.
> - */
> - if (lastill == frame->srr0) {
> - sig = SIGILL;
> + sig = SIGILL;
>  #ifdef DEBUG
> - if (fpe_debug & FPE_EX)
> - kdb_enter(KDB_WHY_UNSET, "illegal instruction");
> + if (fpe_debug & FPE_EX)
> + kdb_enter(KDB_WHY_UNSET, "illegal instruction");
>  #endif
> - }
> - lastill = frame->srr0;
>   break;
>   }
>  
>
> Modified: head/sys/powerpc/include/pcb.h
> ==
> --- head/sys/powerpc/include/pcb.hMon Nov 19 22:18:18 2018
> (r340652)
> +++ head/sys/powerpc/include/pcb.hMon Nov 19 23:54:49 2018
> (r340653)
> @@ -89,6 +89,7 @@ struct pcb {
>   register_t  dbcr0;
>   } booke;
>   } pcb_cpu;
> + vm_offset_t pcb_lastill;/* Last illegal instruction */
>  };
>  #endif
>  
>
> Modified: head/sys/powerpc/powerpc/exec_machdep.c
> ==
> --- head/sys/powerpc/powerpc/exec_machdep.c   Mon Nov 19 22:18:18 2018
> (r340652)
> +++ head/sys/powerpc/powerpc/exec_machdep.c   Mon Nov 19 23:54:49 2018
> (r340653)
> @@ -94,6 +94,8 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  
> +#include 
> +
>  #ifdef FPU_EMU
>  #include 
>  #endif
> @@ -1099,6 +1101,14 @@ ppc_instr_emulate(struct trapframe *frame, struct pcb 
>   }
>   sig = fpu_emulate(frame, >pcb_fpu);
>  #endif
> + if (sig == SIGILL) {
> + if (pcb->pcb_lastill != frame->srr0) {
> + /* Allow a second chance, in case of cache sync issues. 
> */
> + sig = 0;
> + pmap_sync_icache(PCPU_GET(curpmap), frame->srr0, 4);
> + pcb->pcb_lastill = frame->srr0;
> + }
> + }
>  
>   return (sig);
>  }
>

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


Re: svn commit: r339523 - in head/sys: conf dev/amdgpio modules modules/amdgpio

2018-10-22 Thread Nathan Whitehorn



On 10/21/18 1:12 PM, Oleksandr Tymoshenko wrote:
> Nathan Whitehorn (nwhiteh...@freebsd.org) wrote:
>>
>> On 10/20/18 9:52 PM, Oleksandr Tymoshenko wrote:
>>> Author: gonzo
>>> Date: Sun Oct 21 04:52:37 2018
>>> New Revision: 339523
>>> URL: https://svnweb.freebsd.org/changeset/base/339523
>>>
>>> Log:
>>>   Add amdgpio, driver for GPIO controller on AMD-based x86_64 platforms
>>>   
>>>   Submitted by: Rajesh Kumar 
>>>   Differential Revision:https://reviews.freebsd.org/D16865
>>>
>> [...]
>>> Modified: head/sys/modules/Makefile
>>> ==
>>> --- head/sys/modules/Makefile   Sun Oct 21 02:39:13 2018
>>> (r339522)
>>> +++ head/sys/modules/Makefile   Sun Oct 21 04:52:37 2018
>>> (r339523)
>>> @@ -34,6 +34,7 @@ SUBDIR=   \
>>> ale \
>>> alq \
>>> ${_amd_ecc_inject} \
>>> +   ${_amdgpio} \
>>> ${_amdsbwd} \
>>> ${_amdsmn} \
>>> ${_amdtemp} \
>>> @@ -717,6 +718,7 @@ _x86bios=   x86bios
>>>  .endif
>>>  
>>>  .if ${MACHINE_CPUARCH} == "amd64"
>>> +_amdgpio=  amdgpio
>>>  _ccp=  ccp
>>>  _efirt=efirt
>>>  _iavf= iavf
>>>
>> Does this not work on 64-bit AMD processors running i386 kernels?
> I see no reason why it wouldn't. Probably just haven't been tested.
>

It might be nice if we just added it to all architectures where it
conceivably applies. Essentially all of our code is more portable than
the platforms on which it is tested, so there doesn't seem to be a good
reason to limit such things.
-Nathan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r339523 - in head/sys: conf dev/amdgpio modules modules/amdgpio

2018-10-21 Thread Nathan Whitehorn



On 10/20/18 9:52 PM, Oleksandr Tymoshenko wrote:
> Author: gonzo
> Date: Sun Oct 21 04:52:37 2018
> New Revision: 339523
> URL: https://svnweb.freebsd.org/changeset/base/339523
>
> Log:
>   Add amdgpio, driver for GPIO controller on AMD-based x86_64 platforms
>   
>   Submitted by:   Rajesh Kumar 
>   Differential Revision:  https://reviews.freebsd.org/D16865
>
[...]
> Modified: head/sys/modules/Makefile
> ==
> --- head/sys/modules/Makefile Sun Oct 21 02:39:13 2018(r339522)
> +++ head/sys/modules/Makefile Sun Oct 21 04:52:37 2018(r339523)
> @@ -34,6 +34,7 @@ SUBDIR= \
>   ale \
>   alq \
>   ${_amd_ecc_inject} \
> + ${_amdgpio} \
>   ${_amdsbwd} \
>   ${_amdsmn} \
>   ${_amdtemp} \
> @@ -717,6 +718,7 @@ _x86bios= x86bios
>  .endif
>  
>  .if ${MACHINE_CPUARCH} == "amd64"
> +_amdgpio=amdgpio
>  _ccp=ccp
>  _efirt=  efirt
>  _iavf=   iavf
>

Does this not work on 64-bit AMD processors running i386 kernels?
-Nathan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r339413 - in head: libexec libexec/rc libexec/rc/rc.d sbin/init sbin/init/rc.d

2018-10-17 Thread Nathan Whitehorn
Is there some high-level overview of the plan for pkgbase somewhere?
Which things will be in which packages, how the tools will work, etc.?
I'm still a little confused by how things are intended to work and it's
a bit hard to follow from commits with lots of small reorganizations.

Thanks,
Nathan

On 10/17/18 9:49 AM, Bjoern A. Zeeb wrote:
> Author: bz
> Date: Wed Oct 17 16:49:11 2018
> New Revision: 339413
> URL: https://svnweb.freebsd.org/changeset/base/339413
>
> Log:
>   Move the rc framework out of sbin/init into libexec/rc.
>   
>   The reasons for this are forward looking to pkgbase:
>* /sbin/init is a special binary; try not to replace it with
>  every package update because an rc script was touched.
>  (a follow-up commit will make init its own package)
>* having rc in its own place will allow more easy replacement
>  of the rc framework with alternatives, such as openrc.
>   
>   Discussed with: brd (during BSDCam), kmoore
>   Requested by:   cem, bz
>   PR: 231522
>   Approved by:re (gjb)
>
> Added:
>   head/libexec/rc/
>   head/libexec/rc/Makefile   (contents, props changed)
>   head/libexec/rc/netstart
>  - copied unchanged from r339412, head/sbin/init/netstart
>   head/libexec/rc/network.subr
>  - copied unchanged from r339412, head/sbin/init/network.subr
>   head/libexec/rc/pccard_ether
>  - copied unchanged from r339412, head/sbin/init/pccard_ether
>   head/libexec/rc/rc
>  - copied unchanged from r339412, head/sbin/init/rc
>   head/libexec/rc/rc.conf
>  - copied unchanged from r339412, head/sbin/init/rc.conf
>   head/libexec/rc/rc.d/
>  - copied from r339412, head/sbin/init/rc.d/
>   head/libexec/rc/rc.initdiskless
>  - copied unchanged from r339412, head/sbin/init/rc.initdiskless
>   head/libexec/rc/rc.resume
>  - copied unchanged from r339412, head/sbin/init/rc.resume
>   head/libexec/rc/rc.shutdown
>  - copied unchanged from r339412, head/sbin/init/rc.shutdown
>   head/libexec/rc/rc.subr
>  - copied unchanged from r339412, head/sbin/init/rc.subr
>   head/libexec/rc/rc.suspend
>  - copied unchanged from r339412, head/sbin/init/rc.suspend
> Deleted:
>   head/sbin/init/netstart
>   head/sbin/init/network.subr
>   head/sbin/init/pccard_ether
>   head/sbin/init/rc
>   head/sbin/init/rc.conf
>   head/sbin/init/rc.d/
>   head/sbin/init/rc.initdiskless
>   head/sbin/init/rc.resume
>   head/sbin/init/rc.shutdown
>   head/sbin/init/rc.subr
>   head/sbin/init/rc.suspend
> Modified:
>   head/libexec/Makefile
>   head/libexec/rc/rc.d/Makefile
>   head/sbin/init/Makefile
>
> Modified: head/libexec/Makefile
> ==
> --- head/libexec/Makefile Wed Oct 17 16:38:44 2018(r339412)
> +++ head/libexec/Makefile Wed Oct 17 16:49:11 2018(r339413)
> @@ -13,6 +13,7 @@ SUBDIR= ${_atf} \
>   ${_makewhatis.local} \
>   ${_mknetid} \
>   ${_pppoed} \
> + rc \
>   revnetgroup \
>   ${_rlogind} \
>   rpc.rquotad \
>
> Added: head/libexec/rc/Makefile
> ==
> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ head/libexec/rc/Makefile  Wed Oct 17 16:49:11 2018(r339413)
> @@ -0,0 +1,16 @@
> +# $FreeBSD$
> +
> +CONFGROUPS=  CONFETC CONFETCEXEC CONFETCDEFAULTS
> +CONFETCDIR=  /etc
> +CONFETC= network.subr rc rc.initdiskless rc.subr rc.shutdown
> +CONFETCMODE= 644
> +CONFETCEXEC= netstart pccard_ether rc.resume rc.suspend
> +CONFETCEXECDIR=  /etc
> +CONFETCEXECMODE= 755
> +CONFETCDEFAULTSDIR=  /etc/defaults
> +CONFETCDEFAULTS= rc.conf
> +PACKAGE=rc
> +
> +SUBDIR+= rc.d
> +
> +.include 
>
> Copied: head/libexec/rc/netstart (from r339412, head/sbin/init/netstart)
> ==
> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ head/libexec/rc/netstart  Wed Oct 17 16:49:11 2018(r339413, copy 
> of r339412, head/sbin/init/netstart)
> @@ -0,0 +1,57 @@
> +#!/bin/sh -
> +#
> +# Copyright (c) 1993  The FreeBSD Project
> +# 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 

svn commit: r339301 - head/share/mk

2018-10-10 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Oct 11 00:54:39 2018
New Revision: 339301
URL: https://svnweb.freebsd.org/changeset/base/339301

Log:
  Loader GELI support, like lua loader, seems to be broken on PowerPC as
  well as on SPARC64 and can cause boot failures even when no encrypted
  disks are present. Presumably, the reasons, while unknown, are the same
  and most-likely are the result of some endian-unsafe code. Pending
  finding the actual problem, extend the blacklist entry for these parts
  of loader on SPARC to also cover all PowerPC platforms.
  
  Approved by:  re (kib)

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

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Thu Oct 11 00:26:15 2018(r339300)
+++ head/share/mk/src.opts.mk   Thu Oct 11 00:54:39 2018(r339301)
@@ -353,15 +353,12 @@ BROKEN_OPTIONS+=LOADER_OFW
 .if ${__T:Marm*} == "" && ${__T:Mmips*} == "" && ${__T:Mpowerpc*} == ""
 BROKEN_OPTIONS+=LOADER_UBOOT
 .endif
-# GELI and Lua in loader currently cause boot failures on sparc64.
-# Further debugging is required.
-.if ${__T} == "sparc64"
+# GELI and Lua in loader currently cause boot failures on sparc64 and powerpc.
+# Further debugging is required -- probably they are just broken on big
+# endian systems generically (they jump to null pointers or try to read
+# crazy high addresses, which is typical of endianness problems).
+.if ${__T} == "sparc64" || ${__T:Mpowerpc*}
 BROKEN_OPTIONS+=LOADER_GELI LOADER_LUA
-.endif
-# Lua in loader currently cause boot failures on powerpc.
-# Further debugging is required.
-.if ${__T} == "powerpc" || ${__T} == "powerpc64"
-BROKEN_OPTIONS+=LOADER_LUA
 .endif
 
 .if ${__T:Mmips64*}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r336514 - head/sys/dev/vt/hw/ofwfb

2018-07-19 Thread Nathan Whitehorn

Oh wow. That's just... horrific.

Here, it is a string:
https://github.com/open-power/petitboot/blob/master/utils/hooks/30-dtb-updates.c#L560

So I think this code needs to accept both.
-Nathan

On 07/19/18 13:38, Kyle Evans wrote:

Seems like some bad decisions have been made with regards to naming...
e.g. https://lkml.org/lkml/2018/6/25/784

On Thu, Jul 19, 2018 at 3:26 PM, Nathan Whitehorn
 wrote:

Isn't stdout-path supposed to contain a string rather than an ihandle? This
code assumes it is an ihandle (or xref phandle), which I think is wrong.
-Nathan


On 07/19/18 13:22, Justin Hibbits wrote:

Author: jhibbits
Date: Thu Jul 19 20:22:46 2018
New Revision: 336514
URL: https://svnweb.freebsd.org/changeset/base/336514

Log:
ofwfb: Check for /chosen/stdout-path in addition to /chosen/stdout
   Some platforms use /chosen/stdout-path as the property containing
the path to
the stdout node, not /chosen/stdout.

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.cThu Jul 19 20:20:43 2018
(r336513)
+++ head/sys/dev/vt/hw/ofwfb/ofwfb.cThu Jul 19 20:22:46 2018
(r336514)
@@ -102,6 +102,10 @@ ofwfb_probe(struct vt_device *vd)
 if (OF_getprop(chosen, "stdout", , sizeof(stdout)) ==
 sizeof(stdout))
 node = OF_instance_to_package(stdout);
+   if (node == -1)
+   if (OF_getprop(chosen, "stdout-path", , sizeof(stdout))
==
+   sizeof(stdout))
+   node = OF_instance_to_package(stdout);
 if (node == -1) {
 /*
  * The "/chosen/stdout" does not exist try





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


Re: svn commit: r336514 - head/sys/dev/vt/hw/ofwfb

2018-07-19 Thread Nathan Whitehorn
Isn't stdout-path supposed to contain a string rather than an ihandle? 
This code assumes it is an ihandle (or xref phandle), which I think is 
wrong.

-Nathan

On 07/19/18 13:22, Justin Hibbits wrote:

Author: jhibbits
Date: Thu Jul 19 20:22:46 2018
New Revision: 336514
URL: https://svnweb.freebsd.org/changeset/base/336514

Log:
   ofwfb: Check for /chosen/stdout-path in addition to /chosen/stdout
   
   Some platforms use /chosen/stdout-path as the property containing the path to

   the stdout node, not /chosen/stdout.

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.cThu Jul 19 20:20:43 2018
(r336513)
+++ head/sys/dev/vt/hw/ofwfb/ofwfb.cThu Jul 19 20:22:46 2018
(r336514)
@@ -102,6 +102,10 @@ ofwfb_probe(struct vt_device *vd)
if (OF_getprop(chosen, "stdout", , sizeof(stdout)) ==
sizeof(stdout))
node = OF_instance_to_package(stdout);
+   if (node == -1)
+   if (OF_getprop(chosen, "stdout-path", , sizeof(stdout)) ==
+   sizeof(stdout))
+   node = OF_instance_to_package(stdout);
if (node == -1) {
/*
 * The "/chosen/stdout" does not exist try



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


Re: svn commit: r336130 - head/sys/dev/pci

2018-07-09 Thread Nathan Whitehorn
Maybe this file should be renamed and/or split anyway? It's not actually 
very generic and is used only on (some) ARM systems.

-Nathan

On 07/09/18 09:00, Andrew Turner wrote:

This breaks at least armv7. Please either fix, or revert this.

I have some comments below I was planning on adding to the review, but you 
committed before I had the time to do so.


On 9 Jul 2018, at 10:00, Wojciech Macek  wrote:

Author: wma
Date: Mon Jul  9 09:00:16 2018
New Revision: 336130
URL: https://svnweb.freebsd.org/changeset/base/336130

Log:
  ARM64: Add quirk mechanism to pci_host_generic_acpi

  Add few quirks which are necessary to use AHCI on ThX2

  Submitted by:  Patryk Duda 
  Obtained from: Semihalf
  Sponsored by:  Cavium
  Differential revision: https://reviews.freebsd.org/D15929

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

Modified: head/sys/dev/pci/pci_host_generic.c
==
--- head/sys/dev/pci/pci_host_generic.c Mon Jul  9 08:55:07 2018
(r336129)
+++ head/sys/dev/pci/pci_host_generic.c Mon Jul  9 09:00:16 2018
(r336130)
@@ -69,6 +69,25 @@ __FBSDID("$FreeBSD$");
(((func) & PCIE_FUNC_MASK) << PCIE_FUNC_SHIFT)|   \
((reg) & PCIE_REG_MASK))

+typedef void (*pci_host_generic_quirk_function)(device_t);
+
+struct pci_host_generic_quirk_entry {
+   int impl;
+   int part;
+   int var;
+   int rev;
+   pci_host_generic_quirk_function func;
+};
+
+struct pci_host_generic_block_entry {
+   int impl;
+   int part;
+   int var;
+   int rev;
+   int bus;
+   int slot;
+};
+
/* Forward prototypes */

static uint32_t generic_pcie_read_config(device_t dev, u_int bus, u_int slot,
@@ -80,7 +99,22 @@ static int generic_pcie_read_ivar(device_t dev, device
 uintptr_t *result);
static int generic_pcie_write_ivar(device_t dev, device_t child, int index,
 uintptr_t value);
+static void pci_host_generic_apply_quirks(device_t);
+static void thunderx2_ahci_bar_quirk(device_t);

+struct pci_host_generic_quirk_entry pci_host_generic_quirks[] =
+{
+   {CPU_IMPL_CAVIUM, CPU_PART_THUNDERX2, 0, 0, thunderx2_ahci_bar_quirk},
+   {0, 0, 0, 0, NULL}

This breaks non-arm64, please fix.


+};
+
+struct pci_host_generic_block_entry pci_host_generic_blocked[] =
+{
+   /* ThunderX2 AHCI on second socket */
+   {CPU_IMPL_CAVIUM, CPU_PART_THUNDERX2, 0, 0, 0x80, 0x10},
+   {0, 0, 0, 0, 0, 0}

And this.


+};
+
int
pci_host_generic_core_attach(device_t dev)
{
@@ -134,9 +168,30 @@ pci_host_generic_core_attach(device_t dev)
return (error);
}

+   pci_host_generic_apply_quirks(dev);
+
return (0);
}

+static void
+pci_host_generic_apply_quirks(device_t dev)
+{
+   struct pci_host_generic_quirk_entry *quirk;
+
+   quirk = pci_host_generic_quirks;
+   while (1) {
+   if (quirk->impl == 0)
+   break;
+
+   if (CPU_MATCH(CPU_IMPL_MASK | CPU_PART_MASK,
+   quirk->impl, quirk->part, quirk->var, quirk->rev) &&
+   quirk->func != NULL)

This is arm64 specific.


+   quirk->func(dev);
+
+   quirk++;
+   }
+}
+
static uint32_t
generic_pcie_read_config(device_t dev, u_int bus, u_int slot,
 u_int func, u_int reg, int bytes)
@@ -146,11 +201,25 @@ generic_pcie_read_config(device_t dev, u_int bus, u_in
bus_space_tag_t t;
uint64_t offset;
uint32_t data;
+   struct pci_host_generic_block_entry *block;

if ((bus > PCI_BUSMAX) || (slot > PCI_SLOTMAX) ||
(func > PCI_FUNCMAX) || (reg > PCIE_REGMAX))
return (~0U);

+   block = pci_host_generic_blocked;
+   while (1) {
+   if (block->impl == 0)
+   break;
+
+   if (CPU_MATCH(CPU_IMPL_MASK | CPU_PART_MASK,
+   block->impl, block->part, block->var, block->rev) &&
+   block->bus == bus && block->slot == slot)

This is also arm64 specific.


+   return (~0);
+
+   block++;
+   }
+
sc = device_get_softc(dev);

offset = PCIE_ADDR_OFFSET(bus, slot, func, reg);
@@ -392,3 +461,20 @@ static device_method_t generic_pcie_methods[] = {

DEFINE_CLASS_0(pcib, generic_pcie_core_driver,
 generic_pcie_methods, sizeof(struct generic_pcie_core_softc));
+
+static void thunderx2_ahci_bar_quirk(device_t dev)

This should be dependent on arm64 and an appropriate SOC_ check.


+{
+
+   /*
+* XXX:
+* On ThunderX2, AHCI BAR2 address is wrong. It needs to precisely
+* match the one described in datasheet. Fixup it unconditionally.
+*/
+   if (device_get_unit(dev) == 0) {
+   device_printf(dev, "running AHCI BAR fixup\n");
+   PCIB_WRITE_CONFIG(dev, 0, 16, 0, 0x18, 0x0144, 4);
+   PCIB_WRITE_CONFIG(dev, 

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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", , sizeof(height));
OF_getprop(node, "width", , sizeof(width));
-   OF_getprop(node, "linebytes", , sizeof(stride));
+   if (OF_getprop(node, "linebytes", , sizeof(stride)) !=
+   sizeof(stride))
+   stride = width*depth/8;
 
sc->fb.fb_height = height;
sc->fb.fb_width = width;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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_memt, >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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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"   

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-03-14 Thread Nathan Whitehorn



On 03/14/18 10:59, Justin Hibbits wrote:

On Wed, Mar 14, 2018 at 12:53 PM, Nathan Whitehorn
<nwhiteh...@freebsd.org> wrote:


On 03/14/18 09:19, Justin Hibbits wrote:

On Wed, Mar 14, 2018 at 11:16 AM, Nathan Whitehorn
<nwhiteh...@freebsd.org> wrote:

Author: nwhitehorn
Date: Wed Mar 14 16:16:25 2018
New Revision: 330930
URL: https://svnweb.freebsd.org/changeset/base/330930

Log:
The expression (aim | fdt) is always true on PowerPC. The last PowerPC
platform that can run without a device tree (PS3) still uses the
OF_*()
functions to check if one exists and OF_* is used unconditionally in
core parts of the system like powerpc/machdep.c. Reflect this reality
in files.powerpc, for example by changing occurrences of aim | fdt to
standard.

Modified:
head/sys/conf/files.powerpc

Modified: head/sys/conf/files.powerpc

==
--- head/sys/conf/files.powerpc Wed Mar 14 14:45:57 2018(r330929)
+++ head/sys/conf/files.powerpc Wed Mar 14 16:16:25 2018(r330930)
@@ -32,7 +32,7 @@ dev/adb/adb_buttons.c optionaladb
   dev/agp/agp_apple.coptionalagp powermac
   dev/fb/fb.coptionalsc
   # ofwbus depends on simplebus.
-dev/fdt/simplebus.coptionalaim | fdt
+dev/fdt/simplebus.coptionalstandard
   dev/hwpmc/hwpmc_e500.c optionalhwpmc
   dev/hwpmc/hwpmc_mpc7xxx.c  optionalhwpmc
   dev/hwpmc/hwpmc_powerpc.c  optionalhwpmc
@@ -55,7 +55,7 @@ dev/ofw/ofw_if.m  optionalaim
   dev/ofw/ofw_bus_subr.c optionalaim
   dev/ofw/ofw_console.c  optionalaim
   dev/ofw/ofw_disk.c optionalofwd aim
-dev/ofw/ofwbus.c   optionalaim | fdt
+dev/ofw/ofwbus.c   optionalaim

ofwbus is used by Book-E too, not just AIM.  And 'aim' is not defined
for Book-E platforms.  Maybe it should be 'standard' instead?

- Justin


See the comment above this line (which isn't in the diff): ofwbus.c can also
be brought in by conf/files through the definition of options FDT. This
block is just a safety valve for (AIM && !FDT) to make sure we always get
it. We could also mark all of these standard; config is smart enough to
deduplicate things. Would you prefer that?
-Nathan


Just mark them standard, since they are really standard.

- Justin



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


svn commit: r330936 - head/sys/conf

2018-03-14 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Mar 14 18:07:40 2018
New Revision: 330936
URL: https://svnweb.freebsd.org/changeset/base/330936

Log:
  Fix fat-fingering ("optional standard") and move all the OF code to
  being marked "standard", which is less confusing than having it conditional
  on AIM CPUs here, and then picked up through options FDT from conf/files
  on Book-E.
  
  Request by:   jhibbits

Modified:
  head/sys/conf/files.powerpc

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Wed Mar 14 17:53:37 2018(r330935)
+++ head/sys/conf/files.powerpc Wed Mar 14 18:07:40 2018(r330936)
@@ -31,8 +31,6 @@ dev/adb/adb_if.m  optionaladb
 dev/adb/adb_buttons.c  optionaladb
 dev/agp/agp_apple.coptionalagp powermac
 dev/fb/fb.coptionalsc
-# ofwbus depends on simplebus.
-dev/fdt/simplebus.coptionalstandard
 dev/hwpmc/hwpmc_e500.c optionalhwpmc
 dev/hwpmc/hwpmc_mpc7xxx.c  optionalhwpmc
 dev/hwpmc/hwpmc_powerpc.c  optionalhwpmc
@@ -46,19 +44,21 @@ dev/iicbus/max6690.coptionalmax6690 
powermac
 dev/iicbus/ofw_iicbus.coptionaliicbus aim
 dev/nand/nfc_fsl.c optionalnand mpc85xx
 dev/nand/nfc_rb.c  optionalnand mpc85xx
-# ofw can be either aim or fdt: fdt case handled in files. aim only powerpc 
specific.
-dev/ofw/openfirm.c optionalaim
-dev/ofw/openfirmio.c   optionalaim
-dev/ofw/ofw_bus_if.m   optionalaim
-dev/ofw/ofw_cpu.c  optionalaim
-dev/ofw/ofw_if.m   optionalaim
-dev/ofw/ofw_bus_subr.c optionalaim
+# Most ofw stuff below is brought in by conf/files for options FDT, but
+# we always want it, even on non-FDT platforms.
+dev/fdt/simplebus.cstandard
+dev/ofw/openfirm.c standard
+dev/ofw/openfirmio.c   standard
+dev/ofw/ofw_bus_if.m   standard
+dev/ofw/ofw_cpu.c  standard
+dev/ofw/ofw_if.m   standard
+dev/ofw/ofw_bus_subr.c standard
 dev/ofw/ofw_console.c  optionalaim
 dev/ofw/ofw_disk.c optionalofwd aim
-dev/ofw/ofwbus.c   optionalaim
+dev/ofw/ofwbus.c   standard
 dev/ofw/ofwpci.c   optionalpci
 dev/ofw/ofw_standard.c optionalaim powerpc
-dev/ofw/ofw_subr.c optionalaim powerpc
+dev/ofw/ofw_subr.c standard
 dev/powermac_nvram/powermac_nvram.c optional   powermac_nvram powermac
 dev/quicc/quicc_bfe_fdt.c  optionalquicc mpc85xx
 dev/scc/scc_bfe_macio.coptionalscc powermac
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-03-14 Thread Nathan Whitehorn



On 03/14/18 09:19, Justin Hibbits wrote:

On Wed, Mar 14, 2018 at 11:16 AM, Nathan Whitehorn
<nwhiteh...@freebsd.org> wrote:

Author: nwhitehorn
Date: Wed Mar 14 16:16:25 2018
New Revision: 330930
URL: https://svnweb.freebsd.org/changeset/base/330930

Log:
   The expression (aim | fdt) is always true on PowerPC. The last PowerPC
   platform that can run without a device tree (PS3) still uses the OF_*()
   functions to check if one exists and OF_* is used unconditionally in
   core parts of the system like powerpc/machdep.c. Reflect this reality
   in files.powerpc, for example by changing occurrences of aim | fdt to
   standard.

Modified:
   head/sys/conf/files.powerpc

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Wed Mar 14 14:45:57 2018(r330929)
+++ head/sys/conf/files.powerpc Wed Mar 14 16:16:25 2018(r330930)
@@ -32,7 +32,7 @@ dev/adb/adb_buttons.c optionaladb
  dev/agp/agp_apple.coptionalagp powermac
  dev/fb/fb.coptionalsc
  # ofwbus depends on simplebus.
-dev/fdt/simplebus.coptionalaim | fdt
+dev/fdt/simplebus.coptionalstandard
  dev/hwpmc/hwpmc_e500.c optionalhwpmc
  dev/hwpmc/hwpmc_mpc7xxx.c  optionalhwpmc
  dev/hwpmc/hwpmc_powerpc.c  optionalhwpmc
@@ -55,7 +55,7 @@ dev/ofw/ofw_if.m  optionalaim
  dev/ofw/ofw_bus_subr.c optionalaim
  dev/ofw/ofw_console.c  optionalaim
  dev/ofw/ofw_disk.c optionalofwd aim
-dev/ofw/ofwbus.c   optionalaim | fdt
+dev/ofw/ofwbus.c   optionalaim

ofwbus is used by Book-E too, not just AIM.  And 'aim' is not defined
for Book-E platforms.  Maybe it should be 'standard' instead?

- Justin



See the comment above this line (which isn't in the diff): ofwbus.c can 
also be brought in by conf/files through the definition of options FDT. 
This block is just a safety valve for (AIM && !FDT) to make sure we 
always get it. We could also mark all of these standard; config is smart 
enough to deduplicate things. Would you prefer that?

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


svn commit: r330930 - head/sys/conf

2018-03-14 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Mar 14 16:16:25 2018
New Revision: 330930
URL: https://svnweb.freebsd.org/changeset/base/330930

Log:
  The expression (aim | fdt) is always true on PowerPC. The last PowerPC
  platform that can run without a device tree (PS3) still uses the OF_*()
  functions to check if one exists and OF_* is used unconditionally in
  core parts of the system like powerpc/machdep.c. Reflect this reality
  in files.powerpc, for example by changing occurrences of aim | fdt to
  standard.

Modified:
  head/sys/conf/files.powerpc

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Wed Mar 14 14:45:57 2018(r330929)
+++ head/sys/conf/files.powerpc Wed Mar 14 16:16:25 2018(r330930)
@@ -32,7 +32,7 @@ dev/adb/adb_buttons.c optionaladb
 dev/agp/agp_apple.coptionalagp powermac
 dev/fb/fb.coptionalsc
 # ofwbus depends on simplebus.
-dev/fdt/simplebus.coptionalaim | fdt
+dev/fdt/simplebus.coptionalstandard
 dev/hwpmc/hwpmc_e500.c optionalhwpmc
 dev/hwpmc/hwpmc_mpc7xxx.c  optionalhwpmc
 dev/hwpmc/hwpmc_powerpc.c  optionalhwpmc
@@ -55,7 +55,7 @@ dev/ofw/ofw_if.m  optionalaim
 dev/ofw/ofw_bus_subr.c optionalaim
 dev/ofw/ofw_console.c  optionalaim
 dev/ofw/ofw_disk.c optionalofwd aim
-dev/ofw/ofwbus.c   optionalaim | fdt
+dev/ofw/ofwbus.c   optionalaim
 dev/ofw/ofwpci.c   optionalpci
 dev/ofw/ofw_standard.c optionalaim powerpc
 dev/ofw/ofw_subr.c optionalaim powerpc
@@ -74,7 +74,7 @@ dev/syscons/scgfbrndr.c   optionalsc
 dev/syscons/scterm-teken.c optionalsc
 dev/syscons/scvtb.coptionalsc
 dev/tsec/if_tsec.c optionaltsec
-dev/tsec/if_tsec_fdt.c optionaltsec fdt
+dev/tsec/if_tsec_fdt.c optionaltsec 
 dev/uart/uart_cpu_powerpc.coptionaluart
 dev/usb/controller/ehci_fsl.c  optionalehci mpc85xx
 dev/vt/hw/ofwfb/ofwfb.coptionalvt aim
@@ -136,12 +136,12 @@ powerpc/mambo/mambo_disk.coptionalmambo
 powerpc/mikrotik/platform_rb.c optionalmikrotik
 powerpc/mikrotik/rb_led.c  optionalmikrotik
 powerpc/mpc85xx/atpic.coptionalmpc85xx isa
-powerpc/mpc85xx/ds1553_bus_fdt.c   optionalds1553 fdt
+powerpc/mpc85xx/ds1553_bus_fdt.c   optionalds1553
 powerpc/mpc85xx/ds1553_core.c  optionalds1553
 powerpc/mpc85xx/fsl_diu.c  optionalmpc85xx diu
 powerpc/mpc85xx/fsl_espi.c optionalmpc85xx spibus
 powerpc/mpc85xx/fsl_sata.c optionalmpc85xx ata
-powerpc/mpc85xx/i2c.c  optionaliicbus fdt
+powerpc/mpc85xx/i2c.c  optionaliicbus
 powerpc/mpc85xx/isa.c  optionalmpc85xx isa
 powerpc/mpc85xx/lbc.c  optionalmpc85xx
 powerpc/mpc85xx/mpc85xx.c  optionalmpc85xx
@@ -158,7 +158,7 @@ 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/openpic_ofw.c  optionalaim | fdt
+powerpc/ofw/openpic_ofw.c  optionalstandard
 powerpc/ofw/rtas.c optionalaim
 powerpc/powermac/ata_kauai.c   optionalpowermac ata | powermac atamacio
 powerpc/powermac/ata_macio.c   optionalpowermac ata | powermac atamacio
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r330925 - in head/sys: conf powerpc/powernv

2018-03-14 Thread Nathan Whitehorn



On 03/14/18 02:20, Wojciech Macek wrote:

Author: wma
Date: Wed Mar 14 09:20:03 2018
New Revision: 330925
URL: https://svnweb.freebsd.org/changeset/base/330925

Log:
   PowerNV: Fix I2C to compile if FDT is disabled
   
   Submitted by:  Wojciech Macek 

   Obtained from: Semihalf
   Sponsored by:  IBM, QCM Technologies


I don't think this makes any sense, for several reasons:
1. You are gating on #ifdef FDT for things that are using the OF_* API 
and aren't actually FDT-specific, so the #ifdef checks are testing the 
wrong thing.
2. It isn't possible to even build a PowerPC/AIM kernel, like PowerNV, 
without the Open Firmware support code that this uses, so there is no 
circumstance in which this helps anything.
3. The PowerNV platform is non-functional without a device tree 
intrinsically, so, even if you could build a kernel like this somehow, 
it would be impossible for it to work.


Given all of that, why was this necessary? It seems to just add 
pointless #ifdef to code that does not need it.

-Nathan



Modified:
   head/sys/conf/files.powerpc
   head/sys/powerpc/powernv/opal_i2c.c
   head/sys/powerpc/powernv/opal_i2cm.c
   head/sys/powerpc/powernv/powernv_centaur.c
   head/sys/powerpc/powernv/powernv_xscom.c

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Wed Mar 14 08:48:40 2018(r330924)
+++ head/sys/conf/files.powerpc Wed Mar 14 09:20:03 2018(r330925)
@@ -186,8 +186,8 @@ powerpc/powermac/vcoregpio.coptionalpowermac
  powerpc/powernv/opal.coptionalpowernv
  powerpc/powernv/opal_console.coptionalpowernv
  powerpc/powernv/opal_dev.coptionalpowernv
-powerpc/powernv/opal_i2c.c optionaliicbus fdt powernv
-powerpc/powernv/opal_i2cm.coptionaliicbus fdt powernv
+powerpc/powernv/opal_i2c.c optionaliicbus powernv
+powerpc/powernv/opal_i2cm.coptionaliicbus powernv
  powerpc/powernv/opal_pci.coptionalpowernv pci
  powerpc/powernv/opalcall.Soptionalpowernv
  powerpc/powernv/platform_powernv.c optional   powernv

Modified: head/sys/powerpc/powernv/opal_i2c.c
==
--- head/sys/powerpc/powernv/opal_i2c.c Wed Mar 14 08:48:40 2018
(r330924)
+++ head/sys/powerpc/powernv/opal_i2c.c Wed Mar 14 09:20:03 2018
(r330925)
@@ -120,7 +120,9 @@ static int
  opal_i2c_probe(device_t dev)
  {
  
+#ifdef FDT

if (!(ofw_bus_is_compatible(dev, "ibm,opal-i2c")))
+#endif
return (ENXIO);
  
  	device_set_desc(dev, "opal-i2c");

@@ -131,6 +133,7 @@ opal_i2c_probe(device_t dev)
  static int
  opal_i2c_attach(device_t dev)
  {
+#ifdef FDT
struct opal_i2c_softc *sc;
int len;
  
@@ -150,6 +153,9 @@ opal_i2c_attach(device_t dev)

I2C_LOCK_INIT(sc);
  
  	return (bus_generic_attach(dev));

+#else
+   return (ENXIO);
+#endif
  }
  
  static int


Modified: head/sys/powerpc/powernv/opal_i2cm.c
==
--- head/sys/powerpc/powernv/opal_i2cm.cWed Mar 14 08:48:40 2018
(r330924)
+++ head/sys/powerpc/powernv/opal_i2cm.cWed Mar 14 09:20:03 2018
(r330925)
@@ -57,14 +57,17 @@ struct opal_i2cm_softc
  
  static int opal_i2cm_attach(device_t);

  static int opal_i2cm_probe(device_t);
+#ifdef FDT
  static const struct ofw_bus_devinfo *
  opal_i2cm_get_devinfo(device_t, device_t);
+#endif
  
  static device_method_t opal_i2cm_methods[] = {

/* Device interface */
DEVMETHOD(device_probe, opal_i2cm_probe),
DEVMETHOD(device_attach,opal_i2cm_attach),
  
+#ifdef FDT

/* ofw_bus interface */
DEVMETHOD(ofw_bus_get_devinfo,  opal_i2cm_get_devinfo),
DEVMETHOD(ofw_bus_get_compat,   ofw_bus_gen_get_compat),
@@ -72,6 +75,7 @@ static device_method_t opal_i2cm_methods[] = {
DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
+#endif
  
  	DEVMETHOD_END

  };
@@ -82,8 +86,10 @@ static int
  opal_i2cm_probe(device_t dev)
  {
  
+#ifdef FDT

if (!(ofw_bus_is_compatible(dev, "ibm,centaur-i2cm") ||
ofw_bus_is_compatible(dev, "ibm,power8-i2cm")))
+#endif
return (ENXIO);
  
  	device_set_desc(dev, "centaur-i2cm");

@@ -93,6 +99,7 @@ opal_i2cm_probe(device_t dev)
  static int
  opal_i2cm_attach(device_t dev)
  {
+#ifdef FDT
phandle_t child;
device_t cdev;
struct ofw_bus_devinfo *dinfo;
@@ -116,13 +123,18 @@ opal_i2cm_attach(device_t dev)
}
  
  	return (bus_generic_attach(dev));

+#else
+   return (ENXIO);
+#endif
  }
  
+#ifdef FDT

  static const struct 

Re: svn commit: r330925 - in head/sys: conf powerpc/powernv

2018-03-14 Thread Nathan Whitehorn



On 03/14/18 07:21, Ian Lepore wrote:

On Wed, 2018-03-14 at 09:20 +, Wojciech Macek wrote:

Author: wma
Date: Wed Mar 14 09:20:03 2018
New Revision: 330925
URL: https://svnweb.freebsd.org/changeset/base/330925

Log:
   PowerNV: Fix I2C to compile if FDT is disabled
   
   Submitted by:  Wojciech Macek 

   Obtained from: Semihalf
   Sponsored by:  IBM, QCM Technologies


This seems to be a nonsensical commit.  What's the point of compiling
in a driver which is hard-coded to return failure from the probe and
attach routines?  The pre-change code seemed more correct: the driver
can only possibly work if FDT/OFW data is available, so only compile it
in when that option is in effect.

-- Ian



It's even worse than that: the files.powerpc uses of fdt are *also* 
wrong, because it depends on OF, not FDT per se, which is 
unconditionally available on all AIM-type PowerPC kernels, so there is 
no need to test for *anything*.

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


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

2018-03-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Mar 13 18:24:21 2018
New Revision: 330870
URL: https://svnweb.freebsd.org/changeset/base/330870

Log:
  Restore missing temporary variable, deleted by accident in r330845. This
  unbreaks the ppc32 AIM build.
  
  Reported by:  jhibbits

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

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Tue Mar 13 17:57:53 2018
(r330869)
+++ head/sys/powerpc/aim/aim_machdep.c  Tue Mar 13 18:24:21 2018
(r330870)
@@ -228,9 +228,10 @@ aim_cpu_init(vm_offset_t toc)
register_t  msr;
uint8_t *cache_check;
int cacheline_warn;
-   #ifndef __powerpc64__
+#ifndef __powerpc64__
+   register_t  scratch;
int ppc64;
-   #endif
+#endif
 
trap_offset = 0;
cacheline_warn = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330845 - in head/sys/powerpc: aim ofw powerpc

2018-03-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Mar 13 15:03:58 2018
New Revision: 330845
URL: https://svnweb.freebsd.org/changeset/base/330845

Log:
  Execute PowerPC64/AIM kernel from direct map region when possible.
  
  When the kernel can be in real mode in early boot, we can execute from
  high addresses aliased to the kernel's physical memory. If that high
  address has the first two bits set to 1 (0xc...), those addresses will
  automatically become part of the direct map. This reduces page table
  pressure from the kernel and it sets up the kernel to be used with
  radix translation, for which it has to be up here.
  
  This is accomplished by exploiting the fact that all PowerPC kernels are
  built as position-independent executables and relocate themselves
  on start. Before this patch, the kernel runs at 1:1 VA:PA, but that
  VA/PA is random and set by the bootloader. Very early, it processes
  its ELF relocations to operate wherever it happens to find itself.
  This patch uses that mechanism to re-enter and re-relocate the kernel
  a second time witha new base address set up in the early parts of
  powerpc_init().
  
  Reviewed by:  jhibbits
  Differential Revision:D14647

Modified:
  head/sys/powerpc/aim/aim_machdep.c
  head/sys/powerpc/aim/locore64.S
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/ofw/ofwcall64.S
  head/sys/powerpc/powerpc/machdep.c

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Tue Mar 13 15:02:46 2018
(r330844)
+++ head/sys/powerpc/aim/aim_machdep.c  Tue Mar 13 15:03:58 2018
(r330845)
@@ -160,15 +160,72 @@ extern void   *dlmisstrap, *dlmisssize;
 extern void*dsmisstrap, *dsmisssize;
 
 extern void *ap_pcpu;
+extern void __restartkernel(vm_offset_t, vm_offset_t, vm_offset_t, void *, 
uint32_t, register_t offset, register_t msr);
 
+void aim_early_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry,
+void *mdp, uint32_t mdp_cookie);
 void aim_cpu_init(vm_offset_t toc);
 
 void
+aim_early_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void 
*mdp,
+uint32_t mdp_cookie)
+{
+   register_t  scratch;
+
+   /*
+* If running from an FDT, make sure we are in real mode to avoid
+* tromping on firmware page tables. Everything in the kernel assumes
+* 1:1 mappings out of firmware, so this won't break anything not
+* already broken. This doesn't work if there is live OF, since OF
+* may internally use non-1:1 mappings.
+*/
+   if (ofentry == 0)
+   mtmsr(mfmsr() & ~(PSL_IR | PSL_DR));
+
+#ifdef __powerpc64__
+   /*
+* If in real mode, relocate to high memory so that the kernel
+* can execute from the direct map.
+*/
+   if (!(mfmsr() & PSL_DR) &&
+   (vm_offset_t)_early_init < DMAP_BASE_ADDRESS)
+   __restartkernel(fdt, 0, ofentry, mdp, mdp_cookie,
+   DMAP_BASE_ADDRESS, mfmsr());
+#endif
+
+   /* Various very early CPU fix ups */
+   switch (mfpvr() >> 16) {
+   /*
+* PowerPC 970 CPUs have a misfeature requested by Apple that
+* makes them pretend they have a 32-byte cacheline. Turn this
+* off before we measure the cacheline size.
+*/
+   case IBM970:
+   case IBM970FX:
+   case IBM970MP:
+   case IBM970GX:
+   scratch = mfspr(SPR_HID5);
+   scratch &= ~HID5_970_DCBZ_SIZE_HI;
+   mtspr(SPR_HID5, scratch);
+   break;
+   #ifdef __powerpc64__
+   case IBMPOWER7:
+   case IBMPOWER7PLUS:
+   case IBMPOWER8:
+   case IBMPOWER8E:
+   /* XXX: get from ibm,slb-size in device tree */
+   n_slbs = 32;
+   break;
+   #endif
+   }
+}
+
+void
 aim_cpu_init(vm_offset_t toc)
 {
size_t  trap_offset, trapsize;
vm_offset_t trap;
-   register_t  msr, scratch;
+   register_t  msr;
uint8_t *cache_check;
int cacheline_warn;
#ifndef __powerpc64__
@@ -198,32 +255,6 @@ aim_cpu_init(vm_offset_t toc)
 * Bits 1-4, 10-15 (ppc32), 33-36, 42-47 (ppc64)
 */
psl_userstatic &= ~0x783fUL;
-
-   /* Various very early CPU fix ups */
-   switch (mfpvr() >> 16) {
-   /*
-* PowerPC 970 CPUs have a misfeature requested by Apple that
-* makes them pretend they have a 32-byte cacheline. Turn this
-* off before we measure the cacheline size.
-*/
-   case IBM970:
-   case IBM970FX:
-   case IBM970MP:
-   case IBM970GX:
-   scratch = 

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

2018-03-10 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Mar 11 01:09:31 2018
New Revision: 330754
URL: https://svnweb.freebsd.org/changeset/base/330754

Log:
  Make FDT-using parts of ofw_machdep.c condition on options FDT. This fixes
  the kernel build when options FDT is absent.

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

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==
--- head/sys/powerpc/ofw/ofw_machdep.c  Sun Mar 11 00:38:08 2018
(r330753)
+++ head/sys/powerpc/ofw/ofw_machdep.c  Sun Mar 11 01:09:31 2018
(r330754)
@@ -223,6 +223,7 @@ parse_ofw_memory(phandle_t node, const char *prop, str
return (sz);
 }
 
+#ifdef FDT
 static int
 excise_fdt_reserved(struct mem_region *avail, int asz)
 {
@@ -310,6 +311,7 @@ excise_fdt_reserved(struct mem_region *avail, int asz)
 
return (asz);
 }
+#endif
 
 /*
  * This is called during powerpc_init, before the system is really initialized.
@@ -348,9 +350,11 @@ ofw_mem_regions(struct mem_region *memp, int *memsz,
asz += res/sizeof(struct mem_region);
}
 
+#ifdef FDT
phandle = OF_finddevice("/chosen");
if (OF_hasprop(phandle, "fdtmemreserv"))
asz = excise_fdt_reserved(availp, asz);
+#endif
 
*memsz = msz;
*availsz = asz;
@@ -409,6 +413,7 @@ OF_bootstrap()
} else
 #endif
if (fdt != NULL) {
+#ifdef FDT
 #ifdef AIM
bus_space_tag_t fdt_bt;
vm_offset_t tmp_fdt_ptr;
@@ -445,6 +450,7 @@ OF_bootstrap()
err = OF_init((void *)fdt_va);
 #else
err = OF_init(fdt);
+#endif
 #endif
} 
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330610 - in head/sys: dev/vt/hw/ofwfb powerpc/aim powerpc/include powerpc/ofw powerpc/powerpc powerpc/ps3

2018-03-07 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Mar  7 17:08:07 2018
New Revision: 330610
URL: https://svnweb.freebsd.org/changeset/base/330610

Log:
  Move the powerpc64 direct map base address from zero to high memory. This
  accomplishes a few things:
  - Makes NULL an invalid address in the kernel, which is useful for catching
bugs.
  - Lays groundwork for radix-tree translation on POWER9, which requires the
direct map be at high memory.
  - Similarly lays groundwork for a direct map on 64-bit Book-E.
  
  The new base address is chosen as the base of the fourth radix quadrant
  (the minimum kernel address in this translation mode) and because all
  supported CPUs ignore at least the first two bits of addresses in real
  mode, allowing direct-map addresses to be used in real-mode handlers.
  This is required by Linux and is part of the architecture standard
  starting in POWER ISA 3, so can be relied upon.
  
  Reviewed by:  jhibbits, Breno Leitao
  Differential Revision:D14499

Modified:
  head/sys/dev/vt/hw/ofwfb/ofwfb.c
  head/sys/powerpc/aim/aim_machdep.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/moea64_native.c
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/aim/trap_subr64.S
  head/sys/powerpc/include/sr.h
  head/sys/powerpc/include/vmparam.h
  head/sys/powerpc/ofw/ofw_machdep.c
  head/sys/powerpc/ofw/ofw_real.c
  head/sys/powerpc/powerpc/bus_machdep.c
  head/sys/powerpc/powerpc/genassym.c
  head/sys/powerpc/powerpc/mem.c
  head/sys/powerpc/powerpc/uma_machdep.c
  head/sys/powerpc/ps3/platform_ps3.c

Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c
==
--- head/sys/dev/vt/hw/ofwfb/ofwfb.cWed Mar  7 16:55:15 2018
(r330609)
+++ head/sys/dev/vt/hw/ofwfb/ofwfb.cWed Mar  7 17:08:07 2018
(r330610)
@@ -489,7 +489,7 @@ ofwfb_init(struct vt_device *vd)
#if defined(__powerpc__)
OF_decode_addr(node, fb_phys, >sc_memt, >fb.fb_vbase,
NULL);
-   sc->fb.fb_pbase = sc->fb.fb_vbase; /* 1:1 mapped */
+   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)))

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Wed Mar  7 16:55:15 2018
(r330609)
+++ head/sys/powerpc/aim/aim_machdep.c  Wed Mar  7 17:08:07 2018
(r330610)
@@ -455,11 +455,33 @@ va_to_vsid(pmap_t pm, vm_offset_t va)
 
 #endif
 
+/*
+ * These functions need to provide addresses that both (a) work in real mode
+ * (or whatever mode/circumstances the kernel is in in early boot (now)) and
+ * (b) can still, in principle, work once the kernel is going. Because these
+ * rely on existing mappings/real mode, unmap is a no-op.
+ */
 vm_offset_t
 pmap_early_io_map(vm_paddr_t pa, vm_size_t size)
 {
+   KASSERT(!pmap_bootstrapped, ("Not available after PMAP started!"));
 
-   return (pa);
+   /*
+* If we have the MMU up in early boot, assume it is 1:1. Otherwise,
+* try to get the address in a memory region compatible with the
+* direct map for efficiency later.
+*/
+   if (mfmsr() & PSL_DR)
+   return (pa);
+   else
+   return (DMAP_BASE_ADDRESS + pa);
+}
+
+void
+pmap_early_io_unmap(vm_offset_t va, vm_size_t size)
+{
+
+   KASSERT(!pmap_bootstrapped, ("Not available after PMAP started!"));
 }
 
 /* From p3-53 of the MPC7450 RISC Microprocessor Family Reference Manual */

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cWed Mar  7 16:55:15 2018
(r330609)
+++ head/sys/powerpc/aim/mmu_oea64.cWed Mar  7 17:08:07 2018
(r330610)
@@ -551,7 +551,8 @@ moea64_add_ofw_mappings(mmu_t mmup, phandle_t mmu, siz
/* If this address is direct-mapped, skip remapping */
if (hw_direct_map &&
translations[i].om_va == PHYS_TO_DMAP(pa_base) &&
-   moea64_calc_wimg(pa_base + off, VM_MEMATTR_DEFAULT) 
== LPTE_M)
+   moea64_calc_wimg(pa_base + off, VM_MEMATTR_DEFAULT)
+   == LPTE_M)
continue;
 
PMAP_LOCK(kernel_pmap);
@@ -664,25 +665,26 @@ moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernel
  }
}
PMAP_UNLOCK(kernel_pmap);
-   } else {
-   size = moea64_bpvo_pool_size*sizeof(struct pvo_entry);
-   off = (vm_offset_t)(moea64_bpvo_pool);
-   for (pa = off; pa < off + size; pa += PAGE_SIZE) 
-  

svn commit: r330542 - head/sys/powerpc/powernv

2018-03-06 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Mar  6 15:52:43 2018
New Revision: 330542
URL: https://svnweb.freebsd.org/changeset/base/330542

Log:
  Fix use of unitialized variables.

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

Modified: head/sys/powerpc/powernv/opal_pci.c
==
--- head/sys/powerpc/powernv/opal_pci.c Tue Mar  6 15:51:59 2018
(r330541)
+++ head/sys/powerpc/powernv/opal_pci.c Tue Mar  6 15:52:43 2018
(r330542)
@@ -429,6 +429,7 @@ opalpci_read_config(device_t dev, u_int bus, u_int slo
config_addr, reg, vtophys());
break;
default:
+   error = OPAL_SUCCESS;
word = 0x;
}
 

Modified: head/sys/powerpc/powernv/platform_powernv.c
==
--- head/sys/powerpc/powernv/platform_powernv.c Tue Mar  6 15:51:59 2018
(r330541)
+++ head/sys/powerpc/powernv/platform_powernv.c Tue Mar  6 15:52:43 2018
(r330542)
@@ -127,7 +127,7 @@ powernv_attach(platform_t plat)
char buf[255];
pcell_t prop;
phandle_t cpu;
-   int res, len, node, idx;
+   int res, len, idx;
register_t msr;
 
/* Ping OPAL again just to make sure */
@@ -194,7 +194,7 @@ powernv_attach(platform_t plat)
 * for the encoding of the property.
 */
 
-   len = OF_getproplen(node, "ibm,segment-page-sizes");
+   len = OF_getproplen(cpu, "ibm,segment-page-sizes");
if (len > 0) {
/*
 * We have to use a variable length array on the stack
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330371 - head/stand/powerpc/ofw

2018-03-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Mar  4 04:49:09 2018
New Revision: 330371
URL: https://svnweb.freebsd.org/changeset/base/330371

Log:
  Where we can, pass the kernel an FDT facsimile of the OF device tree rather
  than a pointer to Open Firmware by default. This eliminates a number of
  potentially unsafe calls to firmware from the kernel and provides better
  performance.
  
  This feature is meant to be expanded until it is on by default
  unconditionally and, ideally, we can then garbage-collect the
  nightmare pile of hacks required to call into Open Firmware from a live
  kernel.
  
  Reviewed by:  jhibbits

Modified:
  head/stand/powerpc/ofw/main.c

Modified: head/stand/powerpc/ofw/main.c
==
--- head/stand/powerpc/ofw/main.c   Sun Mar  4 03:23:19 2018
(r330370)
+++ head/stand/powerpc/ofw/main.c   Sun Mar  4 04:49:09 2018
(r330371)
@@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$");
 #include "libofw.h"
 #include "bootstrap.h"
 
+#include 
+
 struct arch_switch archsw; /* MI/MD interface boundary */
 
 extern char end[];
@@ -47,6 +49,16 @@ static char heap[HEAP_SIZE]; // In BSS, so uses no spa
 
 #define OF_puts(fd, text) OF_write(fd, text, strlen(text))
 
+static __inline register_t
+mfmsr(void)
+{
+   register_t value;
+
+   __asm __volatile ("mfmsr %0" : "=r"(value));
+
+   return (value);
+}
+
 void
 init_heap(void)
 {
@@ -144,6 +156,15 @@ main(int (*openfirm)(void *))
env_setenv("loaddev", EV_VOLATILE, bootpath, env_noset,
env_nounset);
setenv("LINES", "24", 1);   /* optional */
+
+   /*
+* On non-Apple hardware, where it works reliably, pass flattened
+* device trees to the kernel by default instead of OF CI pointers.
+* Apple hardware is the only virtual-mode OF implementation in
+* existence, so far as I am aware, so use that as a flag.
+*/
+   if (!(mfmsr() & PSL_DR))
+   setenv("usefdt", "1", 1);
 
archsw.arch_getdev = ofw_getdev;
archsw.arch_copyin = ofw_copyin;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330365 - in head/stand: ofw/common ofw/libofw powerpc/ofw

2018-03-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Mar  3 23:39:07 2018
New Revision: 330365
URL: https://svnweb.freebsd.org/changeset/base/330365

Log:
  Move "common" Open Firmware parts of the loader used only on PowerPC to
  the powerpc/ subdirectory. These have never used by SPARC and we have
  no other (and almost certainly will have no other) Open Firmware platforms.
  This makes the directory structure simpler and lets us avoid some
  cargo-cult MI patterns on code that is, and always was,
  architecture-specific.

Added:
  head/stand/powerpc/ofw/elf_freebsd.c
 - copied, changed from r330364, head/stand/ofw/libofw/elf_freebsd.c
  head/stand/powerpc/ofw/main.c
 - copied unchanged from r330364, head/stand/ofw/common/main.c
  head/stand/powerpc/ofw/ppc64_elf_freebsd.c
 - copied unchanged from r330364, head/stand/ofw/libofw/ppc64_elf_freebsd.c
Deleted:
  head/stand/ofw/common/
  head/stand/ofw/libofw/elf_freebsd.c
  head/stand/ofw/libofw/ppc64_elf_freebsd.c
Modified:
  head/stand/ofw/libofw/Makefile
  head/stand/ofw/libofw/libofw.h
  head/stand/powerpc/ofw/Makefile
  head/stand/powerpc/ofw/conf.c

Modified: head/stand/ofw/libofw/Makefile
==
--- head/stand/ofw/libofw/Makefile  Sat Mar  3 23:23:23 2018
(r330364)
+++ head/stand/ofw/libofw/Makefile  Sat Mar  3 23:39:07 2018
(r330365)
@@ -4,7 +4,7 @@
 
 LIB=   ofw
 
-SRCS=  devicename.c elf_freebsd.c ofw_console.c ofw_copy.c ofw_disk.c \
+SRCS=  devicename.c ofw_console.c ofw_copy.c ofw_disk.c \
ofw_memory.c ofw_module.c ofw_net.c ofw_reboot.c \
ofw_time.c openfirm.c
 .PATH: ${ZFSSRC}
@@ -12,10 +12,6 @@ SRCS+=  devicename_stubs.c
 
 # Pick up the bootstrap header for some interface items
 CFLAGS+=   -I${LDRSRC}
-
-.if ${MACHINE_CPUARCH} == "powerpc"
-SRCS+= ppc64_elf_freebsd.c
-.endif
 
 .ifdef(BOOT_DISK_DEBUG)
 # Make the disk code more talkative

Modified: head/stand/ofw/libofw/libofw.h
==
--- head/stand/ofw/libofw/libofw.h  Sat Mar  3 23:23:23 2018
(r330364)
+++ head/stand/ofw/libofw/libofw.h  Sat Mar  3 23:39:07 2018
(r330365)
@@ -62,17 +62,9 @@ void ofw_memmap(int);
 struct preloaded_file;
 struct file_format;
 
-intofw_elf_loadfile(char *, vm_offset_t, struct preloaded_file **);
-intofw_elf_exec(struct preloaded_file *);
-
 /* MD code implementing MI interfaces */
 vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
 vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
-
-extern struct file_format  ofw_elf;
-#ifdef __powerpc__
-extern struct file_format  ofw_elf64;
-#endif
 
 extern voidreboot(void);
 

Modified: head/stand/powerpc/ofw/Makefile
==
--- head/stand/powerpc/ofw/Makefile Sat Mar  3 23:23:23 2018
(r330364)
+++ head/stand/powerpc/ofw/Makefile Sat Mar  3 23:39:07 2018
(r330365)
@@ -17,7 +17,7 @@ NEWVERSWHAT=  "Open Firmware loader" ${MACHINE_ARCH}
 INSTALLFLAGS=  -b
 
 # Architecture-specific loader code
-SRCS=  conf.c vers.c start.c
+SRCS=  conf.c vers.c main.c elf_freebsd.c ppc64_elf_freebsd.c start.c
 SRCS+= ucmpdi2.c
 
 .include   "${BOOTSRC}/fdt.mk"
@@ -37,10 +37,6 @@ RELOC?=  0x1C0
 CFLAGS+=   -DRELOC=${RELOC}
 
 LDFLAGS=   -nostdlib -static -T ${.CURDIR}/ldscript.powerpc
-
-# Pull in common loader code
-.PATH: ${BOOTSRC}/ofw/common
-.include   "${BOOTSRC}/ofw/common/Makefile.inc"
 
 # Open Firmware standalone support library
 LIBOFW=${BOOTOBJ}/ofw/libofw/libofw.a

Modified: head/stand/powerpc/ofw/conf.c
==
--- head/stand/powerpc/ofw/conf.c   Sat Mar  3 23:23:23 2018
(r330364)
+++ head/stand/powerpc/ofw/conf.c   Sat Mar  3 23:39:07 2018
(r330365)
@@ -97,6 +97,9 @@ struct netif_driver *netif_drivers[] = {
  * rather than reading the file go first.
  */
 
+struct file_format ofw_elf;
+struct file_format ofw_elf64;
+
 struct file_format *file_formats[] = {
 _elf,
 _elf64,

Copied and modified: head/stand/powerpc/ofw/elf_freebsd.c (from r330364, 
head/stand/ofw/libofw/elf_freebsd.c)
==
--- head/stand/ofw/libofw/elf_freebsd.c Sat Mar  3 23:23:23 2018
(r330364, copy source)
+++ head/stand/powerpc/ofw/elf_freebsd.cSat Mar  3 23:39:07 2018
(r330365)
@@ -89,8 +89,8 @@ __elfN(ofw_exec)(struct preloaded_file *fp)
dev_cleanup();
if (dtbp != 0) {
OF_quiesce();
-   ((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, 
0, 0,
-   (void *)mdp, sizeof(mdp));
+   ((int (*)(u_long, u_long, u_long, void *, 

svn commit: r330306 - head/sys/powerpc/ps3

2018-03-02 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Mar  3 02:06:48 2018
New Revision: 330306
URL: https://svnweb.freebsd.org/changeset/base/330306

Log:
  Honor physical memory regions marked unavailable in the FDT, when present.
  The most notable of these is the FDT itself, which it is a bad idea to
  overwrite.

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

Modified: head/sys/powerpc/ps3/platform_ps3.c
==
--- head/sys/powerpc/ps3/platform_ps3.c Sat Mar  3 02:04:40 2018
(r330305)
+++ head/sys/powerpc/ps3/platform_ps3.c Sat Mar  3 02:06:48 2018
(r330306)
@@ -141,37 +141,38 @@ void
 ps3_mem_regions(platform_t plat, struct mem_region *phys, int *physsz,
 struct mem_region *avail_regions, int *availsz)
 {
-   uint64_t lpar_id, junk, ppe_id;
+   uint64_t lpar_id, junk;
+   int i;
 
-   /* Get real mode memory region */
-   avail_regions[0].mr_start = 0;
-   lv1_get_logical_partition_id(_id);
-   lv1_get_logical_ppe_id(_id);
-   lv1_get_repository_node_value(lpar_id,
-   lv1_repository_string("bi") >> 32, lv1_repository_string("pu"),
-   ppe_id, lv1_repository_string("rm_size"),
-   _regions[0].mr_size, );
+   /* Prefer device tree information if available */
+   if (OF_finddevice("/") != -1) {
+   ofw_mem_regions(phys, physsz, avail_regions, availsz);
+   } else {
+   /* Real mode memory region is first segment */
+   phys[0].mr_start = 0;
+   phys[0].mr_size = ps3_real_maxaddr(plat);
+   *physsz = *availsz = 1;
+   avail_regions[0] = phys[0];
+   }
 
/* Now get extended memory region */
+   lv1_get_logical_partition_id(_id);
lv1_get_repository_node_value(lpar_id,
lv1_repository_string("bi") >> 32,
lv1_repository_string("rgntotal"), 0, 0,
-   _regions[1].mr_size, );
+   [*physsz].mr_size, );
+   for (i = 0; i < *physsz; i++)
+   phys[*physsz].mr_size -= phys[i].mr_size;
 
/* Convert to maximum amount we can allocate in 16 MB pages */
-   avail_regions[1].mr_size -= avail_regions[0].mr_size;
-   avail_regions[1].mr_size -= avail_regions[1].mr_size % (16*1024*1024);
+   phys[*physsz].mr_size -= phys[*physsz].mr_size % (16*1024*1024);
 
/* Allocate extended memory region */
-   lv1_allocate_memory(avail_regions[1].mr_size, 24 /* 16 MB pages */,
-   0, 0x04 /* any address */, _regions[1].mr_start, );
-
-   *availsz = 2;
-
-   if (phys != NULL) {
-   memcpy(phys, avail_regions, sizeof(*phys)*2);
-   *physsz = 2;
-   }
+   lv1_allocate_memory(phys[*physsz].mr_size, 24 /* 16 MB pages */,
+   0, 0x04 /* any address */, [*physsz].mr_start, );
+   avail_regions[*availsz] = phys[*physsz];
+   (*physsz)++;
+   (*availsz)++;
 }
 
 static u_long
@@ -260,12 +261,22 @@ ps3_reset(platform_t plat)
 static vm_offset_t
 ps3_real_maxaddr(platform_t plat)
 {
-   struct mem_region *phys, *avail;
-   int nphys, navail;
+   uint64_t lpar_id, junk, ppe_id;
+   static uint64_t rm_maxaddr = 0;
 
-   mem_regions(, , , );
+   if (rm_maxaddr == 0) {
+   /* Get real mode memory region */
+   lv1_get_logical_partition_id(_id);
+   lv1_get_logical_ppe_id(_id);
 
-   return (phys[0].mr_start + phys[0].mr_size);
+   lv1_get_repository_node_value(lpar_id,
+   lv1_repository_string("bi") >> 32,
+   lv1_repository_string("pu"),
+   ppe_id, lv1_repository_string("rm_size"),
+   _maxaddr, );
+   }
+   
+   return (rm_maxaddr);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330305 - in head/sys/powerpc: powerpc ps3

2018-03-02 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Mar  3 02:04:40 2018
New Revision: 330305
URL: https://svnweb.freebsd.org/changeset/base/330305

Log:
  Remove assumption that all physical memory is available to the kernel and
  that the physical and available memory arrays are interchangeable.

Modified:
  head/sys/powerpc/powerpc/platform.c
  head/sys/powerpc/ps3/ps3bus.c

Modified: head/sys/powerpc/powerpc/platform.c
==
--- head/sys/powerpc/powerpc/platform.c Sat Mar  3 01:53:51 2018
(r330304)
+++ head/sys/powerpc/powerpc/platform.c Sat Mar  3 02:04:40 2018
(r330305)
@@ -156,10 +156,14 @@ mem_regions(struct mem_region **phys, int *physsz, str
}
}
 
-   *phys = pregions;
-   *avail = aregions;
-   *physsz = npregions;
-   *availsz = naregions;
+   if (phys != NULL)
+   *phys = pregions;
+   if (avail != NULL)
+   *avail = aregions;
+   if (physsz != NULL)
+   *physsz = npregions;
+   if (availsz != NULL)
+   *availsz = naregions;
 }
 
 int

Modified: head/sys/powerpc/ps3/ps3bus.c
==
--- head/sys/powerpc/ps3/ps3bus.c   Sat Mar  3 01:53:51 2018
(r330304)
+++ head/sys/powerpc/ps3/ps3bus.c   Sat Mar  3 02:04:40 2018
(r330305)
@@ -337,7 +337,7 @@ ps3bus_attach(device_t self) 
rman_manage_region(>sc_intr_rman, 0, ~0);
 
/* Get memory regions for DMA */
-   mem_regions(>regions, >rcount, >regions, >rcount);
+   mem_regions(>regions, >rcount, NULL, NULL);
 
/*
 * Probe all the PS3's buses.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r330240 - in head/sys: conf powerpc/conf powerpc/powernv

2018-03-01 Thread Nathan Whitehorn



On 03/01/18 06:11, Wojciech Macek wrote:

Author: wma
Date: Thu Mar  1 14:11:07 2018
New Revision: 330240
URL: https://svnweb.freebsd.org/changeset/base/330240

Log:
   PowerNV: Initial support for OPAL I2C transfers
   
   Add I2C OPAL driver and a set of dummy-ones to allow

   all I2C things on Power8 to attach.
   
   TODO: better async token management
   
   Submitted by:  Wojciech Macek 

   Obtained from: Semihalf
   Sponsored by:  IBM, QCM Technologies

Added:
   head/sys/powerpc/powernv/opal_i2c.c   (contents, props changed)
   head/sys/powerpc/powernv/opal_i2cm.c   (contents, props changed)
   head/sys/powerpc/powernv/powernv_centaur.c   (contents, props changed)
   head/sys/powerpc/powernv/powernv_xscom.c   (contents, props changed)
Modified:
   head/sys/conf/files.powerpc
   head/sys/powerpc/conf/GENERIC64
   head/sys/powerpc/powernv/opal.h

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Thu Mar  1 13:52:18 2018(r330239)
+++ head/sys/conf/files.powerpc Thu Mar  1 14:11:07 2018(r330240)
@@ -186,9 +186,13 @@ powerpc/powermac/vcoregpio.c   optionalpowermac
  powerpc/powernv/opal.coptionalpowernv
  powerpc/powernv/opal_console.coptionalpowernv
  powerpc/powernv/opal_dev.coptionalpowernv
+powerpc/powernv/opal_i2c.c optionaliicbus fdt powernv
+powerpc/powernv/opal_i2cm.coptionaliicbus fdt powernv


These don't use FDT functions directly (and shouldn't), so you should 
remove the fdt part on the right. We only gate on 'options FDT' for 
things that are really FDT- (as opposed to OF-) specific.



  powerpc/powernv/opal_pci.coptionalpowernv pci
  powerpc/powernv/opalcall.Soptionalpowernv
  powerpc/powernv/platform_powernv.c optional   powernv
+powerpc/powernv/powernv_centaur.c  optionalpowernv
+powerpc/powernv/powernv_xscom.coptionalpowernv
  powerpc/powerpc/altivec.c optionalpowerpc | powerpc64
  powerpc/powerpc/autoconf.cstandard
  powerpc/powerpc/bcopy.c   standard

Modified: head/sys/powerpc/conf/GENERIC64
==
--- head/sys/powerpc/conf/GENERIC64 Thu Mar  1 13:52:18 2018
(r330239)
+++ head/sys/powerpc/conf/GENERIC64 Thu Mar  1 14:11:07 2018
(r330240)
@@ -206,6 +206,7 @@ device  fwe # Ethernet over 
FireWire (non-standard!)
  
  # Misc

  deviceiicbus  # I2C bus code
+device iic


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


svn commit: r329941 - head/sys/powerpc/ps3

2018-02-24 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Feb 24 22:34:56 2018
New Revision: 329941
URL: https://svnweb.freebsd.org/changeset/base/329941

Log:
  Avoid dereferencing random memory when kickstarting DMA.
  
  MFC after: 1 week

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

Modified: head/sys/powerpc/ps3/if_glc.c
==
--- head/sys/powerpc/ps3/if_glc.c   Sat Feb 24 21:28:05 2018
(r329940)
+++ head/sys/powerpc/ps3/if_glc.c   Sat Feb 24 22:34:56 2018
(r329941)
@@ -832,7 +832,8 @@ glc_txintr(struct glc_softc *sc)
/* Speculatively (or necessarily) start the TX queue again */
error = lv1_net_start_tx_dma(sc->sc_bus, sc->sc_dev,
sc->sc_txdmadesc_phys +
-   txs->txs_firstdesc*sizeof(struct glc_dmadesc), 0);
+   ((txs == NULL) ? 0 : txs->txs_firstdesc)*
+sizeof(struct glc_dmadesc), 0);
if (error != 0)
device_printf(sc->sc_self,
"lv1_net_start_tx_dma error: %d\n", error);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-02-21 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Feb 21 15:15:58 2018
New Revision: 329721
URL: https://svnweb.freebsd.org/changeset/base/329721

Log:
  Add definition for the PowerPC A2.

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

Modified: head/sys/powerpc/include/spr.h
==
--- head/sys/powerpc/include/spr.h  Wed Feb 21 15:15:31 2018
(r329720)
+++ head/sys/powerpc/include/spr.h  Wed Feb 21 15:15:58 2018
(r329721)
@@ -170,6 +170,7 @@
 #define  IBMPOWER3PLUS   0x0041
 #define  IBM970MP0x0044
 #define  IBM970GX0x0045
+#define  IBMPOWERPCA20x0049
 #define  IBMPOWER7PLUS   0x004a
 #define  IBMPOWER8E  0x004b
 #define  IBMPOWER8   0x004d
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-02-21 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Feb 21 15:15:31 2018
New Revision: 329720
URL: https://svnweb.freebsd.org/changeset/base/329720

Log:
  Add definitions for the new Radix MMU mode on POWER9+ CPUs.

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

Modified: head/sys/powerpc/include/pte.h
==
--- head/sys/powerpc/include/pte.h  Wed Feb 21 15:12:14 2018
(r329719)
+++ head/sys/powerpc/include/pte.h  Wed Feb 21 15:15:31 2018
(r329720)
@@ -125,6 +125,37 @@ struct lpteg {
 #defineLPTE_RW LPTE_BW
 #defineLPTE_RO LPTE_BR
 
+/* POWER ISA 3.0 Radix Table Definitions */
+#defineRPTE_VALID  0x8000ULL
+#defineRPTE_LEAF   0x4000ULL /* is a PTE: 
always 1 */
+#defineRPTE_SW00x2000ULL
+#defineRPTE_RPN_MASK   0x00FFF000ULL
+#defineRPTE_RPN_SHIFT  12
+#defineRPTE_SW10x0800ULL
+#defineRPTE_SW20x0400ULL
+#defineRPTE_SW30x0200ULL
+#defineRPTE_R  0x0100ULL
+#defineRPTE_C  0x0080ULL
+
+#defineRPTE_ATTR_MASK  0x0030ULL
+#defineRPTE_ATTR_MEM   0xULL /* PTE M */
+#defineRPTE_ATTR_SAO   0x0010ULL /* PTE WIM */
+#defineRPTE_ATTR_GUARDEDIO 0x0020ULL /* PTE IMG */
+#defineRPTE_ATTR_UNGUARDEDIO   0x0030ULL /* PTE IM */
+
+#defineRPTE_EAA_MASK   0x000FULL
+#defineRPTE_EAA_P  0x0008ULL /* Supervisor 
only */
+#defineRPTE_EAA_R  0x0004ULL /* Read allowed */
+#defineRPTE_EAA_W  0x0002ULL /* Write (+read) 
*/
+#defineRPTE_EAA_X  0x0001ULL /* Execute 
allowed */
+
+#defineRPDE_VALID  RPTE_VALID
+#defineRPDE_LEAF   RPTE_LEAF /* is a PTE: 
always 0 */
+#defineRPDE_NLB_MASK   0x0F00ULL
+#defineRPDE_NLB_SHIFT  8
+#defineRPDE_NLS_MASK   0x001FULL
+
+
 #ifndefLOCORE
 typedefstruct pte pte_t;
 typedefstruct lpte lpte_t;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r329579 - in head/sys: dev/ofw powerpc/ofw

2018-02-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Feb 19 15:49:14 2018
New Revision: 329579
URL: https://svnweb.freebsd.org/changeset/base/329579

Log:
  Set internal error returns for OF_peer(), OF_child(), and OF_parent() to
  zero, matching the IEEE 1275 standard. Since these internal error paths
  have never, to my knowledge, been taken, behavior is unchanged.
  
  Reported by:  gonzo
  MFC after:2 weeks

Modified:
  head/sys/dev/ofw/ofw_standard.c
  head/sys/powerpc/ofw/ofw_real.c

Modified: head/sys/dev/ofw/ofw_standard.c
==
--- head/sys/dev/ofw/ofw_standard.c Mon Feb 19 15:47:09 2018
(r329578)
+++ head/sys/dev/ofw/ofw_standard.c Mon Feb 19 15:49:14 2018
(r329579)
@@ -232,7 +232,7 @@ ofw_std_peer(ofw_t ofw, phandle_t node)
 
args.node = node;
if (openfirmware() == -1)
-   return (-1);
+   return (0);
return (args.next);
 }
 
@@ -254,7 +254,7 @@ ofw_std_child(ofw_t ofw, phandle_t node)
 
args.node = node;
if (openfirmware() == -1)
-   return (-1);
+   return (0);
return (args.child);
 }
 
@@ -276,7 +276,7 @@ ofw_std_parent(ofw_t ofw, phandle_t node)
 
args.node = node;
if (openfirmware() == -1)
-   return (-1);
+   return (0);
return (args.parent);
 }
 

Modified: head/sys/powerpc/ofw/ofw_real.c
==
--- head/sys/powerpc/ofw/ofw_real.c Mon Feb 19 15:47:09 2018
(r329578)
+++ head/sys/powerpc/ofw/ofw_real.c Mon Feb 19 15:49:14 2018
(r329579)
@@ -366,7 +366,7 @@ ofw_real_peer(ofw_t ofw, phandle_t node)
argsptr = ofw_real_map(, sizeof(args));
if (openfirmware((void *)argsptr) == -1) {
ofw_real_stop();
-   return (-1);
+   return (0);
}
ofw_real_unmap(argsptr, , sizeof(args));
ofw_real_stop();
@@ -395,7 +395,7 @@ ofw_real_child(ofw_t ofw, phandle_t node)
argsptr = ofw_real_map(, sizeof(args));
if (openfirmware((void *)argsptr) == -1) {
ofw_real_stop();
-   return (-1);
+   return (0);
}
ofw_real_unmap(argsptr, , sizeof(args));
ofw_real_stop();
@@ -424,7 +424,7 @@ ofw_real_parent(ofw_t ofw, phandle_t node)
argsptr = ofw_real_map(, sizeof(args));
if (openfirmware((void *)argsptr) == -1) {
ofw_real_stop();
-   return (-1);
+   return (0);
}
ofw_real_unmap(argsptr, , sizeof(args));
ofw_real_stop();
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r329257 - head/sys/powerpc/pseries

2018-02-13 Thread Nathan Whitehorn
There is another set of these that Linux added recently that are used 
for Meltdown/Spectre workarounds. Might be worth importing while these 
are being updated...

-Nathan

On 02/13/18 18:48, Justin Hibbits wrote:

Author: jhibbits
Date: Wed Feb 14 02:48:27 2018
New Revision: 329257
URL: https://svnweb.freebsd.org/changeset/base/329257

Log:
   powerpc64/pseries: Define new hcalls
   
   Summary:

   Define new hcalls as in 'Linux on Power Architecture Platform Reference'
   version 1.1 (24 March 2016) downloaded from:
   
   https://members.openpowerfoundation.org/document/dl/469
   
   Submitted by:	Breno Leitao

   Differential Revision:   https://reviews.freebsd.org/D14281

Modified:
   head/sys/powerpc/pseries/phyp-hvcall.h

Modified: head/sys/powerpc/pseries/phyp-hvcall.h
==
--- head/sys/powerpc/pseries/phyp-hvcall.h  Wed Feb 14 00:34:02 2018
(r329256)
+++ head/sys/powerpc/pseries/phyp-hvcall.h  Wed Feb 14 02:48:27 2018
(r329257)
@@ -296,7 +296,25 @@
  #define H_VPM_STAT0x2bc
  #define H_SET_MPP 0x2d0
  #define H_GET_MPP 0x2d4
-#define MAX_HCALL_OPCODE   H_GET_MPP
+#define H_MO_PERF  0x2d8
+#define H_REG_SUB_CRQ  0x2dc
+#define H_FREE_SUB_CRQ 0x2e0
+#define H_SEND_SUB_CRQ 0x2e4
+#define H_SEND_SUB_CRQ_IND 0x2e8
+#define H_HOME_NODE_ASSOC  0x2ec
+/* Reserved ... */
+#define H_BEST_ENERGY  0x2f4
+#define H_REG_SNS  0x2f8
+#define H_X_XIRR   0x2fc
+#define H_RANDOM   0x300
+/* Reserved ... */
+#define H_COP_OP   0x304
+#define H_STOP_COP_OP  0x308
+#define H_GET_MPP_X0x314
+#define H_SET_MODE 0x31C
+/* Reserved ... */
+#define H_GET_DMA_XLATES_L 0x324
+#define MAX_HCALL_OPCODE   H_GET_DMA_XLATES_L
  
  int64_t phyp_hcall(uint64_t opcode, ...);

  int64_t phyp_pft_hcall(uint64_t opcode, uint64_t flags, uint64_t pteidx,



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


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

2018-02-09 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Feb  9 20:09:32 2018
New Revision: 329080
URL: https://svnweb.freebsd.org/changeset/base/329080

Log:
  Fix PowerMac G5 thermal management, plus likely other bugs, introduced in
  r328113 and affecting SMP systems.
  
  The way the time is set on PowerMacs is racy and relies on all the
  CPUs in the system setting a register simultaneously in a rendezvous. A
  few-cycle delay can result in out-of-sync times, which can break the
  scheduler and result in calls like mtx_sleep() and pause() never timing out
  if the thread is migrated while sleeping. r328113 added a call to a no-op
  function between the beginning of the rendezvous and setting the time that
  was only called on APs and added enough cycles to cause a problematic offset.
  For some reason, the fan-management code was the first place this appeared.
  
  Clue from:andreast
  Reported by:  many

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

Modified: head/sys/powerpc/powerpc/mp_machdep.c
==
--- head/sys/powerpc/powerpc/mp_machdep.c   Fri Feb  9 20:00:51 2018
(r329079)
+++ head/sys/powerpc/powerpc/mp_machdep.c   Fri Feb  9 20:09:32 2018
(r329080)
@@ -81,11 +81,20 @@ machdep_ap_bootstrap(void)
__asm __volatile("or 27,27,27");
__asm __volatile("or 6,6,6");
 
-   /* Give platform code a chance to do anything necessary */
+   /*
+* Set timebase as soon as possible to meet an implicit rendezvous
+* from cpu_mp_unleash(), which sets ap_letgo and then immediately
+* sets timebase.
+*
+* Note that this is instrinsically racy and is only relevant on
+* platforms that do not support better mechanisms.
+*/
+   platform_smp_timebase_sync(ap_timebase, 1);
+
+   /* Give platform code a chance to do anything else necessary */
platform_smp_ap_init();
 
-   /* Initialize DEC and TB, sync with the BSP values */
-   platform_smp_timebase_sync(ap_timebase, 1);
+   /* Initialize decrementer */
decr_ap_init();
 
/* Serialize console output and AP count increment */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r328835 - in head/stand: ofw/common ofw/libofw powerpc/ofw

2018-02-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Feb  3 23:49:21 2018
New Revision: 328835
URL: https://svnweb.freebsd.org/changeset/base/328835

Log:
  Fix regression introduced in r328806, preventing boot at least on all
  PowerPC Apple hardware, and likely all Open Firmware systems.
  
  The loader would allocate memory for its heap at whatever address Open
  Firmware gave it, which would in general be the lowest unallocated address,
  usually starting a page or two above 0. As the kernel is linked at 1 MB,
  and loader insists on running the kernel at its link address, any heap
  larger than 1 MB would overlap the kernel, causing loader memory allocations
  to corrupt the kernel and vice versa.
  
  Although r328806 made this problem much worse by increasing the heap size
  to 8 MB, causing 88% of the loader heap to overlap with the kernel, the
  problem has always existed. The old heap size was 1 MB and, unless that
  started exactly at zero, which would cause other problems, some number of
  pages of the loader heap still overlapped with the kernel.
  
  This patch solves the issue in two ways and cleans up some related code:
  - Moves the loader heap inside of the loader. This guarantees that the
heap will be contiguous with the loader and simplifies the heap
allocation code at no cost, since the heap lives in BSS.
  - Moves the loader, previously at 28 MB and dangerously close to the kernel
it loads, a bit higher to 44 MB. This has the effect of breaking loader
on non-embedded PPC machines with < 48 MB of RAM, but we did not support
those anyway.
  
  The fundamental problem is that the way loader loads ELF files is
  incredibly fragile, but that can't be fixed without fundamental
  architectural changes.
  
  MFC after:10 days

Modified:
  head/stand/ofw/common/main.c
  head/stand/ofw/libofw/elf_freebsd.c
  head/stand/ofw/libofw/libofw.h
  head/stand/ofw/libofw/ofw_copy.c
  head/stand/ofw/libofw/ofw_memory.c
  head/stand/ofw/libofw/ppc64_elf_freebsd.c
  head/stand/powerpc/ofw/ldscript.powerpc

Modified: head/stand/ofw/common/main.c
==
--- head/stand/ofw/common/main.cSat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/ofw/common/main.cSat Feb  3 23:49:21 2018
(r328835)
@@ -43,22 +43,16 @@ u_int32_t   acells, scells;
 static char bootargs[128];
 
 #defineHEAP_SIZE   0x80
+static char heap[HEAP_SIZE]; // In BSS, so uses no space
 
 #define OF_puts(fd, text) OF_write(fd, text, strlen(text))
 
 void
 init_heap(void)
 {
-   void*base;
-   ihandle_t stdout;
+   bzero(heap, HEAP_SIZE);
 
-   if ((base = ofw_alloc_heap(HEAP_SIZE)) == (void *)0x) {
-   OF_getprop(chosen, "stdout", , sizeof(stdout));
-   OF_puts(stdout, "Heap memory claim failed!\n");
-   OF_enter();
-   }
-
-   setheap(base, (void *)((int)base + HEAP_SIZE));
+   setheap(heap, (void *)((int)heap + HEAP_SIZE));
 }
 
 uint64_t

Modified: head/stand/ofw/libofw/elf_freebsd.c
==
--- head/stand/ofw/libofw/elf_freebsd.c Sat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/ofw/libofw/elf_freebsd.c Sat Feb  3 23:49:21 2018
(r328835)
@@ -87,7 +87,6 @@ __elfN(ofw_exec)(struct preloaded_file *fp)
printf("Kernel entry at 0x%lx ...\n", e->e_entry);
 
dev_cleanup();
-   ofw_release_heap();
if (dtbp != 0) {
OF_quiesce();
((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, 
0, 0,

Modified: head/stand/ofw/libofw/libofw.h
==
--- head/stand/ofw/libofw/libofw.h  Sat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/ofw/libofw/libofw.h  Sat Feb  3 23:49:21 2018
(r328835)
@@ -58,8 +58,6 @@ extern intofw_boot(void);
 extern int ofw_autoload(void);
 
 void   ofw_memmap(int);
-void   *ofw_alloc_heap(unsigned int);
-void   ofw_release_heap(void);
 
 struct preloaded_file;
 struct file_format;

Modified: head/stand/ofw/libofw/ofw_copy.c
==
--- head/stand/ofw/libofw/ofw_copy.cSat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/ofw/libofw/ofw_copy.cSat Feb  3 23:49:21 2018
(r328835)
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$");
 #defineREADIN_BUF  (4 * 1024)
 #definePAGE_SIZE   0x1000
 #definePAGE_MASK   0x0fff
-#define MAPMEM_PAGE_INC 16
+#defineMAPMEM_PAGE_INC 128 /* Half-MB at a time */
 
 
 #defineroundup(x, y)   x)+((y)-1))/(y))*(y))

Modified: head/stand/ofw/libofw/ofw_memory.c
==
--- head/stand/ofw/libofw/ofw_memory.c  Sat Feb  3 23:14:11 2018
(r328834)
+++ 

svn commit: r328651 - in head/sys/powerpc: aim booke include powerpc

2018-01-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Feb  1 05:31:24 2018
New Revision: 328651
URL: https://svnweb.freebsd.org/changeset/base/328651

Log:
  Change the default MSR values used when starting userland and kernel
  threads from compile-time defines to global variables. This removes a
  significant amount of duplicated runtime patches to the compile-time
  defines, centralizing the conditional logic in the early startup code.
  
  Reviewed by:  jhibbits

Modified:
  head/sys/powerpc/aim/aim_machdep.c
  head/sys/powerpc/aim/mp_cpudep.c
  head/sys/powerpc/booke/booke_machdep.c
  head/sys/powerpc/include/psl.h
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/powerpc/powerpc/genassym.c
  head/sys/powerpc/powerpc/machdep.c
  head/sys/powerpc/powerpc/vm_machdep.c

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Thu Feb  1 05:28:02 2018
(r328650)
+++ head/sys/powerpc/aim/aim_machdep.c  Thu Feb  1 05:31:24 2018
(r328651)
@@ -178,6 +178,27 @@ aim_cpu_init(vm_offset_t toc)
trap_offset = 0;
cacheline_warn = 0;
 
+   /* General setup for AIM CPUs */
+   psl_kernset = PSL_EE | PSL_ME | PSL_IR | PSL_DR | PSL_RI;
+
+#ifdef __powerpc64__
+   psl_kernset |= PSL_SF;
+   if (mfmsr() & PSL_HV)
+   psl_kernset |= PSL_HV;
+#endif
+   psl_userset = psl_kernset | PSL_PR;
+#ifdef __powerpc64__
+   psl_userset32 = psl_userset & ~PSL_SF;
+#endif
+
+   /* Bits that users aren't allowed to change */
+   psl_userstatic = ~(PSL_VEC | PSL_FP | PSL_FE0 | PSL_FE1);
+   /*
+* Mask bits from the SRR1 that aren't really the MSR:
+* Bits 1-4, 10-15 (ppc32), 33-36, 42-47 (ppc64)
+*/
+   psl_userstatic &= ~0x783fUL;
+
/* Various very early CPU fix ups */
switch (mfpvr() >> 16) {
/*

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cThu Feb  1 05:28:02 2018
(r328650)
+++ head/sys/powerpc/aim/mp_cpudep.cThu Feb  1 05:31:24 2018
(r328651)
@@ -111,7 +111,7 @@ cpudep_ap_bootstrap(void)
 {
register_t msr, sp;
 
-   msr = PSL_KERNSET & ~PSL_EE;
+   msr = psl_kernset & ~PSL_EE;
mtmsr(msr);
 
pcpup->pc_curthread = pcpup->pc_idlethread;

Modified: head/sys/powerpc/booke/booke_machdep.c
==
--- head/sys/powerpc/booke/booke_machdep.c  Thu Feb  1 05:28:02 2018
(r328650)
+++ head/sys/powerpc/booke/booke_machdep.c  Thu Feb  1 05:31:24 2018
(r328651)
@@ -210,6 +210,16 @@ booke_cpu_init(void)
 
cpu_features |= PPC_FEATURE_BOOKE;
 
+   psl_kernset = PSL_CE | PSL_ME | PSL_EE;
+#ifdef __powerpc64__
+   psl_kernset |= PSL_CM;
+#endif
+   psl_userset = psl_kernset | PSL_PR;
+#ifdef __powerpc64__
+   psl_userset32 = psl_kernset & ~PSL_CM;
+#endif
+   psl_userstatic = ~(PSL_VEC | PSL_FP | PSL_FE0 | PSL_FE1);
+
pmap_mmu_install(MMU_TYPE_BOOKE, BUS_PROBE_GENERIC);
 }
 

Modified: head/sys/powerpc/include/psl.h
==
--- head/sys/powerpc/include/psl.h  Thu Feb  1 05:28:02 2018
(r328650)
+++ head/sys/powerpc/include/psl.h  Thu Feb  1 05:31:24 2018
(r328651)
@@ -90,28 +90,13 @@
 #definePSL_FE_PREC (PSL_FE0 | PSL_FE1) /* precise */
 #definePSL_FE_DFLT PSL_FE_DIS  /* default == none */
 
-#if defined(BOOKE_E500)
-/* Initial kernel MSR, use IS=1 ad DS=1. */
-#define PSL_KERNSET_INIT   (PSL_IS | PSL_DS)
+#ifndef LOCORE
+extern register_t psl_kernset; /* Default MSR values for kernel */
+extern register_t psl_userset; /* Default MSR values for userland */
 #ifdef __powerpc64__
-#define PSL_KERNSET(PSL_CM | PSL_CE | PSL_ME | PSL_EE)
-#else
-#define PSL_KERNSET(PSL_CE | PSL_ME | PSL_EE)
+extern register_t psl_userset32;   /* Default user MSR values for 32-bit */
 #endif
-#define PSL_SRR1_MASK  0xUL/* No mask on Book-E */
-#elif defined(BOOKE_PPC4XX)
-#define PSL_KERNSET(PSL_CE | PSL_ME | PSL_EE | PSL_FP)
-#define PSL_SRR1_MASK  0xUL/* No mask on Book-E */
-#elif defined(AIM)
-#ifdef __powerpc64__
-#definePSL_KERNSET (PSL_SF | PSL_EE | PSL_ME | PSL_IR | PSL_DR | 
PSL_RI)
-#else
-#definePSL_KERNSET (PSL_EE | PSL_ME | PSL_IR | PSL_DR | PSL_RI)
+extern register_t psl_userstatic;  /* Bits of SRR1 userland may not set */
 #endif
-#define PSL_SRR1_MASK  0x783fUL/* Bits 1-4, 10-15 (ppc32), 33-36, 
42-47 (ppc64) */
-#endif
-
-#definePSL_USERSET (PSL_KERNSET | PSL_PR)
-#definePSL_USERSTATIC  (~(PSL_VEC | PSL_FP | PSL_FE0 | PSL_FE1) & 
~PSL_SRR1_MASK)
 
 #endif /* _MACHINE_PSL_H_ */

Modified: 

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

2018-01-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Feb  1 05:28:02 2018
New Revision: 328650
URL: https://svnweb.freebsd.org/changeset/base/328650

Log:
  Fix build on 32-bit PowerPC, broken in r328537.

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

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cThu Feb  1 02:00:36 2018
(r328649)
+++ head/sys/powerpc/aim/mp_cpudep.cThu Feb  1 05:28:02 2018
(r328650)
@@ -85,15 +85,20 @@ cpudep_ap_early_bootstrap(void)
break;
case IBMPOWER8:
case IBMPOWER8E:
+#ifdef __powerpc64__
if (mfmsr() & PSL_HV) {
isync();
-   /* Direct interrupts to SRR instead of HSRR and reset 
LPCR otherwise */
+   /*
+* Direct interrupts to SRR instead of HSRR and
+* reset LPCR otherwise
+*/
mtspr(SPR_LPID, 0);
isync();
 
mtspr(SPR_LPCR, LPCR_LPES);
isync();
}
+#endif
break;
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r328616 - head/sys/powerpc/aim

2018-01-31 Thread Nathan Whitehorn
Thanks! Since PSL_HV is only defined on powerpc64, you also need some 
#ifdef here or the ppc32 kernel build will break. Also, the comment is 
longer than 80 characters.

-Nathan

On 01/30/18 22:42, Wojciech Macek wrote:

Author: wma
Date: Wed Jan 31 06:42:01 2018
New Revision: 328616
URL: https://svnweb.freebsd.org/changeset/base/328616

Log:
   PowerNV: fix compilation on non-NV platforms
   
   Submitted by:  Wojciech Macek 

   Obtained from: Semihalf
   Sponsored by:  IBM, QCM Technologies

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

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cWed Jan 31 05:07:43 2018
(r328615)
+++ head/sys/powerpc/aim/mp_cpudep.cWed Jan 31 06:42:01 2018
(r328616)
@@ -85,13 +85,15 @@ cpudep_ap_early_bootstrap(void)
break;
case IBMPOWER8:
case IBMPOWER8E:
-   isync();
-   /* Direct interrupts to SRR instead of HSRR and reset LPCR 
otherwise */
-   mtspr(SPR_LPID, 0);
-   isync();
+   if (mfmsr() & PSL_HV) {
+   isync();
+   /* Direct interrupts to SRR instead of HSRR and reset 
LPCR otherwise */
+   mtspr(SPR_LPID, 0);
+   isync();
  
-		mtspr(SPR_LPCR, LPCR_LPES);

-   isync();
+   mtspr(SPR_LPCR, LPCR_LPES);
+   isync();
+   }
break;
}
  



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


Re: svn commit: r328593 - head/release/scripts

2018-01-30 Thread Nathan Whitehorn
Do we even want to include the ports tree on install media? Extracting 
ports from some out-of-date tarball doesn't seem to match best practices 
for ports and it takes up quite a lot of space.

-Nathan

On 01/30/18 08:34, Steve Wills wrote:

Author: swills (ports committer)
Date: Tue Jan 30 16:34:56 2018
New Revision: 328593
URL: https://svnweb.freebsd.org/changeset/base/328593

Log:
   Change installer default to not install ports tree
   
   Reviewed by:	gjb, dteske, allanjude, bdrewery, mat

   Approved by: gjb
   Differential Revision:   https://reviews.freebsd.org/D14064

Modified:
   head/release/scripts/make-manifest.sh

Modified: head/release/scripts/make-manifest.sh
==
--- head/release/scripts/make-manifest.sh   Tue Jan 30 16:24:15 2018
(r328592)
+++ head/release/scripts/make-manifest.sh   Tue Jan 30 16:34:56 2018
(r328593)
@@ -32,6 +32,7 @@ desc_tests="${tests}"
  
  default_doc=off

  default_src=off
+default_ports=off
  default_tests=off
  default_base_dbg=off
  default_lib32_dbg=off



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


Re: svn commit: 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 <nwhiteh...@freebsd.org 
<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 <p...@semihalf.com
<mailto:p...@semihalf.com>>
   Submitted by:          Wojciech Macek <w...@semihalf.com
<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);
+
 

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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
==
--- 

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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: 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++) {
-

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 looks right to me, unless I
misunderstand 

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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 the direct map may not b

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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) = 
*((register_t *)TRAP_TOCBASE) = toc;
-
-   bcopy(, (void *)EXC_DSE,(size_t) - (size_t));
-   bcopy(, (void *)EXC_ISE,(size_t) - (size_t));
#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(, (void *)EXC_DSE,(size_t) - (size_t));
+   bcopy(, (void *)EXC_ISE,(size_t) - (size_t));
+   __syncicache((void *)EXC_DSE, 0x80);
+   __syncicache((void *)EXC_ISE, 0x80);
 #endif
 
/* Get physical memory regions from firmware */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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: 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;

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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(_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(_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: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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", , 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", , 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", , 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", ,
+   sizeof(cpuid));
+   if (res <= 0)
+   res = OF_getencprop(cpu, "reg", , 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, ncpus, err;
-   struct 

svn commit: r327487 - in head/usr.sbin/bsdinstall: partedit scripts

2018-01-01 Thread Nathan Whitehorn
rm, "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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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, _cpus);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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 = _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", _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", >fb_info.fb_height);
TUNABLE_INT_FETCH("hw.ps3fb.width", >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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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([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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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, );
+   prop = fdt_getprop(fdtp, offset, propname, );
 
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, , 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, );
+   prop = fdt_getprop_by_offset(fdtp, 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   4   5   6   7   8   9   10   >