67529 Commits

Author SHA1 Message Date
Vladimir Serbinenko
874ba40fd6 bootloader/efi: Make sure PML4 is below 4GB.
See inline comment.

Co-authored-by: Augustin Cavalier <waddlesplash@gmail.com>
Change-Id: I94e1af7e176c3d2a98629eb68ded0616d20394fe
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9023
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58672
2025-02-21 04:16:16 +00:00
Augustin Cavalier
22dfef3281 bootloader: panic if an ELF is non-relocatable and got placed at the wrong location.
Otherwise we'll just fault when entering the kernel.

Change-Id: Ib847ed4c02bccd36dce03b47ae2d4e79293c94d5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9025
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58671
2025-02-21 04:08:51 +00:00
Augustin Cavalier
0463b9511c bootloader: Refactor semantics of platform_allocate_region() functions.
This cleans up a lot of subtle or hidden inconsistencies:

 * Drop the "exactAddress" parameter. It was added in hrev15708 (2005),
   but all callers in all bootloaders passed "false" to it until 2022,
   when one codepath in the ARM32 EFI loader started using it.

 * Adjust EFI's platform_allocate_lomem to platform_allocate_region_below,
   and add a platform_assign_kernel_address_for_region(). This allows the
   aforementioned ARM EFI codepath to continue to do what it wants,
   which is to get an identity-mapped trampoline page, without having
   functions with confusingly different semantics ("allocate_lomem"
   assigned the virtual addresses as identity-mapped unconditionally,
   but it didn't insert these into the virtual allocated ranges.)

   This also paves the way for other EFI loaders to use this method
   to allocate memory below whatever default the boot services
   would give us.

 * Drop fixed virtual address allocation for all arches on EFI, with the
   exception of fixed addresses inside KERNEL_LOAD_BASE, same as on
   other boot platforms. Anything which wants fixed virtual addresses
   outside that region can use the new "assign kernel address" method.

 * Validate kernel base and size against kMaxKernelSize, instead of
   assuming it fits. This matches behavior of other boot platforms.
   Ideally we would have some more generic routine for mapping the
   kernel, but this suffices for now.

Tested with x86_64 and ARM; both still boot (well, ARM boots as
far as it did before this commit, anyway.)

Change-Id: Ieb4fba752994101191a2335cb5395eb2b726fcbb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9024
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-21 04:08:51 +00:00
Vladimir Serbinenko
e364871049 bootloader: Support x2apic
On my darp10-b EFI works and leaves APIC configured in x2apic mode. While
we can switch it back to xapic, it's better to support x2apic properly.

Change-Id: Ia00c69ccffc508497f45217462cdb6868c4629f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9005
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58670
2025-02-21 02:27:20 +00:00
Vladimir Serbinenko
801a0ee83d kernel: Change x86_*_msr to be an inline function on 32-bit platform
Change-Id: Ida5ff96cda06ca4463f15b636f1275977f3ec0ac
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9015
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-21 02:27:20 +00:00
Daniel Martín
2013cf27d1 VMCache: Fix typo on AddConsumer() description comment
Change-Id: Ie444550e1785cf13095f72c048ed592a63ceeedd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9026
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58669
2025-02-20 22:21:13 +00:00
PulkoMandy
85fc17e562 Migrate syscalls documentation from the website to Haiku internals book
Change-Id: I997049a1e174e7dd346e1342a2513a67e118a93b
hrev58668
2025-02-20 22:38:20 +01:00
Augustin Cavalier
b190b70845 kernel/x86: Do not hang forever if the serial line is dead.
Some newer hardware does not have COM1 at all. It seems this isn't
easy to detect, and so the best solution is just to use a maximum
spins timeout. This is in fact what FreeBSD does already, and the
"timeout" value of 256K unsuccessful spins is the same one they use
(see "COMC_TXWAIT" definition).

If the timeout happens once, then just disable serial or mark it
as timing out and don't try again (unless we eventually load
a settings file that specifies a new serial port.)

