Commit graph

1250 commits

Author SHA1 Message Date
Olivier Certner
986edb19a4
LinuxKPI: Have kvzalloc() rely on kvmalloc(), not kmalloc()
Since commit 19df0c5abc ("LinuxKPI: make __kmalloc() play by the
rules"), kmalloc() systematically allocates contiguous physical memory,
as it should.  However, kvzalloc() was left defined in terms of
kmalloc(), which makes it allocate contiguous physical memory too.  This
is a too stringent restriction, as kvzalloc() is supposed to be a simple
page-zeroing wrapper around kvmalloc().

According to Linux's documentation ("memory-allocation.rst"), kvmalloc()
first tries to allocate contiguous memory, falling back to
non-contiguous one if that fails.  Thus, callers are already supposed to
deal with the possibility of non-contiguous memory being returned.

Reviewed by:    bz
Fixes:          19df0c5abc ("LinuxKPI: make __kmalloc() play by the rules")
MFC after:      10 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D51247
2025-07-13 15:46:49 +09:00
Bjoern A. Zeeb
16c6a3444a LinuxKPI: device.h add (*shutdown)
There are too many ways to call (*shutdown)() and others in Linux
it seems;  rather than using the one from dev_pm_ops or directly
on the bus system device, some wireless drivers are setting it on
struct device_driver so add it.

Bump __FreeBSD_version as this changes the size of various other
structs which have struct device_driver embedded.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50679
2025-07-04 03:22:22 +00:00
Bjoern A. Zeeb
2f5666c172 LinuxKPI: MODULE_DEVICE_TABLE() factor out the bus specific MODULE_PNP_INFO()
In order to be able to use MODULE_DEVICE_TABLE() with multiple bus
attachments, factor out the bus-specfic MODULE_PNP_INFO() and place
it next to the structure defining the table.

As it turns out bnxt(4) has been using the MODULE_DEVICE_TABLE() with
PCI attachments for the "auxillary" bus so far.  That makes little sense.
Define the MODULE_PNP_INFO() to nothing for that.  We may consider
pulling these LinucKPI bits in semi-native drivers into LinuxKPI
one day as that route is not really sustainabke.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51049
2025-07-04 03:22:22 +00:00
Bjoern A. Zeeb
f58e032410 LinuxKPI: MODULE_DEVICE_TABLE() remove hard coded pci
While we currently only use MODULE_DEVICE_TABLE() for pci (or so I
thought [*]), this may soon change.  Remove a hard coded "pci" for
the bus and use the bus name passed in as _bus.

[*] see follow-up change

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51048
2025-07-04 03:22:22 +00:00
Ed Maste
cdbff1b299 linuxkpi: Remove incorrect + 1 from HWEIGHT* macros
Fixes: 4cc8a9da49 ("LinuxKPI: add HWEIGHT32()")
Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51010
2025-06-24 18:42:16 -04:00
Jean-Sébastien Pédron
1609b4d456
linuxkpi: Add pm_runtime_get_if_active() variant from Linux 6.9
With Linux 6.9, `pm_runtime_get_if_active()` lost its second `bool`
argument.

This change is put behind a check of `LINUXKPI_VERSION` to keep
compatibility.

Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50991
2025-06-24 00:16:04 +02:00
Jean-Sébastien Pédron
cf16d65c2e
linuxkpi: Define div64_ul() as a synonym to div64_u64()
Reviewed by:	bz
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50986
2025-06-24 00:07:56 +02:00
Alan Cox
797020a764 vm: retire vm_page_lock()
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
2025-06-11 15:19:41 -05:00
Brooks Davis
e453e498cb machine/stdarg.h -> sys/stdarg.h
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
2025-06-11 17:39:02 +01:00
Bjoern A. Zeeb
2ab7cbdc34 net80211: LinuxKPI: migrate HE defines to net80211, put correct values
Migrate most LinuxKPI 802.11 definitions for HE IEs to net80211.
During that process also properly define them as most of them only
had dummy values.  Some of the definitions are sparse;  that is, only
the bits used by drivers so far were listed and annotated with the
standards section.

There seems to be little point to mangle the names and have two copies
of all these bit field definitions.  We can add "_S" (shift/mask)
variants to those we need in net80211 (if we do).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D50677
2025-06-09 21:44:26 +00:00
Bjoern A. Zeeb
84c5998ccb LinuxKPI: skbuff: add dummy skb_copy_header()
There's one case which needs skb_copy_header();  add a dummy function
for now until we get to the code which uses it to test an implementation.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-06-03 18:35:10 +00:00
Bjoern A. Zeeb
4b6b9c1368 LinuxKPI: netdev features style, annotate, and add %b decoding mask
Start to sort through the netdevice features to match them with
FreeBSD.  Annotate them a bit more verbose though the names are
pretty telling already.

While here adjust style(9) as well.

Lastly add the bit definitions for use with printf(9) %b as names
read easier than bitmasks.  We will use that in LinuxKPI 802.11.

No functional changes.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-06-03 18:35:10 +00:00
Bjoern A. Zeeb
36ca21722c LinuxKPI: skbuff: make csum_unfold return __wsum
Given the internal field now stores a __wsum csum (after we added
the type) also make sure csum_unfold() returns a __wsum.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Fixes:		59481c7db2
2025-06-03 18:35:10 +00:00
Bjoern A. Zeeb
a02180cf60 LinuxKPI: Implement dma_map_resource/dma_unmap_resource functions
dma_map_resource() and dma_unmap_resource() functions are used to map
and unmap of memory-mapped IO resources so they can be accessed by
the device.

Required by drm-kmod v5.5 to be built.

While for drm-kmod 6.6-lts only amdgpu uses these in one place and
the code apparently has not been exercised a lot it has been around
like this for years.  With changing the underlying implementations
bring it into the tree; should we find errors with it they can also
be fixed here.

Bump __FreeBSD version to be able to detect this change.

Obtained from:	D30933 (by wulf)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D49625
2025-06-03 18:35:09 +00:00
Bjoern A. Zeeb
f99d393f7f LinuxKPI: add missing bus_dmamap_sync() calls or exclude them
Rename linux_dma_unmap() to lkpi_dma_unmap(), and linux_dma_map_phys()
to lkpi_dma_map_phys() so that we get the full set of function
arguments (direction and attributes were missing).
Leave the old functions as wrappers as they are called from drm-kmod
linuxkpi/bsd still, and leaving them also allows us to MFC this
change.

Add missing bus_dmamap_sync() calls.  Rather than inlining them
in each inline function push them down to the actual implementation.
From there do not inline them either but call the appropriate
function dealing with the sync so that we do not have the same
code splattered in many places.

Adhere to the DMA_ATTR_SKIP_CPU_SYNC attribute and skip synching
when requested.

A previous, less complete version of this change already allowed
me to load firmware on arm64 for iwlwifi (again).

There are four more places which are not currently done as the
functions which came with an OFED sync a long time ago seem to be
unused these days.  Leaving a pr_debug("TODO") call there.

Also dma_[un]map_resource() when brought in from drm-kmod/linuxkpi/bsd
(D30933) should be adjusted to pass the full arguments as the amdgpu
callers are requesting to skip synching.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D45294
2025-06-03 18:35:09 +00:00
Bjoern A. Zeeb
54d0e1772f LinuxKPI: add struct_group_tagged()
Restructure struct_group() into a wrapper around __struct_group().
Various callers have arguments annotated as /* no foo */ so try to
add all we can find.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50157
2025-05-28 10:42:58 +00:00
Bjoern A. Zeeb
6cbf8a04b1 LinuxKPI: 802.11: mark struct ieee80211_ht_cap __packed
In lkpi_sta_sync_ht_from_ni() we are casting the information element (IE)
data to this struct as net80211 does not save the mcs/rx_mask.
Not marking the structs packed results in the mcs information not being
copied correctly and rx_nss calculations possibly being off.  Even worse,
at a later stage iwlwifi mvm/rs.c would extract the mcs values from the
same field to pass to the firmware which will than crash in an assert
as we would want to do HT with an empty MCS set.

Sponsored by:	The FreeBSD Foundation
MFC after:	sunrise
Discovered:	while testing other features on arm64.
2025-05-26 23:33:08 +00:00
Jean-Sébastien Pédron
e3b16f53a6
linuxkpi: Add folio and folio_batch APIs
They are used by the i915 DRM driver in Linux 6.6 (although this change
was only backported with Linux 6.7 DRM drivers).

`struct folio` simply wraps `struct page` for now.

`struct folio_batch` is the same as `struct pagevec` but it works with
`struct folio` instead of `struct page` directly.

Reviewed by:	bz, kib, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48743
2025-05-12 19:08:03 +02:00
Jean-Sébastien Pédron
c8089810a9
linuxkpi: Make "free page" code paths closer to Linux
There is basically one code path to free pages on Linux. In particular,
`free_pages()` is used for other pages than those returned by
`alloc_pages()`.

Also on Linux, `release_pages()` takes either `struct page` or `struct
folio`. `struct folio` support will be added in a followup commit.
Regardless, because pages come from several sources,
`linux_free_pages()` need to accept managed and unmanaged pages.

Reviewed by:	bz, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49813
2025-05-12 19:08:02 +02:00
Jean-Sébastien Pédron
5a263e8458
linuxkpi: Constify struct page arg to linux_page_address()
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49812
2025-05-12 19:08:02 +02:00
Jean-Sébastien Pédron
fe5ce9eb02
linuxkpi: Move put_page() closer to get_page()
This is to prepare a future change to the implementation and make it
easier to review.

Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49811
2025-05-12 19:08:02 +02:00
Jean-Sébastien Pédron
e51729f608
linuxkpi: Move release_pages() to linux_page.c
We want to avoid putting code managing memory in inline functions in the
future.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49810
2025-05-12 19:08:02 +02:00
Jean-Sébastien Pédron
6d720cdfe7
linuxkpi: Add woken_wake_function() and wait_woken()
They are used by the i915 DRM driver starting with Linux 6.7.

`(struct wait_queue)->flags` is no longer always zero. I wonder if some
code relied on this...

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48755
2025-05-12 19:08:02 +02:00
Mark Johnston
eed3be4796 linuxkpi: Fix up jiffies handling
A few issues found by code inspection while hunting for bugzilla PR
286512:
- The "expires" field in struct delayed_work should be unsigned.
- In linux_timer_jiffies_until(), clamp the return value to INT_MAX:
  this return value is used as a ticks count, not a jiffies count, so we
  should avoid returning too large a value, lest it get truncated.  It's
  unlikely we are dealing with values that large, but we should be
  careful anyway.
- In linux_add_to_sleepqueue(), truncate the timeout to INT_MAX, as this
  value is passed to sleepq_set_timeout() as a ticks value.  Typically
  it's multiplied by ticks_sbt to get an sbintime, and we should make
  sure the multiplication doesn't overflow.  In drm-kmod, there is at
  least one call mod_delayed_work(... MAX_SCHEDULE_TIMEOUT).

Fixes:		325aa4dbd1 ("linuxkpi: Introduce a properly typed jiffies")
Reviewed by:	olce, bz, dumbbell, kib
Tested by:	dumbbell, bz
Differential Revision:	https://reviews.freebsd.org/D50192
2025-05-12 14:08:39 +00:00
Bjoern A. Zeeb
93b82146c4 LinuxKPI: add ktime_get_boottime_seconds()
ktime_get_boottime_seconds() is needed by an updated iwlwifi driver.

Sposored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50005
2025-05-09 19:45:10 +00:00
Bjoern A. Zeeb
71576ed24b LinuxKPI: add _devcd_free_sgtable() to devcoredump.h
It may be that once we implement freeing of chained tables
_devcd_free_sgtable() will become our _lkpi_dev_coredumpsg_free()
but further investigations need to happen.  For now make an
updated iwlwifi driver happy which should not need more.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50006
2025-05-09 19:45:10 +00:00
Bjoern A. Zeeb
a4618caa43 LinuxKPI: add is_unicast_ether_addr()
Needed by mediatek/mt76 wireless driver.

While here adjust the way is_multicast_ether_addr() is implemented
to not look weird. [1]

Sponsored by:	The FreeBSD Foundation
Suggested by:	emaste [1]
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50152
2025-05-05 10:44:22 +00:00
Bjoern A. Zeeb
675e6b1c68 LinuxKPI: 802.11: header updates for mt76
Add more structs, fields, flags, defines.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-05-05 10:44:22 +00:00
Bjoern A. Zeeb
8ba4d145d3 mt76: update Mediatek's mt76 driver
This version is based on
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
38fec10eb60d687e30c8c6b5420d86e8149f7557 ( tag: v6.14 ).

Sponsored by:   The FreeBSD Foundation
2025-05-04 22:55:08 +00:00
Bjoern A. Zeeb
9c05d6320c LinuxKPI: netdev: add NETIF_F_HW_TC
Add a new flag needed by mt76.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-05-04 22:10:46 +00:00
Mark Johnston
325aa4dbd1 linuxkpi: Introduce a properly typed jiffies
Now that we have a long-sized tick counter, we can migrate to using
properly typed timeout parameters in various bits of the LinuxKPI.  This
fixes a subtle incompatibility that is otherwise difficult to paper over
and leads to bugs when ticks values are sign-extended.

- Introduce a "jiffies" symbol in subr_ticks.S, declared only in the
  LinuxKPI as an unsigned long.
- Remove all references to "ticks" from the LinuxKPI.
- Convert interfaces to match Linux's type signatures where it makes
  sense.

Reviewed by:	manu
Tested by:	bz
Differential Revision:	https://reviews.freebsd.org/D48523
2025-04-29 13:53:40 +00:00
Bjoern A. Zeeb
8b51cd07f6 LinuxKPI: define time64_t
Define time64_t to int64_t for all supported architectures
unconditionally.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	imp, markj, emaste
Differential Revision: https://reviews.freebsd.org/D50004
2025-04-27 19:03:42 +00:00
Bjoern A. Zeeb
e6010da639 LinuxKPI: 802.11: updates to headers for driver update
Move some structs into the appropriate header to be visible.
Add new fields to structs and enums.

Remove arguments from two functions (one function currently unused
by drivers in the tree, for the other the argument was unused).
Adjust the iwlwifi accordingly.  This is in preparation for new
driver versions to allow a smooth transition.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-04-24 22:13:55 +00:00
Bjoern A. Zeeb
e29d72ac3d LinuxKPI: pci: add pci_info()
Add pci_info() needed for a driver update.  While here prefix
__VA_ARGS__ with ## for pci_err and pci_info in case we are only
passed a string without format arguments.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50009
2025-04-24 22:13:54 +00:00
Bjoern A. Zeeb
f94d731954 LinuxKPI: sysfs: implement sysfs_match_string()
Use a macro to automatically gather the length of the array while
we can.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50007
2025-04-24 22:13:54 +00:00
Bjoern A. Zeeb
6841b9987e LinuxKPI: add container_of_const()
Implement container_of_const() needed for wireless driver updates.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D49999
2025-04-24 22:13:54 +00:00
Bjoern A. Zeeb
69880fede7 LinuxKPI: extend struct and enum for leds
An updated rtw88 driver requires minimal changes to leds.h.  On
the positive side we can now remove the __DUMMY from the enum as we
actually have a valid field name.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50002
2025-04-24 22:13:54 +00:00
Bjoern A. Zeeb
059136a95a LinuxKPI: add cleanup.h to mutex.h
Some code relies on header pollution (or self-sustainability).
Add cleanup.h to mutex.h as that is one case it seems to be used with.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50001
2025-04-24 22:13:54 +00:00
Bjoern A. Zeeb
c8e2458de5 LinuxKPI: add ASMEDIA vendor ID for PCI
This is needed for rtw89 updates.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste, zarychtam_plan-b.pwste.edu.pl
Differential Revision: https://reviews.freebsd.org/D50000
2025-04-24 22:13:53 +00:00
Bjoern A. Zeeb
a23908728e LinuxKPI: 802.11: fix TKIP RX/TX MIC offsets
TKIP has a special key buffer.  While keylen only identifies the
key length, the two MIC are appended.  The LinuxKPI offsets for
these were unfortunately never set correct which lead to constant
Micheal counter measures as the MIC never was correct when calculations
were offloaded to firmware.  This is the first half of the fix.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-04-23 16:24:21 +00:00
Bjoern A. Zeeb
59481c7db2 LinuxKPI: skbuff: fix types, shuffle fields
Fix the types of a few remaining fields.
Shuffle the fields around so the important ones align to 64byte on a
64bit platform.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-04-22 23:45:49 +00:00
Bjoern A. Zeeb
73e3969fd4 LinuxKPI: skbuff: remove _alloc_len field
Initially we saved the exact allocation length for contigfree(9).
contigfree can now be replaced by free(9) so there is no need to
remember that value anymore.  Removing it also simplifies the
linuxkpi_kfree_skb() code.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-04-22 23:45:33 +00:00
Bjoern A. Zeeb
c925e0a776 LinuxKPI: add type for __wsum
Seems this is the correct type for the csum field in an sk_buff.
Add it as uint32_t __bitwise__.

Sponsored by;	The FreeBSD Foundation
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D49831
2025-04-22 23:42:44 +00:00
Jean-Sébastien Pédron
21b556557e
linuxkpi: Fix pci_upstream_bridge() with DRM devices
In the case of DRM drivers, the passed device is a child of `vgapci`. We
want to start the lookup from `vgapci`, so the parent of the passed
`drmn`. We use the `isdrm` flag to determine if we are in this
situation.

This fixes an infinite loop with the amdgpu DRM driver that started to
use this function in Linux 6.8: `pci_upstream_bridge()` was returning
itself and the code in amdgpu was calling it again, hoping to get a
device with a vendor that is not "ATI".

Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49388
2025-04-13 11:51:13 +02:00
Jean-Sébastien Pédron
d9a2c2e250
linuxkpi: Add memcpy_{from,to}_page()
The i915 DRM driver started to use it in Linux 6.8.

Reviewed by:	bz
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49384
2025-04-13 11:50:42 +02:00
Jean-Sébastien Pédron
78e25e65bf
lindebugfs: Add debugfs_create_str()
This function is used by the i915 DRM driver starting with Linux 6.8.

Reviewed by:	bz, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49067
2025-04-13 11:50:14 +02:00
Bjoern A. Zeeb
a3e6f97bf5 LinuxKPI; cleanup slab.h a bit; move more free() into slab.c
Move kfree() into slab.c as an implementation and hide the private
function linux_kfree_async() entirely.

Remove a ; at the end of a define and sort some defines into place.

Remove extern from function declarations and move the closer to where
they belong.

Sort the functions into "base allocator/free" functions--these have
an implementation in slab.c and are ensuring contiguous physical
memory allocations.

Followed by inline functions using these base allocators to implement
their functionality; vmalloc/kvalloc, and misc functions.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D49572
2025-04-12 20:49:20 +00:00
Bjoern A. Zeeb
1c95d401eb LinuxKPI: implement krealloc() for memory being contiguous
Implement krealloc_array() using krealloc().  Implement krealloc()
doing the various size checks ourselves and use realloc() or kmalloc()
depending on old and new allocation sizes.
This way we can ensure that allocated memory stays physically contiguous.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Suggested by:	jhb (see D46657)
Reviewed by:	jhb, markj
Differential Revision: https://reviews.freebsd.org/D49571
2025-04-12 20:49:20 +00:00
Bjoern A. Zeeb
1c81ebec74 LinuxKPI: switch mallocarray to an lkpi implementation using __kmalloc()
With mallocarray() we cannot guarantee that any size larger than
PAGE_SIZE will be contiguous.  Switch kmalloc_array() and
kmalloc_array_node() to use __kmalloc()/lkpi___kmalloc_node() as their
underlying implementation which now does provide that guarantee.
Likewise adjust kcalloc_node() to use kmalloc_array_node().
This means we only have two (plain + _node) underlying allocation
routines for the entire category of functions.

Also adjust kvmalloc() and kvmalloc_array() to be a "mirrored"
implementation to their non-v counterparts. These may return
non-contiguous memory so can use malloc().

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	jhb
Extra thanks to: jhb for helping sorting this out
Differential Revision: https://reviews.freebsd.org/D46657
2025-04-12 20:49:19 +00:00
Bjoern A. Zeeb
4359672e65 LinuxKPI: add seq_hex_dump()
Move the implementation of print_hex_dump() into linux_compat.c as
lkpi_hex_dump() taking an extra function pointer and argument.
Add two internal wrappers for printf and sbuf_printf to get a common
function definition (sbuf_printf takes the extra argument).

Use these to implement print_hex_dump() and the newly added
seq_hex_dump().

This allows us to re-use the same implementation of print_hex_dump()
for both functions without duplicating the code.

Initial implementation:	D49381 by dumbbell
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D49637
2025-04-12 20:49:19 +00:00