Commit Graph
100 Commits
Author SHA1 Message Date
Augustin Cavalier 4fbebc21b8 registrar: Back out change to convert case in B_REG_MIME_GET_SUPPORTING_APPS.
This reverts commit 3ab43722bf.

Now that GetSupportingApps does case conversion, we don't need to do it here.
2024-01-26 18:20:35 -05:00
Augustin Cavalier cdf3559b27 Storage Kit: Do case conversion in SupportingApps::{Get,Set}SupportedTypes.
We already convert everything to lowercase in BuildSupportingAppsTable(),
so we should do the same here.

Fixes #18752 (again.)
2024-01-26 18:19:16 -05:00
Augustin Cavalier 89fcf815e6 Storage Kit: Source clean up to SupportingApps.
Remove extraneous comments, early-return on error (and thus de-indent.)
No functional change intended.
2024-01-26 18:09:33 -05:00
Augustin Cavalier 94d33dcbb6 XHCI: Rework _LinkDescriptorForPipe to avoid double-links.
The previous logic would link from the end of the ring to the start,
and the TRB there would always itself be a link TRB. Now, we avoid this
by linking back to the start from within the TD segments, and putting
the "Event Data" TRB there.

May help with some problems.

Change-Id: I92c4e135ee28c8c89646594a99fb40ee0d6c4484
2024-01-26 17:36:26 -05:00
Augustin Cavalier 45436c7a67 freebsd_iflib: Remove workaround for multi-packet receive.
Following the last commit, we can just let if_input
process the whole chain at once.

The logic here may not have been correct, and possibly
caused memory leaks under high-traffic conditions.

May help with #18585 and others.
2024-01-26 16:02:48 -05:00
Augustin Cavalier 9504fccf29 freebsd_network: ether_input needs to support multiple packets.
It does on FreeBSD, though not many drivers make use
of this functionality (on Haiku, only iflib appeared to,
and it has a workaround at the moment.)
2024-01-26 16:00:13 -05:00
Augustin Cavalier 17aa6d0125 IPv4: Make header fields go out of scope when no longer usable.
There was a comment indicating where this happened, but then
there was a use of one of them after this point. Fix that,
and add { } around their use to prevent this from happening again.
2024-01-26 14:32:59 -05:00
Augustin Cavalier aeb3a97aba XHCI: Properly handle "Length invalid" and erroring TRBs on the endpoint ring.
Should improve #18432 and other tickets.

Change-Id: Iaafe2d9d61bc0514e4dd6283b9e75496d5e2d44a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7341
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-01-18 19:14:04 +00:00
Augustin Cavalier a2270c7035 kernel/vm: Avoid committing memory in vm_map_file for PRIVATE_MAP without PROT_WRITE.
Instead, rely on commitment being done later, when the
protections are changed. set_area_protection() already
did just that, but set_memory_protection did not, so
it is implemented here.

Fixes #18733.

Change-Id: Ia58aee93faf1296fce69d723b12d0fa0a8440706
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7339
Reviewed-by: waddlesplash <[email protected]>
2024-01-17 20:21:30 +00:00
Augustin Cavalier e5e1f48bf5 PCI: Convert constant missed in prior commit. 2024-01-15 15:24:58 -05:00
Augustin Cavalier fabb71cc0e PCI: Support more than 6 PCI memory ranges.
Also use the standard kernel-wide constants for IO or memory space
rather than defining new ones, as well as the PCI constants for
address types.

Change-Id: Iad03f7666ad5121a5c9a398339aa1a191339a1d1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7336
Reviewed-by: waddlesplash <[email protected]>
2024-01-15 20:18:57 +00:00
Augustin Cavalier 6533df4fe4 iaxwifi200 & idualwifi7260: Synchronize with OpenBSD. 2024-01-15 14:12:49 -05:00
Augustin Cavalier 7bcc4a30f9 openbsd_wlan: Synchronize net80211 with OpenBSD. 2024-01-15 14:12:09 -05:00
Augustin Cavalier 2fb174a701 kernel/fs: Add missing initialization. 2024-01-10 12:51:10 -05:00
Augustin Cavalier 79c0b6288f kernel/fs: Make vnode_path_to_vnode and derived methods take VnodePutter&.
Upcoming changes will make this method return values in _vnode even
when they return error codes under some conditions. To avoid easily-
caused memory leaks, this commit refactors the output variable to
be VnodePutter&, and all consuming methods to thus make use of Putters.

