Commit Graph

65182 Commits

Author SHA1 Message Date
Autocomitter
5146c41132 Update translations from Pootle 2023-06-17 08:17:02 +00:00
Alexander von Gluck IV
06898ee467 build/profile: Add nightly-mmc for riscv64 (and arm later)
Change-Id: I6aeddabedb8cf3e1505519f4393e4d0f2af5ea7f
2023-06-16 14:45:25 -05:00
X512
4a6b1e401c repo/riscv64: Bump HaikuPorts build-packages for riscv64
Change-Id: Idba2bc58c46deaa182ad27011b5a99e3231afe56
2023-06-16 14:44:48 -05:00
Alexander von Gluck IV
5676ddf7ca repo/riscv64: Bump HaikuPorts build-packages for riscv64
Change-Id: Ib230422bc514831983cd8b4d2794c37f46d62343
2023-06-16 13:10:53 -05:00
Alexander von Gluck IV
710016817c tests/qemu: Fix network on riscv64 test vm
* While virtio was attaching, network connectivity
  wasn't functional.
* Use usb-net for now to get things working.
* Move to a user network with dhcp for simplicity
* Forward port 5555 on the host to 22 on the guest
  for debugging / testing

Change-Id: Ieac095d7272c3132c39e4eaa0ccc461a32972dd2
2023-06-16 11:29:59 -05:00
David Karoly
b6e15e8bf5 boot/arm: enable TEX remap
Configure PRRR and NMRR as follows:
- memory type 0 is Strongly-Ordered
- memory type 1 is Shareable Device
- memory type 2 is Normal, Inner/Outer Write-Through
- memory type 3 is Normal, Inner/Outer Write-Back, no Write-Allocate

This way no change is needed in B and C bits so we can keep the
existing MemoryTypeToPageTableEntryFlags() implementation.

Change-Id: Icb4b18b0082774fdbef28576cee8624fae610538
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6607
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2023-06-15 10:43:14 +00:00
Augustin Cavalier
6554d7448d kernel: Print the first 4 chars of cvar names in KDL "threads" command.
Condition variables are now a pretty common way the kernel blocks threads.
That means the "threads" command was getting difficult to navigate, since
at any given time, a lot of threads could be blocked on "cvar".

Now we try (carefully, because it could fault!) to fetch the first 4
characters of the "type" name and display then. This suffices to
distinguish the most common object block types in the list at a glance
(e.g. "cvar:port" for port reads, the most common.)

Change-Id: I94f4b59fd78b7ebdce913944551a5e98f0ca2e33
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6605
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-06-13 19:41:07 +00:00
KENZ
f0e9ed4488 Debugger: just skip .debug_frame/.eh_frame section contains a 0-length CIE
Some executables (or shared objects) may have .debug_frame or
.eh_frame section which contains the CIE(/FDE) length is 0.
The DWARF spec doesn't describe this case explicitly, but doesn't
prohibit it.
LSB says to treat this a terminator of the CIE.

https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html

Previous code failed to load the entire debug info of the
executable.

