Commit Graph
100 Commits
Author SHA1 Message Date
Augustin Cavalier a08764fd75 kernel/scheduler: Avoid packing IRQs if it's not going to change much.
If we've gotten to pack_irqs, it means the current CPU is idle,
so it's not totally overloaded. We then check whether the "small
task" core is less loaded than us, or whether it has a significant
load difference from us, and bail if it doesn't.

This avoids thousands of unnecessary IRQ reassignments when
using power saving mode.

Follows up #18588.
(cherry picked from commit 5ba228dfc6fbf87de734d3f08369c824bd4553a3)

Change-Id: Idc914023911f374ec70a87e13437ce388bcdbd8a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11520
Reviewed-by: waddlesplash <[email protected]>
2026-08-11 21:15:55 +00:00
Augustin Cavalier 5e58c857f1 kernel/vm: Fix a memory leak in PageWriterRun.
These now get deleted when page writer threads exit.

Change-Id: I750e4522e0ff0b83f22dada3ac69f9ce3174f0d7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11487
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit 294143db82a27e3256afcd6d4a071597aab8cfed)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11489
2026-08-10 19:09:18 +00:00
waddlesplash 3aa6bdccbd kernel_debug_config: Fix KDEBUG_LEVEL. 2026-08-10 18:27:49 +00:00
Augustin Cavalier a964c2cdaf kernel/vm: Move page ACCESS state up in VMCache::Delete.
Should fix #20240.
(cherry picked from commit 5e3fdaa3cc70c1c9a09d6995e585ca400451cf56)

Change-Id: I090439121e036bf3ba5cccd9bac2bbb081aa77e1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11500
Reviewed-by: waddlesplash <[email protected]>
2026-08-08 17:24:38 +00:00
Augustin Cavalier 8c1b894d60 multiuser: Use setresgid, setresuid and fix checks.
pw_gid and pw_uid aren't pointers, so checking them for 0 just
meant we didn't change the UIDs if we were something other
than root.
(cherry picked from commit acf0e80dc0fe1ae63d89211dfd28133a254a9753)

Change-Id: Ia567d61f645356bb122dd1bce99c581369f8f19f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11498
Reviewed-by: waddlesplash <[email protected]>
2026-08-08 17:13:13 +00:00
Augustin Cavalier b86ecd28ca su: Fix authentication when passwords are in the shadow file.
As they usually are.

Also delete an unused utility function.
(cherry picked from commit 8cd127ed218340c7d293f1dd94a60ab479204c92)

Change-Id: I43ad195f24c2bd26e875715ea18a63b1222d4e52
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11496
Reviewed-by: waddlesplash <[email protected]>
2026-08-08 16:58:22 +00:00
Augustin Cavalier 1f47d9a206 freebsd_wlan: Reinstate the IEEE80211_SCAN_NOJOIN flag set.
It was accidentally lost in e67600e2a4.
(cherry picked from commit 9f618d40ff38a8128d4b621d1923cb0882503474)

Change-Id: I6ba6acfb1f25825d630e700828af3f6910f23ae5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11494
Reviewed-by: waddlesplash <[email protected]>
2026-08-08 16:40:37 +00:00
Augustin Cavalier d2fee32bba kernel/x86: Add locking around IO-APIC register accesses.
On SMP systems, we may call ioapic_assign_interrupt_to_cpu from
multiple CPUs at a time, at least under low-latency mode.

May fix #18588.

Change-Id: Ie76e4127b05a8abc5f411d7719997dcfff9c2ff0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11491
Reviewed-by: waddlesplash <[email protected]>
2026-08-07 21:57:59 +00:00
Augustin Cavalier 02fad68b15 kernel/util: Always clear next/prev in list_remove_link.
The C++ DoublyLinkedList does the same.

Change-Id: I22b2f0ba1dfacd6509360dfa903457fcbb80b4d6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11486
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit 428c5b99988817ae35e93cd62e47d969ebf2985d)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11488
2026-08-07 20:27:26 +00:00
Augustin Cavalier edd8271a9c kernel/fs: Institute a "vnode undertaker".
This is a separate thread that takes care of actually freeing vnodes,
so we can avoid doing that (or doing an expensive "free unused vnodes")
from some random thread that called put_vnode.

We still (try to) free vnodes directly in unlink(), though, so that
removal writes go through.

Note that the "reenter" parameter is now load-bearing, as put()
calls that come from a filesystem are executed directly instead of
being deferred. This is necessary in the unmount case.

This should break the deadlock in #20234.

