Commit Graph

65261 Commits

Author SHA1 Message Date
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
Augustin Cavalier
20313e56ed usb_disk: Clean up and consolidate mutex/semaphore creation/destruction. 2023-05-30 14:19:57 -04:00
Augustin Cavalier
dd6e7cb90d usb_disk: Use get_attr_uint8 instead of a loop to get class/subclass/protocol.
Suggested by axeld. The original logic was copied from the USB-ECM
driver, which may also be able to be simplified here.
2023-05-30 14:19:07 -04:00
Augustin Cavalier
9b1ff49d87 kernel/io_request: Add assertion in NotifyFinished() that fStatus is set. 2023-05-30 14:01:23 -04:00
Augustin Cavalier
831bb20728 kernel/dma_resource: Add an assertion to prevent Init() from being called twice. 2023-05-30 14:00:47 -04:00
Augustin Cavalier
92b8f3e74c kernel/dma_resource: Fix tracing. 2023-05-30 14:00:44 -04:00
Augustin Cavalier
197e4b5a6a usb_disk: Use DMAResource for bouncing and support physical I/O requests.
A "bypass" mechanism is left in for when DMAResource would just add
overhead for no reason. All other I/O goes through it and is submitted
to the USB stack as physical addresses.

Tested in QEMU, can still boot from USB on all busses.

Fixes #15569.

Change-Id: I26bfd2208de4ebe1a17170a7034316076927663f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6480
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-30 17:54:28 +00:00
Augustin Cavalier
55a468820c USB: Support physical-vector bulk requests.
Introduce a new utility method, "generic_memcpy", which takes
generic_addr_t plus indications of whether these specify virtual or
physical addresses (and potentially user addresess) and calls the
appropriate memcpy variant depending.

All bus drivers adjusted to support this at once. We don't actually
take advantage of the physical addresses in any way (yet), as USB
controllers have some pretty specific requirements that would have
to be carefully validated to use these directly.

All bus drivers tested and confirmed to still be working.

Change-Id: I66326667e148091147bb2b3d0843a26fb7e5bda6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6479
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-30 17:54:28 +00:00
Augustin Cavalier
99626c2908 USB: Use generic_io_vec in Transfer.
Prepares the way for actual physical-address request support,
which is not yet wired up.

Change-Id: I1b2d04a31e334a79b8361280fa0f3a5fbdb43d2b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6478
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-30 17:54:28 +00:00
Augustin Cavalier
65cdc13e7d kernel: Migrate struct generic_io_vec to a private header outside src/.
This way it is more easily accessed from drivers outside the kernel,
which it soon will be, without having to add an explicit UseHeaders.
(The drivers that use it already all use the IOScheduler.)

No functional change.

Change-Id: Ibc2d2678e37d9d7ab73391cb17b72cca86f92132
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6477
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-30 17:54:28 +00:00
Jérôme Duval
47b66bb676 loopback_frame: when the interface address isn't set, use the destination
fix #18429

Change-Id: Ifd0a15e052bbde9eb3d8875249e03152e6292994
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6482
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-30 16:15:49 +00:00
Augustin Cavalier
c88d446192 usb_disk: Move icon data to a separate header. 2023-05-29 16:11:30 -04:00
Augustin Cavalier
5c99f9668e XHCI: Disable MSI-X for now.
Breaks USB on some hardware. This might be a bug in Haiku's
MSI-X implementation.
2023-05-29 15:47:22 -04:00
Augustin Cavalier
e223e8e94b kernel/x86: Initialize IO-APIC only after PCI enumeration is complete.
Before the PCI refactor, PCI initialization/enumeration occurred
immediately after the PCI module was loaded, and so by the time
we got to IOAPIC initialization, it was already complete.

After the refactor, PCI enumeration is deferred until slightly later,
and so we would try to initialize IO-APICs without knowing PCI
information. This would fail, as read_irq_routing_table needs to
have that available.

Hopefully fixes #18425, #18393, #18398.

Change-Id: I1e4b06367da26eeb10085a1c6322ed39885b632b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6476
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-29 19:44:32 +00:00
Augustin Cavalier
b256fa4adf usb_disk: Transition to "new" driver API.
Change-Id: Ia46cb6ddc9f83917a8f797149508d35b770e44f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6473
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-29 18:11:26 +00:00
Jérôme Duval
7c18d58f2b usb: explore on BusManager::Start()
registering new devices requires the device_manager lock. The explore thread would wait
that the initial device scan is over to register devices.

Change-Id: I46529ab0926f349023f06ada3411979c0950dfcf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6475
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-05-29 18:11:26 +00:00
Zardshard
3c416c7aa7 Tracker: Remove failing ASSERT
This ASSERT causes a crash in the debug build of libtracker.so.

The crash occurs when two conditions are met:
1. There are files in the directory with icons specific to them. This
   is the case with image files, whose icons preview what the contents
   of the image are.
2. Tracker has not displayed those icons yet. This happens if the user
   has not scrolled down far enough to see the icons.

One way to meet these conditions is to configure the build system to
compile a debug build of libtracker.so. Then compile icon-o-matic.
Then run icon-o-matic with the debug build of libtracker.so
LD_PRELOAD'ed.

With that, press File->Open and navigate to
/system/documentation/BeBook/images/admonitions. While in the images
folder, do not scroll up or down to view the icons of the images in the
folder. They should remain unrendered. It should crash as soon as
Tracker enters the admonitions folder.

The crash occurs because NodeIconCache::Deleting is called without a
corresponding call to NodeIconCache::AddItem. Tracker calls
NodeIconCache::AddItem whenever it renders an icon to cache the result.
Tracker, however, is lazy, and only renders the icon when it comes into
view. When navigating out of the directory, Tracker has to call
Deleting for every file in the directory since it doesn't keep track of
which icons it rendered and which icons it didn't. Thus, AddItem has
been called for some of the files, but Deleting has been called for all
of them, causing the assert to fail and the program to crash.

This commit fixes the problem by not requiring a call to AddItem for
each call to Deleting.

Change-Id: I1038ce70ca345c44812becee7f3752567e5b562a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6474
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-05-29 18:09:32 +00:00
PulkoMandy
7da4ade74b Remove version constraints for ICU
These are populated with the correct version automatically when building
the package, so there's no need for an explicit setting. This had
already been cleaned up for the other packages, but not yet for
haiku_secondary

Change-Id: I5bcc94fb80f639610899ec31fc77a6e678ca9e80
2023-05-28 17:03:35 +02:00
PulkoMandy
80cb3bc23e Add source for Misc_WebSearch icon
Used in WebSearchFS.

Change-Id: I55a6c74dfb2b57f2a1ea6141727f40a187a9868f
2023-05-28 16:59:19 +02:00
PulkoMandy
5bf195cdad Remove libicutu and libicutest from Haiku dependencies
These are used only by ICU tests and should not be in the ICU package.
They will be removed in the next versions of the ICU package when we
update.

Change-Id: Ib8bb2dd24ce1671e8b369c775b89d49b9b6e84eb
2023-05-28 16:59:19 +02:00
Autocomitter
86574d08dd Update translations from Pootle 2023-05-27 08:12:45 +00:00
Augustin Cavalier
958b83c3ed PoorMan: Default to UTF-8 character set.
Ideally we would default to no character set, but
libhttpd does not seem to support that.

Fixes #18424.
2023-05-25 16:21:40 -04:00