aboutsummaryrefslogtreecommitdiff
path: root/sys/powerpc
Commit message (Collapse)AuthorAgeFilesLines
...
* powerpc: Reserve correct scratch region size below stackTimothy Pearson2025-07-131-3/+3
| | | | | | | | | | | | | According to the ELF ABI v2, two scratch regions are reserved below the stack pointer, one 288 byte general region and one 224 byte compiler region. FreeBSD only reserved the 288 byte region. Follow the ELV v2 ABI and reserve the full 512 byte region as specified. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1756
* pmap: Degrade pmap_page_set_attr*() into a no-op on same attributeOlivier Certner2025-07-133-0/+10
| | | | | | | | | | | | For 32-bit arm, move the no-op test that was already in place at start of the function so that it stays first even if the '#if 0' block around the call to sf_buf_invalidate_cache() is uncommented at some point (if ever). Reviewed by: jeffpc_josefsipek.net, kib MFC after: 10 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51253
* gpio: attach gpiobus when the controller is readyAhmad Khalifa2025-07-041-2/+2
| | | | | | | | | | Only attach gpiobus when the controller is fully initialized. Children of gpiobus expect this to be the case. Reviewed by: mmel, imp, andrew Approved by: imp (mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D51088
* nexus: Add device_shutdown where missingJustin Hibbits2025-06-251-0/+1
| | | | | | | | | | | | | At shutdown devices may need to do extra work to clean up state, etc. This is done in a device_shutdown kobj method on a driver, with the default being a `do nothing` method. Only x86's nexus driver includes the device_shutdown method to propagate down to its children, so on other architectures the device_shutdown stops at the root, and thus device_shutdown is never called for any real devices. Add this missing method to the nexus drivers of the other architectures so devices have a chance to properly shutdown. Sponsored by: Juniper Networks, Inc.
* sys: Add AT_HWCAP3 and AT_HWCAP4Andrew Turner2025-06-243-0/+7
| | | | | | | | | It is likely we will need these on arm64. Add them in preparation for flags in these to be added at some point in the future. Reviewed by: brooks, imp, kib Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D51005
* newbus: replace leftover device unit wildcardsAhmad Khalifa2025-06-2110-15/+16
| | | | | | Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
* pmap_growkernel(): do not panic immediately, optionally return the errorKonstantin Belousov2025-06-193-9/+27
| | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47935
* runq: Deduce most parameters, remove machine headersOlivier Certner2025-06-181-55/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'runq' machinery now depends on only two settable parameters, RQ_MAX_PRIO, the maximum priority number that can be accepted, the minimum being 0, and RQ_PPQ, the number of priorities per queue (to reduce the number of queues). All other parameters are deduced from these ones. Also, all architectures automatically get a runq word that is their natural word. RQB_FFS() always was 'ffsl() - 1' except for amd64 where it was 'bsfq()'. Now that all these finally call compiler builtins, the resulting assembly code is the same, so there is no cost to removing this special case. After all these changes, <machine/runq.h> headers have no more purpose, so remove them. While here, fix potentially confusing parameter name for RQB_WORD() and RQB_BIT(). While here, include all necessary headers so that <sys/runq.h> can be included standalone. No functional change (intended). Reviewed by: kib MFC after: 1 month Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45387
* vm: remove pa_index from the machine-independent layerAlan Cox2025-06-131-1/+4
| | | | | | | | | | | After the demise of vm_page_lock(), the only remaining uses of pa_index() are in various pmap implementations. In many cases, e.g., amd64, the pmap implementations already provided their own definitions, often identical to the machine-independent one. For those that didn't provide one, this change adds it. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D50823
* vm: retire vm_page_lock()Alan Cox2025-06-112-7/+1
| | | | | | | | | | | vm_page_lock() and its underlying array of locks, pa_lock[], have been replaced throughout the virtual memory system by either atomics or busy-style, per-page synchronization. The Linux KPI support contained the only remaining use cases. Eliminate or update them as appropriate to each case. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D50767
* machine/stdarg.h -> sys/stdarg.hBrooks Davis2025-06-117-7/+7
| | | | | | | | | | | | | Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
* thr_new: pass params.flags to cpu_set_user_tls()Konstantin Belousov2025-05-311-1/+1
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week
* powerpc: Enable VIMAGE on more kernel configsLi-Wen Hsu2025-05-203-0/+3
| | | | Sponsored by: The FreeBSD Foundation
* Revert "powernv: Add RF_BIGENDIAN resource flag"Justin Hibbits2025-05-144-6/+3
| | | | | | | | | | | After further thinking, the nexus bus mappings are for the immediate peripherals, not downstream. Given this, and that historically PowerPC platforms have been big-endian by default, it makes sense to default mappings to BE always. If this changes in the future, the platform devices can explicitly mark their mappings with the RF_LITTLEENDIAN flag instead. This reverts commit 86d20eaadfd1a03e19d8bc8333c689b820299d52.
* powernv: Add RF_BIGENDIAN resource flagJustin Hibbits2025-05-134-3/+6
| | | | | | | | | | | | | The big-endian analogue to the RF_LITTLEENDIAN flag, if this flag is set on a memory resource it's always mapped big endian. This is needed by the PowerNV OPAL resources (XIVE and PCI), as these top-level peripherals are always big-endian. Tested by: pkubaj Fixes: c4921a0f("powerpc: Always use BE tag in nexus_map_resource") MFC after: 1 day X-MFC-with: c4921a0f
* powerpc: Always use BE tag in nexus_map_resourceJustin Hibbits2025-05-131-1/+1
| | | | | | | | | | | | | | | | 7b5a5e4e replaced nexus_activate_resource() with the bus generic equivalent, which uses bus_map_resource(). However, though not intended to have a functional change, nexus_map_resource() uses the bus tag of the build (BE vs LE), while nexus_activate_resource() always explicitly set a big-endian tag, leading to failures on powerpc64le now. Using BE unless otherwise explicitly specified with the RF_LITTLEENDIAN fixes LE on bare metal, and doesn't hurt in a VM, which nexus_map_resource() was added for. Reported by: pkubaj Tested by: pkubaj Fixes: 7b5a5e4e("powerpc nexus: Use bus_generic_rman_*") MFC after: 1 day
* powerpc: add missing headerDoug Moore2025-04-211-0/+1
| | | | | | Add missing vm/vm_radix.header. Fixes: b6cd84ca2d08 ("powerpc: replace tailq pointers with iterators")
* powerpc: replace tailq pointers with iteratorsDoug Moore2025-04-214-33/+46
| | | | | | | | Change architecture-specific code to use iterators rather than tailq pointers. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D49927
* powerpc: silence compiler warningDoug Moore2025-04-211-0/+4
| | | | | | | | Function moea64_sp_demote_aligned() is only invoked if VM_NRESERVLEVEL > 0. Add #if/#endif pairs around the declaration and definition of that function to silence warnings about unused static functions. Reviewed by: kib
* powerpc/trap: Change prediction of NOFAULTING in trap_pfault()Justin Hibbits2025-03-291-1/+1
| | | | | | | This was probably intended to match the amd64 check, but that tests NOFAULTING against non-zero, while this checks against 0. We're most likely to end up in this function when faulting is allowed, so predict_true is the better option.
* sys: add wlan_gcmp to GENERIC kernels as appropriateAdrian Chadd2025-03-272-0/+2
| | | | | | | Add wlan_gcmp wherever CCMP is defined in kernel configs. Differential Revision: https://reviews.freebsd.org/D49343 Reviewed by: bz, cy
* powernv: Explicitly enable the facilities we supportJustin Hibbits2025-03-192-0/+11
| | | | | | | | | | Thus far we've relied on the firmware setting HFSCR correctly, enabling all facilities. However, it appears some recent firmwares do not. Linux explicitly enables all facilities it supports (including transactional memory, which new firmwares apparently do not enable), so do the same here, explicitly enable all the facilities FreeBSD supports. MFC after: 1 week
* powerpc: Add Hypervisor Facility Unavailable handlingJustin Hibbits2025-03-192-0/+4
| | | | | | | | | | Treat Hypervisor Facility Unavailable as an illegal instruction in user space. This way programs that use facilities like transactional memory, which will never be supported as it has been removed from the ISA, will not crash the kernel. Tested by: pkubaj MFC after: 1 week
* powerpc: mmu_radix_page_array_startup(): Don't force allocation from domain 0Olivier Certner2025-02-191-1/+1
| | | | | | | | | | | In this case, the domain from which the memory to back the VM page array is allocated does not matter, so just let vm_phys_early_alloc() choose a suitable domain. Reviewed by: jhibbits, markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48888
* powerpc: Remove flag CTLFLAG_TUN from sysctl knob hw.platformZhenlei Huang2025-02-131-13/+4
| | | | | | | | | | | | | | | | | | | | Prior to change [1] this flag is useless but harmless. After the change plat_name[] will be fetched from kernel environment after invoking the platform probe function `platform_probe_and_attach()`. The probe function runs at early boot stage prior to `mi_startup()` thus it is too late and pointless to set plat_name[] after the probe. Nathan mentioned that the logic to specify the platform pre-dates the powerpc64 work, and is from the original pre-FDT Book-E bringup from like 2008, so it's irrelevant these days. Instead of fixing setting the sysctl knob hw.platform, let's clean it up now. [1] 3da1cf1e88f8 Extend the meaning of the CTLFLAG_TUN flag to ... Discussed with: nwhitehorn Reviewed by: olce (previous version), jhibbits, #powerpc MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D48897
* busdma: Always initialize bounce page STAILQShawn Anastasio2025-02-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Always call STAILQ_INIT in bus_dmamap_create regardless of whether BUS_DMA_COULD_BOUNCE is set. This avoids tripping the assertions added by commit 34740937f7a4 when the queue is checked with STAILQ_EMPTY in free_bounce_pages. Test Plan: Without this patch applied, booting fails as follows (pseries guest on Linux/ppc64le KVM host): vtblk0: <VirtIO Block Adapter> numa-domain 0 on virtio_pci1 panic: Empty stailq 0x8ed4480->stqh_last is 0, not head's first field address cpuid = 0 time = 1 KDB: stack backtrace: 0xc00800000000bcc0: at kdb_backtrace+0x60 0xc00800000000bdd0: at vpanic+0x1d4 0xc00800000000be80: at panic+0x44 0xc00800000000beb0: at bus_dmamap_unload+0x394 0xc00800000000bf60: at vtblk_poll_request+0x16c 0xc00800000000bff0: at vtblk_attach_completed+0x208 0xc00800000000c220: at vtpci_legacy_probe_and_attach_child+0x224 0xc00800000000c270: at vtpci_legacy_attach+0x2c0 0xc00800000000c320: at device_attach+0x568 0xc00800000000c400: at bus_attach_children+0x8c 0xc00800000000c440: at ofw_pcibus_attach+0x398 0xc00800000000c550: at device_attach+0x568 0xc00800000000c630: at bus_attach_children+0x8c 0xc00800000000c670: at ofw_pcib_attach+0x68 0xc00800000000c6a0: at rtaspci_attach+0x18c 0xc00800000000c6f0: at device_attach+0x568 0xc00800000000c7d0: at bus_generic_new_pass+0x198 0xc00800000000c820: at bus_generic_new_pass+0x10c 0xc00800000000c870: at bus_generic_new_pass+0x10c 0xc00800000000c8c0: at root_bus_configure+0x6c 0xc00800000000c910: at configure+0x1c 0xc00800000000c940: at mi_startup+0x298 0xc00800000000ca50: at __start+0xfc KDB: enter: panic [ thread pid 0 tid 100000 ] Stopped at kdb_enter+0x70: ori r0, r0, 0x0 With the patch applied to properly initialize the STAILQ unconditionally, the assertion is no longer hit and the system boots as expected. Reviewers: jhibbits, jhb, #powerpc, markj Reviewed By: jhibbits, jhb, #powerpc, markj Subscribers: imp, bdragon, luporl, alfredo, #powerpc Tags: #powerpc Differential Revision: https://reviews.freebsd.org/D48600
* sys: Add cpu_update_pcb hookJohn Baldwin2025-01-315-13/+4
| | | | | | | | | | | | | This MD function is invoked before dumping register set notes when writing out a core dump to ensure that the PCB for a given thread is up to date. This provides a centralized place to update the PCB with values of the current thread for each arch rather than doing this work in each register set's get method. Discussed with: jrtc27 Reviewed by: kib, markj Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D44910
* sys: use globals for the ELF kernel and module type stringsAhmad Khalifa2025-01-241-5/+4
| | | | | | | | | | Initialize the globals with macros so we can use the same values in the loader. Also remove unnecessary "elfN module" checks. Reviewed by: imp, kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1394
* sys: make the kernel metadata pointer globalAhmad Khalifa2025-01-241-27/+28
| | | | | | | | | | | | | | | | | The way we got the kernel metadata pointer was by calling preload_search_by_type with one of the following three: "elf kernel", "elf32 kernel" and "elf64 kernel". Which one(s) we used wasn't consistent though. Sometimes we would only try "elf kernel", and other times we would try one of the latter two if the first failed. However, the loader only ever sets "elf kernel" as the kernel type. Now, the kmdp is a global, preload_kmdp, and it's initialized using preload_initkmdp in machdep.c (or machdep_boot.c on arm/64). preload_initkmdp takes a single boolean argument that tells us whether not finding the kmdp is fatal or not. Reviewed by: imp, kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1394
* ps3disk.c: Rewrite ps3disk_transferChattrapat Sangmanee2025-01-241-41/+55
| | | | | | | | | | | | | | | | | | | | | This function is bugged since the beginning, but it never hit because its variable doesn't allow. However, since commit a77e1f0f81df5fa3b4a6a38728ebace599cb18a4 it happen now. First, it assume that ds_len will always equal to real user requested size. So it being used for sector count calculation. This is no longer true, and will fail if attempt to read last few sectors. Use bp->bio_length instead. Second, this being a loop is pointless because nsegs will never be > 1 as specified at bus_dma_tag_create() call. And all it doing is to repeat very same command again but with different ds_addr. Since bio_driver2 tag ident pointer are being reused, the result will be discarded at ps3disk_intr(). Signed-off-by: Chattrapat Sangmanee <aomsin27@hotmail.co.th> Reviewed by: imp,mav Pull Request: https://github.com/freebsd/freebsd-src/pull/1414
* pci: cleanup __PCI_REROUTE_INTERRUPTSMitchell Horne2025-01-231-3/+0
| | | | | | | | This flag was used as a transition for differing pcib implementations. Today it is defined for all supported architectures, and can be removed. Reviewed by: imp, jhb Differential Revision: https://reviews.freebsd.org/D48485
* Fix latency spikes on return from stop on POWER9+Timothy Pearson2025-01-211-10/+19
| | | | | | | | | | | | | | On POWER9 and higher platforms, cpu_idle_power9() directly control the external interrupt enable lines when entering / exiting stop states. This does not provide needed information to the rest of the kernel regarding the core going into a stop state, and results in random, significant latency spikes (>200ms) due to the stopped core not receiving wakeup interrupts in a deterministic manner. Bring cpu_idle_power9() in line with cpu_idle_powerx() by using spinlock entry / exit to control the interrupt state vs. direct MSR read / write. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
* Add machdep.cpu_idle_max_stop_state tunableTimothy Pearson2025-01-211-1/+39
| | | | | | | | | | | | Multiple idle and deep sleep states are supported on Power7+ platforms, with each state having a characteristic latency and effect on system real-time performance. Add a tunable to allow a maximum sleep state (maximum theoretical sleep-related latency) to be set, in order to better support specific latency-sensitive applications / real time workloads. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
* Centralize and simpify implemention of some VM macrosBrooks Davis2025-01-141-7/+0
| | | | | | | | | | | | | These macros have substantially identical implementations on each platform. Use roundup2/rounddown2 for round_page/trunc_page. This version standardizes on not using explicit casts and instead preserving the original type. A couple of tweaks were required to make this work. Reviewed by: brooks, kib, markj Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D48450
* atomics: Constify loadsOlivier Certner2024-12-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | In order to match reality, allow using these functions with pointers on const objects, and bring us closer to C11. Remove the '+' modifier in the atomic_load_acq_64_i586()'s inline asm statement's constraint for '*p' (the value to load). CMPXCHG8B always writes back some value, even when the value exchange does not happen in which case what was read is written back. atomic_load_acq_64_i586() further takes care of the operation atomically writing back the same value that was read in any case. All in all, this makes the inline asm's write back undetectable by any other code, whether executing on other CPUs or code on the same CPU before and after the call to atomic_load_acq_64_i586(), except for the fact that CMPXCHG8B will trigger a #GP(0) if the memory address is part of a read-only mapping. This unfortunate property is however out of scope of the C abstract machine, and in particular independent of whether the 'uint64_t' pointed to is declared 'const' or not. Approved by: markj (mentor) MFC after: 5 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46887
* Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin2024-12-0624-26/+48
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
* Replace calls to bus_generic_probe with bus_identify_childrenJohn Baldwin2024-12-062-2/+2
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47674
* powernv/opal: Add missing DEVMETHOD_END to method listJustin Hibbits2024-12-011-1/+3
| | | | | Reported by: ehem_freebsd_m5p.com MFC after: 1 week
* powerpc: Remove unnecessary prototype.Justin Hibbits2024-11-271-1/+0
| | | | This crept in with the interrupt rework back in 2019.
* powerpc: Get rid of interrupt subterfuge for IPIsJustin Hibbits2024-11-271-12/+20
| | | | | Instead of playing games with the interrupt event structure after the fact when setting up IPIs, do the work in the interrupt initializer.
* atomic(9): Implement atomic_testand(clear|set)_ptrJohn Baldwin2024-11-191-0/+10
| | | | | | | | | | For current architectures, these are just aliases for the existing operation on the relevant scalar integer. Reviewed by: imp, kib Obtained from: CheriBSD Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D47631
* atomic(9): Remove fcmpset-based fallback for atomic_testand(clear|set)John Baldwin2024-11-191-6/+0
| | | | | | | | All architectures implement a MD version Reviewed by: kib Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D47629
* sys: Avoid relying on pollution from refcount.hMark Johnston2024-11-051-0/+2
| | | | | | | | | | Fix up headers which previously assumed that refcount.h includes systm.h, and make them more self-contained. Then, replace the systm.h include in refcount with kassert.h. Reviewed by: imp, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47450
* Check for errors when detaching children first, not lastJohn Baldwin2024-11-053-3/+18
| | | | | | | | | | | | These detach routines in these drivers all ended with 'return (bus_generic_detach())' meaning that if any child device failed to detach, the parent driver was left in a mostly destroyed state, but still marked attached. Instead, bus drivers should detach child drivers first and return errors before destroying driver state in the parent. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47387
* powerpc: Add nominal support for POWER10 and POWER11Justin Hibbits2024-10-113-0/+22
|
* ps3: add elfv2 supportChattrapat Sangmanee2024-09-142-224/+230
| | | | | | | | | | ps3 are broken since we moved to clang/elfv2. Fix this by updating the hypercall glue to the new ABI. Signed-off-by: Chattrapat Sangmanee <aomsin27@hotmail.co.th> Reviewed by: jhibbits MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1413
* kernel: Make some compile time constant variables constZhenlei Huang2024-08-301-2/+3
| | | | | | | | | | | | | | Those variables are not going to be changed at runtime. Make them const to avoid potential overwriting. This will also help spotting accidental global variables shadowing, since the variable's name such as `version` is short and commonly used. This change was inspired by reviewing khng's work D44760. No functional change intended. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D45227
* pmap_growkernel: Use VM_ALLOC_NOFREE when allocating pagetable pagesBojan Novković2024-07-301-3/+3
| | | | | | | | | | | This patch modifies pmap_growkernel in all pmaps to use VM_ALLOC_NOFREE when allocating new pagetable pages. This should help reduce longterm fragmentation as these pages are never released after they are allocated. Differential Revision: https://reviews.freebsd.org/D45998 Reviewed by: alc, markj, kib, mhorne Tested by: alc
* conf: Remove kernel stack swapping support, part 12Mark Johnston2024-07-291-1/+0
| | | | | | | | | | Remove the NO_SWAPPING option. There is still some code in vm_swapout.c, but it relates to RACCT handling. Remove the option and make compilation of vm_swapout.c conditional on RACCT. Tested by: pho Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D46130
* vm: Remove kernel stack swapping support, part 5Mark Johnston2024-07-291-12/+0
| | | | | | | | - Remove cpu_thread_swapin() and cpu_thread_swapout(). Tested by: pho Reviewed by: alc, imp, kib Differential Revision: https://reviews.freebsd.org/D46116