Commit Graph

63257 Commits

Author SHA1 Message Date
Augustin Cavalier
3e0eea85ec XHCI: Add support for fragmented transfers.
I was not actually aware that our USB stack already supported
breaking (bulk) transfers up into smaller units as necessary;
these APIs are not very well documented.

This makes #15569 occur far less often, though it is still
more than possible to trigger.
2021-09-20 12:25:09 -04:00
Augustin Cavalier
bc7fd43358 USB: Rename Transfer::VectorLength to Transfer::FragmentLength.
It did not return the length of the vectors, but only the current
fragment's worth of vectors. It also modified the fFragmented flag,
which really should have been set in SetVectors in the first place.

As everything seemed to call IsFragmented after VectorLength,
this is not a behavioral change.
2021-09-20 11:52:54 -04:00
Coldfirex
120e8f6ace Listusb: Fix Wformat-security
Change-Id: Ibd750392467ae097b8728346bd0e9ce33a461a06
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4481
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-09-20 13:38:53 +00:00
Coldfirex
01d5efe3d9 Malloc_debug: Fix Wformat-security
Change-Id: I2f891fff74a003aac7774ee91f2c28d5e65a18f7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4486
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-09-20 13:38:53 +00:00
Coldfirex
5d9604a222 ifconfig: Fix Wformat-security
Change-Id: Ie4cf563f1ac333824932e1154e44d23e5ea046e3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4482
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-09-20 13:38:53 +00:00
Augustin Cavalier
c8eaa6f988 packagefs: Use WeakReference in PackageNode.
This allows us to stop storing the package flags, which saves 4
bytes per package node (a value that really adds up when there
are thousands upon thousands of PackageNodes), at the cost of an extra
sizeof(int32) allocation for the WeakPointer object per-package (of
which there are are much fewer, of course.)

This also is safer overall, as now consumers of GetPackage() or VFSInit()
will now hit a NULL dereference if they have failed to check if the
package still exists, instead of a use-after-free.

Change-Id: Iea97ffcd491c6e2da7093730a7fa951b84dcefdf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4478
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
2021-09-20 11:08:13 +00:00
Augustin Cavalier
522c74f3e7 libroot: Use strnlen in strndup.
This is both more correct, as we need to not read past the 'size'
position of the passed pointer, and much faster, in the case where
the passed pointer is into some very large block of memory.

This provides an unbelievable speedup to a microbenchmark posted on IRC
that makes heavy use of this function in tandem with some rather
large allocations. (Some variants of it go from multiple minutes
to under a second!)
2021-09-18 18:20:44 -04:00
Autocomitter
ed246fcd6e Update translations from Pootle 2021-09-18 08:45:44 +00:00
Rudolf Cornelissen
96c8657d24 intel_extreme: fix haswell virt display scroll/pan, ticket #17261 2021-09-17 23:46:00 +00:00
Coldfirex
4411ed75b4 Kernelland_emu: Fix Wformat-security
Change-Id: I3b031335844ab4512b8eebc8ead216af9c5fc4ee
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4476
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-09-17 21:24:13 +00:00
Coldfirex
b1ce138fe8 PXE_ia32 Network: Fix Wformat-security
Change-Id: I926cdafa422f7544ff7a0fdcc9c5561759066a3e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4475
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-09-17 21:24:13 +00:00
Coldfirex
81329d5c90 ATATracing: Fix wformat-security
Change-Id: I36e71a4705b811e45935bf3faa11b15617b04cc0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4474
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-09-17 21:24:13 +00:00
Coldfirex
a33cf10dcf USB Vision and FreeBSDCompat: Fix Wformat-security
Change-Id: Idd7fd80546b414c9db21bc0979412bcd4bf7878d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4460
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-09-17 21:24:13 +00:00
Coldfirex
59642dc3e8 ACPICAHaiku.cpp: Fix wformat-security
Change-Id: I6d06e68e60ced2ca311c3fc505f9f9f51ee05563
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4473
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-09-17 21:24:13 +00:00
Augustin Cavalier
5ea9360258 package_infos/haiku: OpenSSL is enabled for minimum images and not just regular ones.
It has been since 2019. It seems to be added to images anyway,
probably because something else depends on it, but for correctness,
it belongs outside the REGULAR section.
2021-09-17 16:27:59 -04:00
Augustin Cavalier
744f487bc5 headers/libs: Remove expat headers.
We now have an expat build feature that uses packaged headers instead.
2021-09-17 16:26:06 -04:00
Augustin Cavalier
a812e3cab1 kernel/debug: Only create an area for the debug syslog if reusing one.
If the debug_output pointer is just a kernel_args_malloc'd structure,
then it is already mapped and we should not be re-mapping it; we only
need to do that if we are using a fixed-map ring.
2021-09-17 16:06:13 -04:00
Augustin Cavalier
4d1c59078b EFI: Hand off bootloader log to the kernel.
Eventually, EFI should get support for the debug log ring_buffer
like bios_ia32 has for transparent handoffs, but this preserves
everything except for the pre-start MMU dump, which is an improvement.

