aboutsummaryrefslogtreecommitdiff
path: root/sys/powerpc
Commit message (Collapse)AuthorAgeFilesLines
* powerpc64: initial conversion of oea64 to rwlocksAdrian Chadd2026-02-221-18/+32
| | | | | | | Convert the oea64 mmu code to rwlocks. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D54936
* bus: Document special ranges of IVARsJohn Baldwin2026-02-172-2/+2
| | | | | | | | | | | | | Some IVAR indices are special in that they have global meaning across multiple buses where as other IVARs are always private to the local bus. Try to document this a bit and add constants for the various ranges to avoid future conflicts. This is a no-op, but IVAR indices are now generally defined as enums as that makes it easier to define them in terms of ranges. Reviewed by: imp, royger, andrew Differential Revision: https://reviews.freebsd.org/D54159
* powerpc: document the magic constants for 16MB page sizeAdrian Chadd2026-02-161-0/+13
| | | | | | | | After discussion with jhibbits@, we pulled out what is supported here and how it's supported. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D55093
* powerpc: enable HPT superpages by defaultAdrian Chadd2026-02-161-7/+2
| | | | | | | | It's time to flip these on and see if anything happens in -HEAD. It can be turned back off before 16.0-RELEASE if there are problems. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D55071
* 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
* powerpc64: Fix disappearing low memory on radix MMU systems (POWER9)Timothy Pearson2026-02-053-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The FreeBSD radix implementation piggybacks on the physical memory allocation function from the HPT implementation, but did not share the same state information for number of physical memory ranges. This led to a situation where the HPT physical memory allocator would attempt to shift the physical memory ranges in the shared range table, but would use the wrong number of entries, thus overwriting the large segment of low memory that should have been available for e.g. 32-bit DMA. Incorrect physical memory map: real memory = 33997058048 (32422 MB) available KVA = 34359619583 (32767 MB) Physical memory chunk(s): 0x0000000000003000 - 0x0000000000002fff, 0 bytes (0 pages) 0x000000000000e000 - 0x000000000000ffff, 8192 bytes (2 pages) 0x0000000000094000 - 0x0000000000ffffff, 16171008 bytes (3948 pages) 0x0000000100000000 - 0x00000007a2042fff, 28487987200 bytes (6955075 pages) 0x00000007d0006000 - 0x00000007fc72dfff, 745701376 bytes (182056 pages) 0x00000007fdc00000 - 0x00000007ff79ffff, 28966912 bytes (7072 pages) 0x00000007ff7d1000 - 0x00000007ff7effff, 126976 bytes (31 pages) avail memory = 29190103040 (27837 MB) FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs Correct physical memory map: real memory = 33997058048 (32422 MB) available KVA = 34359619583 (32767 MB) Physical memory chunk(s): 0x0000000000003000 - 0x0000000000002fff, 0 bytes (0 pages) 0x000000000000e000 - 0x000000000000ffff, 8192 bytes (2 pages) 0x0000000000094000 - 0x0000000000ffffff, 16171008 bytes (3948 pages) 0x0000000002000000 - 0x000000000284ffff, 8716288 bytes (2128 pages) 0x0000000004627000 - 0x000000002fffffff, 731746304 bytes (178649 pages) 0x0000000034040000 - 0x00000000efffffff, 3153854464 bytes (769984 pages) 0x0000000100000000 - 0x00000007982ecfff, 28323008512 bytes (6914797 pages) 0x00000007cc20a000 - 0x00000007fc72dfff, 810696704 bytes (197924 pages) 0x00000007fdc00000 - 0x00000007ff79ffff, 28966912 bytes (7072 pages) 0x00000007ff7d1000 - 0x00000007ff7effff, 126976 bytes (31 pages) avail memory = 32984436736 (31456 MB) FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> Sponsored-by: Raptor Computing Systems, LLC
* powerpc64/pmap: No need to use r0 anymore in tlbieJustin Hibbits2026-02-051-14/+3
| | | | | | | | | | | The only use of `tlbie %rN, 0` is now explicit and covered in the block above. Since there's no need for an explicit `tlbie %rN, 0` now, drop this convoluted piece and let the compiler decide. While here, a trivial optimization of the old-style tlbie block, by clearing tlbie_lock and returning, instead of going to the end which checks again if the lock is needed. Since it's already known to be needed, there's no need to check again.
* sdt: Enable on 32-bit powerpc and powerpc64leMark Johnston2026-02-041-2/+2
| | | | | | Reviewed by: jhibbits, adrian MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54814
* powerpc/pmap: Use a constant for HPT superpage shiftJustin Hibbits2026-02-032-4/+5
| | | | | | | | 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/pmap/oea64: Make PV_LOCK superpage sizedJustin Hibbits2026-02-031-45/+3
| | | | | | | | | HPT superpages are 16MB, not 2MB. Taking 8 locks to lock a super page almost defeats the purpose of using the super page. Expanding the PV_LOCK scope to cover 16MB (24 bit shift) reduces this to a single lock. MFC after: 3 weeks
* powerpc/pmap: Mark more CPUs as lockless TLBIEJustin Hibbits2026-02-031-2/+2
| | | | | | | | | | Add POWER10 and POWER11 to the list of lockless TLBIE capable CPUs. According to Linux, anything POWER5 and later should be able to do this, but that hasn't been tested with FreeBSD. POWER10 and POWER11, being derived after the POWER9, implicitly have this capability per the ISA spec. MFC after: 1 week
* cpufreq(4): Fix a typo in a source code commentGordon Bergling2026-01-311-1/+1
| | | | | | - s/transcation/transaction/ MFC after: 5 days
* powerpc: explicitly cast the timebase printfsAdrian Chadd2026-01-301-8/+8
| | | | This is causing compilation issues on powerpc:powerpc GENERIC.
* cpu_switch(): unconditionally wait on the blocked mutex transientKonstantin Belousov2026-01-292-4/+2
| | | | | | | | | | It is nop for 4BSD. Reviewed by: olce Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54831
* kern/sched_shim.c: Provide a scheduler selection machineryKonstantin Belousov2026-01-291-0/+2
| | | | | | | | Reviewed by: olce Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54831
* sys: Use __is_aligned and __align_down for some kstack alignment operationsJohn Baldwin2026-01-273-7/+6
| | | | | | | Reviewed by: kib, jhibbits Effort: CHERI upstreaming Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D54840
* powerpc: Fix alignment of initial PCB on kstackJohn Baldwin2026-01-272-2/+2
| | | | | | | | | | | | | | | | | | | | | Commit cc81c44dd806737f98b4fd4094674dd71c8749f3 aimed to consolidate duplicated code between the Book-E and AIM backends. For cpu_thread_alloc cpu_thread_alloc and cpu_fork it used the AIM functions which used a bogus alignment mask (~0x2f). The Book-E functions used a proper alignment mask (~0x3f). The AIM functions appear to have been busted since they were first imported in commit 919cb3362fded33aca682a6ac57777f8fff86e36. To fix, use the Book-E mask which requests 64 byte alignment. Probably this was harmless in practice since td_kstack is page aligned and struct pcb is probably a multiple of 32 bytes in size, so the 0x10 bit should have been clear anyway. Reviewed by: fuz, jhibbits Fixes: cc81c44dd806 ("Unify ABI-related bits of the Book-E and AIM...") Effort: CHERI upstreaming Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D54839
* powerpc: disable the TLBIE lock, it's not needed for POWER8Adrian Chadd2026-01-271-0/+5
| | | | | | | | | | | | According to POWER8_UM_v1.3_16MAR2016 3.8.3 Translation Lookaside Buffer (TLB), POWER8 supports lockless TLBIE operations. Locally Tested: * IBM POWER8 Revision 2.0, dual socket, 160 threads Differential Revision: https://reviews.freebsd.org/D54855 Approved by: jhibbits
* powerpc: add a best-effort SMP time base sync for G5's that need itAdrian Chadd2026-01-271-9/+90
| | | | | | | | | | | | | | | | | | | | | | There's no timebase freeze platform routine registered on my dual 2.3GHz G5 PPC970FX Apple PowerMac. For platforms without an explicit timebase freeze/unfreeze, we'll have to make do with what we have - which for now is an explicit hand-crafted spinlock/rendezvous method. * For existing platforms, they'll still continue to clock freeze / rendezvous; albeit with some stronger atomic bits now (from jhibbits@.) * Instead of the fallback being "no timesync", implement a best-effort one which does a similar rendezvous barrier between BSP and APs, but instead of freeze/unfreeze the first instruction after the CPUs all register they're ready is to set the timebase. This has resulted in many reboots of my Powermac G5 dual-socket device correctly starting and running in SMP mode. Differential Revision: https://reviews.freebsd.org/D54821 Reviewed by: jhibbits
* powerpc/mpc85xx: Fix PCI attach error cleanupJustin Hibbits2026-01-211-2/+17
| | | | | | | | | If an error occurs during attach after ofw_pcib_init() runs, the device is torn down, leaving the rmans embedded in the softc attached to the rman list, thus corrupting the rman list. Fix this by undoing everything that was done by this point. MFC after: 1 week
* powerpc/mpc85xx: Set pc_hwref to the primary thread IDJustin Hibbits2026-01-211-2/+14
| | | | | | On multithreaded cores (e6500) the CPU ID in the device tree (reg[0]) is the primary core, which may not match the cpuid, until Book-E threading is added.
* 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-128-111/+0
| | | | | | Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1957
* conf: remove powerpcspeMinsoo Choo2026-01-091-685/+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 4a5a1c17ac43356fae053524187bb16f8fc1ac70)
* conf: remove MPC85XXSPEMinsoo Choo2026-01-091-151/+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 40a49bccf388494f9685a81cfa781050f5f8bb1f)
* 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)
* powerpc: put the isync inside the TD_LOCK() checking loopAdrian Chadd2026-01-042-2/+2
| | | | | | | | | | | | | | | | | | | Fix a narrow window where the lock is unlocked but the checking CPU hasn't flushed things appropriately. Inside this window the CPU inside cpu_switch() will loop forever thinking the destination thread is still blocked/locked even though it is not. This manifests as the system hanging after starting all APs. I've seen this reliably trigger in qemu-system-ppc64 running power9 pseries guests; the more CPUs the more likely it triggers at boot. PR: kern/292167 Differential Revision: https://reviews.freebsd.org/D54478 Reviewed by: jhibbits MFC after: 1 week Relnotes: yes
* powerpc/intr: Minor cleanupJustin Hibbits2025-12-201-7/+1
| | | | Use MTX_SYSINIT() instead of rolling our own.
* 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
* bus_alloc_resource: Pass rid by value to BUS_ALLOC_RESOURCE DEVMETHODJohn Baldwin2025-12-098-38/+34
| | | | | | | | | The wrapper functions such as bus_alloc_resource_any() still support passing the rid by value or pointer, but the underlying implementation now passes by value. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53402
* 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
* sys: RealTek -> Realtekykla2025-11-272-4/+4
| | | | | | | | | | | Realtek changed how it styled its name 25 or so years ago, but the old style persisted in many places. These products use the new styling in their datasheets. Signed-off-by: ykla yklaxds@gmail.com Sponsored by: Chinese FreeBSD Community Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1901
* powerpc: Don't use cache to zero pagesJustin Hibbits2025-11-194-15/+10
| | | | | | | pmap_zero_page() may be called on uncached pages, so using the cache to zero uncached pages may trigger a fault. MFC after: 2 weeks
* random: allow disabling of entropy harvesting from keyboard & miceDavid E. O'Brien2025-11-112-0/+8
| | | | | | Reviewed by: jmg Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D53390
* powerpc: Move openpic_intr, since it's hidden nowJustin Hibbits2025-10-301-11/+11
| | | | | | | | | Last minute change by me (diff reduction), that I didn't build. This was in the original commit. Fixes: 8fb1789612 ("intr/powerpc: create openpic_class kobj") MFC after: 2 weeks X-MFC-with: 8fb1789612
* intr/powerpc: create openpic_class kobjElliott Mitchell2025-10-305-52/+38
| | | | | | | | | | | | 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
* intr/powerpc: cleanup extraneous spaces in PowerMAC CPC HT driverElliott Mitchell2025-10-301-10/+10
| | | | | | | | Spotted while examing this driver. Remove some end of line spaces/tabs. Replace some spaces which should instead be tabs. 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
* imgact: Mark brandinfo and note structures as constZhenlei Huang2025-10-182-10/+10
| | | | | | | | | No functional change intended. Reviewed by: kib MFC after: 10 days MFC with: 80336636b6b9f7a3bdad007c400e85eae017d2a2 Differential Revision: https://reviews.freebsd.org/D53173
* powerpc: Use proper prototype for SYSINIT functionsZhenlei Huang2025-10-132-3/+4
| | | | MFC after: 1 week
* u2f(4): Invert U2F_MAKE_UHID_ALIAS kernel build optionVladimir Kondratyev2025-09-252-2/+0
| | | | | | | This makes non-GENERIC kernel configs easier to maintain. Requested by: glebius MFC after: 2 days
* 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
* sys: NOTES: Fix comment for wlan_* devices; GENERIC*: Re-order 'wlan_tkip'Olivier Certner2025-09-092-2/+2
| | | | | | | | | | | | | | | | | Fix the comment introducing the 'wlan_*' devices (AES-CCMP is missing) after introducing AES-GCMP. While here, re-order the devices in order of appearance of the related technologies. No functional change (intended). Reviewed by: adrian, emaste Fixes: 7bf82ea4fdda ("sys: add wlan_gcmp to GENERIC kernels as appropriate") MFC after: 3 days MFC to: stable/15 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52444
* u2f(4): a HID driver for FIDO/U2F security keysVladimir Kondratyev2025-08-172-0/+2
| | | | | | | | | | | | | | | | | While FIDO/U2F keys were already supported by the generic uhid(4) and hidraw(4) drivers, this driver adds some additional features an does steps to tighten the security of FIDO/U2F access. - It automatically loads through devd. - Automatically enables HQ_NO_READAHEAD for FIDO/U2F devices. - Implements only miminum set of features. - Do not requires external devfs configuration to set character device permissions. - Names character device as u2f/# to make possible capsicum or any other pledge()-style sandboxing. PR: 265528 Differential Revision: https://reviews.freebsd.org/D51612
* gpio: remove gpiobus_attach_busAhmad Khalifa2025-08-131-1/+2
| | | | | | | | | | | | Since gpiobus_attach_bus can attach the gpiobus child along with its children in the same bus pass, the parent controller's reference to gpiobus might not be set by the time the children need it. Instead, drivers should use gpiobus_add_bus and explicitly call bus_attach_children. Reviewed by: mmel, imp (older version) Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D51578
* busdma: another fix for small bounce transfersMitchell Horne2025-08-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | More fallout from a77e1f0f81df. When the tag has an alignment requirement but a small (remaining) transfer size, the transfer will be rounded up to exceed its bounds, resulting in memory corruption. The issue is observed on powerpc as noted in the pull request: https://github.com/freebsd/freebsd-src/pull/1415 I also observe the issue locally on riscv hardware, with an 8-byte transfer having 64-byte alignment. There is some uncertainty about the purpose/need for the alignment roundup; both its original intention and present effect. Notably, it is no longer present at all in arm/arm64 implementations. Possibly, this roundup can be removed altogether, but this requires more careful analysis of the edge-cases and history of the property. For now, simply clamp sgsize to be no larger than the remaining buflen, as this is certain to be correct within the current scheme and fixes the affected transfers. Discussed with: jhb, markj MFC after: 3 weeks Fixes: a77e1f0f81df ("busdma: better handling of small segment bouncing") Sponsored by: The FreeBSD Foundation Pull Request: https://github.com/freebsd/freebsd-src/pull/1415 Signed-off-by: Chattrapat Sangmanee <aomsin27@hotmail.co.th> Co-authored-by: Chattrapat Sangmanee <aomsin27@hotmail.co.th> Differential Revision: https://reviews.freebsd.org/D47807
* powerpc: Fix multiple issues with FP/VSX save/restoreTimothy Pearson2025-07-134-22/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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