aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/asm
Commit message (Collapse)AuthorAgeFilesLines
* linuxkpi: fix 32-bit arm buildKyle Evans117 min.1-2/+0
| | | | | | | | | | | | | The new KPI is only used in <asm/set_memory.h>, but it's provided in linux_page.c. The latter only includes the former indirectly by way of <linux/io.h>, and that's only conditionally included outside of 32-bit ARM there. All of our archs have the necessary pmap_page_set_memattr(), so just move the declaration into <linux/page.h> instead of trying to reason about the usability of <asm/set_memory.h> directly in linux_page.c. Reported by: jenkins (via ivy)
* linuxkpi: work with numpages > 1 in the set_pages_*() KPIsKyle Evans12 hours1-12/+5
| | | | | | | | | | | | | | | | | | | These calls are used for buddy pages at least in drm's ttm_pool, which leads to a panic when we invoke lowmem handlers and drm tries to shrink the pool. Cope with numpages > 1 by traversing the contiguous pages and executing the adjustment there, as well, as suggested by markj@. Previous versions have tried to use the corresponding `set_memory_*()` functions, but it is believed that not updating `md.pat_mode` breaks subsequent userspace mappings in ways that may result in things like screen tearing or other artifacts when running i915kms. This stabilized my amdgpu laptop running two VMs, chromium and a concurrent buildworld. Reviewed by: bz, markj Differential Revision: https://reviews.freebsd.org/D57004
* linuxkpi: Define `VFM_*()` macros in <asm/cpu_device_id.h>Jean-Sébastien Pédron2026-04-302-0/+42
| | | | | | | | | | | | | | They use another set of constants and macros in <asm/intel-family.h>. All these macros are defined regardless of the architecture, even though they are specific to x86. Perhaps we should restrict them using #ifdefs. The amdgpu DRM driver started to used `VFM_MODEL()` and the `INTEL_*LAKE*` constants in Linux 6.12.x. Reviewed by: bz, olce Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D56585
* pmap_change_attr: Use void * instead of vm_offset_tJohn Baldwin2026-04-231-3/+3
| | | | | | | Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* linuxkpi: Define `PMD_SHIFT`Jean-Sébastien Pédron2026-04-061-0/+34
| | | | | | | | | | For now, only define it for x86 architectures. The DRM generic code started to use it in Linux 6.11. Reviewed by: bz, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55734
* linuxkpi: Add get_unaligned_le64()Jean-Sébastien Pédron2026-01-051-0/+7
| | | | | | | | | | | This function was the only one missing in the `get_unaligned_*()` family. This is going to be used by the imported `linux_siphash.c` in a future commit, which itself is used by DRM drivers starting from Linux 6.10. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54500
* linuxkpi: Add the `topology_*()` functionsJean-Sébastien Pédron2025-08-091-0/+54
| | | | | | | | | | | ... from <asm/topology.h>. The amdgpu DRM driver started to use `topology_num_cores_per_package()` in Linux 6.9. Reviewed by: manu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50993
* LinuxKPI: Add smp_store_release and smp_load_acquire functionsVladimir Kondratyev2024-06-261-0/+3
| | | | | | | Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D45611
* linuxkpi: Fix set_memory_*Tijl Coosemans2024-05-031-15/+6
| | | | | | | | | | | | | set_memory_* is currently implemented using PHYS_TO_DMAP but not all architectures have a DMAP. Looking at how this function is used the given address isn't physical but virtual so the PHYS_TO_DMAP call can simply be removed. Also cast numpages before shifting it to avoid overflow. Reviewed by: kib, markj MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D45057
* LinuxKPI: Add x86_vendor field to struct cpuinfo_x86Vladimir Kondratyev2023-12-241-0/+13
| | | | | | | | | and initialize it at linuxkpi module load. Sponsored by: Serenity Cyber Security, LLC Reviewed by: manu MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42820
* LinuxKPI: Add asm/hypervisor.h headerVladimir Kondratyev2023-12-241-0/+19
| | | | | | | | Sponsored by: Serenity Cyber Security, LLC Obtained from: OpenBSD Reviewed by: manu, bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42802
* LinuxKPI: reduce impact of large MAXCPUBjoern A. Zeeb2023-12-221-1/+1
| | | | | | | | | | | | | | | | | Start scaling arrays dynamically instead of using MAXCPU, resulting in extra allocations on startup but reducing the overall memory footprint. For the static single CPU mask we provide two versions to further save memory depending on a low or high CPU count system. The threshold to switch is currently at 128 CPUs on 64bit platforms. More detailed comments on the implementations can be found in the code. If I am not wrong on a MAXCPU=65536 system the memory footprint should roughly go down from 512M to 1.5M for the static single CPU mask. Submitted by: olce (most of this final version) Sponsored by: The FreeBSD Foundation PR: 274316 Differential Revision: https://reviews.freebsd.org/D42345
* linuxkpi: Fix uses of `pmap_change_attr()`Jean-Sébastien Pédron2023-10-031-3/+21
| | | | | | | | | | | | | | | | | | | | | | | [Why] This function takes an offset and a length as argument, not a physical address and a number of pages. This misuse caused the `set_memory_*()` and `arch_io_reserve_memtype_wc()` functions to return EINVAL. Another problem was the fact that they returned errors as a positive integer, whereas Linux uses negative integers. [How] Physical addresses and number of pages are converted to offset+length in the `set_memory_*()` functions. `arch_io_reserve_memtype_wc()` now calls `pmap_change_attr()` directly instead of using `set_memory_wc()`. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D42053
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-1612-24/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* LinuxKPI: reduce usage of struct vm_page and vm_page_tBjoern A. Zeeb2023-08-071-6/+6
| | | | | | | | | | | | | | We currently define (Linux) page to (FreeBSD) vm_page. Cleanup some of the direct struct vm_page and vm_page_t declarations and usages in the Linux KPI and make them 'struct page' or 'struct page *' to prepare for more upcoming work. This should be a NOP. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D41255
* LinuxKPI: add put_unaligned_le16() and get_unaligned_be64()Bjoern A. Zeeb2023-05-201-1/+17
| | | | | | | | | | Add the two new functions needed by wireless drivers by the same implementation pattern we did for different sizes. Sponsored by: The FreeBSD Foundation MFC after: 10 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D40174
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-123-3/+3
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* linuxkpi: Add alderlake defines in intel-familyEmmanuel Vadot2023-03-281-0/+3
| | | | | | Needed by drm-kmod. Sponsored by: Beckhoff Automation GmbH & Co. KG
* linuxkpi: Define `pat_enabled()`Jean-Sébastien Pédron2023-03-211-0/+18
| | | | | | | | | This new <asm/memtype.h> header is included from <linux/pci.h> because that's how it is included in Linux too. DRM drivers depend on this. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D39052
* linuxkpi: Define `cpu_data(cpu)`Jean-Sébastien Pédron2023-02-132-0/+6
| | | | | | | | | | | | | | | | | | `cpu_data(cpu)` evaluates to a `struct cpuinfo_x86` filled with attributes of the given CPU number. The CPU number is an index in the `__cpu_data[]` array with MAXCPU entries. On FreeBSD, we simply initialize all of them like we do with `boot_cpu_data`. While here, we add the `x86_model` field to the `struct cpuinfo_x86`. We use `CPUID_TO_MODEL()` to set it. At the same time, we fix the value of `x86` which should have been set to the CPU family. It was using the same implementation as `CPUID_TO_MODEL()` before. It now uses `CPUID_TO_FAMILY()`. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38542
* linuxkpi: Try to solve headers dependenciesJean-Sébastien Pédron2023-01-301-0/+4
| | | | | | | | I'm sure I got it wrong but at least the DRM drivers compile. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38157
* linuxkpi: Fix `atomic_long_sub()` overflowJean-Sébastien Pédron2023-01-251-1/+7
| | | | | | | | | | By (ab)using `atomic_long_add_return()`, `atomic_long_sub()` was making the atomic long overflow. Indeed the underlying FreeBSD atomic is based on an unsigned long. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38090
* copyright: chase my name and email changeVal Packett2023-01-062-2/+2
| | | | | Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D37945
* linuxkpi: Add `cmpxchg64()` in <asm/atomic.h>Jean-Sébastien Pédron2022-12-011-0/+1
| | | | Differential Revision: https://reviews.freebsd.org/D36966
* linuxkpi: Define `boot_cpu_data.x86_max_cores`Jean-Sébastien Pédron2022-11-111-0/+1
| | | | | | Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D36971
* linuxkpi: Move cpu_relax out of ifdef for x86Emmanuel Vadot2022-11-101-2/+2
| | | | | | | It's needed by drm-kmod and this allow building on arm64 and powerpc. Reported by: jhibbits Sponsored by: Beckhoff Automation GmbH & Co. KG
* LinuxKPI: add virt_to_phys()Bjoern A. Zeeb2022-11-081-0/+7
| | | | | | | | | Add virt_to_phys() as a define to vtophys(). This is used by a wireless driver for dma related work; sigh. MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37301
* linuxkpi: retire now-unused MIPS supportEd Maste2022-10-172-5/+2
| | | | | | Reviewed by: bz, manu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37023
* linuxkpi: Add asm/processor.hEmmanuel Vadot2022-08-181-0/+46
| | | | | | | | | Also fill the boot_cpu_data struct as drm needs it. Reviewed by: bz Obtained from: drm-kmod Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36107
* linuxkpi: pgtable: Add more definesEmmanuel Vadot2022-08-181-0/+15
| | | | | | | | | Needed by drm-kmod Reviewed by: bz Obtained from: drm-kmod Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36101
* linuxkpi: Add smp_mb__before/after_atomicEmmanuel Vadot2022-08-081-0/+3
| | | | | | | Reviewed by: hselasky Obtained from: drm-kmod Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36020
* linuxkpi: Add try_cmpxchg and atomic_try_cmpxchgEmmanuel Vadot2022-08-081-0/+22
| | | | | | | | Needed by drm-kmod Obtain from: drm-kmod Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36015
* linuxkpi: atomic: Add atomic_fetch_incEmmanuel Vadot2022-08-081-0/+7
| | | | | | Reviewed by: hselasky Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D35936
* linuxkpi: Add asm/set_memory.hEmmanuel Vadot2022-06-291-0/+117
| | | | | | | | Provide functions needed for drm-kmod. MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D35571
* linuxkpi: Add asm/iosfmbi.hEmmanuel Vadot2022-06-291-0/+15
| | | | | | | | | Provide dummy functions needed for drm-kmod. Obtain from: OpenBSD (via drm-kmod) MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D35570
* LinuxKPI: add asm/neon.hGreg V2022-06-211-0/+40
| | | | | | | | This is equivalent to asm/fpu/api.h, but is included by drm on aarch64. Reviewed by: bz, imp, hselasky MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D35512
* linuxkpi: Add atomic64_fetch_addEmmanuel Vadot2022-02-171-0/+6
| | | | | | | | | Linux variant of atomic_fetchadd_64. Reviewed by: bz MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D34296
* linuxkpi: Add user_write_access_*Emmanuel Vadot2022-02-171-0/+3
| | | | | | | | | Needed by drm-kmod v5.8 Reviewed by: bz MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D34284
* LinuxKPI: add get_unaligned_le16()Bjoern A. Zeeb2022-02-141-0/+7
| | | | | | | | Add get_unaligned_le16() to asm/unaligned.h needed by a driver. MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D34224
* LinuxKPI: Constantly use _LINUXKPI_ prefix in include guardsVladimir Kondratyev2022-01-1015-44/+44
| | | | | | MFC after: 1 week Reviewed by: bz, emaste, hselasky, manu Differential Revision: https://reviews.freebsd.org/D33562
* LinuxKPI: Add static_cpu_has() implementationVladimir Kondratyev2022-01-101-0/+37
| | | | | | | | | static_cpu_has returns true if CPU supports requested feature. Obtained from: OpenBSD MFC after: 1 week Reviewed by: hselasky, manu Differential Revision: https://reviews.freebsd.org/D33301
* LinuxKPI: Implement smp_*mb barriers with atomic_thread_fence_*Vladimir Kondratyev2022-01-101-0/+58
| | | | | | | | for x86 and move them to asm/barrier.h MFC after: 1 week Reviewed by: bz, hselasky, manu Differential Revision: https://reviews.freebsd.org/D33296
* LinuxKPI: Add dummy pgprot_decrypted() implementationVladimir Kondratyev2021-09-291-0/+2
| | | | | | | | to reduce number of #ifdefs in drm-kmod Reviewed by: hselasky MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D32094
* LinuxKPI: Make FPU sections thread-safe and use the NOCTX flag.Hans Petter Selasky2021-07-311-34/+6
| | | | | | | | Reviewed by: kib Submitted by: greg@unrelenting.technology Differential Revision: https://reviews.freebsd.org/D29921 MFC after: 1 week Sponsored by: NVIDIA Networking
* LinuxKPI: byteorder.hBjoern A. Zeeb2021-05-251-36/+102
| | | | | | | | | | | | Add a few more le<n>_{tp,add}_cpu*() #defines/functions found in wireless drivers. While here fill most of the combinatorics gaps and also add the remaining combinations [1]. Suggested by: emaste [1] (for one part) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D30418
* LinuxKPI: remove < 5.0 version supportBjoern A. Zeeb2021-03-241-4/+0
| | | | | | | | | | | | | | We are not aware of any out-of-tree consumers anymore which would need KPI support for before Linux version 5. Update the two in-tree consumers to use the new KPI. This allows us to remove the extra version check and will also give access to {lower,upper}_32_bits() unconditionally. Sponsored-by: The FreeBSD Foundation Reviewed-by: hselasky, rlibby, rstone MFC-after: 2 weeks X-MFC: to 13 only Differential Revision: https://reviews.freebsd.org/D29391
* LinuxKPI: upstream a collection of drm-kmod conflicting changesBjoern A. Zeeb2021-01-281-0/+78
| | | | | | | | | | | | | | | | | The upcoming in-kernel implementations for LinuxKPI based on work on iwlwifi (and other wireless drivers) conflicts in a few places with the drm-kmod graphics work outside the base system. In order to transition smoothly extract the conflicting bits. This included "unaligned" accessor functions, sg_pcopy_from_buffer(), IS_*() macros (to be further restricted in the future), power management bits (possibly no longer conflicting with DRM), and other minor changes. Obtained-from: bz_iwlwifi Sponsored-by: The FreeBSD Foundation MFC after: 3 days Reviewed by: kib, hselasky, manu, bdragon (looked at earlier versions) Differential Revision: https://reviews.freebsd.org/D26598
* linuxkpi: add kernel_fpu_begin/kernel_fpu_endEmmanuel Vadot2021-01-121-0/+68
| | | | | | | | | | | With newer AMD GPUs (>=Navi,Renoir) there is FPU context usage in the amdgpu driver. The `kernel_fpu_begin/end` implementations in drm did not even allow nested begin-end blocks. Submitted by: Greg V Reviewed By: manu, hselasky Differential Revision: https://reviews.freebsd.org/D28061
* Allow LinuxKPI types to be used in bootloaders, by checking for theHans Petter Selasky2020-11-181-2/+2
| | | | | | | | | | | | _STANDALONE definition. No functional change intended. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=367789
* compat: clean up empty lines in .c and .h filesMateusz Guzik2020-09-013-3/+0
| | | | Notes: svn path=/head/; revision=365080