Tested on a custom build of QEMU hacked to reply to all reads
to the serial ports with zeroes (by just adding "return 0" to
"serial_ioport_read".)

Fixes #18561. May fix #19425.
hrev58667
2025-02-19 20:01:32 -05:00
Chris Roberts
9090152e40 screen_blanker: minor code optimization
No functional change.  I had been testing a minimum time before
showing the password window while still keeping the screen locked.
We can simplify the check for now though.

Change-Id: Id67c1ea07bb04ae477cd2f021fb15725c0144dbe
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9022
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58666
2025-02-20 00:22:26 +00:00
Chris Roberts
682c0438e7 ScreenSaver: trailing whitespace cleanup
Change-Id: I26d0806eea8d3ae6059d0dec3b1439dbb44e3b9c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9021
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-20 00:22:26 +00:00
John Scipione
d6c5aee9f9 Tracker: Draw all columns, fixes bug invalidating off-screen columns
AFAIK this has always been this way, however, the confusion seems to
be that pose->CalcRect() takes false for minimal rect while pose->Draw()
takes true for full-draw so they are opposites of each other.

This means we draw all columns on Invalidate(), not just the first one.

Change-Id: I40ddf5fa75b46d6da987fd5d5f83cdc4782fa851
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9019
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58665
2025-02-19 22:05:05 +00:00
John Scipione
6848bca37f Tracker: Raise opacity of dragged and cut items, fixes #19429
Change-Id: If498bb79a55697b2c270f3f21383d3c4f3a3d567
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9014
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-19 22:05:05 +00:00
John Scipione
40bb2f8c9f Tracker: Make drag fade rect a bit bigger and compose it
Change-Id: I2bfa9b5416cced7627f87613180c6b7c192be0d2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9013
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2025-02-19 22:05:05 +00:00
John Scipione
c24d316399 Tracker: Gray text on selected items in inactive windows, fixes #19428
Change-Id: If73faba3682c5360a15e4e87983d8c377216cb5b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9017
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-19 22:05:05 +00:00
John Scipione
82c55a447b Tracker: Use drawView instead of view in one place
Change-Id: I8ae87ca92c0749ce41bc11d1d59dcbcf38d9f25e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9016
Reviewed-by: John Scipione <jscipione@gmail.com>
2025-02-19 22:05:05 +00:00
Augustin Cavalier
a4f506a803 kernel/vm: Handle commitment > size in set_memory_protection more gracefully.
See inline comment: this can happen in the case of fork() pretty easily.
If it happens more often than that, something may be wrong; so for now,
at least, add a syslog print (under KDEBUG only) indicating that a full
recompute of the area commitment is being done.

Fixes #19337.
hrev58664
2025-02-19 15:26:36 -05:00
Augustin Cavalier
2deebfa44b BMenuBar: Move new reserved field to the proper place.
Without this, the amount of padding on the end of the class changes,
which could affect the ABI of any classes that inherit from this one.
2025-02-19 15:10:55 -05:00
John Scipione
0f430ba35c BMenu: Revert a small piece of hrev58661
Do not _Uninstall() whenever we _Hide() in BMenu again.

Fixes menus in Terminal and elsewhere.

Change-Id: Ic89ee2e4b0a94cc11c7a4091d9ce01e6ff6bb915
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9018
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58663
2025-02-19 20:07:55 +00:00
Augustin Cavalier
1c024a2361 kernel/block_cache: Disable object depot for the buffers cache.
The buffers are large, and we will pretty much always hold the block
cache lock anyway while allocating them, so a depot is just a waste.

Also slight code cleanup to the cache notifications declarations.
hrev58662
2025-02-19 14:18:20 -05:00
Augustin Cavalier
f554fbe3e6 kernel/vm: Panic if we can't allocate a mapping object.
Failing here with ENOMEM means SIGSEGV sent to the process, which will
likely result in it getting killed.