Change-Id: I458f4003b9b8014ca326d477df4782492d8db437
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11444
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit bc46fb3e9a83dca0d684bc0d9f1518aafac945be)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11483
2026-08-07 04:45:13 +00:00
Augustin Cavalier 3ed9989152 HaikuPorts: Correct libvpx version on x86_gcc2.
(cherry picked from commit 52f0f2799ab995e46d97821110e402588c23404a)

Change-Id: I08995e0bd564bcfb951f5275928a51315b619a13
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11464
Reviewed-by: waddlesplash <[email protected]>
2026-08-07 02:33:34 +00:00
Augustin Cavalier 5b5b75a197 HaikuPorts: Synchronize x86_64 and x86_gcc2.
(cherry picked from commit 9baba7643dd0401c3e9baeedd219eeb0f417534e)

Change-Id: I5c06ae6f457748cd0b96f78eb9ffe3ad0e284054
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11447
Reviewed-by: waddlesplash <[email protected]>
2026-08-07 02:19:23 +00:00
Augustin Cavalier 748825cf77 XHCI: Don't bail out early in CancelQueuedTransfers.
If the endpoint is in HALT state, we need to clear that.

Follows up on #20232.

Change-Id: I4249d34d1af3e4ce08900dd8b0a3ec98625378a7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11443
Reviewed-by: waddlesplash <[email protected]>
2026-08-06 18:22:45 +00:00
Augustin Cavalier f53d451b7a kernel/device_manager: Unlock before calling hooks in devfs_delete_vnode.
Should fix #6300.
(cherry picked from commit 86fb9229fa1207ad4c7066f909733f486ace53ca)

Change-Id: I885baa07341b81da5c2d03525ccc720d9a3d230c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11433
Reviewed-by: waddlesplash <[email protected]>
2026-08-05 16:53:48 +00:00
Augustin Cavalier feaf5c27d6 pthread: Add the start routine's image name to the thread name.
We do the same for mmap. This is at least a little better than
only having "pthread func" for pthreads that don't get renamed.
(cherry picked from commit fdc03c5ef9f386e84b9229c667ddba11fabed55e)

Change-Id: Iaaafc4f5393537d3c3e16da04ed12bc56adb88ff
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11423
Reviewed-by: waddlesplash <[email protected]>
2026-08-04 16:50:40 +00:00
Augustin Cavalier 0836d9e705 usb_disk: Call removed() from uninit() if necessary.
It seems this may happen in some cases if the device wasn't fully
initialized.

Should fix #20227.

Change-Id: I02d78c0e30c9fb790e317b8b069672f9129d3b48
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11422
Reviewed-by: waddlesplash <[email protected]>
2026-08-04 16:50:20 +00:00
Augustin Cavalier f70d950766 nvmm: preempt_disable should be able to be nested.
May fix #20224.

Change-Id: Ide859c35c76b525af1dd6bc5ab3b640e89039503
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11415
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit 4fc9b717c3e4e5d22a9d434b25c032f78a56f5c4)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11418
2026-08-04 16:20:37 +00:00
Augustin Cavalier b87d2919ef kernel/device_manager: Remove the marker at the end of the _Scheduler loop.
Otherwise we could exit with it still in the list.

Change-Id: I8b159aa09b094b07de74536c9946ec2d261dc1c9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11416
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit f6954953c950b424d85110d07335f123b5572f81)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11419
2026-08-04 16:20:31 +00:00
Augustin Cavalier 37d9955590 kernel: Make reschedule_disabled a uint8 instead of a boolean.
Allows some recursion.

Change-Id: I15cd36dd01dd59480e60c3106c4a741ae6284c80
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11414
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit 19e3dda0f15d6183908132dd7385b3a6ca781c27)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11417
2026-08-04 16:19:07 +00:00
Augustin Cavalier be1b4b813d kernel/device_manager: Always use the marker in the IOScheduler.
When dropping the lock (or calling _Finisher) the owner could go away.
So we have to keep track of our position in the list a different way.

Fixes #20213.

Change-Id: I1f0857c05ec985c7fe2f913a75be20ea91e6994c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11405
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit e6155d041190f459d601022bd63840819d2beecc)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11407
2026-08-04 02:49:05 +00:00
Augustin Cavalier 52d627b267 kernel/vm: Add handling for pages in MODIFIED state in VMCache::Delete.
Should fix #20221.
(cherry picked from commit 518a54b774411b901e99fc5a691a3c6dfc113c8d)

Change-Id: Ia626d379c293ca710671a741d2b7525c60b29347
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11404
Reviewed-by: waddlesplash <[email protected]>
2026-08-03 20:53:51 +00:00
Augustin Cavalier b641780cc9 kernel/util: Accept inputs of 0 bytes in utf16_to_utf8.
There's no reason to reject them; they should just result in
a zero-byte output.