Should not be a functional change.

Change-Id: Id7b9066f8cd50c159d52c921b16e475e4e1de806
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7301
Reviewed-by: waddlesplash <[email protected]>
2024-01-10 17:43:46 +00:00
Augustin Cavalier bb09458028 kernel/vfs: Convert from custom VNodePutter to the generic VnodePutter.
The latter is actually an AutoDeleter based on CObjectDeleter.
No functional change intended.
2024-01-08 15:14:09 -05:00
Augustin Cavalier 76f69a9e77 kernel/fs: More usage of FileDescriptorDeleter.
Remaining non-uses are mostly in specialized functions that e.g. operate
on many file descriptors at once (like vfs_exec_io_context.)

Reduces "goto"s. Should not have any functional change.
2024-01-08 14:57:38 -05:00
Augustin Cavalier 1bde6f6c36 kernel/fs: Standardize AutoDeleters for file_descriptor on FileDescriptorPutter.
No functional change intended.
2024-01-08 14:52:14 -05:00
Augustin Cavalier fa766875af kernel: Rename DescriptorPutter to FileDescriptorPutter.
For consistency. No functional change.
2024-01-08 14:11:30 -05:00
Augustin Cavalier 1322e37a03 docs/user: Fix typo. 2024-01-08 14:07:53 -05:00
Augustin Cavalier 12bba3817d nvme, mmc: Fix SMAP violations in B_GET_MEDIA_STATUS.
Fixes #18736.
2024-01-06 12:07:25 -05:00
Augustin Cavalier 141cc59300 TCP: Actually invoke SendQueued when the window widens.
IMMEDIATE_ACKNOWLEDGE invokes SendQueued ... but with
a send window size forced to 0, so it just generates an
ACK (or a duplicate ACK as the case may be), and doesn't
actually trigger sending of data.

So, adjust the check, introduce a new action flag, and
invoke it properly.

Fixes traffic stalls caused by waiting for the
persist timeout to occur.

This amends hrev51540 (yes, from 2017.)

Change-Id: I6344463938cfaa0134bb8cf3e224789cded0987c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7285
Reviewed-by: waddlesplash <[email protected]>
2023-12-31 03:36:27 +00:00
Augustin Cavalier d7c71d7b49 TCP: Coalesce more ACKs in DelayedAcknowledge.
First, we don't need to generate ACKs for every other
segment received, only every second full-size segment
or within 500ms, as the comment notes. So check the
receive window size before deciding to send an ACK
immediately.

Second, let the timeout routine handle sending the ACK
even in the immediate invocation case. This way, we
don't spend time in receive routines waiting for the
send path locks, and also multiple packets received in
quick succession will have one ACK generated instead of
many.

Also, following the previous commit, the timeout routine
will avoid generating duplicate ACKs now. In the case
where a duplicate ACK really needs to be generated,
DelayedAcknowledge won't be used anyway.

Inspired by ambroff's remarks and patch in
comment:14 of #18203.

Greatly reduces the number of ACKs generated,
and increases throughput due to less duplicate ACKs
causing congestion logic to kick in.

Change-Id: I37991464b1a802aceb3e2b453df8dc4cb2e14ce5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7284
Reviewed-by: Alex von Gluck IV <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-12-31 03:36:27 +00:00
Augustin Cavalier 5e7d399ef4 TCP: Check state in Persist and DelayedAcknowledge timeouts.
As the comment already notes, it's possible that we wind up
in the timeout routine despite the timer being cancelled, if
the cancellation was done after execution was in progress.

In either case, do not invoke Send if there is nothing to do,
as invoking Send...(force = true) will generate a duplicate ACK.
Duplicate ACKs will be noticed by the remote end as a sign of
congestion, so we don't want that to happen.

Change-Id: Iac30c140c322ccf0b0477e434459e7674bc24e1a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7283
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2023-12-31 03:36:27 +00:00
Augustin Cavalier 265e1e4d6a TCP: Update implementation comment at the top of the file.
A variety of things marked "not implemented" actually are,
at least partially, but the comment was not adjusted.

Change-Id: I760cca8ef3f601d27c0143f7dc75f5049d02f899
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7282
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2023-12-31 03:36:27 +00:00
Augustin Cavalier 6b7fde3300 tcp_shell: Don't include dropped packets in the dump.
Otherwise it's just confusing.

