Commit Graph
10600 Commits
Author SHA1 Message Date
Augustin Cavalier 95ace7f374 kernel/vm: Introduce methods to change the cache of all an area's clones.
This will be useful in the case of cloned device caches based
around physical memory, e.g. for framebuffers.

Change-Id: If2b864208e86f436e91379b73c4b866b0bd5e1d7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10558
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-24 14:01:11 +00:00
Augustin Cavalier 861f644f19 app_server & BWindowScreen: Do away with AS_GET_FRAME_BUFFER_CONFIG.
It can't work if the framebuffer is mapped per-application.
Instead, use the accelerant hook to get the framebuffer.

The BScreen methods this disables were deprecated and marked
private already, so no Haiku applications should be affected.
(If really necessary they could be reimplemented with BWindowScreen.)

Remove first _GetCardInfo in BWindowScreen; we invoke it
later, closer to where the buffer is actually used.

Tested with ParticlesII (which uses BWindowScreen) on VESA
with the new user-only-mapping accelerant.

Change-Id: I405bcfa8cb1eb2d0c346fafbc6233bef15196134
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10572
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-24 14:01:11 +00:00
Augustin Cavalier f6be811473 BDirectWindow: Clone the framebuffer from app_server, if necessary.
This paves the way for accelerants to map the framebuffer in
user memory, not kernel memory. It uses the ServerMemoryAllocator
in order to avoid mapping the framebuffer multiple times in
client applications.

While at it, clean up some names.

Tested with DirectWindowStars and GLTeapot, both work.