Fixes #15455.
2021-09-17 16:04:20 -04:00
Augustin Cavalier
80519e78aa bootloader: Clarify comment in text_console.h.
The following colors are "foreground colors only" not "foreground colors,
only if".
2021-09-17 15:36:57 -04:00
Augustin Cavalier
5e2d0005c1 libroot: Fix previous commit. 2021-09-17 15:35:51 -04:00
Augustin Cavalier
ffbe2ad946 libroot: Reinstate tdestroy.
It was removed in hrev55422 as we never had declared it in any headers.
But it seems some software came to depend on it anyway. Reinstate it,
and add a declaration for it, behind _GNU_SOURCE.
2021-09-17 15:34:10 -04:00
Augustin Cavalier
aa04f48dcf Remove some unused headers. 2021-09-17 15:29:00 -04:00
Augustin Cavalier
5ee918678e USB: Track object busy-ness and wait for an unbusy state before teardown.
This reverts and replaces hrev53141, hrev53200~1, and hrev53888.

Two years ago (in hrev53141), I added checks to validate that Devices
were not in the process of being torn down before using them, to fix
a race condition KDL. Further logic was added in hrev53200~1 and in
hrev53888 for Pipes.

Well, upon closer inspection following the reports of #16794 et al.,
it appears upon closer inspection there were still two more race
conditions lurking in there: the first between Get and InitCheck, and
the second between InitCheck and use.

To resolve both of these, a new atomic "busy" flag is added to objects,
which is incremented before unlocking the objects array, and then
waited on before actually proceeding with teardown.

The older checks about initialization status are now superfluous
and are removed in favor of an earlier PutUSBID() invocation in Device.

While #16794 was fixed by hrev55429, some of those or related KDLs
might have been caused by these races. This also re-resolves #15115,
along with #14949 and #15710.

Change-Id: Ifcae84945a81123af5ef4683a6e33dc1eec5b23c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4421
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-09-17 18:25:00 +00:00
Augustin Cavalier
b3683d8aee XHCI: Get rid of the PortSlots array and use ControllerCookie in FreeDevice.
This array was introduced by korli in hrev44089~1 (2012). It "mapped"
ports to slots using a device's HubPort, and then used this value in
FreeDevice() to locate the xhci_device struct in question.

Well, when there are non-root hubs in use, the HubPort values can
of course collide, leading us to tear down the wrong device in many
circumstances. This appears to have been the true cause of #16794,
and probably also #16878 and #17266, and maybe even some others.
2021-09-17 13:33:02 -04:00
Augustin Cavalier
31caaec069 kernel: Print <DROP> at the beginning and not the end of dropped regions.
This way there is a better indication of where the drop occurred.
2021-09-16 15:05:48 -04:00
Augustin Cavalier
7cde125283 kernel: Write parts of truncated messages to the log.
In case any one message (or, more likely, importing the bootloader's
syslog buffer) is too large for our buffer, do not discard it, but
keep as much as we can, and print <TRUNC> at the beginning of it,
to distinguish from <DROP>. (Documentation already notes <TRUNC> as
a possible thing to find in the syslog.)
2021-09-16 15:04:54 -04:00
Augustin Cavalier
7fd1fb8745 kernel: Correct bootloader syslog buffer handoff logic.
If keep_debug_output_buffer is true, then we reused the syslog buffer
the bootloader allocated (and which has just been re-mapped above),
so we do not need to write the buffer in again (and moreover doing so
is incorrect, as it contains a raw ring_buffer header, and will be
larger than the buffer.)