Change-Id: Ic88550c05a957b06917cfc08d1163ffe5b2e0652
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7281
Reviewed-by: Alex von Gluck IV <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-12-31 03:36:27 +00:00
Augustin Cavalier dc8bc8c1ce tcp_shell: Add send_loop command.
Useful for sending more data than fits in one buffer.
With "send_loop 100m", the traffic stalls are readily
reproduced.
2023-12-30 16:30:14 -05:00
Augustin Cavalier dbb0ad7129 tcp_shell: Fix crash on close. 2023-12-30 16:29:37 -05:00
Augustin Cavalier 87cfc3b883 tcp_shell: Support dumping packets to a pcap file.
For analysis in Wireshark (and other tools.)
It should be possible to use this mode with
a FIFO for real-time analysis, too.
2023-12-30 15:55:09 -05:00
Augustin Cavalier 295124473f tcp_shell: Fix build and revive.
It works!

I think this was last used in 2008 or thereabouts.
The various TCP refactors in the interim likely
would have profited from it...
2023-12-29 15:51:26 -05:00
Augustin Cavalier 819c51084f network: Update device statistics (mostly) in the stack.
We bypass device logic in datalink_send_routed_data() in the case
of RTF_LOCAL, so if we don't update the stats there, they'll never
get updated. Furthermore, there's places packets can be dropped
inside the device reader thread. So, we might as well consolidate
the stats-updating logic and get it out of drivers.

(The only remaining case where drivers need to update stats is when
they drop a packet in receive(), as the stack can't tell when an error
from receive() is due to a dropped packet or not.)

Fixes a potential leak on packet drops in the device reader thread,
and fixes loopback statistics for TCP/UDP/etc.
2023-12-29 12:59:24 -05:00
Augustin Cavalier 45b72f4c60 pkgman: Use natural sorting in "search" output.
Fixes #18676.
2023-12-23 23:05:08 -05:00
Augustin Cavalier 0387c6accb Network: Do not default to Wi-Fi icons in the Interfaces preflet.
At least TUN/TAP don't appear with the "wireless" icon anymore.
2023-12-23 22:36:51 -05:00
Augustin Cavalier 094f638456 kernel/vm: Perform area ownership check before protection check.
This way we do not "leak" area protection status (not really a
significant concern at the moment, but might as well while I
was looking at this.)
2023-12-23 22:31:28 -05:00
Augustin Cavalier 04f148c74a kernel/vm: Allow B_CLONEABLE_AREA flag to be added through set_area_protection. 2023-12-23 22:28:57 -05:00
Augustin Cavalier 64408be772 acpi: Fix copy/paste error in GlobalLock functions.
Should fix #18701.
2023-12-07 16:08:44 -05:00
Augustin Cavalier f7fb846f5b Tracker: Store the correct time value in the thumbnail creation attribute.
We were storing real_time_clock_usecs() but comparing against
BStatable::GetModificationTime() which is just a time_t. The
values were thus displayed wrongly in the "Get Info" window,
but also thumbnails would not have been updated when the file was.

Should fix #18691 and possibly some other tickets.
2023-11-30 17:42:08 -05:00
Augustin Cavalier b6c24e6b40 network: Overhaul TUN/TAP subsystem.
* Rename the "tun" network device to "tunnel". FreeBSD calls theirs
   "tuntap" but speaks of both TUN and TAP devices as interfaces for
   tunnels. The other BSDs seem to do likewise.

 * Fold the "tun" driver into the "tunnel" network device. The
   network device now publishes entries in devfs when interfaces
   are created, and unpublishes them when interfaces are destroyed.

   This removes the need for the driver and device to communicate
   through a file descriptor, and thus allows the receive queue
   to be totally eliminated, massively simplifying that logic.

 * Use standard net-stack FIFOs instead of TCP BufferQueue, which is
   specialized to TCP's needs in far too many ways. Thanks to the
   previous commit adding support for interrupting semaphore waits,
   we can use the FIFO wait mechanisms, too.

 * Restructure the TAP logic, and generate MAC addresses more like
   Linux does.

 * Actually set type = IFT_TUN, and use the "loopback" frame handler
   instead of the "ethernet" frame handler. This allows significant
   cleanup of the header handling logic.

 * In TUN mode, reject packets that don't look like IP packets.

 * Delete "tunconfig"; it was mostly stubs and is now unnecessary.