Should fix #20222.
(cherry picked from commit 4b6aad38968f9fe91712e742aff9166fec6e67a1)

Change-Id: Ifdbe17618d74eca0b873a6808ec0b14a7d38189a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11402
Reviewed-by: waddlesplash <[email protected]>
2026-08-03 20:05:16 +00:00
Augustin Cavalier 0de032d683 kernel/vm: Manage VMArea references to VMAddressSpace inside VMArea.
Instead of elsewhere. Fixes another missed Put(), in VMUserAddressSpace's
_InsertAreaIntoReservedRegion(), and guards against such problems
happening in the future.

Change-Id: If6d87d36225907e281e2341e8b53c461e6954f22
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11381
Reviewed-by: waddlesplash <[email protected]>
2026-07-28 20:28:04 +00:00
Augustin Cavalier 88e0124d1a kernel/vm: Fix handling of non-page-aligned addresses in get_memory_map_etc.
They were passed to TranslationMap::Query() directly, assuming that the
TranslationMap would just round down to the nearest page address. This
actually isn't guaranteed in the case of X86VMTranslationMap64Bit and
the physical map area, which uses hugepages, and so adds the offset
to the page address itself.

So, here the logic is rewritten to always pass page-aligned addresses
to Query(), and then re-add the offset for the first page only. We then
increment virtualAddress instead of an offset, making the next Query
naturally page-aligned.

This was the cause of #20142: when the BFS I/O hook was disabled,
virtual addresses in the physical map region were passed down to
the disk I/O routines, which were then mistranslated by this function,
resulting in corruption of adjacent pages by DMA, and incorrect
data in the pages where it was supposed to be read into.

Fixes #20142.

Change-Id: Ibacd00b7f5ce23a7b41c620224ddf8d338b6de4a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11377
Reviewed-by: waddlesplash <[email protected]>
2026-07-28 16:51:23 +00:00
Augustin Cavalier f0a83b8afe OverlayImage: Check fText actually exists before updating colors.
Should fix #20208.
(cherry picked from commit 472699848d96d84927e7992df1f6e575acd19414)

Change-Id: Ie057ecb43cccca1b348c083b0c0d963ef08a6ff5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11370
Reviewed-by: waddlesplash <[email protected]>
2026-07-27 17:21:49 +00:00
Augustin Cavalier 35487c6fba nvmm: Don't ever use B_FULL_LOCK.
vm_map_cache doesn't handle mapping pages, and it seems we don't need
to implement that here.

Change-Id: Ib8ff3e181c066275e2b55093485d44788632a110
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11339
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit 6f168cbe77c0d211bea884c8980da086c09a2c76)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11340
2026-07-23 17:05:57 +00:00
Augustin Cavalier edc2131db9 kernel/vm: Always use uint64 for memory amounts.
We want to be able to support more than 4GB of swap even on 32-bit.

Change-Id: I52c3aa8c0b77bbbd60a9b9ac37a4a7ad254aa201
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11335
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit e4c6bf453d4be138dbc8dd81a687c548cec6afdc)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11336
2026-07-23 16:53:17 +00:00
Augustin Cavalier f360d43984 NVMM: Correct area wiring flags.
The cache may not have all pages needed to be fully locked. Therefore
we have to use B_LAZY_LOCK if it doesn't.

Fixes some KDLs I was seeing when using NVMM against a raw disk device.
(cherry picked from commit 0ea1a0a835e8093355c5ea4fbe08dc9be93e3eb5)