All needed memory for mapping should be reserved upfront, or we should
at least fail earlier when trying to reserve pages for mapping. So
failure here indicates a problem with kernel memory accounting, and
shouldn't result in processes crashing, ideally.
2025-02-19 14:02:01 -05:00
Augustin Cavalier
3e9660c184 kernel/x86: Clear page table entries in Unmap().
And not just their flags. This method is only used in the boot process
as part of vm_free_unused_boot_loader_range() as far as I can tell.
All the other unmapping routines already clear table entries.

Closes #14673.
2025-02-19 14:00:24 -05:00
John Scipione
ac55439364 Interface Kit: BWindow owns (and deletes) menu sem
_Uninstall() before _Hide() in BMenu because the window must
be available when we _Uninstall() especially for shortcuts.

Remove #define and always assume USE_CACHED_MENUWINDOW.

_Uninstall() whenever we _Hide() in BMenu.

Change-Id: I5dae85f6edf1f0b4ccf67a6d9d77470576671cee
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9012
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58661
2025-02-19 17:28:00 +00:00
Vladimir Serbinenko
87c49a5119 Fix smp trace formatting arguments
Change-Id: I086cc8ae617ed6eb4753a3f8af2986f0a56ae725
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9003
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
hrev58660
2025-02-19 17:24:55 +00:00
John Scipione
adc74a927c Tracker: Take precautions against rounded invert rect, fixes #18826
Change-Id: Ic4a33b960d8be6c5242d66f21aae2e0184c5cbc8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8976
Reviewed-by: John Scipione <jscipione@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
hrev58659
2025-02-19 08:02:08 +00:00
John Scipione
fbe7c9072c Tracker: Update pose/text widget to fix some problems
* Remove the unused width param from TextWidget::Draw(), we don't need it.
* Simplify UpdateIcon() with new _ListIconRect() and _IconRect() methods.
* Remove bad drawView->SetDrawingMode(B_OP_OVER) from TextWidget:Draw().
* Set cut and dragged item text based on high color instead of low color
  initially, then switch to low color when drawing text widget since the
  low color has been set.
* Restore cut item and dragged item high color after drawing outline.
* Fix regression in list view drawing dragged item label.
* Use correct CurrentPoseList() in list mode and icon mode.
* Always break when encountering NULL pose, don't bother to continue.
* Invalidate instead of redrawing on Select all.
* Split Extent() into ListModeExtent() and IconModeExtent().
* Init fListElemHeight and fListOffset in the initilizer list
* Init sFontHeight in earlier in InitCommon().
* Rename resultingIndex to resultIndex to make it fit on one line.
* Update pose and text widget CalcRect() to position everything
  (it basically already was but this standardizes ceilf and floorf).
* (use / 2.f to avoid trunction, just in case)

Change-Id: Idc8ccffdbe000bb126ab195e9739e7e5b9392bb3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8971
Reviewed-by: John Scipione <jscipione@gmail.com>
2025-02-19 08:02:08 +00:00
John Scipione
cd461bd05c BColumnListView: push/pop state to restore colors after column resize
Change-Id: Ic6d6d96a3a401051ca399cf853c3d800afe6d3fe
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8970
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: John Scipione <jscipione@gmail.com>
2025-02-19 08:02:08 +00:00
Chris Roberts
353ffc5de2 screen_blanker: add -l arg to allow immediate locking
This can be used when you want a keyboard shortcut to immediately lock
the screen or to lock the screen at boot time.

Change-Id: I12192fd3db9ae7a05046dee8e6d878c7fb3095a9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9011
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58658
2025-02-19 04:21:38 +00:00
Chris Roberts
84c99b4abf screen_blanker: switch to exclusive launch
There doesn't seem to be a need for multiple launches of screen_blanker
and it can cause some problems when screen_blanker is being launched
manually(e.g. via keyboard shortcut)

Change-Id: Ib2ac49a5539dbc668725bdf2126ea92646c878d9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9010
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-19 04:21:38 +00:00
Chris Roberts
c10ecdf570 screensaver: allow using the system password to unlock
This replaces the non-functioning "Network password" option that was
never implemented.