TUN mode tested and confirmed as working by kallisti5 with OpenVPN.
TAP mode partially tested, but not yet confirmed as working.

Fixes #18673.

Change-Id: Ibd803139474e8db556a4f567901da15ee4083621
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7143
Reviewed-by: Alex von Gluck IV <[email protected]>
2023-11-30 20:44:44 +00:00
Augustin Cavalier daf1dd9c40 kernel/sem: Use "count" as thread_unblock status in B_RELEASE_ALL.
Previously, "count" did nothing for B_RELEASE_ALL. Now, if it is
< 0, it will be the error code returned by acquire_sem() of any
waiting threads.

As B_RELEASE_ALL is a Haiku extension, this change should not
cause any compatibility problems that we cannot fix.

This will be useful in implementing some features of TUN/TAP
with network FIFOs.

Change-Id: I2dbccedefac2024fe740b87543ff3b80f5257e20
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7163
Reviewed-by: waddlesplash <[email protected]>
2023-11-30 20:44:44 +00:00
Augustin Cavalier 255314f734 libroot: Make stpncpy compatible with GCC2. 2023-11-28 21:47:39 -05:00
Augustin Cavalier 611d3d7803 BSocket: Fix swapped parameters in Bind().
Spotted by X512.
2023-11-28 20:41:02 -05:00
Augustin Cavalier 15a3f4c540 libroot: Add stpncpy.
Imported from musl.

It is in POSIX.1-2017.
2023-11-28 20:37:15 -05:00
Augustin Cavalier 783aa308c3 network/stack: Clean up socket_receive.
* Reshuffle variable declarations, most are placed much
   closer to first usages now.

 * Turn a confusingly worded comment into an ASSERT(),
   and remove another one that was outdated.

 * Fix some minor code style problems.

 * Make the copying logic more consistent between first
   and then subsequent copies.

 * Make it possible for B_BAD_ADDRESS (EFAULT) to be
   returned. This is not listed in POSIX, but as per
   online sources, at least Linux does do this.

Change-Id: Idcfbed30531c1ab4796c4ee37f7f4ce8078e535b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7147
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-11-27 17:10:19 +00:00
Augustin Cavalier 2926dfaa3f network/stack: Fix handling of MSG_TRUNC in socket_receive.
This is a Linux extension (which at least FreeBSD has also
adopted.) It's used in the Haiku port of libpcap (where it's
a necessity) and wpa_supplicant (where it wasn't, and I
removed it.) It seems that we've had it for quite some time.

Fixes tcpdump following addition of flag checks.
2023-11-24 23:07:18 -05:00
Augustin Cavalier ceeea27b72 freebsd_wlan: Fix compilation of ieee80211_ioctl.h under GCC2 in C mode.
GCC2 tolerates [] FLAs in C++ mode but not in C mode, as discovered
when trying to build wpa_supplicant against R1/beta4. A workaround
was added there for now, but this is the more general solution.
2023-11-24 12:57:07 -05:00
Augustin Cavalier 459fa41f17 network/stack: Get rid of socket_readv and socket_writev.
These have not been used in years (maybe since the redesign of the
network stack?). Only socket_writev had an implementation, which was
mostly just an incomplete version of socket_send.

Scatter/gather I/O is already supported via msghdr's msg_iov/len fields,
so this is redundant anyway.

Change-Id: If41c4f4ee021856f6db49c7cb95422a9c1aa7700
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7127
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2023-11-24 16:28:38 +00:00
Augustin Cavalier 5188904bfa loopback: Actually update device statistics.
ifconfig shows numbers other than 0 for the loopback interface now.
2023-11-23 15:03:21 -05:00
Augustin Cavalier 75874bab1a ethernet: Device statistics must be updated using atomic operations.
Both send and receive can be called concurrently, and there aren't
any locks protecting these fields, so they must be updated with atomics.
2023-11-23 15:02:45 -05:00
Augustin Cavalier 6461885e2e TUN: Remove redundant comments.
They only described things that the function names and parameters
already indicated. As per the Coding Guidelines, such excessive
commenting is to be removed.