Change-Id: I403eaf2f14677101cdd327d4b99c12318815c116
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11332
Reviewed-by: waddlesplash <[email protected]>
2026-07-22 21:26:46 +00:00
Augustin Cavalier e20e66d8a2 packagefs: Add a missing initialization.
Discovered by compiling with UBSan (it triggered as a compile-time
warning; I don't know if this actually causes any problems at runtime.)
(cherry picked from commit 6b28f736c09757156abadd560e69b8e090e60f25)

Change-Id: I91f6930fd4b9e870ecc1bad357aae2722f252cd1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11329
Reviewed-by: waddlesplash <[email protected]>
2026-07-22 20:04:51 +00:00
Augustin Cavalier 9d80b76b46 kernel/vm: Use 64-bit signed types explicitly for memory computations.
off_t is a signed 64-bit type, but size_t isn't signed or 64-bit
on 32-bit platforms. That meant adding a sign bit caused strange
things to happen there.

Fixes incorrect free-memory computations on 32-bit.
(cherry picked from commit cc565c81afd2dfba34de6ced607199d757080a8d)

Change-Id: I294f92ac1279a6311347b5e25341542d8c862013
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11326
Reviewed-by: waddlesplash <[email protected]>
2026-07-22 17:37:42 +00:00
Augustin Cavalier 0178ddbc88 VMKernelAddressSpace: Disable the object depot for the RangesObjectCache.
We allocate/free ranges with the write lock held, so the depot is
just a waste, and actually in low-memory conditions hurts (if we
need a Range and there's none in the cache but there were in the
depots, a scenario I saw when trying to boot with a DEBUG=1 kernel
on my laptop.)
(cherry picked from commit ad189ca258d42e68f493c22bb3ce5f904e1589bc)

Change-Id: Id4af983a8b1337f8e90640218fe63402543355f8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11322
Reviewed-by: waddlesplash <[email protected]>
2026-07-22 15:51:38 +00:00
Augustin Cavalier b5a3401119 Enable NVMM.
It works!
(cherry picked from commit 56c1178ccbc073733f10a10ab1dfac433bdec3fd)

Change-Id: Ie66aabbbbdac0923f78acc4edb895cf2f8810c9f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11317
Reviewed-by: waddlesplash <[email protected]>
2026-07-22 03:42:13 +00:00
Augustin Cavalier b0310ba160 nvmm: Always use B_FULL_LOCK for non-swapping caches.
Otherwise the page daemon will unmap pages unnecessarily.
2026-07-22 03:14:58 +00:00
Augustin Cavalier 27c16710b9 nvmm: Implement curthread_save/restore_fpu.
It actually is needed to reset MXCSR.

Doesn't seem to affect behavior, though.
2026-07-22 03:14:57 +00:00
Augustin Cavalier e0ff341bce kernel: Check early safemode options in frame_buffer_console_init.
(cherry picked from commit 596150abbbf4e79d6c50d253c867e5200ae60017)

Change-Id: I691540cad733a342f50ad54bcbcedb878a549863
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11315
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-07-22 03:09:24 +00:00
Augustin Cavalier 7dc7df27e9 x86: Make "Disable BIOS calls" boot option actually work.
It was a complete no-op before. Now, when enabled, BIOS calls
won't be done past the bootloader, and the Framebuffer driver
will be used instead of VESA.
(cherry picked from commit 7f12208162a5fc676f7a03e050f7671919f4fb12)

Change-Id: Id7670cc060ab5273411222e27467a6dfdbbb9e7f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11313
Reviewed-by: waddlesplash <[email protected]>
2026-07-22 02:31:43 +00:00
Augustin Cavalier bb98e98305 safemode_defs: Sort and organize.
No functional change. Reasonably we should have architecture-specific
headers for some of these, but that can wait.
(cherry picked from commit 450728b4b717b3ea09fb2145daf2e6a24874c6de)

Change-Id: I887d37a54b44e127e4d1fe46675bf57bc2a392dc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11312
Reviewed-by: waddlesplash <[email protected]>
2026-07-22 02:31:04 +00:00
Augustin Cavalier d56f3f2265 usb_disk: Change a dprintf to CALLED.
(cherry picked from commit b861fcbd866e04256d46725bd5a26f3ea1c5ff8c)

Change-Id: I314b98b8a5c7a0f1e3304b473b82fa759dff60f3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11307
Reviewed-by: waddlesplash <[email protected]>
2026-07-21 22:30:18 +00:00
Augustin Cavalier 0c29b31205 usb_disk: Unpublish devices in the driver removed hook.
We publish devices in the driver register hook, and if we try
to unpublish them from the device removed hook, not the driver
removed hook, we'll confuse the device_manager and cause it
to do use-after-frees on list iteration.

The two are called in quick succession of each other, so this
shouldn't cause problems.

Fixes a KDL reported by OscarL when unplugging a USB card reader
(which I reproduced with another USB card reader.) It seems the problem
would happen with any USB disk device that published more than
one LUN.
(cherry picked from commit a688b173e7c1e903845b6cac78baa7bd2ea23c31)

Change-Id: Ia9fae3428a45e199cb2c903acfe9c689dfa9bed4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11305
Reviewed-by: waddlesplash <[email protected]>
2026-07-21 22:25:07 +00:00
Augustin Cavalier 42371830dc usb_disk: Don't try to reset or test if the device was removed.
Avoids the media checker retrying uselessly after devices have been
removed.
(cherry picked from commit a88cbfae4fcaf80d8786d144fccbeb349c3bd91b)

Change-Id: I3fefcbe515bf46bb84b6a6476e9cef7dcbbb48eb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11304
Reviewed-by: waddlesplash <[email protected]>
2026-07-21 22:24:59 +00:00
Augustin Cavalier bf5e6e673f kernel/device_manager: Pass the correct pointer to device_removed.
We want the DriverData not the device_node.

Discovered while working on usb_disk. I wonder if anyone ever actually
used this method for hot-unplug before...? Looking at the source code
of other modules, only a select few try to do anything with the cookie,
and most of those likely don't use hot-unplug.
(cherry picked from commit 5fec48b27d7b4c1c831b93db3d4abc1cfaee4982)

Change-Id: Iaf8973b8212758ba2148ad88832f9f96aa5158f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11303
Reviewed-by: waddlesplash <[email protected]>
2026-07-21 22:24:30 +00:00
Augustin Cavalier 5c0e7a34aa kernel/x86: Fix the build with KDEBUG_LEVEL 0.
(cherry picked from commit 99502154ea8699761f7b8dd7705e51ac62e3ea28)

Change-Id: Ibd6a544f8b5dfb912423d9d58fc5d3ec7b1947dd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11293
Reviewed-by: waddlesplash <[email protected]>
2026-07-21 20:03:11 +00:00
Augustin Cavalier 1f0f4c0937 ACPI & PCI: Move the x86 config space fallback to the PCI module.
This way, we can use it even after the "early" boot phase is over
but before PCI is initialized, and also add the locking necessary
once there are multiple threads.

Should fix #20196.

Change-Id: Ie96daf44cc7c82050d0aa686d0d395228ffa4f20
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11285
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit 4e8abe02f6384e6c35895785557b1eeaed85a607)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11287
2026-07-21 17:56:30 +00:00
Augustin Cavalier 779d435149 Adjust repositories to r1beta6. 2026-07-18 21:12:51 -04:00
Augustin Cavalier 04fcdf7756 build: Enable HAIKU_OFFICIAL_RELEASE. 2026-07-18 21:10:16 -04:00
Augustin Cavalier 32edc757b0 Disable serial debug output by default.
EFI doesn't have a boot keys mechanism so we just disable the
routine that enables it entirely. Also disable it in early kernel
output before the settings file has been read.
2026-07-18 21:09:32 -04:00
Augustin Cavalier 103df455af kernel_debug_config: Turn KDEBUG_LEVEL down from 2 to 1.
Per the ReleaseCookbook.
2026-07-18 21:09:02 -04:00
Augustin Cavalier 86e70e9a62 Versioning: This will be R1/beta6. 2026-07-18 21:08:43 -04:00
Augustin Cavalier 618e42b86d Versioning: Add BETA_6 and PRE_BETA_7 version constants.
* PRE_BETA_7 is now the default in master.
2026-07-18 21:07:28 -04:00
Augustin Cavalier edf3ed94bf Tracker: Drop Sync() during copy operations.
This mostly reverts commit e8d394bd51.