This fixes "<DROP>" appearing at the beginning of all syslogs (or at least,
ones that began with handoffs from the bootloader) spuriously when
the whole buffer was really present anyway.
2021-09-16 15:02:05 -04:00
Augustin Cavalier
ad56cbbb6e USB: Add asserts under KDEBUG that IDs being put have no remaining children.
Change-Id: I100828d2724d65ab0841e1262c7db7e144b56aab
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4441
2021-09-16 13:17:34 -04:00
Augustin Cavalier
838251124c USB: Rework Device deinitialization and destruction.
* Destroy interfaces and endpoints before deleting the default pipe,
   as all of these may actually use the default pipe at any time
   while they are alive.

 * Remove the default pipe and then ourselves from the stack before
   deleting the default pipe, as it also may be used at any time.

May help with some of the open tickets about USB stack KDLs.
2021-09-16 13:17:34 -04:00
Franck LeCodeur
1fb138bf94 ext2: Fix build warnings, enable Werror
This fix is for ticket #9460 to enable -Werror for ext2.

- Unused functions are removed.

- The ASSERT macro was redefining a different ASSERT macro from the included files. Now it gets undefined first.

- One comparison side was cast to ptrdiff_t because X86_gcc2 complained about signed/unsigned comparison

Change-Id: Ib0caade2f83de34c04acc0fc6aa5ed50712daec4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4453
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2021-09-16 06:52:00 +00:00
Augustin Cavalier
4d21f567e7 XHCI: Fix up 3a71862e99.
Now the logic is actually identical.
2021-09-15 19:20:25 -04:00
Augustin Cavalier
1da090bc56 XHCI: Add assert that the context is really page-aligned if needed.
_OffsetContextAddr assumes it will be in order to do some rather
annoying pointer arithmetic, but that was never actually asserted.
2021-09-15 19:02:50 -04:00
Augustin Cavalier
2296578c93 XHCI: Put speeds in order.
No functional change.
2021-09-15 19:01:57 -04:00
Augustin Cavalier
decd5b8ff5 USB: Clarify that BusManagers do not really have usb_ids.
Instead their IDs are indexes into the stack, and are used primarily
for TRACE*() printing, so move the getter function into a "protected"
block and rename the variable appropriately.
2021-09-15 19:01:39 -04:00
Augustin Cavalier
3a71862e99 XHCI: Rework port route computation code.
The new code should be functionally identical to the old,
but it uses fewer variables and should be significantly easier
to understand than the old.
2021-09-15 19:00:38 -04:00
Augustin Cavalier
f20f55692d XHCI: The root hub address is always 1.
AllocateAddress() is the pre-USB3 way of doing things;
as we never use it anywhere else and it is specific to
each BusManager, we always just got 1, which is what
the root hub will always be anyway.

Additionally, clarify the logic in _InsertEndpointForPipe
that is special-casing the root hub.

No functional change intended.
2021-09-15 18:58:46 -04:00
Augustin Cavalier
05709fe3f7 headers: Fix B_CURRENT_IMAGE_SYMBOL for GCC2.
Apparently GCC2 does not like &__func__, so just drop the &.
Fixes #17253.
2021-09-15 11:38:20 -04:00
Augustin Cavalier
abe937985d libroot: Replace glibc search implementation with musl's.
glibc's hsearch and tree functions are old and rather slow.
While these APIs do not appear to be used very often, these
changes can make a big difference: in one benchmark I was sent,
this change is nearly a 10x speedup or more in some cases.
2021-09-15 10:52:02 -04:00
Augustin Cavalier
64e742def3 media: Declare wildcard fields const.
This is a source compatibility break from BeOS, but should not
be an ABI one (I checked, the symbols are identical.)

Also use "= {}" in the definitions of the fields. We use this
in plenty of places in the kernel, so it should be OK for GCC2.

Change-Id: Ibe05b2236d46024d7b4563ae16e1cc7140fed965
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4434
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-09-14 20:43:29 +00:00
Jérôme Duval
40793c1ef6 RAWTranslator: switch to libraw as backend when available
tested with .cr2 and .dng single pictures.