Also fix some other (minor) code style issues while at it.
2023-11-23 14:27:40 -05:00
Augustin Cavalier c1f1032016 network/stack: Enumerate TUN after loopback. 2023-11-23 14:24:35 -05:00
Augustin Cavalier a1d837369f lgtm.yml: Delete.
"LGTM" code scanning was bought out and merged into GitHub Actions.
The code scanning setup there has a different mechanism for configuration,
and so this file is not useful anymore.
2023-11-23 13:46:19 -05:00
Augustin Cavalier e1480b40af ext2: Adjust short and pretty names to just be "ext" and not "ext2".
The filesystem name returned by read_fs_info will be correct (i.e.
returning "ext3" or "ext4" as appropriate), but some things just list
the filesystem driver's name, which can cause confusion.

Change-Id: Ic4acf497fc5db5c167131aeb323b45eeb78594d6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7126
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2023-11-23 18:20:04 +00:00
Augustin Cavalier 973f6d3320 network: Migrate SIGPIPE generation into the socket module.
This removes the burden of determining whether to and then
actually sending SIGPIPE from the protocol modules, meaning
the MSG_NOSIGNAL flag can now be implemented entirely in
the socket module and not even passed further down the chain.

Change-Id: I9ba976c4aff60d533cb4b390bbba1560c0de423f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7124
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-11-23 06:51:39 +00:00
Augustin Cavalier da2f2c65b7 network/stack: Mask off MSG_NOSIGNAL at the top of socket_receive.
Fixes WebKitGTK spinning endlessly and spawning lots of
short-lived worker processes following the addition of
flag checks and EOPNOTSUPP to the various socket modules.

Change-Id: I6d944b4d0235eea9e8a9333645fcb531805f340f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7123
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-11-23 06:23:12 +00:00
Augustin Cavalier e7371da8b5 network/stack: Add back a #pragma mark. 2023-11-22 12:04:38 -05:00
Augustin Cavalier 407d3f1046 network/stack: De-templatize base_fifo methods.
Following the removal of the "Fifo" class, they
do not need to be templated anymore.
2023-11-22 12:00:02 -05:00
Augustin Cavalier 0b829b1151 network/stack: Remove unused "Fifo" class.
Its declarations were moved from another header to this file
in 2008, with a comment in the commit message and a TODO here
questioning whether it was needed for anything. In the 15 years
since then, nothing has used it.
2023-11-22 11:47:52 -05:00
Augustin Cavalier 4100480724 network/stack: Return EOPNOTSUPP when unhandled flags are specified.
This method is invoked directly in some protocols, e.g. L2cap (Bluetooth.)
2023-11-22 11:41:18 -05:00
Augustin Cavalier 73eb03214e net/ProtocolUtilities: Return EOPNOTSUPP when unhandled flags are specified.
Same as has already been done for UNIX domain sockets and TCP
(this is used in the implementation of UDP.)
2023-11-22 11:40:02 -05:00
Augustin Cavalier 42e4cb759a net/ProtocolUtilities: Correct implementation of MSG_DONTWAIT.
We don't want to restore the timeout from a restarted syscall
if MSG_DONTWAIT has been specified.
2023-11-22 11:39:29 -05:00
Augustin Cavalier fca1b0ec50 protocols/tcp: Return EOPNOTSUPP when unhandled flags are specified.
Same as was done for UNIX domain sockets in 74a44f5aed.
2023-11-21 23:36:07 -05:00
Augustin Cavalier 93a6528df8 protocols/tcp: Correct implementation of MSG_DONTWAIT.
Waiting for state changes correctly checked MSG_DONTWAIT,
but the overall data timeout only did in ReadData, not
SendData. This corrects that and makes the implementation
more consistent overall.
2023-11-21 23:34:59 -05:00
Augustin Cavalier f860cfc76c protocols/tcp: Correct implementation of MSG_NOSIGNAL.
The other send_signal invocation correctly checked NOSIGNAL already.
2023-11-21 23:34:33 -05:00
Augustin Cavalier 3bae07fc29 protocols/unix: Implement MSG_NOSIGNAL.
Same logic as in the TCP protocol module.

This fixes a regression from hrev57383: curl now works
again. (Perhaps it shouldn't be called a "regression",
though, but instead an uncovered bug / missing feature.)

Fixes #18666.
2023-11-16 12:08:47 -05:00
Augustin Cavalier 74a44f5aed protocols/unix: Return EOPNOTSUPP when unhandled flags are specified.
Fixes the "bug" part of #18653 (however the flags still need to
actually be implemented.)