After the changes to how modified page writes are handled,
this shouldn't be needed anymore.

Fixes #19673.

Change-Id: I1d55f5b80f10836b3eee74a1165a682375d10ec6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11268
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-07-18 18:51:43 +00:00
Augustin Cavalier 47a645b6a0 kernel/fs: Fix reference leak of KDiskDevices.
WriteLockDevice() acquires a reference, so we have to release that
after we unlock.

May help with #18044.

Change-Id: I9f7b32ec044c310091079e17669d2186b9f6a155
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11267
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-07-18 18:51:43 +00:00
Augustin Cavalier 3bfaa91290 kernel/vm: Per-KDiskDevice modified queues and page writers.
This solves an old TODO, that the page writer could potentially cause
deadlocks when writing pages of different devices back at once. It's
also necessary after the previous change, as otherwise simultaneous
writes to disks with different write speeds would cause the quota
computations to be fluctuating and inconsistent.

Change-Id: I1c485f66625ea9013f17ab4fee007d7d58afd2ea
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8619
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-07-18 18:51:43 +00:00
Augustin Cavalier de0a0420a8 kernel/vm: Implement modified page quotas and wait for them in the file cache.
Otherwise, if we're marking pages modified faster than we can
write them out, the number of modified pages will just grow
unboundedly. This can lead (e.g.) to `sync` taking multiple
minutes after copying a lot of data to a slow disk. So, instead,
we now have a quota of no more than 3 seconds for all pages
to be written back.

Also drop a TODO comment from the page_writer thread. Since
we only start writing pages if there's at least 256 to be written,
or if someone wakes us up deliberately (which the page daemon
does, if it schedules pages to be written out), we shouldn't
need to wait shorter.