Change-Id: I9b7362f4e05d7f1a4be321e1a9aade62559794d2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9009
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-19 04:21:38 +00:00
Augustin Cavalier
8a1adae8b3 kernel/vm: Resize the first new cache only after mapping the second succeeded.
Having a cache larger than its area is harmless, but resizing the
cache too early could lead to not having enough memory available
if we hit errors and need to resize it back later on, which would
be bad. So put the Resize() that shrinks the first area's cache
at the end, to avoid such a potential problem.
hrev58657
2025-02-18 21:11:28 -05:00
Augustin Cavalier
fc65c189c0 kernel/vm: Remove unused variable.
No longer needed after the change to add fresh pages to top caches always.
2025-02-18 20:40:16 -05:00
Augustin Cavalier
e34dc1b157 kernel/vm: Steal commitment from the first cache in the general cut case.
This makes cutting larger caches much less likely to fail.

In the case of overcommit or resizePriority == -1, we already use
similar logic at the end of this method.
2025-02-18 20:39:42 -05:00
Augustin Cavalier
e810bebac0 libroot/malloc: Handle munmap() failing in the PagesAllocator.
This can happen if cut_area() in the kernel fails to reserve memory
for the cut caches. If it happens, just re-add the chunk to the free
maps and return a success status.
2025-02-18 20:37:20 -05:00
Augustin Cavalier
7ed236f0d9 kernel/vm: Don't release original cache references manually in cut_area.
There was one case in the old logic where we would double-release
references: if the secondCache->Resize() failed (or the Adopt(),
but this is much less likely to fail.)

Just reset the cacheChainLocker after we unlock all except the top cache.
It will unlock and release the reference as applicable.
2025-02-18 20:00:13 -05:00
Ilmari "ilzu" Siiteri
8ba36076c9 JsonMessageWriter: fix mismatched parameters
* The parameters for status and line number were out of order

Change-Id: Ie9c64908a8de095b4287f78eccd186411a955e65
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9008
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58656
2025-02-19 00:51:09 +00:00
Augustin Cavalier
0f15752ff5 kernel/vm: Forbid page faults in free_cached_pages().
Any that do occur in this state will be errors, but the page fault
handlers try to reserve pages to handle the fault even before checking
if the fault can be handled, so we could hit deadlocks or double-locks
before getting to the panic() without this.

Would have helped with diagnosing #12772.
hrev58655
2025-02-18 16:57:06 -05:00
Augustin Cavalier
d95b90791e nvme_disk: Give the interrupt condition variable a name.
Makes debugging easier.
2025-02-18 16:52:51 -05:00
John Scipione
13d645a0fe Tracker: Set read-only low color on ColumnResize()
Change-Id: I6344d7e3e6363da068b8b5ede818c01070c7484c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8998
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58654
2025-02-18 21:13:51 +00:00
John Scipione
046f27c114 Tracker: Prevent Add-ons from being rebuilt too fast, fixes #19426
Change-Id: I016aa63979c9e4b3a28d486538e98df8cd2e2fa9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9007
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
hrev58653
2025-02-18 21:13:40 +00:00
Augustin Cavalier
58436dc467 kernel/x86: Handle overflows in apic_timer_set_hardware_timer.
This is relatively harmless in all cases except where the lower 32 bits
are all zeroes, as in that case we would never get a timer interrupt.
In all other cases we would just time out too soon, and the timer
interrupt handler would reschedule.

We need to add clock divisor selection to this module so that we can
be sure that at least reasonably-sized timeouts (a few seconds, e.g.)
will not overflow 32 bits, though.

Change-Id: I62c829aa740bbd611aab788854d722cfa659a0d8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9001
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
hrev58652
2025-02-18 21:04:59 +00:00
Augustin Cavalier
4edec1770c kernel/x86: Use APIC timer frequency from hypervisor CPUID leaf, if present.
It is on VMware at least, and is faster and more accurate than measuring.

Change-Id: I42cd16869ca8531bb9710b148609d8218ff870e8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9000
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-18 21:04:59 +00:00
Augustin Cavalier
3d840c4289 kernel/x86: Determine the APIC frequency in the kernel instead of the bootloader.
We use the TSC to measure the APIC frequency, but the TSC frequency
is only fully initialized in the kernel (where it's read from CPUID
on recent hardware).