Change-Id: I4e0c003fae99891044af0a5e6e1d6a4506da6430
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10571
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-24 14:01:11 +00:00
Augustin Cavalier a277043c1f kernel: Overhaul debug heaps system.
Instead of the kernel heap being a compile-time parameter, make it
a runtime parameter (if DEBUG_HEAPS is specified, at least; otherwise
we're hardwired to the slab heap as before.)

This is similar to what's done in userland: there LD_PRELOAD and
MALLOC_DEBUG control the heaps, here "kernel_malloc" and then
"guarded_heap_options" kernel settings control the heap.

While at it, apply fixes to the guarded and debug heaps to ensure
a minimum alignment of sizeof(void*), if no specific alignment
is requested.

Tested with a lot of build configurations (DEBUG_HEAPS 0, 1;
DEBUG_HEAPS_DEFAULT slab, guarded; USE_DEBUG_HEAPS_FOR_OBJECT_CACHE
0, 1) and with various parameters specified in the bootloader.
2026-03-23 23:01:26 -04:00
Augustin Cavalier 4fd16356e0 kernel: Move the debug heap to a separate file in the debug directory. 2026-03-23 23:01:26 -04:00
Augustin Cavalier 7e813b6181 bluetooth: Drop unused int128.
This should be done using __int128 if necessary.
2026-03-23 14:34:25 -04:00
Augustin Cavalier 935941e772 kernel/vm: Drop team argument from vm_set_area_protection.
It's not needed and just creates confusion. Permissions checks
are done with the current team and the "kernel" parameter.
2026-03-23 14:31:00 -04:00
Augustin Cavalier 5fffbbfc48 kernel/vm: Minor API changes for consistency in VMCache.
* Insert/Remove can't fail, so drop status_t return values.

 * "TransferAreas" is really "TakeAreasFrom", so rename it. This
   avoids confusion with the "transfer_area" API call, which moves
   an area to another address space (keeping the same cache.)
2026-03-21 12:30:02 -04:00
Augustin Cavalier 05f1182cca kernel/vm: Overhaul protection checks and fixup.
* Give arch_vm_supports_protection a team_id argument (primarily
   to allow the kernel address space to be more restricted than
   user ones.)

 * Move invocation of arch_vm_supports_protection to a static method,
   and also call fix_protection from there.

 * Consolidate protection checks.
2026-03-21 09:26:44 -04:00
John Davis 17a4eb1ef9 hyperv: Add SCSI controller support
Adds support for the Hyper-V SCSI controller as part of the hyperv_scsi
driver. This driver enables the use of Hyper-V generation 2 VMs as
the SCSI controller is the only storage method supported.

IDE hard disks can be supported in the future on generation 1 VMs by
this driver, but this will require a mechansim to prevent the ATA
bus manager from handling hard disks and conflicting with this one.

Change-Id: Iabb9c0471578caf1ef80754f39a09e1ce0eb4249
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10504
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-21 11:20:30 +00:00
Sam Roberts 593f25d6f1 arm64: Fixes for booting in EL2 w/ E2H
* E2H (EL2 Host) is enabled by default and usually can't be disabled
  on CPUs with FEAT_VHE. Since EL2 becomes a superset of EL1 with
  E2H, we can simply do nothing and everything that expects EL1
  will Just Work
* Changed some register bits numbers to avoid C integer promotion
  issues
* sEmptyTable needs to be filled in earler, before the kernel team
  is created. Otherwise, we put the uninitialized value of sEmptyTable
  in TTBR0, which immediately pends SError on Apple M1

Change-Id: I84ff7fd9134448f27315dadfd12bdd9df8c75b10
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10547
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-19 15:33:11 +00:00
Augustin Cavalier 87e0daf0a1 kernel: Include <smp.h> in VMTranslationMap.
RISC-V at least doesn't implicitly include it.
2026-03-17 14:49:13 -04:00
Augustin Cavalier cf2179fa35 kernel: Add invalidation utility routines to VMTranslationMap.
These allow us to move a lot of the basic logic out of the
TranslationMaps. In the process, it extends the fix applied
to x86 in the previous commit to all the other maps.
2026-03-17 13:30:11 -04:00
Augustin Cavalier 19bcb3be0a kernel/scheduler: Make invoke_scheduler atomic to skip unnecessary ICIs.
Following upon a KDL reported by atomozero, on wait-for-free-SMP-messages
on an unblock occurring with interrupts disabled.

In changing cpu_ent, move disabled to the beginning to avoid
enlarging the structure unncessarily.

On a 4-core VM, this skips around 200 sends during boot, and
over 3000 during a rebuild of HaikuDepot + mime_db (cold). On
bare metal (i3, 2x2), it skips around 150 during boot, and a bit
below 3000 during a rebuild of HaikuDepot + mime_db (over a much
longer time than in the VM, as the hardware is slower.)

Performance in the VM doesn't look much different. But this might
help in VirtualBox, or other situations where ICI latency is far
above what it should be.
2026-03-17 11:25:36 -04:00
John Davis 4f6e4b41ba hyperv: Add reference counter support
Adds support for the Hyper-V partition reference counter.

Change-Id: Ie74b4d3af1b320b7b724776bdb6a22f643873f80
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10500
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2026-03-17 06:25:53 +00:00
Augustin Cavalier 7512053757 kernel/smp: Refactor ICI broadcast/multicast to invoke the current CPU too.
Since the methods now don't just "send", the names are changed
also (which is fitting since they're now API-incompatible.)

The changes in the TranslationMaps to adopt this fixes a correctness
issue: previously TLB invalidations would be done either with or
without interrupts enabled depending on how they were invoked.
Now, they'll always be done with interrupts disabled. (This is
the same fix that was recently done to x86.)

The idea with processing the ICIs on the current CPU too is
that presumably the other CPUs will take just as much, if not
more, time processing the ICI than the sending CPU. So, we might
as well do the processing while we wait, rather than before or after.

Testing shows this to indeed be the case. On a bare metal i3, kernel
map invalidations (with global invalidations always forced) across
a boot-to-desktop go from around ~60.8ms cumulative before,
to ~51.8ms cumulative after this change.

Change-Id: Icd0343d462de7cf11043e6438f47b02f6b88bb8b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10472
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-16 13:41:00 +00:00
Augustin Cavalier 913f501fbd kernel: Use uint64 for seconds in datetime conversion routines. 2026-03-16 08:35:51 -04:00
vighnesh-sawant c122595a54 bluetooth: Make RemoteDevice::Authenticate actually pair after
connecting

Sends an auth request to the controller, if connection was initated by
us

Change-Id: I32af0a24b902d0223bb4e773258ea9e9749a899c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10527
Reviewed-by: waddlesplash <[email protected]>
2026-03-16 12:19:26 +00:00
vighnesh-sawant aa864b9d41 bluetooth: Add support for SSP and refactor AcceptConnection and
CreateConnection

Move expecting commands from RemoteDevice::Authenticate to where they
are called.In SSP we expect for the events after ConnectionComplete.
For the state machine, LINK_KEY_NOTIFY tells us the end of the pairing
in both pairings, so we clear all expected events there for the ones we added in
ConnectionComplete, In SimplePairingComplete we clear the ones added
in IOCapabilityRequest. Tested with both bluetooth 2.1 and older pairing.

Change-Id: Ia208506c9f289d9f44dc3b8b0e4cd8a726a5d726
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10526
Reviewed-by: waddlesplash <[email protected]>
2026-03-16 12:19:26 +00:00
vighnesh-sawant e7eb60f1a7 bluetooth: Implement EIR parsing for HCI_EVENT_EXTENDED_INQUIRY_EVENT
This parses only EIR_NAME_SHORT and EIR_NAME_COMPLETE, others are not
yet usefull, adds a way to fetch the cached friendly name and adds a
friendlyName field to RemoteDevice. Refactors DeviceListItem to work on
RemoteDevice as it's only being used for that.Also adds a check if the
cached name is complete or not. If not ask for the complete name.

Change-Id: I7e37fb9cf44cb5598ef348fdd4d781c5ae04e24e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10489
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-16 12:19:26 +00:00
John Davis 51805ac6d3 kernel/x86: Fix IO-APIC initialization on non-PCI systems
Currently the IO-APIC is fully initialized after PCI initialization
resulting in the IO-APIC not being initialized on systems without a
PCI bus (i.e. Hyper-V Gen2 VMs). This change moves IO-APIC
initialization to occur during early init, deferring PCI interrupt
enumeration and routing until after PCI initialization has been
completed.

Change-Id: I00be0be05d2e7668c3c6bc7af3afc4ff8d04a129
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10414
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: X512 X512 <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-13 18:08:44 +00:00
Sam Roberts e438946e25 kernel/arm64: Add kernel support for Samsung UART
Tested on M1 MacBook Air.

Change-Id: Idda9b2a168642b55a9e30336be1c4f4936670035
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10487
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-13 08:34:54 +00:00
vighnesh-sawant c0336fd788 bluetooth: Add support for HCI_EVENT_EXTENDED_INQUIRY_RESULT
Follow up of a4e1f4d8ce,
this contains only response per event.

Change-Id: I6582f9530a273699048c04481fa0ef4a31a315ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10486
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-12 17:01:16 +00:00
vighnesh-sawant 230470d6d4 bluetooth: Add support for HCI_EVENT_INQUIRY_RESULT_WITH_RSSI
Follow up of a4e1f4d8ce, details given
in that commit message on parsing of this event message

Change-Id: Icc0b54bdafe3cb167553d2fda3f62762d2d2595e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10485
Reviewed-by: waddlesplash <[email protected]>
2026-03-12 17:01:16 +00:00
John Davis 6e270b5f8c hyperv: Add mmio_size attribute to device nodes
Some devices such as graphics and PCI passthrough bridges require
MMIO space. Add this as a device node attribute if present.

Change-Id: Id374ff61c29c1ccad10e3a7f3f7053c14d02aa5e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10483
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2026-03-12 15:09:09 +00:00
John Davis 19630fa076 hyperv: Fix definition of HV_MS_TO_US
Definition is intended to be used where bigtime_t is accepted
and should be signed.

Change-Id: I6ebe21c55ae47b0b4f46f0df655942b582759d51
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10482
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-12 15:09:09 +00:00
Sam Roberts d2819f9e83 arm64: Add apple,s5l UART driver
This is the debug UART found in Apple SoCs. Tested on M1 MacBook Air.

Registers definitions were taken from:
  - https://github.com/AsahiLinux/m1n1/blob/18eb02fa92789dfcdab8e00e8b1cace7ab002718/src/uart_regs.h
  - https://www.sistemasorp.es/blog/S3C2410%20-%20datasheet.pdf

Change-Id: I2e4c8b7927fc823cedca421e1a2623b91f5ef112
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10480
Reviewed-by: waddlesplash <[email protected]>
2026-03-11 23:38:03 +00:00
Sam Roberts 5bb69a0f33 build: Fixes for arm64 macOS
* macOS ships an ancient version of GNU Bison which wants
  an '=' after %name-prefix

* macOS awk doesn't support strftime, so try to find a working
  awk.

* _haiku_build_{open,openat,fcntl} are declared and defined with
  different prototypes (variadic vs non-variadic). This is bad
  on its own, but it "happens to" work on most platforms since
  variadic parameters are usually passed in registers, same as other
  arguments. On arm64 macOS, variadic parameters are always passed
  on the stack, so you get weird and confusing bugs when using
  these functions.

Change-Id: I8cee9ecac0ac9b039be6b7e35ceaf8ad7c0f4c44
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10468
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-11 02:21:34 +00:00
Augustin Cavalier 3c28d298f7 kernel: Don't fail if the private string.h is included under GCC2. 2026-03-10 13:10:25 -04:00
Augustin Cavalier 69499b0e00 kernel: Use compiler-builtin memset, memcpy, memmove, memcmp.
Since the kernel is built with -ffreestanding, and thus -fno-builtin,
the compiler ignores the function names and doesn't perform optimizations
(e.g. inlining for small values) that it otherwise could. So, here,
we add a string.h that supplements the default, and uses #define to
reinstate the builtins, and thus the optimizations.

Linux and FreeBSD at least apparently do the same. A quick compile
benchmark in a VM doesn't show much difference, maybe a slight
decrease in sys time.
2026-03-10 12:00:59 -04:00
Augustin Cavalier 2adbc5705a Eliminate "UsePrivateHeaders kernel" from most of userland.
Now that the DoublyLinkedList and other classes are in a "util"
directory, this isn't needed.
2026-03-10 12:00:58 -04:00
Augustin Cavalier 103ca61228 bluetooth: Eliminate the need for kernel headers in userland. 2026-03-10 12:00:57 -04:00
Augustin Cavalier dd2eeb7dff kernel/smp: Style fixes.
No functional change intended.
2026-03-09 21:08:52 -04:00
Augustin Cavalier dd24eecac1 kernel/smp: Distinguish CPUSet::GetBit from GetBitAtomic.
I checked all invocations of GetBit; as far as I can tell,
only the two adjusted here in smp.cpp are done while the Set
may be concurrently modified, and even then I don't know
that they really need to be atomics, anyway.
2026-03-09 20:58:54 -04:00
John Davis 480c96550c hyperv: Refactor read packet function
Currently, a packet being read is split into header and data buffers.
Change to a single buffer to simplify logic in drivers, especially
for those that receive packets with variable sized headers.

This change also implements the pending send size functionality for
the receive buffer.

Change-Id: Ic4a3698fcfe813fbcf4fd9c1941102b5adaeb3b2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10418
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2026-03-07 09:06:41 +00:00
John Davis 76c0c7d4bb hyperv: Rename device type item name to reflect data type
Change-Id: I86d4d0dd08beef3b403d82713d2299840d73818f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10417
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2026-03-07 09:06:41 +00:00
Augustin Cavalier 11280e1b51 kernel/device_manager: Remove unnecessary includes of Locker.h. 2026-03-05 13:35:14 -05:00
John Davis 4d75e43574 hyperv: Implement additional driver functions
* Switch instance ID from string to raw attribute
* Implement device allocate/free GPADL functions
* Add definitions and functions for additional VMBus packet types

Change-Id: I01e9a30f567358fad520df95b1c14b7ea9671915
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10402
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-05 18:14:42 +00:00
X512 02683a08de View: optimize Fill/StrokePolygon with raw points array argument
Converting points array to `BPolygon` has significant cost, including
heap allocation, when drawing a lot of polygons.

Change-Id: I81e6b4031bac4beadcc79412c58eedddffc00a82
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10337
Reviewed-by: waddlesplash <[email protected]>
2026-03-05 02:42:51 +00:00
Augustin Cavalier 7ef695df5c kernel: Allocate user_mutex_contexts when adding the second thread to a team.
This allows us to gracefully fail if memory allocation fails,
rather than panic()ing. If a single-threaded application tries
to wait on a non-shared user_mutex in single-threaded mode, it
will now be dropped into the debugger.
2026-03-04 21:42:03 -05:00
Augustin Cavalier e6569ec320 kernel: Add an AssertLocked() to Team.
The mutex member is private, so this is necessary for other methods
to assert the team mutex is locked.
2026-03-04 21:38:43 -05:00
Kacper Kasper bd6b50bed7 Refactor Support Kit tests
* Use CPPUNIT_TEST(_SUITE) macros and autoregistration.
* Remove unnecessary header files.
* Consolidate Archivable, Autolock, MemoryIO and MallocIO tests into
  one .cpp file.
* This structure makes it easier to add new tests - from adding .cpp
  and .h + updating Addon.cpp file (3 files), only one .cpp file is
  needed now.
* Convert string_utf8 test from standalone app to CppUnit test.

Change-Id: I18d90eb66b7cfc5576626b66ed85e47eb64547bf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10399
Reviewed-by: Kacper Kasper <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-04 17:58:38 +00:00
Augustin Cavalier 61c7d7e4ee Package Kit: Move a number of headers into the source directory.
These classe aren't used, and probably shouldn't be used, outside
Package Kit itself.

Also drop some files from libpackage_build that are not needed.
2026-03-03 17:45:28 -05:00
Augustin Cavalier 5f0f0b02b4 Package Kit, pkgman, SoftwareUpdater: Offer to delete old state directories.
This adds a new job to the Package Kit, and an invocation
in pkgman after changes are applied. The job takes a time_t before,
and an int32 minToKeep, and (after confirmation) deletes all state
directories which were last modified before that time, but also
keeps at least the minimum specified.

pkgman defaults to calling it with (now - 30 days, minimum 10).
SoftwareUpdater does the same, but without bothering the user
and just defaults to doing the cleanup.

Change-Id: I15f5232b11daba5955e7fa07f696ad7785507931
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10404
Reviewed-by: waddlesplash <[email protected]>
2026-03-03 22:14:57 +00:00
Augustin Cavalier 79ab5081b2 Package Kit: Rename InstallationLocationInfo::OldState to ActiveState.
It doesn't refer to some random old state, but the currently active
one. (If the currently active state is the default one, then it will
return nothing.) So, this should make things clearer.

Change-Id: Ib3fe842f5fb51eaf2ef2f31bad8b292b47a3fb36
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10403
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-03 22:14:57 +00:00
Augustin Cavalier 418769d64b BResources: Mark deprecated methods _DEPRECATED. 2026-03-02 21:11:39 -05:00
Augustin Cavalier f071ee419d BMimeType: Use the new _DEPRECATED to mark SetType deprecated.
This is the first use of this new macro.
2026-03-02 21:03:25 -05:00
Augustin Cavalier b6441edfac BLooperList: Use rw_lock.
Improves efficiency, as some functions can use a read lock
instead of a write lock.

Eliminates another statically-created BLocker.
2026-03-02 20:17:51 -05:00
Augustin Cavalier 5eef2f1d00 BTokenSpace: Use pthread_mutex instead of BLocker.
This header gets included in the build platform, so we can't use
the private recursive_lock.

Eliminates another statically created BLocker, due to gDefaultTokens.
2026-03-02 20:16:32 -05:00
Augustin Cavalier ae70142168 BBlockCache: Use a pthread_mutex instead of BLocker.
The lighter "struct mutex" is in a private header, so we can't
inline it in a public one, so just use pthread_mutex here.

By adjusting padding, the class size stays the same (72 bytes
on 32-bit, 96 bytes on 64-bit; confirmed via static_assert.)

A quick benchmark running "new/delete BMessage" in a loop on 4
threads at once goes from 30-36 seconds before this commit
to around 13-17 seconds, sometimes as low as 3 seconds, afterwards,
so clearly this is a significant improvement.

This also eliminates another BLocker allocated on application startup.
2026-03-02 19:37:13 -05:00