This should fix #5777 and related tickets.

Change-Id: I4d419d149ea780677b462f5fa46cfe4d65044b2c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10811
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-07-18 18:51:43 +00:00
Augustin Cavalier ebedce12c3 kqueue: Notify when semaphores and ports are closed.
Use EV_EOF for this purpose.

Follows up on #19974.
2026-07-17 16:55:42 -04:00
Augustin Cavalier 6fcd55350f kernel/vm: Check page ACCESS state in UnaccessedPageUnmapped. 2026-07-17 16:55:42 -04:00
Augustin Cavalier 22b415d0c7 kernel/vm: Make vm_page::physical_page_number const.
For safety.
2026-07-17 16:55:42 -04:00
Augustin Cavalier 77ce22f10a kernel/fifo: Don't allow selecting events we don't support.
fd_select() will just ignore them and set the selected_events
appropriately.

Change-Id: I122fe35be5ac5fca3ae8544fd78268fdc6a15a02
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11253
Reviewed-by: waddlesplash <[email protected]>
2026-07-16 14:37:51 +00:00
Augustin Cavalier d4c6110550 kernel/device_manager: Clarify IOBuffer::LockMemory second argument.
It doesn't mean "write to this memory", but rather "this is for
a write IORequest" (i.e. if true, the memory will be read from
only.)

No functional change, but clarifies things around #20173.
2026-07-15 20:43:53 -04:00
Augustin Cavalier 5d403cc1e7 kernel/vm: Correct inversion of B_READ_DEVICE in lock_memory().
The documentation comment just above explains its purpose correctly:

> requests that the range must be wired writable ("read from device
> into memory").

The Be Book confirms, and there are numerous examples in the Haiku
source which are written with this behavior in mind. It appears the
original implementation of this function got it right, but then
it was broken in 550376ffb8 (which,
coincidentally, is the same commit that added the documentation
comment quoted above...)

Primary fix for #20173.
2026-07-15 20:38:42 -04:00
Augustin Cavalier f03c1740a5 kqueue: Add support for Haiku-specific object types.
Apple Darwin also extends kqueue to support other object types,
like Mach ports, so we might as well do the same for Haiku (Be)
object types.

Fixes #19974.
2026-07-15 20:01:11 -04:00
Augustin Cavalier d25d9bef1e kernel/event_queue: Also report behavior in Select().
Probably not necessary but we might as well.

Change-Id: Ie299e72f9a85d932bbe4ff7f8d313297cdb6e962
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11252
Reviewed-by: waddlesplash <[email protected]>
2026-07-09 19:41:45 +00:00
Augustin Cavalier 53630a31a0 kqueue: Implement EV_RECEIPT.
Tested with a modified FreeBSD test.

Also fix EVFILT_READ + EVFILT_WRITE failing to select only returning
one error, and not two as it's supposed to.
2026-07-09 15:36:05 -04:00
Augustin Cavalier 1699186567 kernel/event_queue: Copy back all results at once.
Copies more bytes, but should be cheaper overall as user_memcpy
does have overhead.
2026-07-09 15:31:18 -04:00
Augustin Cavalier b309eb594c kernel/event_queue: Report back what events were actually selected.
If less than requested was selected, userland will want to
know that.
2026-07-09 15:23:34 -04:00
Augustin Cavalier e388b7dedb BFS: Update node times when the file size changes.
Fixes #20164.

Change-Id: I4b66cbcc5e9b0e8bf34564b4fa5d54f0b67e835f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11199
Reviewed-by: waddlesplash <[email protected]>
2026-07-09 17:43:12 +00:00
Augustin Cavalier 8bd9d9bb9b app_server: Fix lock order inversion in HWInterface cursor routines.
Fixes the hang reported in #2539.
2026-07-01 12:30:22 -04:00
Augustin Cavalier 0e76803f9e vesa: Update the kernel framebuffer information when changing modes.
We need to update it even if we don't remap. Otherwise the KDL
screenmode will be wrong.

Noticed in #2539.
2026-07-01 12:29:38 -04:00
Augustin Cavalier 59e22cef16 bootloader: Restore activation of CR0 PAGING bit in init_page_directory.
Otherwise it may not be activated until much later.

May fix #20155.
2026-06-30 16:56:55 -04:00
Augustin Cavalier c0317b3e7b kernel: Revert UserTimer deletion changes.
This reverts a small portion of f5842905e3.

I added these asserts instead of the deletions to hedge against
the Team/Thread reaching this point with timers still active.
But it seems that doesn't happen, while if thread init fails
due to OOM, we have the default timers still present, which need
to be deleted.

Fixes #20154 and #20148.
2026-06-30 16:37:01 -04:00
Augustin Cavalier ad6cb5efd3 app_server: More fixes to screen configuration management.
* Retrieve info from the stored configuration in GetScreenMode &
   GetScreenFrame if needed.

 * Use the stored configurations in _SetCurrentWorkspaceConfiguration.

The last part seems to fix #20136.
2026-06-30 16:21:38 -04:00
Augustin Cavalier 41ca6fdabd network/unix: Return as soon as we've written the minimum data.
Otherwise we could block forever if the data size is
larger than the buffer size. Partial writes are an
expected behavior of stream sockets, so this should
not cause any other problems.

Fixes #20163.
2026-06-30 14:55:23 -04:00
Augustin Cavalier 95703fb82d ramfs: Update file times on resize even if the size stays the same.
Part of #20164.
2026-06-30 14:01:06 -04:00
Augustin Cavalier 3970f91248 ramfs: Coding style cleanup to File, no functional change. 2026-06-30 13:55:03 -04:00
Augustin Cavalier e079fff682 file_systems/bindfs: Pass the correct node to the underlying FS in rename().
We were passing our own fs_vnode, not the underlying filesystem's.

I guess this was just never tested, because it would've always crashed?

Fixes #20156.
2026-06-30 13:38:21 -04:00
Augustin Cavalier ac8b58038a network/stack: Use DoublyLinkedList<> instead of struct list for data_nodes.
Includes better assertion checking (and allows more things to be
inlined.)
2026-06-23 15:13:19 -04:00
Augustin Cavalier 2221fefb84 Tracker: Rework the file panel initialization locking changes.
* Don't unlock in ContainerWindow's constructor; instead leave
   the BWindow locked, as the BWindow constructor itself does.

 * Call Run() at the end of TFilePanel's constructor. This way,
   the TFilePanel will be in the state existing applications expect
   it to be after the constructor runs (i.e. running and not locked),
   while also performing all necessary initialization before actually
   doing that, to avoid races.

 * Drop TFilePanel::Show as it's not needed now.

 * Revert changes to BFilePanel::Show as they're now not neede.

I retested #19499 with this change, and couldn't get it to reproduce
(while it reproduced easily with Run() called at the top of TFilePanel()
followed by the Lock/Unlock scheme.)

This should be a much simpler solution that hopefully will cause no
regressions in any of #19499, #20125, #20128, #20131, #20144.
2026-06-23 15:08:03 -04:00
Augustin Cavalier eabae69d20 Tracker: Reacquire the lock in TFilePanel::Show.
See inline comment.

Fixes #20144.
2026-06-23 14:41:23 -04:00
Augustin Cavalier dbaf648047 app_server: Properly lock the HWInterface in cursor routines.
A comment in the header says the cursor handling functions "do their
own Read/Write locking", but they didn't actually lock the framebuffer.

Should fix #20141 and #2539.
2026-06-23 12:03:13 -04:00
Augustin Cavalier 2b6e9091da kernel/slab: Fix KDEBUG check.
KDEBUG itself is an expression already.
2026-06-22 14:52:02 -04:00
Augustin Cavalier bc3624c0a9 kernel/vm: Fix typo in comment. 2026-06-22 14:51:41 -04:00
Augustin Cavalier 22d9a23207 kernel/device_manager: Add some missing checks in DMAResource::TranslateNext.
* Ensure memory is locked before doing virtual->physical translation.

 * Make sure get_memory_map_etc actually returned an entry.

I didn't see either of these trip in some basic testing though.
2026-06-22 14:51:27 -04:00
Augustin Cavalier 7bee547af0 kernel/x86: Assert locked in X86VMTranslationMap64Bit::Map. 2026-06-22 14:50:29 -04:00
Augustin Cavalier 719b0ce380 kernel/vm: Consolidate and add an assert in vm_page. 2026-06-18 18:06:09 -04:00
Augustin Cavalier 59fb06ae9d kernel/vm: Overhaul set_memory_protection's handling of caches with multiple areas.
* Properly handle copy-on-write in the case of consumers, same as
   set_area_protection. This seems to fix most of the remaining problems
   in boehm-gc's mprotect-VDB.

 * Do not call set_area_protection if the whole range is covered,
   as it tries to acquire address space locks, which can lead to
   deadlocks: that was the cause of #20138. Instead, handle changing
   the protection of all pages in here.

 * Don't unmap pages of lower caches; just don't allow writing to
   those pages. This allows us to avoid unlocking the translation map,
   and also should mean a lot fewer page faults, hopefully improving
   performance.

Fixes #20138.
2026-06-18 18:06:09 -04:00
Augustin Cavalier bd8dfa4693 kernen/device_manager: Add a missing clear of an area_id.
Probably not needed, but doesn't hurt.
2026-06-18 18:06:09 -04:00
Augustin Cavalier 7214df8d3c kernel/slab: Keep ACCESS page state during mapping.
We don't assert this inside Map() at present, but I added one there
for debugging purposes, and this is one of the few places that tripped.
2026-06-18 18:06:09 -04:00
Augustin Cavalier 61445814f2 kernel/vm: Allow calling AddressSpaceWriteLocker::SetTo with something already set.
Other Lockers behave this way, and the behavior will be needed in
_user_set_memory_protection.
2026-06-18 18:06:09 -04:00
Augustin Cavalier 2e98b42157 kernel/vm: Add some more ASSERT_WRITE_LOCKED assertions. 2026-06-18 18:06:09 -04:00
Augustin Cavalier 40c254f71c kernel/locks: Allow passing const rw_locks to ASSERT_READ_LOCKED_RW_LOCK. 2026-06-18 18:06:09 -04:00
Augustin Cavalier 22a2180aa5 app_server: Always store the current configuration when adding screens.
Should hopefully fix #20136.

Change-Id: I29730bdb9bd9ceaaa68028f00797cc275ecd4629
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11107
Reviewed-by: waddlesplash <[email protected]>
2026-06-14 02:34:18 +00:00
Augustin Cavalier 2a0ccdfd34 app_server: Handle brightness more similarly to other screen configurations.
Untested as I don't have hardware with supported brightness control,
but the changes are relatively straightforward.

Should fix #20134.

Change-Id: I45b78bc8006a54cc5ba4f65a026df99401c621b5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11083
Reviewed-by: waddlesplash <[email protected]>
2026-06-14 02:34:18 +00:00
Augustin Cavalier 2a209bcf58 build: Enable S3 driver & accelerant on x86_64.
It works there now. Fixes #20112.
2026-06-10 11:58:27 -04:00
Augustin Cavalier dd5feaa4a6 freebsd_network: Drop the scan_done_sem.
It's not used anymore. Thanks to madmax for noticing!
2026-06-10 11:57:17 -04:00
Augustin Cavalier 7288df8b9c nvmm: Reinstate fallback in os_mtx_lock.
It is actually needed for the VMX backend at least.
2026-06-10 11:50:52 -04:00
Augustin Cavalier 4402cb4497 nvmm: Implement FPU save/restore.
Otherwise, the host won't be able to modify the guest FPU (and we could
clobber the state, too.)