Change-Id: Icd296af8b409416317ba3d02735504729949fd08
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7109
Reviewed-by: Niels Sascha Reedijk <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-11-15 16:33:38 +00:00
Augustin Cavalier eb4d2229f0 Debugger: Select "local" interface if none specified in MSG_DEBUG_THIS_TEAM.
The debug_server sends MSG_DEBUG_THIS_TEAM but of course it doesn't
have a way to specify the internal interface pointer. We should thus
assume the local one is implied.

Fixes #18645, which is not a regression but has been the case since
the initial host-interface refactors years ago, apparently.

Change-Id: I48078232f154f2f8f7cdf28792d39ae58471ce19
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7074
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-10-30 23:57:14 +00:00
Augustin Cavalier e8d328979c ICUTimeConversion: Fix buffer overflows and add more error handling.
* Declare databridge buffer lengths in LocaleBackend.
 * Use strcpy instead of strlcpy when writing to databridge buffers
   (this is the first fix for #18598.)
 * Check for overflows and error out when they happen.
 * Verify that ICU actually knows the timezone in question
   and fall back to GMT if it does not (this would also fix that crash.)

Fixes #18598.
2023-10-28 16:36:12 -04:00
Augustin Cavalier c199c568de DebugAnalyzer: Fix -Werror=mismatched-new-delete. 2023-10-28 14:20:31 -04:00
Augustin Cavalier bb2808d615 bootloader: Implement TSC calibration via hypervisor CPUID leaf.
While debugging some problems on the HaikuPorts build VMs, mmlr
noticed their clocks had an alarming amount of drift. This prompted
an investigation into TSC calibration mechanisms, and the discovery
that there is a VM-specific one which we did not implement.

This mechanism is more accurate than counting cycles on VMs where
cycles can be "stolen" (the probable cause of the aforementioned
clock drift.)

Tested in VMware (works out of the box) and on QEMU/KVM
(may need TSC frequency specified or a host with invariant TSC.)

Change-Id: I4ccfdb2e4e2621404ec9026e7106c02bf96faf18
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7063
Reviewed-by: waddlesplash <[email protected]>
2023-10-25 00:53:55 +00:00
Augustin Cavalier b8fbb723ea fs_shell: Use UINTPTR_MAX not LONG_MAX.
Fixes the build after the previous commit.
2023-10-24 19:16:19 -04:00
Augustin Cavalier 5c040b731c People: Fix buffer overflow in string handling.
Also move some variable declarations closer to their usages.

Fixes #18618.
2023-10-23 22:15:27 -04:00
Augustin Cavalier de9f473cda Terminal: Colors are stored using untranslated names.
The previous code did not work on non-English locales,
a problem readily detectable when running in Terminal
inside a Terminal session, e.g.:

PrefHandler::getRGB(Hintergrund) - key not found

Fixes #18614.
2023-10-23 21:29:12 -04:00
Augustin Cavalier 8764a29843 build/jam: Only add C++ header directories to include path for C++ code.
There are now some system headers (e.g. <stdatomic.h>) that have outright
different versions for C and C++ which are not compatible with each other.

Change-Id: Ibf797e0817f0fe4d5241424d7d06023b19888c02
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6991
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-10-13 16:18:47 +00:00
Augustin Cavalier 5c32c5ef2f condition_variable: Reorder members for optimal sizing.
Class size now 48 instead of 56 bytes (on x86_64.) No functional change.
2023-10-09 21:08:53 -04:00
Augustin Cavalier 788b1b12b6 Get rid of kernel_c++_structs mechanism.
This undoes fc7864091e.

It was only ever used by the FreeBSD compatibility layer,
only supported one structure, and created problems with
concurrent builds.
2023-10-09 20:26:21 -04:00
Augustin Cavalier 7a701128f1 drivers/network: Remove now-unneeded manual dependency declarations. 2023-10-09 20:21:23 -04:00
Augustin Cavalier 869de36dcd freebsd_network: Remove the need for <kernel_c++_structs.h>.
Use sizeof()+roundup() to build a char[] of the correct size,
and add a static_assert to ensure it stays so.

The <kernel_c++_structs.h> header needs to have its dependency
manually declared, and not all consumers of this file properly
declared it as such. This then fixes a concurrent build problem.

Fixes #17965 as this was the only consumer of this header.
2023-10-09 20:21:06 -04:00
Augustin Cavalier d8bca3564a Tracker: Check whether the default button is disabled on double-click.
The comment above this block specified the correct behavior: the
button's status is already updated elsewhere, so just check IsEnabled().
But the code did not actually do that.

It appears this has been incorrect all the way back to the initial
OpenTracker import in 2001.

Fixes #13721.
2023-09-23 17:05:19 -04:00
Augustin Cavalier 2d42fb1a9a Tracker: Adjust open button status when B_DIRECTORY_NODE is set.
In hrev51155, it was changed to be always enabled no matter what,
so that the current directory (without anything selected) could be opened.
But this means it would also be enabled for files, which is misleading.

Instead, remove the function, and adjust the logic detecting whether
to enable the button or not to take B_DIRECTORY_NODE into account.
2023-09-23 17:05:06 -04:00
Augustin Cavalier d95a9b63f7 iaxwifi200: Synchronize to OpenBSD trunk.
CVS revision(s) are in first-line comments.

Requires a new firmware package (from HaikuPorts). There are some
changes in here which may fix some of the odder issues, like failures
to connect to access points. There is also support for one new PCI ID.

Tested by PulkoMandy who reports it's still working.
2023-09-23 15:10:10 -04:00
Augustin Cavalier 76681bd900 kernel: Rewrite B_DEBUG_SPINLOCK_CONTENTION.
* Replace count_low/count_high with bigtime_t fields plus an int32.
   sizeof(spinlock) is now 32 bytes with the debug option enabled.

 * Adjust and clean up all spinlock code to use the new fields.

 * Fold DEBUG_SPINLOCK_LATENCIES into the new code. Remove the bootloader
   option and other flags for it (these were not compiled in by default.)

The new code should be much easier to understand and also more powerful.
However, the information transmitted to userland isn't as useful now;
the KDL command output will have the interesting information.

(Things could be reworked to transmit more interesting information to
userland again if desired, but as this code clearly hadn't been compiled
for many years, as it referred to global spinlocks that have been gone
for a very long time.)

Change-Id: I2cb34078bfdc7604f288a297b6cd1aa7ff9cc512
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6943
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-09-23 18:41:04 +00:00
Augustin Cavalier ef9e2f627b kernel/arch: Make arch_debug_get_caller() a macro implemented by a builtin.
Only the x86 and PPC implementations look like they would have worked,
while the builtin is available and will work across all architectures.
We already use it unconditionally in some parts of libroot.

Change-Id: I2dffb3b2c7cdd605092382b9d649151adb921bb4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6942
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-09-23 18:41:04 +00:00
Augustin Cavalier d0c34f9331 kernel/debug: Invoke cpu_pause in trap_cpu_in_kdl.
This is the loop that runs on all CPUs besides the one
actually running the kernel debugger. It's functionally
a spin-loop around a few different variables, and so it
should be safe to use cpu_pause() here, just as real
spinlocks do.

(cpu_pause() just runs a "pause" or equivalent instruction,
it doesn't use the CPU-idle modules, which indeed may be
unsafe to use in KDL.)

A glance at FreeBSD seems to indicate they also do this
when their kernel debugger is active.

Seriously improves power consumption while KDL is active:
even running in a VM with only a few cores, there would be
obvious fan spin-up when entering KDL. After this change,
there's barely any at all (while overall CPU usage % remains
basically identical.)
2023-09-23 14:07:17 -04:00
Augustin Cavalier f0a016dcb1 BBufferedDataIO: Fix Write().
I looked at this code as a reference when writing similar code in another
project, and realized then that this was broken to the point where I
don't think anyone could have actually used it:

1. Writes larger than the buffer should only return the amount written
by this Write() call, not the amount flushed beforehand.

2. fDirty was only set if there were bytes remaining after the first
write to the buffer. So, if you wrote small amounts of data, they
would be silently discarded most of the time!

3. When filling the buffer, we might as well flush simultaneously.
This allows the logic to be consolidated into a loop and remove the
duplicate memcpy. In case of failure, just return the bytes-written
as the write could be retried later.

4. Flush() should always return an error or 0, not bytes written.

While at it, add some basic tests for this class.

Change-Id: I2de01d0b31e3fe22863cef21dd7b0b62ed47121b
2023-09-22 19:56:04 -04:00
Augustin Cavalier 35bc8b401a ArchitectureRules: Disable autovectorization for the kernel (for now.)
See #18593.
2023-09-22 16:27:37 -04:00
Augustin Cavalier 55b2baf2f6 kernel: Use correct type for semaphore numbers.
It must be unsigned short, otherwise in some places we would use
negative offsets and wind up out-of-bounds.

Fixes #18586.
2023-09-21 22:28:55 -04:00
Augustin Cavalier 959d9cd069 kernel: Cleanups to the XSI message queue & semaphore implementations.
* Remove unused/unneeded parameters to Dequeue.
 * Make use of StackOrHeapArray.
 * Reorder syscall-entry checks for efficiency.
 * Inline the unlock-block method and unset variables in the process.
 * Reorder code for clarity and to reduce indentation.