Change-Id: I9a4802300fd2afe14c085ca18faa8a1e20c52bfd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4452
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-09-14 08:06:41 +00:00
Rudolf Cornelissen
f2a79670ae intel_extreme: Fixed virtualscreen setup, ticket #17261 2021-09-14 02:04:02 +00:00
Coldfirex
9a76b18fb6 Libnetapi: Fix wformat-security
Change-Id: I0898cd18e7721eee26ccbe557c385f4e61c3025f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4448
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-09-13 19:39:11 +00:00
Lt-Henry
a731585f88 HID: Fix usage page following hrev55413.
Modifications made on hrev55413 removed UsageID from array Items,
but also (bug here) broke UsagePage, needed by KeyboardHandler
in order to recognize items as Keyboard ones.

Fixes #17263.

Change-Id: I4b73c69240f31d3c8c2aacf6bab0d270f2053387
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4458
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2021-09-13 18:13:32 +00:00
Panagiotis Vasilopoulos
c1740f4f53 Drivers: Fix -Wformat-security
Follow-up for Alan Shearer's change. Useful when the buffer contains the
character "%".

Change-Id: Ia6771a2d71306ca97e7c03f0e986ad3cfe100684
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4459
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2021-09-13 09:24:14 +00:00
Jérôme Duval
cc6736afae StreamBuffer: fix Position() for read streams
the file position corresponds to the end of the buffer.

Change-Id: Ib67dcfe1f43d959777c2f6dbf84181f25a022a7c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4447
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2021-09-13 05:53:22 +00:00
Coldfirex
5b2fc19fa0 PC_Serial and USB_Serial: Fix -Wformat-security
Change-Id: Ia150eaf0e639c03b3d1f267d9ee582ff82bf0d21
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4442
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2021-09-11 16:59:47 +00:00
Lt-Henry
366e9a62e9 hid: Fixed report parsing bug. Support for keyboards using bitmap reports
* I've added support to multiple min-max ranges to array reports too.
* All possible usages are stored in an array (Vector<uint32>). Perhaps, this can be squashed into an array of ranges.
* Usage array is stored in HIDReport class, so there is only one copy of it.
* HIDReportItem no longer has UsageMinimum()/UsageMaximum() as this no longer works. Instead, a Usage() member has been introduces.
* HIDReportItems of type variable, have a Usage ID assigned to them. HIDReportItems of type array have a zero usage ID as it has no sense.
* Having a variable typed HIDReportItem to store a range of usages ID doesn't seem a good idea to me because Data() method would have to return the values of all usages... or perhaps ask for a specific usage value with something like Data(0x03). This will require changes in hid stack and overcomplicate things.
* A bitmap keyboard is a worst-case scenario: Near a hundred of usages (uint32) are stored and the same quantity of HIDReportItems are created (this is already happening on Haiku). It doesn't seem a resource drama to me.
* Keyboard Handler has room for improvement, but I would like to left that for another patch series.

Change-Id: I556fa0aebfda831ef5334be5ae3a37f099ffa35d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4403
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-09-11 11:12:38 +00:00
Jessica Hamilton
8f362bfdfc haiku_devel: use relative symlinks to libraries in haiku package.
* This helps with creating a sysroot, otherwise extracted package
  links refer to /system, which is outside of the sysroot.
* Should have no functional impact on Haiku, as these are already
  symlinks

Change-Id: I29f719dc2c0839dd090e7f33eea0b8f98e0d6355
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4218
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-09-11 11:12:10 +00:00
Autocomitter
b40866e65f Update translations from Pootle 2021-09-11 08:50:45 +00:00
Augustin Cavalier
60fee365f5 kernel/vm: Allow locking kernel space if allocating page_protections for userspace.
Some applications may request per-page protections for an especially
large area (e.g. multiple GB), which leads to allocating a rather
large page protections area (e.g. 512KB), which we cannot allocate
without locking the kernel space to get new slabs.

We only need to avoid locking the kernel space if the area in question
is in the kernel space, as in that case, kernel space will already be
read-locked by the current thread.

Fixes #16898.

Change-Id: If52413a594da66edfc2821811d959085a2c3c78e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4436
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-09-10 18:49:33 +00:00