This doesn't seem to fix the general problems seen so far, however.
2026-06-08 16:31:21 -04:00
Augustin Cavalier e2accec408 nvmm: Remove now-unnecessary hack from os_mtx_lock().
It's not needed after implemeting a real os_return_needed.
2026-06-08 16:31:21 -04:00
Augustin Cavalier aeadb071a2 Tracker: Fix deadlock on opening file panels a second time.
Follows up on #20125.
2026-06-08 16:24:06 -04:00
Augustin Cavalier 29393e16ae graphics/s3: Fixes for 64-bit.
Untested as I don't have this hardware, but relatively straightforward.

Part of #20112.
2026-06-08 12:11:18 -04:00
Augustin Cavalier 658cb74bed kernel/x86: Initialize CR0 in the kernel more than the bootloader.
The bootloader is now only responsible for setting up Protected Mode
and Paging. It otherwise preserves the existing CR0, and leaves setup
to the kernel.

The kernel now sets CR0 for each CPU in preboot_init_percpu().
Some redundant sets are removed from x86_init_fpu, which now
panic()s in the case where we don't have a FPU, and avoids
unnecessary prints.

This fixes a massive oversight where CR0 was never reset on x86
systems booted using the EFI loader, except on the boot CPU! That
meant that NUMERIC_ERROR and possibly even WRITE_PROTECT were
simply not set on non-boot CPUs, unless the EFI BIOS had set them up
already. (On the BIOS loader, smp_start_kernel() ran on all CPUs.)

Fixes NVMM initialization on non-boot CPUs on Intel hardware.
2026-06-04 18:18:28 -04:00
Augustin Cavalier de79d42abb nvmm: Use dummy kernel & current process maps to avoid allocations.
Removes a bunch of #ifdef __HAIKU__ and avoids unnecessary overhead.
2026-06-04 12:35:08 -04:00