2023-09-21 22:20:31 -04:00
Augustin Cavalier f759ab2733 headers/compatibility/bsd: Update headers to remove BSD advertising clause.
Rewrite link.h entirely.
2023-09-21 18:38:10 -04:00
Augustin Cavalier 2e0e70b5bb libroot: Delete some old private math headers.
These haven't been needed or used in a long time.
2023-09-21 18:31:22 -04:00
Augustin Cavalier d6b37ce996 packagefs: Fix missing unlocks in Volume package content node removal.
When breaking out of _RemovePackageContentRootNode() by encountering
a specified "endPackageNode", we need to unlock all directories.

This case is only possible to encounter when _AddPackageContentRootNode()
fails partway and invokes _Remove() to remove the just-added nodes.

Fixes a hang/deadlock encountered by Diver while testing some (disabled)
HaikuPorts recipes.
2023-09-21 14:53:06 -04:00
Augustin Cavalier 2903a69d4a network/ipv4: Fix NULL dereference in multicast-send.
Fixes the KDL in #18585.
While at it, add a missing NULL check and fix a leak.
2023-09-20 16:39:28 -04:00
Augustin Cavalier 75e1de3c23 libnetwork: Synchronize netresolv with NetBSD 9.3.
Some of the Haiku-specific modifications that were previously unmarked
are now clearly marked with #ifdef __HAIKU__.

BIND9-specific files containing private APIs never exposed in public
headers have been removed.

Tested with wget, curl, pkgman (Network Kit), WebPositive (WebKit/curl),
and Falkon (QtWebEngine/Chromium). All DNS-related operations seem
to still work just fine.

(One patch also imported from NetBSD trunk for GCC 12+ compatibility.)

Change-Id: I4a349577b24b4df008fd9cba5d3a322cd24397f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6879
Reviewed-by: waddlesplash <[email protected]>
2023-08-31 23:38:47 +00:00
Augustin Cavalier ac30bc0ef6 libnetwork: Remove lcl_sv.cpp.
This has not been included in the build for years, probably since the
initial NetResolv merge. Services are now returned via the "protocols"
file, and getservent() has no need for these utility functions.

Change-Id: If18bdd9593463b38a9aaedb7a621d0ddc15530e4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6878
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-08-31 23:38:47 +00:00
Augustin Cavalier 4dcc1ed654 kernel: Synchronize inet_addr.c to remove advertising clause.
Change-Id: I03665bcad679e3fddaea0d8a95663be12b003bd8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6877
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-08-31 23:38:47 +00:00
Augustin Cavalier 56241aab2f Zip-O-Matic: Fix and enable _SelectInTracker().
Based on a code example from humdinger.
2023-08-31 15:25:06 -04:00
Augustin Cavalier 711b36b44c Tracker: Merge SelectPosesListMode and SelectPosesIconMode.
There was a TODO comment about this, which dated all the way back
to the original OpenTracker import over 20 years ago.

There's still more cleanup needed, so I left another TODO.
2023-08-31 15:13:06 -04:00
Augustin Cavalier 46a6070b57 libroot: Replace strcspn and strchrnul with musl versions.
Removes the last BSD advertising clause from the "string" directory.
2023-08-31 15:10:19 -04:00
Augustin Cavalier bc328a435b libroot: Import a lot of changes to stdlib, string code from FreeBSD.
Includes licensing clause removal. Also deleted 2 files that are
not used in the build and are not referenced anywhere else.
2023-08-31 15:10:19 -04:00
Augustin Cavalier a573f9e4be libroot: Fix build of new time files under GCC2. 2023-08-30 22:46:36 -04:00
Augustin Cavalier a8e2f08853 libroot: Replace the old localtime fallback backend with musl code.
This allows for the deletion of quite a lot of ugly C89 code.
2023-08-30 22:32:58 -04:00