aboutsummaryrefslogtreecommitdiff
path: root/sys/powerpc/include
Commit message (Collapse)AuthorAgeFilesLines
* powerpc/booke: Add a machine check stackJustin Hibbits3 days1-3/+4
| | | | | | | | | | | Machine check and critical exceptions are independent of each other, and can interrupt each other. Since they're asynchronous we cannot trust that the existing stack pointer (%r1) is correct at time of entry, so add a private machine check stack separate from the critical exception stack. As part of this, switch to the STANDARD_CRIT_PROLOG() for machine check exceptions, and overload the macro to specify the stack to switch to. Also add a savearea argument to CRIT_SRR_RESTORE() so that we can restore machine check exception state from the right location.
* libc: Add WCHAR_WIDTH in <wchar.h> as wellFaraz Vahedi10 days1-1/+0
| | | | | | | | | | | Define __WCHAR_WIDTH in sys/_types.h and derive WCHAR_WIDTH from that, the same way as WCHAR_MIN and WCHAR_MAX, in both <wchar.h> and <stdint.h> as per C23 §7.31.1 and §7.22.3.4, respectively. Reviewed by: fuz Approved by: fuz (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D59385
* powerpc/ddb: Dump more state in `show pcpu`Justin Hibbits10 days1-0/+5
| | | | | | | | | | | Add a new CPU-family `show pcpu` handler, cpu_db_show_mdpcpu() to dump CPU-specific PCPU data. Only Book-E is populated for now, but AIM may be populated later. These new field prints: save areas, TLB miss nesting, the new critical stack pointer. All of them have been very useful for debugging very esoteric bugs, so make them easier to see from DDB, instead of having to rummage through hex dumps.
* powerpc/booke: Use a dedicated critical exception stackJustin Hibbits10 days1-2/+10
| | | | | | | | | A critical exception, such as a watchdog, can trigger at any time, including the middle of a standard exception prologue or epilogue, so GPRs, including %r1 (the stack pointer) cannot be trusted at all. Instead, use a private stack pointer for critical interrupts. Each CPU now has its own critical exception stack, with the boot stack in the bss.
* powerpc/watchdog: Make e500 watchdog action tunableJustin Hibbits10 days1-0/+1
| | | | | | There are 4 options for e500 watchdog timeout, which may be core- or even SoC- specific. Add support to tune the behavior via a tunable (machdep.watchdog_mode). The tunable value is an integer 0-3.
* libc: Add PRIb*, PRIB*, and SCNb* macros as per C23Faraz Vahedi13 days1-0/+45
| | | | | | | Reviewed by: fuz Approved by: fuz (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D59293
* powerpc/pmap: Fix SLB VSID maskJustin Hibbits2026-08-251-1/+1
| | | | | Bits [0:1] map to "B", the "Segment size selector", and are not part of the VSID. Correct this mask.
* sys/limits.h: Fix typoFaraz Vahedi2026-08-131-1/+1
| | | | | | | Reviewed by: fuz Approved by: fuz (mentor) MFC after: 1 month Pull Request: https://github.com/freebsd/freebsd-src/pull/2352
* powerpc64: Bump KVA to 2TBJustin Hibbits2026-08-071-1/+1
| | | | | This reflects what amd64 has, and is needed for using GPUs with large VRAM.
* vm: Make sure NULL is defined for vm_memattr_name()Mark Johnston2026-07-191-0/+2
| | | | Fixes: a7e483ee146a ("vm_phys: Add a sysctl to dump registered fictitious memory ranges")
* vm_phys: Add a sysctl to dump registered fictitious memory rangesMark Johnston2026-07-191-0/+25
| | | | | | | | | | I've wanted this a couple of times in the past. Save the memattr in the fictitious memory segment structure so that we can report it from the sysctl handler, and add conversion routines for each platform. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D58283
* powerpc/pmap: Use variable-sized TIDJustin Hibbits2026-06-211-0/+2
| | | | | | | | e6500 core supports 14-bit TIDs (16384), while all earlier cores support only 8 bit TIDs. Dynamically allocate the tidbusy array at bootstrap time so that it stays in the TLB1, but is sized appropriately for the core. With MAXCPU of 32, a e6500 tidbusy would be (8 * 32 * 16384), or 4MB for this array, while e5500 would use (8 * 32 * 256), or 64kB.
* powerpc/booke: Extend TID register bits to the maxJustin Hibbits2026-06-211-1/+1
| | | | | | Some Book-E cores (at least e6500) can have much larger PID fields, up to 14 bits. Extend the PID mask space to the full space, and future changes may take advantage of this extended space.
* powerpc64le: switch long double to IEEE binary128Piotr Kubaj2026-06-191-0/+17
| | | | | | | | | | | Change powerpc64le's long double from 64-bit double to IEEE 754 binary128 (quad, 113-bit mantissa), matching aarch64 and riscv64. Gated on FreeBSD 16 and powerpc64le only. Differential Revision: https://reviews.freebsd.org/D57388 Reviewed by: adrian Relnotes: yes
* powerpc/booke: Add watchdog driverJustin Hibbits2026-06-101-0/+3
| | | | | | | | | The Book-E watchdog is effectively a state machine based around an AND mask of the timebase register. A single bit (0-63) is watched in the timebase register, and when it transitions (by counting *or* by programmatically setting) an exception is triggered. The first exception triggers a core interrupt. The second is programmable. In our case, we panic on the first and reset on second.
* sys: Consistently use ptoa() with td_kstack_pagesJohn Baldwin2026-05-271-1/+1
| | | | | | | Suggested by: kib Reviewed by: kib, andrew (arm changes) Sponsored by: AFRL, DARPA Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/23
* sys: Add td_kstack_top inline helper functionJohn Baldwin2026-05-271-2/+1
| | | | | | | | This function returns a pointer to the top of the kstack. Reviewed by: kib, andrew (arm changes) Sponsored by: AFRL, DARPA Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/23
* types: provide __SIZEOF_{INT{8,16,32,64},TIME,TIME32}_TRyan Libby2026-05-081-0/+1
| | | | | | | Suggested by: kib Reviewed by: imp, kib Discussed with: emaste, jrtc27 Differential Revision: https://reviews.freebsd.org/D56783
* powerpc: refactor common busdma tag setupAdrian Chadd2026-05-011-0/+6
| | | | | | | | | | | Refactor the common busdma tag setup code into busdma_machdep.c Locally tested: * qemu VM, pseries-9 / power9 * qemu VM, pseries-8 / power8 Differential Revision: https://reviews.freebsd.org/D55340
* powerpc: add in some busdma domain setupAdrian Chadd2026-05-011-0/+1
| | | | | | | | | | * Implement the basic tag domain set routine * Set the domain to the parent domain if provided This is just plumbing for eventual work to re-allocate things into the currently configured domain. Differential Revision: https://reviews.freebsd.org/D55315
* powerpc: initial straight port of busdma_machdep.c -> busdma_bounce.cAdrian Chadd2026-05-012-2/+225
| | | | | | | | | | | | | This is a straight port of the code and doesn't yet handle different implementations (which will be in a subsequent commit.) Locally tested: * G5 SMP (2x PPC970mp) * power8 / power9 pseries QEMU VM * power8 powernv Differential Revision: https://reviews.freebsd.org/D55313
* Define stdint.h macros unconditionallyDimitry Andric2026-05-011-8/+0
| | | | | | | | | | | | | | | Similar to glibc, define all the stdint.h macros such as `SIZE_MAX`, `UINT64_C`, etc unconditionally. I.e. no longer check whether `__STDC_CONSTANT_MACROS` or `__STDC_LIMIT_MACROS` are defined. See also <https://sourceware.org/bugzilla/show_bug.cgi?id=15366>. This is part of reverting base 00bee6fcd77f, which reverted an upstream libc++ commit that eliminated libc++'s stdint.h wrapper header. Submitted by: Nikolas Klauser <nikolasklauser@berlin.de> MFC after: 1 week Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D56746
* Remove extraneous tab characters at EOL in various _stdint.h filesDimitry Andric2026-05-011-2/+2
| | | | MFC after: 3 days
* powerpc/pic: fix the openpic CPU logic to work on powermacAdrian Chadd2026-05-011-0/+1
| | | | | | | | | | | | | | | | | | | | | Earlier work (40bcad56f - powerpc/pic: Add a PIC_AP_INIT() to set up AP PIC info) broke booting my dual G5 powermac. After much digging, jhibbits@ and I discovered that the openpic implementation for the memory/bus controller used in the G5 CPUs doesn't implement /all/ of the openpic specification. Notably it sticks the WHOAMI register in a different location. This is reading 0x0 back for all the PICs which is .. very not great. So to restore the previous behaviour, use a quick for now that jhibbits@ can set appropriately to trust WHOAMI. I've tested this on my dual G5 PPC and it boots/runs fine. Fixes: 40bcad56f Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D56751
* powerpc/openpic: Increase the maximum number of IRQs allowedJustin Hibbits2026-04-302-2/+3
| | | | | | | | | | | | | The Freescale MPIC supports up to 2048 IRQs, but since we only build an array of 768 interrupts in intr_machdep, clamp the max at 512. The most any Freescale PowerPC chip actually supports is 452 on the T4240, so 512 is sufficient. As part of this, increase the vector mask to the full openpic vector mask, and use this limit as the terminator for the dispatch loop, instead of a hard-coded 255. Differential Revision: https://reviews.freebsd.org/D56422
* powerpc/pic: Add a PIC_AP_INIT() to set up AP PIC infoJustin Hibbits2026-04-301-0/+1
| | | | | | | | | | | pc_cpuid may not match the PIC's idea of a given CPU. Since openpic has a WHOAMI register, we can use that to get the PIC's idea of the CPU. This needs to be done on each AP, so add a PIC_AP_INIT device method so the PIC can perform any AP-specific initialization at AP bootstrap time. This fixes SMP on e6500, which is still lacking SMT support. Differential Revision: https://reviews.freebsd.org/D56421
* PHYS_TO_DMAP: Return a void * instead of a vm_offset_tJohn Baldwin2026-04-231-1/+2
| | | | | | | | | | Add a new PHYS_TO_DMAP_ADDR that still returns an address for use in places that only need an address and not a pointer. Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* sys: Permit passing pointers to VIRT_IN_DMAP and DMAP_TO_PHYSJohn Baldwin2026-04-231-1/+1
| | | | | | | | | | | | Add explicit uintptr_t casts to the arguments to these macros so that the work both with virtual addresses (e.g. vm_offset_t) and pointers. Drop no-longer-needed casts in various invocations of DMAP_TO_PHYS. Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* pmap_map: Use void * for the return value instead of vm_offset_tJohn Baldwin2026-04-231-1/+1
| | | | | | | Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* sys: Switch td_kstack from vm_offset_t to char *John Baldwin2026-04-231-4/+4
| | | | | | | Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* kva_alloc/free: Use void * instead of vm_offset_tJohn Baldwin2026-04-231-1/+1
| | | | | | | Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* pmap_qenter/qremove: Use void * instead of vm_offset_tJohn Baldwin2026-04-231-2/+2
| | | | | | | Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* pmap_change_attr: Use void * instead of vm_offset_tJohn Baldwin2026-04-232-2/+2
| | | | | | | Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* pmap_quick_(enter|remove)_page: Use void * instead of vm_offset_tJohn Baldwin2026-04-231-2/+2
| | | | | | | Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* powerpc/pmap: Add support for page sizes found on E6500Justin Hibbits2026-04-162-13/+18
| | | | | | E6500 cores (MMUv2) support all powers-of-2 page sizes from 4k to 1TB, not just powers of 4. By using the other page sizes (8k, 32k, etc) we can save on TLB1 space, saving up to ~1/3 of used TLB1 entries.
* Revert "pcb.h: mark struct pcb to be preserved"Konstantin Belousov2026-02-091-5/+0
| | | | | | | kgdb only uses the marked fields from dumppcb for initial frame reconstruction. This reverts commit 8f23665fed2fbaf4481359b4d2fcdd7b9feb40e3.
* pcb.h: mark struct pcb to be preservedMinsoo Choo2026-02-091-0/+5
| | | | | | | | | | There are programs that depend on this structure (e.g. kernel debuggers) that breaks when the ABI changes. Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me> Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D55149
* powerpc/pmap: Use a constant for HPT superpage shiftJustin Hibbits2026-02-031-2/+3
| | | | | | | | There are no plans to allow multiple sizes of HPT superpages, so just use a constant for it. MFC after: 3 weeks Fixes: 1bc75d77e9 ("powerpc/pmap/oea64: Make PV_LOCK superpage sized")
* powerpc: Add ISA 2.06 sub-word atomic set/clearJustin Hibbits2026-01-171-26/+56
| | | | | | | Add atomic_set/clear_short/char for doing 8-bit and 16-bit operations more efficiently on "newer" architectures (POWER7 and later). Piggybacks on b31abc95eb.
* Remove all code under __SPE__Minsoo Choo2026-01-121-8/+0
| | | | | | Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1957
* param.h: remove powerpcspeMinsoo Choo2026-01-091-4/+0
| | | | | | | Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me> Reviewed by: emaste Pull Request: https://github.com/freebsd/freebsd-src/pull/1914 (cherry picked from commit 1bfae8b50814697ac12bc8879ad8013e7ffd77b2)
* Add sys/_align.h replacing machine/_align.hBrooks Davis2025-12-102-52/+1
| | | | | | | | | | | | | | | | Define _ALIGNBYTES using sizeof(void *) (no functional change on any existing architecture) which will allow it to work with CHERI were we must align things up to capability alignment. In _ALIGN, replace integer manipulation which does not preserve pointer provenance with a type and provenance preserving builtin. This requires modest changes in code which assumes _ALIGN returns an integer, but those are relatively rare. Reviewed by: kib, markj Effort: CHERI upstreaming Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D53947
* powerpc/_stdint.h: fix SIG_ATOMIC_{MIN,MAX,WIDTH}Robert Clausecker2025-12-021-10/+5
| | | | | | | | | | | | | On powerpc/powerpc64, sig_atomic_t is an int, but was treated as if it was a long by <machine/_stdint.h>. This was finally caught by the unit test added with 4a1c752 / D53831. Reported by: kib Reviewed by: kib, imp Approved by: markj (mentor) Fixes: c3e289e1ce8c9af8d14e9f727632e22b3bf901f9 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54026
* sys/stdint.h: add C23 _WIDTH macrosRobert Clausecker2025-11-301-0/+33
| | | | | | | | | | | | | | The platform-dependent macros are added to the various _stdint.h headers, those that are always the same are added directly to _stdint.h. We may want to move the definitions for WCHAR_* and WINT_* out of the platform header files as those are always the same. Approved by: markj (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D53830
* sys/limits.h: add C23 _WIDTH macrosRobert Clausecker2025-11-301-0/+3
| | | | | | | | | | | | For compliance with IOS/IEC 9899:2024 ("C23"). These macros define the width in bits of the basic integer types. Another new macro, BITINT_MAXWIDTH, is not yet included as I do not understand what it should be set to. Perhaps it is compiler-specific. Approved by: markj (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D53825
* intr/powerpc: create openpic_class kobjElliott Mitchell2025-10-301-6/+3
| | | | | | | | | | | | Using kobj allows implementing most PIC functions merely by inheriting from the parent class. As there are multiple OpenPIC implementations, this ensures all common hooks go through by default. Note, this adds the suspend/resume functions to other PICs. This should be harmless as suspend/resume isn't working on the devices anyway. Reviewed by: jhibbits MFC after: 2 weeks
* kexec: Add dummy headers for arm, i386, powerpc, and riscvJustin Hibbits2025-10-271-0/+38
| | | | | | | | kexec hasn't been ported to these architectures, yet, so appease the build with dummy headers. Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D51625
* arm, powerpc, riscv: implement atomic_set/clear_16Konstantin Belousov2025-09-201-1/+32
| | | | | | | Reviewed by: jrtc27, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D52626
* powerpc: Fix multiple issues with FP/VSX save/restoreTimothy Pearson2025-07-132-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multiple issues existed within the powerpc FP/VSX save/restore functionality, leading to register corruption and loss of register contents in specific scenarios involving high signal load and use of both floating point and VSX instructions. Issue #1 On little endian systems the PCB used the wrong location for the shadowed FP register within the larger VSX register. This appears to have been an attempt to correct issue #2 without understanding how the vector load/store instructions actually operate. Issue #2 On little endian systems, the VSX state save/restore routines swapped 32-bit words within the 64-bit aliased double word for the associated floating point register. This was due to the use of a word-oriented load/store vs. doubleword oriented load/store. Issue #3 The FPU was turned off in the PCB but not in hardware, leading to a potential race condition if the same thread was scheduled immediately after sigreturn. The triggering codebase for this is Go, which makes heavy use of signals and and generates an unusual mix of floating point and VSX assembler. As a result, when combined with th powerpc lazy FPU restore, a condition was repeatedly hit whereby the thread was interrupted in FP+VSX mode, then restored in FP only mode, thus reliably triggering the issues above. Also clean up the associated asm() style issue flagged by GitHub Actions. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1756
* pmap_growkernel(): do not panic immediately, optionally return the errorKonstantin Belousov2025-06-191-2/+2
| | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47935