Furthermore, on some more recent systems, it seems there may only be
X2APIC and no MMIO APIC timer at all, and the bootloader does not
handle that case.

The method in the kernel uses spin() instead of a fixed instruction
count as well as system_time_nsecs() and a double for (hopefully)
more accurate calibration.

At least on VMware, this method seems more accurate: the APIC frequency
read from the hypervisor CPUID leaf is 66,000,000; the old method in
in the bootloader yielded values like "65,801,075" and "65,106,382",
while the new one yields values like "65,963,920" and "65,962,580"
(those pairs of values are from two consecutive boots.)

The difference was sometimes similar (but smaller as a percentage) in
QEMU with software emulation: e.g. "993,218,085" vs. "992,965,761". But
sometimes it wasn't: e.g "991,619,585" vs. "993,689,669". (QEMU in
software mode doesn't report a frequency via hypervisor CPUID leaf.)

Change-Id: I4fb8535d1d984f13867e2f84e7dfad1ceed42c13
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8999
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-02-18 21:04:59 +00:00
Augustin Cavalier
b801f14f55 pthread: Avoid syscalls in cond_signal if possible.
* If WAITING is not set, we don't need to call unblock().

 * When exiting wait() and there are no more waiters, zero out
   the lock entirely.

Helps with #18216 a bit.
hrev58651
2025-02-18 15:46:36 -05:00
Augustin Cavalier
e63683b2fb kernel/debug: Acquire the output mutex in the syslog sender and repeats checker.
This way we are less likely to encounter "Failed to acquire ... for
a long time", especially when onscreen debug output is enabled.

In the pending repeats checker, we wait at most 100ms to acquire the lock,
since this is run on the "kernel daemon" thread which we don't want
to block for too long.
hrev58650
2025-02-17 15:48:29 -05:00
Augustin Cavalier
05a7e7ba63 libroot/malloc: Avoid memset() of newly mapped memory in OpenBSD malloc.
Saves some time especially on large heap allocations.
hrev58649
2025-02-17 11:45:10 -05:00
Krutarth Patel
c8252422b8 Adding device node tree image to Haiku documentation
In the device driver architecture documentation there is a
TODO for adding an image representation of the device node
tree in Haiku.
This patch adds a .svg image for the same, removing the TODO
line.

Change-Id: If5d1e3ee5abe7d6e84245c837b5cb2f1f0cb670a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8983
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: nephele nephele <nep-git@packageloss.eu>
hrev58648
2025-02-16 21:17:56 +00:00
Augustin Cavalier
07f87734c5 BColumnListView: Don't invalidate if the row is below the visible rect.
Another significant invalidations optimization.
hrev58647
2025-02-15 21:49:31 -05:00
Augustin Cavalier
6f0caabcf7 HaikuDepot: Re-invalidate and re-derive labels in ItemCountView sporadically.
Instead of unconditionally calling _DeriveLabel() and Invalidate()
every time (both expensive operations), use a bool to track whether
we've already invalidated, and derive the label in Draw() if it
was set.

Significantly decreases the invalidations done on full-list rebuilds.
hrev58646
2025-02-15 21:22:55 -05:00
Augustin Cavalier
341d251a45 BScrollBar: Avoid unnecessary invalidations when changing properties.
* _UpdateThumbFrame() calls Invalidate() already, don't call it again
   in SetRange unnecessarily.

 * If the new and old thumb frames are the same, skip invalidation.

Saves a lot of Invalidate() calls in HaikuDepot on building the
"all packages" list especially.
2025-02-15 21:12:30 -05:00
Augustin Cavalier
fbb27923df HaikuDepot: Use more optimal string operations in searching.
* package->Name() is always lowercase, don't bother using lowercase
   operations on it.

 * Use IFindFirst rather than transforming the string; this uses
   strcasestr internally which operates per-character.

Loosely based on a patch by oco in #19421.
2025-02-15 21:10:00 -05:00