New code just skip these section (don't read anymore) after the
Debugger (kit) encounter a 0-length CIE.

Fixes #18438.

Change-Id: I382d0ec409d40570b5bccd384d38fa3c29ae2e7f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6538
Reviewed-by: Rene Gollent <rene@gollent.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2023-06-13 12:22:56 +00:00
Augustin Cavalier
496e411397 pthread_barrier: Ensure the barrier is "idle" during destruction.
If the serial thread tries to destroy barriers immediately, not all threads
may have exited yet. This takes care of that case.
2023-06-12 23:55:08 -04:00
Augustin Cavalier
f79c7ae83e pthread_cond: Use test_and_set in cond_wait.
This is necessary in the case where only one thread is
being woken up at a time.
2023-06-12 23:53:39 -04:00
Augustin Cavalier
ca458a2b55 user_mutex: Adjust semantics of B_USER_MUTEX_UNBLOCK_ALL.
No longer is it required that the mutex be unlocked.
This was the case before the recent refactor, though it
wasn't noted anywhere. Now it is the case once more.

Should fix #18445.
2023-06-12 23:53:02 -04:00
Augustin Cavalier
901b48c2e8 user_mutex: Fix potential race in switch_lock.
We need to set the "to" mutex as locked+waiting before performing
the unlock of the first mutex, otherwise something in userland could
unset the "locked" flag but never call the kernel because "waiting"
had not yet been set.

In practice, the one consumer of this API (pthread_cond) could not,
at present, wind up in that situation, as far as I can tell, so this
race was entirely theoretical.
2023-06-12 22:51:45 -04:00
Jérôme Duval
9c4bd82612 ifconfig: check the family when different from AF_UNSPEC
fix #18443

Change-Id: I05df404311f7e2048b83d5c4ebfdf8e1b0fc64c0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6597
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2023-06-12 14:07:07 +00:00
X512
edd8e471a6 xhci: fix root hub endpoint companion descriptor size
Fixes "SuperSpeed device without an endpoint companion descriptor!" error on riscv64.

Change-Id: Ie4d02997f17b68ea89bb3f3c8ab1ead99a2fc07a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6596
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2023-06-11 21:55:51 +00:00
PulkoMandy
37e1b12911 framebuffer: report display EDID data
This allows to see the display in Screen preferences, and know its DPI
and physical size (as much as EDID data can be trusted). This
information could be used to compute the default font size, for example,
so it's important that all drivers provide it whenever possible.

Change-Id: Ic3d04e53cf5fcb24e22d35661d2b364a257947da
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6576
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2023-06-11 11:23:01 +00:00
Trung Nguyen
29f8da76d7 strace: Add mutex type
Added a dedicated mutex type handler that can print mutex status
flags while still showing the mutex address.

Change-Id: Ie028e5c0a336063a4c03a4f9adf955ffa6911837
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6557
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-06-10 00:34:37 +00:00
Trung Nguyen
c80a875a74 libroot: fix pthread_[g/s]etschedparam
Make `pthread_getschedparam` and `pthread_setschedparam` handle
scheduling policies more consistently with `sched_get_priority_min`
and `sched_get_priority_max`.

Threads running in real-time priority will appear to be under the
`SCHED_RR` policy, while normal threads will appaer to be
`SCHED_OTHER`.

This prevents POSIX code using `sched_get_priority_min` with the
calling thread's current policy returned by `pthread_getschedparam`
to adjust its priority from unwantedly promote into real-time code
and affect overall system performance.

Change-Id: I9664257dc1b98db579e55218ce352cb762524b0c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6556
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2023-06-09 17:07:44 +00:00
Augustin Cavalier
6f3f29c7dd user_mutex: Refactor locking and unblocking mechanism.
Suppose the following scenario:

1. Thread A holds a mutex.

2. Thread B goes to acquire the mutex, winds up in kernel waiting.

3. Thread A unlocks; first unsets the LOCKED flag.
   As WAITING is set, it calls the kernel; but instead of processing
   this immediately, the thread is suspended for any reason (locks,
   reschedule, etc.)

4. Thread B hits a timeout, or a signal. It then unblocks in the kernel,
   which causes the WAITING flag to be unset.

5. Thread C goes to acquire the lock. It sets the LOCKED flag.
   It sees the WAITING flag is not set, so it returns at once,
   having successfully acquired the lock.

6. Thread A, suspended back in step 3, resumes.

Now we encounter the problem. Under the previous code, the following
would occur.

7. Thread A sees that no threads are waiting. It thus unsets the LOCKED
   flag, and returns from the kernel. Now we have a mutex theoretically
   held by thread C but which (illegally) has no LOCKED flag set!

8. Some other thread tries to acquire the lock, and succeeds, for LOCKED
   is not set. We now have one lock owned by two separate threads.
   That's very bad!

The solution, in this commit, is to (1) switch from using "atomic_or"
to lock mutexes, to using "atomic_test_and_set", and (2) mandate that
_kern_unblock_mutex must be invoked with the mutex already unlocked.

Trying to solve the problem with (2) but without (1) produces other
complications and would overall be more complicated. For instance,
all existing userland code expected that it would set LOCKED, but then
check LOCKED|WAITING. If _kern_mutex_unlock does not unset LOCKED,
then whichever thread sets LOCKED when it was previously unset is
now the mutex's undisputed owner, and if it fails to notice this,
would deadlock.

That could have been solved with extra checks at all lock points, but
then that would mean locks would not be acquired "fairly": it would
be possible for any thread to race with an unlocking thread, and
acquire the lock before the kernel had a chance to wake anyone up.

Given how fast atomics can be, and how slow invoking the kernel is
comparatively, that would probably make our mutexes extremely "unfair."
This would not violate the POSIX specification, but it does seem like
a dangerous choice to make in implementing these APIs.

Linux's "futex" API, which our API bears some similarities to, requires
at least one atomic test-and-set for an uncontended acquisition,
and multiple atomics more for even the simplest case of contended
acquisition. If it works for them, it should work for us, too.

Fixes #18436.

Change-Id: Ib8c28acf04ce03234fe738e41aa0969ca1917540
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6537
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-06-08 16:49:05 +00:00
Augustin Cavalier
65a76a0fb9 pthread & os/locks: Add some more assertions and error checks.
The first of these assertions in the pthread code is actually possible
to trigger under some specific circumstances, which is ticket #18436.
This makes that problem more obvious when it does happen.

Change-Id: I026ea6e4c569a7c20d82b70722f752d87e57c5a1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6536
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2023-06-08 16:49:05 +00:00
Zardshard
a127b88ecb Debugger: Add UML class diagram
The debugger.xmi file is the source file meant to be opened by
Umbrello. The other files are generated.

The docbook file is exported from Umbrello and the .rst file is
converted from it using Pandoc, with minor manual fixes.

Change-Id: Idc831d15c6121c21ebb170c245bc8ab97986702e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6483
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2023-06-08 11:46:23 +00:00
Humdinger
95f94193f5 pkgman: add command to show summary and description
Add command "info" to show the summary and description of a package
in a a remote repository.

Change-Id: I254eff3bb6401c90a394a483cd684134ead0a9a3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6516
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-06-07 15:18:10 +00:00
Augustin Cavalier
b24cc7ca75 pthread: Use 1 for PTHREAD_BARRIER_SERIAL_THREAD.
pthread_barrier_wait can return errors, which on Haiku are negative
and so -1 is an error condition, it should not be reused for a magic
constant.

This breaks ABI. However, until the recent fixes, barriers were so broken
that I doubt any application was using them seriously (Mesa, for instance,
has them disabled.)

Change-Id: Ica23921de012a33e9e7aded816bb1347bd157b31
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6517
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: X512 <danger_mail@list.ru>
2023-06-07 15:12:11 +00:00
Augustin Cavalier
4785ffe77c pthread_barrier: Add casts to appease GCC2. 2023-06-06 15:48:15 -04:00
Augustin Cavalier
505fdd612b pthread_barrier: Rewrite critical section.
The previous implementation was prone to deadlocks when the next round
of threads tried to enter the barrier before the prior round exited it.
This new version takes care of that problem, and also removes some
other contention.

Basic design:

 * waiter_count is now atomic, which means only the "serial" thread, or
   in case of contention threads that raced, need acquire the mutex.

 * mutex remains locked during threads wakeup, at which point waiter_count
   is negative. It is only unlocked when count reaches 0 in the last-woken
   thread. This protects against the races that lead to deadlocks.

 * Remove usage of _kern_mutex_switch_lock. This was done incorrectly;
   if it returned EINTR, the first lock would be unlocked but the second
   would not be acquired, creating further races. Instead, we leave
   the barrier lock in "LOCKED" state at all times except when we
   actually want to wake threads up, when it is left "Unlocked"
   (and "unlocked" by each successive exiting thread, just in case.)

Fixes #15736.
2023-06-06 15:25:23 -04:00
Augustin Cavalier
63396c7d13 pthread_barrier_test: Reduce sleep times and increase cycles.
This test now reliably reproduces the deadlock reported in #15736.
2023-06-06 15:25:23 -04:00
David Karoly
f61fb770f0 kernel/arm: don't set Accessed Flag when initially mapping a page
Pages should not be marked as accessed when initially mapping them.

However, there's a short interval during kernel startup when new pages
are mapped but the fault handler is not installed yet.

Therefore, we set Accessed Flag to 1 in early_map.
Once the kernel initialization has progressed enough, we start mapping
new pages with Accessed Flag set to 0.

The chicken and egg problem of initially mapping the vector page is
tackled by preallocating the vector page in the boot loader.

Change-Id: Ie3be4f81812d7a090af57e8c79420598d16182b9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6450
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2023-06-06 18:49:56 +00:00
Trung Nguyen
a2cb4665de strace: Improvements
- Added some utility functions to the `Context` class.
- Updated the `sockaddr` handler to retrieve the next sibling
rather than the sibling at index 2. This allows the handler to
work for syscalls where the `socklen_t` argument is not the third
one, for example, `_kern_recvfrom`.
- Added the ability to print the `flatArgs` for `_kern_exec` and
`_kern_load_image`.

Change-Id: Ia4cf0a30a5cf972274820bbf068101450db52189
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6498
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-06-06 15:10:35 +00:00
Augustin Cavalier
9686d93151 kernel/user_mutex: Fix another instance of addr_t.
Spotted by korli.
2023-06-06 10:54:16 -04:00
Augustin Cavalier
402b41562c kernel/user_mutex: Use phys_addr_t for hash keys.
This could fix address collisions on 32-bit systems with PAE.

Fixes #18435.
2023-06-05 20:56:15 -04:00
Augustin Cavalier
cf1b26a933 kernel/user_mutex: Create utility functions for the user_atomics.
In the future, these should be moved to another file (and fault handlers
used), but at least this de-clutters the code a bit for now.
2023-06-05 20:53:55 -04:00
Trung Nguyen
17d9a20c62 strace: Add support for struct sockaddr
- Updated old `sockaddr *` formatting code to work with current
`strace` structure.
- Add support for `AF_UNIX` family address.

Change-Id: I13f7b0a3eb913ab188bea68f8ea84e928b753154
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6497
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2023-06-05 12:40:24 +00:00
Zach Dykstra
d666f82888 Terminal: satisfy new theme window condition check
Change-Id: I69beb720da2f13faf82596bb655755ff5cea8414
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6487
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2023-06-05 06:54:06 +00:00
Autocomitter
b2b94ad94f Update translations from Pootle 2023-06-03 08:13:05 +00:00
Augustin Cavalier
c4c09e7fed usb_disk: Fix double-lock KDL on device removal.
Fixes #18431.
2023-06-01 11:59:01 -04:00
Trung Nguyen
7be371792f kernel/vm: unlock cache before unmapping addresses
Unlock the current cache in `map_backing_store` before
`unmap_address_range` is called, since `unmap_address_range` may
call `delete_area` which would then also attempt to lock the same
cache if that cache has already been mapped to an area in the
conflicting address range.

Fixes #18422.

Change-Id: I6fc5301c43d11bb6df489a2e6d6bdcd6cd80d2b7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6392
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2023-06-01 08:23:53 +00:00
Augustin Cavalier
0450e7b802 USB: Acquire the device manager lock before Explore.
We must do this to prevent lock order inversion: when busses are
initialized, they are started by the (locked) device manager, and
then acquire the explore lock. We must do the same in Explore itself,
for when called by the explore thread, we would otherwise first acquire
the explore lock, then (when publishing new nodes) acquire the device lock.

Should fix #18421 and #18393.
2023-05-31 16:49:41 -04:00
Augustin Cavalier
bd90416925 USB: Do not wait for first explore in Stack constructor.
Following various refactors, at the point the Stack object is created,
there are no bus managers yet, so exploring will find nothing.
2023-05-31 16:15:54 -04:00
Augustin Cavalier
1eb7837ddd usb_disk: Ensure we are in a consistent locking state before calling free.
Should fix the KDL in #16745.
2023-05-31 15:01:03 -04:00
Augustin Cavalier
cb1df90e30 Revert "kernel/vm: handle page protections in cut_area"
This reverts commit de07bc3fa5.

That's what I get for fixing bugs on test branches.
2023-05-31 14:48:23 -04:00
Augustin Cavalier
fbcc7b2711 BScrollView: Ajust minimum dimensions as little as necessary.
If the dimensions are already larger than needed, don't add to them.
Fixes Terminal and other non-layout applications' display
following the prior change.
2023-05-31 14:47:40 -04:00
Trung Nguyen
de07bc3fa5 kernel/vm: handle page protections in cut_area
- Resize the `page_protections` array in `cut_area` and also shift
the bits if necessary.
- Set the correct protection array as well as the real page
protections for the second area produced by `cut_area`.

Change-Id: I62293480487e828970ebe5a3bc729cec2a14c687
2023-05-31 14:47:40 -04:00
Zardshard
338fedd65a Tracker: Fix memory leak
BMenuField's constructor (called on line 715) used to be passed
fDirMenu. The constructor would create a new BMenuItem using fDirMenu.
TFilePanel::Init did not want this menu so it removed it with a call to
RemoveItem (located on line 721). This call, however, does not actually
free the memory. It just removes it from the menu. The refactor that I
did here fixes this by never creating the new BMenuItem in the first
place. This is done by passing NULL into BMenuField's constructor
instead of fDirMenu. It happens that the refactoring also cleans up
TFilePanel::Init slightly.

Change-Id: I05ef24f429fb309ff41806e342d275f832772b5e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6486
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-31 17:48:17 +00:00
Augustin Cavalier
ef8e820bc7 FileTypes: Remove workaround.
Not needed after the previous commit.
2023-05-31 13:33:50 -04:00
Augustin Cavalier
269de6acca BScrollView: Take both minimum dimensions of scrollbars into account.
Fixes #5678.
2023-05-31 13:33:50 -04:00
Trung Nguyen
bfd3d33765 strace: Print detailed signal information
- Add support for retrieving the `siginfo_t` structure of a signal
event from the Debugger API.
- Add code to `strace` to display this information every time a
signal event occurs, similar to the Linux `strace` tool.

Change-Id: If4e92bbae049ee0b52efaf9fc911d66511da62f4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6393
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-31 16:34:12 +00:00
Adrien Destugues
0992009d13 libnetapi: remove support for old OpenSSL versions, prepare for OpenSSL 3
- Remove backported function that was needed only for old OpenSSL versions
- Add compile time options to declare which version of OpenSSL API we
  want to use

This should make it possible to build with OpenSSL 3 while keeping the
old APIs available. Once the migration to OpenSSL 3 is done, we can bump
the OPENSSL_API_COMPAT value to get compile time errors when using APIs
that are deprecated in OpenSSL3, and rewrite all the code that needs
changes.

Change-Id: I606633739ed12f9698a3013989025b68478352fc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6484
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-31 16:33:08 +00:00
Zardshard
0e86ca77e7 Tracker: Fix memory leak
Change-Id: I2fa8e9e87d1097cfc358cc3653240aeac6efb910
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6485
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-31 16:32:50 +00:00
Augustin Cavalier
ca40d4ab5c usb_disk: Probe by USB configuration instead of attributes.
In the case of devices where the mass-storage interface is not the
first one, we will miss it unless we were to check all attributes
one at a time in order. Instead of doing that, just fetch the configuration
and enumerate it directly.
2023-05-30 15:32:49 -04:00
Augustin Cavalier
e1e2a82dd2 USB: Use BStackOrHeapArray in RegisterNode.
I saw in a KDL stack trace that this function was using over 4KB of stack.
As it is called as part of device_manager startup, where there can be
pretty deep recursion happening, that seems like a bad idea.

Additionally, it did not actually do bounds checking.
Now we dynamically allocate an array of sufficient length.
2023-05-30 15:24:52 -04:00
Augustin Cavalier
ac0506fd90 usb_disk: Granularize locking.
There is now an "io_lock" which must be held when performing any USB
operations. All ioctls that read basic status, size, icon, etc. information
do not need to acquire it, of course, which should improve userland
lockup occurrences on congested USB disks.
2023-05-30 15:23:36 -04:00