Commit Graph

6744 Commits

Author SHA1 Message Date
Augustin Cavalier
aa6411e23e libnetwork: Move from src/kits to src/system.
Properly speaking, this is part of POSIX and not of the Be-style
"kits", and so it should live in system/ alongside libroot.
No functional change intended.

Change-Id: I0fcf78a09c76e220ad4f1719d147978ef4a3bc52
Reviewed-on: https://review.haiku-os.org/726
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-11-25 17:49:00 +00:00
Augustin Cavalier
ef593f61a2 ELF: Ignore PT_EH_FRAME and PT_STACK.
This allows Clang builds (linked with our cross binutils) to
at least start runtime_loader and then try to load launch_daemon.
That fails with an infinite loop somewhere...
2018-11-24 21:08:31 -05:00
Augustin Cavalier
aa0836519a kernel: thread->name is never NULL as it is an array.
Spotted by Clang (-Wtautological-pointer-compare.)
2018-11-24 21:07:18 -05:00
Augustin Cavalier
a87c7773e8 EFI: Make the loader build under Clang.
Clang doesn't support -maccumulate-outgoing-args, -nostartfiles
is not needed in LDFLAGS (and lld doesn't know about it anyway),
and Clang uses .dynstr so we need to copy it also.
2018-11-21 22:02:06 -05:00
Jérôme Duval
8c053e955e vfs: fail write_stat() on file descriptors opened read-only.
Change-Id: I20d586c606c47df6625cc9272f153250a5a621d6
Reviewed-on: https://review.haiku-os.org/706
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-11-18 00:04:26 +00:00
Augustin Cavalier
9cc0f06a01 kernel: Remove the B_KERNEL_AREA protection flag.
It is now no longer used.
2018-11-17 16:46:49 -05:00
Augustin Cavalier
04f1a9beae vm: B_EXECUTE_AREA should not imply B_KERNEL_EXECUTE_AREA.
Trying to execute user-mapped areas in kernel space should trigger
a fault with SMEP enabled anyway (and we have not seen any thus far.)
2018-11-17 15:24:59 -05:00
Augustin Cavalier
d12a2ff55c vm: Block userland from modifying any area owned by the kernel.
Previously this protection was possible via the opt-in B_KERNEL_AREA flag,
however, almost nothing used that, so in practice these protections were
rarely enforced.

Userland can still access kernel areas according to the protection flags
(and due to SMAP, these have been refined and reduced as appopriate)
and clone them (according to B_USER_CLONEABLE_AREA flag, which has
been required since August of this year), but they can no longer
resize them (something no in-tree application does on any shared area),
set protections (otherwise they could add B_USER_CLONEABLE_AREA...),
unmap them, or essentially do anything else besides get their
information (and even that we should restrict to uid 0, in the future.)

From my testing, this does not introduce any issues, and no applications
nor drivers should have been relying on the previous behavior (unlike
SMAP or the clone-area changes, which did affect applications.)
2018-11-17 15:11:12 -05:00
Augustin Cavalier
494a6e4e8e kernel/vm: Remove hacky stack dumper from vm_page_fault.
As the TODO said, we now have good userland debugging facilities, so
this isn't needed (and has been if 0'd out for almost a decade now.)
The dprintf on page faults may still be useful under rare circumstances,
but we already have a "TRACE_FAULTS" configuration for this file,
so guard it behind that.

Fixes part of #14360.
2018-11-10 14:12:18 -05:00
Alexander von Gluck IV
8de3883d8b bcm2835: Move mailbox init into bcm2835 framebuffer
We won't need the mailbox for most chipsets except bcm2835
to determine the framebuffer base address.
(especially at this early boot stage)

This simplifies things by making the mailbox usage limited
to boot_arch_arm and not spreading it all thoughout the
platform u-boot code... however we keep the mailbox driver
as-is since it would make a good kernel driver someday.

mmu_man mentioned us "finding" the fb base from the mailbox
and modifying the FDT to let it know the base reg of the
framebuffer... that's beyond 'just getting things building'
though :-)

Change-Id: Ic2772b85dff004f9d21447ea5958b5ae9776d526
2018-11-02 12:46:54 -05:00
Alexander von Gluck IV
bdcc7b74fc arch_mailbox: Stub out virtual Read/Write functions
* Nice catch mmu_man!

Change-Id: I92a00ec5c66313107e586f7b3ee8a1fa5021b2be
2018-11-01 21:31:56 -05:00
Jérôme Duval
c30513840a runtime_loader: correctly detect gcc7 abi as gcc4 abi compatible.
Change-Id: I0e3df832e2fcc0b687344f54d5b0a639f5add370
Reviewed-on: https://review.haiku-os.org/649
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-11-01 15:25:33 +00:00
Augustin Cavalier
753d3506d8 efi: arch_src also depends on gnuefi.
Fixes the x86_64 parallel build after recent changes.
2018-10-30 22:38:21 -04:00
Augustin Cavalier
811da1f129 efi: aarch64 -> arm64. 2018-10-30 22:37:48 -04:00
Alexander von Gluck IV
645e6f89ce u-boot: Drop openfirmware in u-boot platform hack
* If we need this, we can do builds with openfirmware
  platform on u-boot loader now.

Change-Id: I67b5bda165a78b772e246c008c5018b2d6f459e9
2018-10-30 18:06:26 -05:00
Alexander von Gluck IV
c340bfce91 u-boot: Fix boot arch + platform on arm
Change-Id: I6ecdb9e1b1039ac769b015fb96a3531715b44542
2018-10-30 14:51:15 -05:00
Augustin Cavalier
d1f8f8301c kernel: Tolerate "count" argument to memcpy being 0.
It seems GCC2 occasionally will inline a call to memcpy with
a count of 0, which this function did not previously expect
and would result in a "Divide Error Exception."

Hopefully fixes #14613.
2018-10-29 22:44:01 -04:00
Augustin Cavalier
adb4e6e8c5 kernel: Reset lock holder and count on mutex_destroy().
Previously, there were a number of circumstances where these were
not getting reset properly, leading to some destroyed mutexes having
holders of the last thread which locked them, and some with "-1",
which meant that the next call to "mutex_lock" just behaved as if
the lock was still valid (!), and so the unlucky caller would deadlock
forever.

Now we properly reset these fields, which means from now on attempts to
lock or unlock destroyed mutexes will lead to "PANIC: uninitialized mutex"
on KDEBUG kernels, and (as before) an infinite deadlock on non-KDEBUG
kernels (perhaps we should store the thread_id of the locker on non-KDEBUG
kernels also?).

As the next commits will show, this already uncovered a number of bugs,
and there are of course potentially more strange deadlocks caused by this.
2018-10-29 00:53:41 -04:00
Alexander von Gluck IV
8ee963f940 efi: Begin sorting x86_64 to arch subfolder
Change-Id: I0b724c05d527332fb6a5f4909b44d578ae1c6d0e
2018-10-28 16:43:50 -05:00
Alexander von Gluck IV
ee2c12f4c8 boot/openfirmware: Add missing KERNEL_PLATFORM headers
Change-Id: I408a0b6d94cf7ac7d968e6d7e5dccd4e8920ab12
2018-10-19 15:35:48 -05:00
Alexander von Gluck IV
8522edfe36 jam: Ensure common boot LDFLAGS and ASFLAGS get distributed 2018-10-19 08:55:41 -05:00
Alexander von Gluck IV
49223f54a7 system/boot: Tab cleanup, sorry for spam
Change-Id: If486b772f5d0d1f22ba7cf08363e9a16434b3912
2018-10-18 10:53:55 -05:00
Alexander von Gluck IV
dd45d433ed u-boot: Fix after multi-loader changes
* Move MMU image to a real image define vs being crammed into
  the u-boot bootloader Jamfile
* ARM not working yet, but better!
* x86 still builds

Change-Id: I3fb873dbac06fe2db893915b667bf3ce1df44686
2018-10-18 10:49:59 -05:00
Alexander von Gluck IV
2ff03651b7 efi: Fix missing gnuefi dependency
Change-Id: Iff3b64e781ebee192b769193808f3ec12af1d1fa
2018-10-17 21:21:13 -05:00
Augustin Cavalier
e39df8a97c bios_ia32: Remove some extra debug info. 2018-10-17 17:54:57 -04:00
Alexander von Gluck IV
4124da508a bios_ia32: Fix hdd stage1 boot
* haiku_loader is the hpkg name in system/packages and not the
  loader name.
* bios_ia32 stage1 assumes the bios_ia32 loader is the first
  file in haiku_loader.hpkg. This isn't ideal.. but space in
  stage1 is *limited*
2018-10-17 14:47:54 -05:00
Jessica Hamilton
1f96a3cbde system/boot: Add support for multiple bootloaders 2018-10-17 14:47:46 -05:00
Augustin Cavalier
80be7d09c5 kernel: Handle the user buffers properly in _user_xsi_semctl.
Should fix #14512.
2018-09-23 14:45:01 -04:00
Augustin Cavalier
c609f04f86 kernel: Print interrupt line when assuming no interrupt use on PCI device. 2018-09-23 14:19:25 -04:00
Augustin Cavalier
7d8b7501ba kernel: Treat 255 as an invalid interrupt line on x86.
From mmlr's analysis in #13370 comment:22: "We actually do ignore a missing
routing in case the interrupt line is 0. In this case it isn't 0 but 0xff,
which is invalid and generally treated the same as 0 in the rest of the code.
Ignoring the missing routing on 0xff seems like the way to go here."

Indeed, I managed to locate a footnote in the PCI 3.0 specification which
confirms that this is the case on x86, and a commit in the Linux kernel
which essentially does the same thing this change does:
https://github.com/torvalds/linux/commit/e237a5518425155faa508a087f2826
Interestingly, that commit is only from 2016, while PCI 3.0 is from 2004.

This probably fixes #13370 ("Haiku doesn't MBR boot on Ryzen"), and potentially
other interrupt-routing-related boot failures.

Change-Id: I88129f6507c62d24cb50cf5c78597ca7bd7872d7
Reviewed-on: https://review.haiku-os.org/590
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-09-22 20:50:34 +00:00
Augustin Cavalier
753e006611 kernel: Include the area name and ID in the "attempting to clone" panic message.
Change-Id: Iecc842047929531f8feb7304fbcd1a8f2b28ab2f
Reviewed-on: https://review.haiku-os.org/584
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-09-18 20:03:00 +00:00
Michael Lotz
99888f6b69 kernel: Apply user iframe determination logic to SMAP/SMEP.
Change-Id: I394492a289f01303ac28e6d6670fbfdb326fa4db
Reviewed-on: https://review.haiku-os.org/561
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2018-09-14 10:09:10 +00:00
Michael Lotz
8c005190c4 kernel: Determine kernel vs. user page fault depending on iframe.
The action vm_page_fault takes should depend on whether the iframe to be
handled is a user iframe or not. The check for the user flag in the
error code does however only check if the fault happend in user or
kernel space. Use IFRAME_IS_USER() instead which checks the privilege
level of the iframe. Under 32 bit x86 this also handles vm86
compatibility mode properly.

This is the same logic as used on FreeBSD (TRAPF_USERMODE).

Fixes #13930.

Change-Id: I9c348b6ab4c60daaaaa2c0fe33bcc3336aa29f7b
Reviewed-on: https://review.haiku-os.org/560
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2018-09-14 10:08:03 +00:00
Michael Lotz
0de5a83940 Cleanup: Use symbolic names, compare != 0 and whitespace.
Change-Id: I34c60b3ab8387fe57dbcd91f9b5d278468455cf6
Reviewed-on: https://review.haiku-os.org/559
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-09-14 10:04:54 +00:00
Augustin Cavalier
4d5c5a7e66 libroot: More RETURN_AND_SET_ERRNO cleanup.
No functional change intended.
2018-09-13 16:05:22 -04:00
Augustin Cavalier
77d2c1df0e libroot: Use RETURN_AND_SET_ERRNO from the utils header in ioctl.
No functional change intended.

Change-Id: I5e6a060fe8e036bc4d4b8b8cc95a4e8d0ea00f81
Reviewed-on: https://review.haiku-os.org/549
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-09-13 04:13:19 +00:00
Augustin Cavalier
74e882b39b kernel/fs: Flush the underlying device's write cache as part of sync().
BFS does this as part of journal management, but not as part of block
cache synchronization (which makes sense, as flushing it then would
defeat the purpose of the drive's write cache.) No other file system
seems to touch it at all, so we should do it as part of an explicit sync.

This may help with some of the filesystem corruption issues, as it seems
that on slow disks, the drive might not have enough time to flush the cache
before it is powered off (or on some SATA/AHCI based disks, it is not flushed
before close at all), so triggering it here and, as the ioctl is supposed to be
synchronous, waiting for it also, seems to make sense.

Change-Id: I7d9992c21ca4b59c839711dcc96c973b4b8df052
Reviewed-on: https://review.haiku-os.org/530
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-09-11 20:06:58 +00:00
Augustin Cavalier
f960901a70 EFI: Use proper mnemnoic for retf (lret) to appease Clang. 2018-09-08 18:56:33 -04:00
Nikolas Zimmermann
0e9dc76e5f Fix build with DEBUG_PAGE_QUEUE enabled
Change-Id: Id9ffcd50835a0ba9e4276a3bb5939cc1d4afa128
Reviewed-on: https://review.haiku-os.org/516
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2018-09-06 07:46:25 +00:00
Augustin Cavalier
0df493a13a libroot: Fix handling of debugger() call in abort().
The kernel's handling of SIGABRT is just to terminate the application
immediately without doing anything else (it only notifies the debugger if
there's one installed for this application already.) More serious faults
(e.g. SIGSEGV) originate in the kernel and handle this logic before they
even invoke the signal handler.

So the correct solution is to do the same here in libroot. This incurs
a very, very slight performance penalty of the syscall time for sigaction(),
though I expect whatever applications are causing SIGABRT to be invoked more
than once a second will call raise() directly instead of abort()...
2018-09-02 00:13:40 -04:00
Augustin Cavalier
0217e08a63 vfs: panic() if volume->ops is NULL but status == B_OK.
This panic, unlike the NULL dereference that would otherwise occur, is
at least continuable.
2018-08-21 21:22:52 -04:00
Augustin Cavalier
b2cb85f4d5 libroot: New memcpy for ARM.
It seems the old one was just broken (see mailing list discussion.)

This new one was built from the generic one, but it was done using
a trunk build of Clang 8 with tuned optimization flags, and is
smaller (101 instructions) than GCC 8's (134 instructions) and
the old hand-optimized one (~125 instructions?) as well as being
targeted for ARMv7 instead of ARMv6 like the old one was.

In the future, we may want to look at newlib's ARM memcpy, which
is probably much more hand-optmized than this one is, but this
is at least better than what we had before.
2018-08-20 11:53:47 -04:00
Jérôme Duval
ee692b38b2 x86_64: R_X86_64_PC32 and R_X86_64_DTPOFF32 are 32-bit wide relocations.
Change-Id: I9c4e6c5ae77f4c17c2b6901f2b133db4b9dc48e3
Reviewed-on: https://review.haiku-os.org/445
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-08-15 16:16:20 +00:00
Kacper Kasper
fe8b46fb0d kernel: vm: add unit tests for get_mount_point
Change-Id: I1eb7540ffadb26acf05b695af2e7508c71ac7274
Reviewed-on: https://review.haiku-os.org/460
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-08-15 16:14:18 +00:00
Augustin Cavalier
552fabf1ad libroot: Merge some changes to longlong.h for ARM from upstream.
Gets the ARM/Clang build all the way to the libroot linking stage.
2018-08-15 00:11:30 -04:00
Augustin Cavalier
581da829b5 libroot: ARM does not have regparm.
Also fix the test for USE_REGPARMS in the same file. Gets the Clang
build somewhat further.
2018-08-15 00:10:33 -04:00
Alexander von Gluck IV
9ae04563d6 framebuffer/bcm2835: Check for available mailbox
Change-Id: I6f158335c4bdda108c13c26f62bfd8d814ea1b3f
2018-08-14 16:58:17 -05:00
Alexander von Gluck IV
b795602253 boot/mmu: Fix hrev52228. No returns from mmu_identity_map.
* Pretty sure Jam didn't compile the changes to this file.

Change-Id: I9dccd24e523d5bd575565f1768314a9d8f2be1ab
2018-08-14 16:26:58 -05:00
Alexander von Gluck IV
a6cb002e99 boot/mmu: Consolidate some fdt mapping functions
* Realized we already had a function which iterates over
  an fdt node and maps it's memory regs. Make it work for
  physical mappings or identity mappings.

Change-Id: I0e3e323798bc2dfcead1accc1d403b30a8ab188f
2018-08-14 16:16:01 -05:00
Augustin Cavalier
ab39ceb10c system/glue: Add a crtbegin and crtend implementation.
GCC provides these but Clang does not; these come from the ones Clang
was going to provide, but decided against it in favor of letting libc vendors
distribute them instead, hence the license headers.

For now, they are only enabled when building with Clang, as we still use GCC's
versions otherwise. But I've tested them with apps built with GCC 7 (as Clang
builds are still too broken at present) and they seem to work just fine. (They
will not build with GCC 2 of course, due to how they use __attribute__.)
2018-08-14 16:07:03 -04:00
Humdinger
deeaee6fc9 Boot options: add help text to state selection
To indicate this is a menu you can enter to select a previous
state to boot. Also rename "Latest version" to "Latest state" as
that is more correct.
Thanks waddlesplash for pointers.

Fixes #14362
2018-08-14 21:11:16 +02:00
Augustin Cavalier
f2015c2f81 boot/platform/cfe: Remove, unused.
All platforms it was theoretically useful for also have U-Boot.
OK'd by mmu_man.
2018-08-11 20:21:12 -04:00
Augustin Cavalier
376472a816 libroot: Some fixes for Clang ARM builds. 2018-08-11 15:26:08 -04:00
Alexander von Gluck IV
3718fb861d efi: Drop x86_64 assumptions.
Change-Id: I3d806f43ef951013369fd0bf906eca5977e8d34c
2018-08-08 10:18:06 -05:00
Alexander von Gluck IV
572030aca6 kernel/efi: Add efi platform
Change-Id: Ie3cc4b4652d56983147221db9fbee6b72f177b1b
2018-08-08 09:48:34 -05:00
Augustin Cavalier
023a547dc6 vm: Enable B_USER_CLONEABLE_AREA protection.
Spotted while reading through the VM code while thinking about how to
implement vfork().

When axeld disabled this in 2005 (!), Haiku's kernel was still young,
BeOS drivers were still "a thing," and there was no distinction in this
function from being called by the kernel / not by the kernel.

Now, it's 2018, we manage all drivers ourselves, have SMAP enabled by
default when available, and as axeld recently noted on the mailing lists,
"there's not much reason we still use GCC2 for the kernel anyway." So we
probably don't care about any BeOS drivers that may be broken by this
(are there any still around?)

Besides the usual fixes to get this 13-year-old chunk to work again, there
are two functional changes:
  1) Allow the kernel to clone whatever it likes into the user's address space.
     It seems that this is often done legitimately (e.g. team creation), and
     so attempting to distinguish those cases seems more work than it may be
     worth right now.

     The disadvantage is that drivers without proper checks may be "tricked"
     into cloning areas they shouldn't; but I'm guessing if that's the case,
     then something else is probably broken and the driver should be fixed.
     It seems the reverse case (cloning a userland area into the kernel)
     is much more common (in fact, it looks like all 4 of the 4 places
     where clone_area is used in kernel-space outside the kernel itself
     are doing this.)

 2) At KDEBUG_LEVEL 2 and higher, throw a panic when attempting to clone
    an area that does not have the protection flag set. This should make
    finding any bugs exposed by this change much easier than "hardware doesn't
    work" / "black screen on boot" / etc., as well as any potential future
    bugs introduced in the process of driver development.
2018-08-06 23:27:50 -04:00
Alexander von Gluck IV
91bc3a279a kernel/ppc: Fix PowerPC build after fdt changes
Change-Id: Ieccec192c9d257368f8a9b5c52d01ed3c1c66d23
2018-08-06 19:55:48 -05:00
Kacper Kasper
f26398d462 kernel: vm: remove panic
* That's embarrassing.
2018-08-06 23:09:05 +02:00
Kacper Kasper
7cea6679a8 kernel: vm: fix off-by-one errors in get_mount_point
* Fix for 03df8bfcf2.
* Fix misleading indentation.
* Fixes #14225.
2018-08-06 23:07:27 +02:00
Jérôme Duval
c90a0ee947 posix_spawn(): dup2() again this time on file_action_dup2.
* fixes #14322.
2018-08-06 19:13:32 +02:00
Alexander von Gluck IV
5d0fd0e422 fdt: Major over-haul of fdt
* Consolidate all fdt code into fdt bus_manager
* Build boot and kernel static libraries

Change-Id: I2a69cd7e1f1276999a80734ff12918fd49b599e5
Reviewed-on: https://review.haiku-os.org/440
Reviewed-by: Alexander von Gluck IV <kallisti5@unixzen.com>
2018-08-06 15:46:49 +00:00
Alexander von Gluck IV
c3f9610748 arm/mmu: First iteration at mapping peripherals from FDT
* This fixes booting Haiku on Raspberry Pi and qemu (-M raspi2)
* Makes several assumptions which need corrected.
  /axi is broadcom only
  size is fixed
* The final solution will be "probing" each simple-bus device
  from the fdt. A lot of fdt support code needs written though
  for "finding" compatible devices and determining the full size
  of the devices in memory.

Change-Id: Ifd5fbab7490c8456247115f5aada618909f1bb9e
2018-08-06 08:57:15 -05:00
Augustin Cavalier
daad9a3c1c kernel: Revert MMC bus changes to device_manager.
This broke booting on most (all?) systems.
2018-08-05 21:56:54 -04:00
krish_iyer
25b6a6f19b SDHCI MMC Driver
1. SDHCI PCI Bus: Discovering SDHC device from the PCI bus
	and registers a child node(MMC bus) to which slots
	are attached. SDHC registers are mapped by MMUIO,
	they are binded in a structure(struct* registers).
	A pin based interrupt handler is also installed,
	which triggers the handler function and interrupts
	are being taken care of. Added API's to set-up and
	the clock for SD/MMC card, change frequency and
	reset the registers.

2. Device Manager: Currently, busses subdir lists are har-
	dcoded and in order to load the driver. We hard
	coded the bus dir under PCI devices.

3. MMC Disk Driver: In order to register the slots under
	/dev/disk/mmc and hence data transfer and other
	operations can be done.

4. MMC Bus Manager: Setted up a bus manager to create an object
	to do a particular for eg certain data transfer and
	get freed until another operation is requested.

Change-Id: I369354da6b79adc6b6dfb08fe160334af1392a34
Reviewed-on: https://review.haiku-os.org/318
Reviewed-by: Alexander von Gluck IV <kallisti5@unixzen.com>
2018-08-05 20:56:54 +00:00
Fredrik Holmqvist
1368eabbff Fix gcc2 comparison, and only align if not aligned (8 - 0) 2018-08-03 15:31:03 +02:00
Fredrik Holmqvist
04cbc2588e Use fast clearing of visible screen for splash
memset uses rep stosb on x86 during boot, with memory
not set to write-combining, which makes it slow.

Instead we do aligned writes of 2 x four bytes at once.
Only clear the minimum of size and width * height * 4
UEFI framebuffer size can be huge, upto 512MB here,
and rep stosb seems to be around 25-30MB/s

This is written as generic as possible to work on
old compilers and different platforms, without
expecting boot memset to be optimized.

This makes it almost unnoticable compared to not
clearing.
2018-08-03 13:40:04 +02:00
Jaroslaw Pelczar
5effe7f3ec bootloader: Align boot volume structure to 8 bytes instead of 4.
This alignment is preferred e.g. on ARM when using 64-bit values.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2018-08-02 19:51:53 -04:00
Augustin Cavalier
fb4cc98472 build: Add initial ARM64 target.
It will probably be just stubs for the significant future, but,
here it is anyway.

Regarding the naming: Yes, the official name is "aarch64." However,
Linux, FreeBSD, and Zircon all call it "arm64", and so we will do the same.

I've configured it initially to be a Clang-only port, making no
changes to GCC buildtools whatsoever here. We'll see if that sticks,
however.
2018-08-02 19:48:29 -04:00
Jérôme Duval
20694a0458 posix_spawn(): dup2() returns a fd on success, -1 on error.
* duplicate the just opened file descriptor, instead of the target file descriptor.
* fixes #14308.
2018-08-02 11:21:04 +02:00
Augustin Cavalier
edb6d3b17b kernel_cpp: Move the C++14 operator delete out of the header.
It seems not all of the kernel includes this, but some use new/delete
anyway. Further, operator delete[] was not implemented at all.

Possibly fixes the ARM build.
2018-08-01 23:42:24 -04:00
Augustin Cavalier
ca57e33abb libroot/glibc: Use .double instead of .tfloat on Clang.
Clang's equivalent of .tfloat is .x86_fp80, but apparently that
is not enabled for Haiku. So for now, use .double instead.
This is the same thing MinGW does.
2018-08-01 19:04:25 -04:00
Augustin Cavalier
834100c94f libroot/glibc: Merge newer e_expl* files.
These versions (from ~2015 glibc) do not use some GCC-specific extensions
that Clang's integrated assembler does not like.
2018-08-01 19:02:04 -04:00
Jérôme Duval
0771d6b296 runtime_loader: differentiate between secondary runtime loaders. 2018-08-01 21:18:01 +02:00
Fredrik Holmqvist
15db6949b6 Don't clear video mem on UEFI, efi video mode refactor
Writes to videomem is slow without memory remapping
Can't do the mapping without leaving UEFI, so skipping
the clear. Afaict it should always be cleared by UEFI

This saves ~10 seconds of booting on my machine
(1920*1080*4 bytes)

EFI video mode (should have been it's own commit)
 * Only do strcmp if there are enough params
 * break when found
2018-08-01 21:12:08 +02:00
Jérôme Duval
0594302a65 runtime_loader: <x86>runtime_loader can handle x86_gcc2 binaries.
* <x86_gcc2>runtime_loader can also handle x86 binaries.
* At the moment the x86_64 kernel will execute the x86 runtime_loader
when it sees x86 and x86_gcc2 binaries. The reason is checking the GCC
version of a binary in the kernel seems cumbersome, the kernel should
just fallback using the x86_gcc2 runtime_loader when the x86 one is missing.
2018-08-01 20:59:11 +02:00
Alexander von Gluck IV
605e7eaed3 arch: Cleanup a few typos. Sorry for spam.
Change-Id: Ic2fce841acdee8572005cf2a9710188d03d7cecd
2018-07-31 19:37:01 -05:00
Alexander von Gluck IV
9642f7705b arch: Cleanup of __ARM__ checks
* gcc 7.x defines __arm__ and __ARM__ (and others)
* clang defines __arm__ and __arm
* cleanup a few related ifdef vs if macros

Change-Id: I5da4bafac590f6fa3e10e543688001c2449f840d
2018-07-31 19:12:20 -05:00
Augustin Cavalier
3142fb6996 scheduler: Fix setting priorities following the penalty cancellation changes.
Before hrev46809, the "thread->priority = priority" line was below this
check, and so all was well. But that commit moved the line to its present
location, which means ever since then, the following code which updates
CPU entries, scheduler listeners, etc. has never been run.

On my VMware instance (which is probably pretty affected by the host system
and thus not the greatest performance test), "time jam -j2 HaikuDepot" decreased
from 46.0s real to 43.3s real, 52.3s user to 48.1s user, 12.1s sys to 12.2s sys.
So this seems to make some sort of impact.

Spotted by Fishpond in #10454 and confirmed by korli, but somehow neither of
them followed up on that in the 4.5 years since...
2018-07-11 21:53:44 -04:00
Augustin Cavalier
de6ea5f43f vfs: Move volume->ops NULL check to just after call to mount().
As Rene pointed out on the mailing list, if this is NULL after the file system
mount call occurs, then something has gone very wrong and we should treat it
as an error.
2018-07-10 17:46:59 -04:00
Augustin Cavalier
131c64ad4a vfs: Add missing NULL check of volume->ops.
I got a reproducible KDL that upon close inspection seems to have been
a NULL dereference of this, thanks to GCC's mix-source-and-assembly
functionality.

Unfortunately, I deleted my mount_server settings before I fully understood
what was going on, and afterwards it no longer reproduced, so it seems to
have been related to that. I'm confident enough this is the correct fix to
commit it anyway.
2018-07-09 21:08:57 -04:00
Jérôme Duval
208c323649 real_time_clock: fix _user_get_timezone() after 6ad3d25212
6ad3d25212 changed the timezoneOffset type from
time_t to int32 without adjusting the user_memcpy size. Harmless as the
function is hardly used with a non-null argument.
2018-07-07 16:07:39 +02:00
Jérôme Duval
defd975ae2 Update libroot stubs. 2018-07-06 18:59:36 +02:00
Augustin Cavalier
49da1d2e3b crypt: Use int8 instead of int. 2018-07-05 22:04:35 -04:00
Augustin Cavalier
382d022473 libroot: Use 'int' not 'char' in crypt code.
It seems 'char' is unsigned on ARM, so GCC errors on the -1s in here.
2018-07-03 19:08:33 -04:00
Jérôme Duval
4f5ed463b5 kernel: vfs: common_fcntl() now uses memcpy() for kernel calls.
instead of user_memcpy().

* fix #14204: the NTFS filesystem kernel addon uses the fcntl system call to
lock the underlying device. The user_memcpy replacement in the x86 compat
branch adds range checks for the user pointer, which exposes such problems.
2018-06-30 15:46:52 +02:00
Augustin Cavalier
9216fc0178 More class/struct mixup fixes.
Spotted by Clang.
2018-06-18 23:16:50 -04:00
Augustin Cavalier
9ac3062734 kernel: Small fixes for Clang. 2018-06-18 19:32:13 -04:00
Augustin Cavalier
4a459f066d :kernel: Fix stack alignment in syscall entry on x86_64.
The user iframe and associated data that the syscall entry pushes to the
stack directly were causing the stack to be mis-aligned by 8 bytes. Since
we re-aligned %rsp afterwards, for most usecases this wasn't a problem.
However, since we stored the pre-realinged %rsp in %rbp (as we need it to
access the iframe data), this also meant that anything which depended on
%rbp being 16-byte-aligned would run into serious problems.

As it turned out, GCC 7 assumed that %rbp was indeed 16-byte-aligned, and
so optimized certain accesses to use SSE instructions that depended on this
alignment. Since inside any callstack begining with a syscall this was not
the case, a "General Protection Exception" resulted (see #14160 for an example)
at the first usage of such an instruction. I wasn't really sure what was going
on when it first came up, and so "fixed" it by disabling the GCC optimization
that used such instructions. Replacing the -fdisable... with -mstackrealign thus
also "fixes" the problem, as I discovered earlier today, as it forces GCC to
realign the stack in function prologues.

So instead of rounding %rsp down to the nearest aligned address after the
pushes are complete, we offset %rsp by the amount the pushes are not,
thus fixing both %rsp and %rbp in syscall handling routines. This of course
depends on syscall_rsp being already aligned, which it is.

Thanks to PulkoMandy and js for the advice and guidance (and PulkoMandy
for the ASCII art), as this is essentially my first time working with
kernel assembly.
2018-06-16 17:24:33 -04:00
Alexander von Gluck IV
64d4515abf kernel: Only apply rtl-stv1 hack to x86 & x86_64
Change-Id: I971f7bf3bb95ee466a59ab777c2f6fc56fbcbd43
2018-06-15 13:43:13 +00:00
Augustin Cavalier
4f7b9506fd Revert the rest of the COMPAT_MODE changes (back to hrev52003.)
This reverts commit 458e758f37.
This reverts commit ce5eb94a82.
This reverts commit aac8d4c317.
This reverts commit c70cba914a.
This reverts commit 2ffbe7aaca
This reverts commit c6e120e2d2.
2018-06-15 00:20:56 -04:00
Augustin Cavalier
513403d420 Revert team and thread changes for COMPAT_MODE (hrev52010 & hrev52011).
This reverts commit c558f9c8fe.
This reverts commit 44f24718b1.
This reverts commit a69cb33030.
This reverts commit 951182620e.

There have been multiple reports that these changes break mounting NTFS partitions
(on all systems, see #14204), and shutting down (on certain systems, see #12405.)
Until they can be fixed, they are being backed out.
2018-06-14 22:25:06 -04:00
Jérôme Duval
c558f9c8fe kernel/x86_64: stacktrace for threads in compatibility mode.
* add compat_stack_frame struct.
* user symbols are't yet looked up in compatibility mode.

Change-Id: I94b45f25564c246bb174f9491f4abc4aa8676549
2018-06-12 17:56:55 +02:00
Jérôme Duval
44f24718b1 kernel/x86_64: add compatibility source files to the build.
* add x86 versions of fnsave frstor.
* add missing declaration for elf32_resolve_symbol().

How-to build a x86_64/x86 bootstrap build:
mkdir generated_bootstrap; cd generated_bootstrap
../configure --bootstrap /dir/to/haikuporter/haikuporter /dir/to/haikuports.cross \
  /dir/to/haikuports --build-cross-tools x86_64 /dir/to/buildtools --build-cross-tools x86 -j8 --use-gcc-pipe
jam -q -sHAIKU_PORTER_EXTRA_OPTIONS="-j8 --sourceforge-mirror=freefr --no-source-packages" @bootstrap-raw

Change-Id: I6eae3653c42a53683ae307107fae595c4b8ebcfb
2018-06-12 17:56:55 +02:00
Jérôme Duval
a69cb33030 kernel/x86_64: setup a new thread in compatibility mode.
* define compat_thread_info, compat_rlim_t, compat_rlimit and
compat_thread_creation_attributes to be used when applicable in compatibility
mode.
* handle 32-bit types in _user_spawn_thread(), _user_get_thread_info(),
_user_get_next_thread_info(), _user_getrlimit(), _user_setrlimit(),
other syscalls are compatible as is.
* init TLS for compatibility mode threads.

Change-Id: I483ba95e6198ddac9d240671bcb56fcd2ad831d2
2018-06-12 17:56:55 +02:00
Jérôme Duval
951182620e kernel/x86_64: setup a new team in compatibility mode.
* in load_image_internal(), elf32_load_user_image checks whether the binary
format requires the compatibility mode.
* we then set up the flag THREAD_FLAGS_COMPAT_MODE and the address space size.
* the compatibility mode runtime_loader is hardcoded with x86/runtime_loader.
* if needed, the 64-bit flat_args structure is converted in-place to its 32-bit
layout.
* a 32-bit flat_args isn't handled yet (a 32-bit team execs a 64-bit binary).

Change-Id: Ia6a066bde8d1774d85de29b48dc500e27ae9668f
2018-06-12 17:56:55 +02:00
Jérôme Duval
458e758f37 kernel/x86_64: compatibility syscalls for vm.cpp.
* define compat_area_info to be used when applicable in
compatibility mode.
* handle 32-bit types in _user_reserve_address_range(), _user_get_area_info(),
_user_get_next_area_info(), _user_transfer_area(), _user_clone_area(),
_user_create_area(), _user_map_file(), other syscalls are compatible as is.
* _get_next_area_info() doesn't work well with a 32-bit address cookie (address
could be in 64-bit range). Instead use _compat_get_next_area_info() which uses
the area id as cookie, though the areas are not ordered by address any more.

Change-Id: Ic7519ca8824aa2d534b0f03ea75a1bf6ae321535
2018-06-12 17:56:55 +02:00
Jérôme Duval
ce5eb94a82 kernel/x86_64: compatibility syscall for system_info.cpp.
* define compat_system_info to be used in _user_get_system_info() in
compatibility mode.

Change-Id: Ib917d41a3a87155aee9cb536fd09e7231b232bc8
2018-06-12 17:56:55 +02:00
Jérôme Duval
aac8d4c317 kernel/x86_64: compatibility syscalls for signal.cpp.
* handle 32-bit types in _user_send_signal(), _user_sigaction(), _user_sigwait(),
_user_set_signal_stack(), _user_restore_signal_frame(), other syscalls are
compatible as is.

Change-Id: I4c8dc47bfa80f36e363d444d2a5a7be6c621606d
2018-06-12 17:56:55 +02:00
Jérôme Duval
c70cba914a kernel/x86_64: compatibility syscalls for image.cpp.
* define compat_image_info, compat_extended_image_info
to be used for respective 32-bit types of syscalls in compatibility mode.
* handle 32-bit types in _user_register_image, _user_get_image_info,
_user_get_next_image_info, other syscalls are compatible as is.

Change-Id: Ibbd33e6796208dfa70d869e36bf745bc3e18d330
2018-06-12 15:55:55 +00:00
Jérôme Duval
2ffbe7aaca kernel/x86_64: compatibility syscalls for vfs.cpp.
* define compat_flock, compat_timespec, compat_stat, compat_attr_info,
compat_fs_info, compat_fd_info to be used for respective 32-bit types
of syscalls in compatibility mode.
* handle 32-bit types in common_fcntl(), _user_read_stat(), _user_stat_attr(),
_user_read_index_stat, _user_read_fs_info, _user_write_fs_info,
_user_get_next_fd_info, other syscalls are compatible as is.

Change-Id: I5b372169fe142f67b81fd6c27e0627d5119ba687
2018-06-12 15:55:43 +00:00
Jérôme Duval
c6e120e2d2 kernel/x86_64: add setup_compat_signal_frame.
* add compatibility signal types.

Change-Id: I665020234be0ba2ccbb33bdbc338c11a214ab6e8
2018-06-12 15:55:18 +00:00
Augustin Cavalier
8085ed3fec UserTimer: Zero-initialize sigevents.
CID 1234670 and friends. Probably harmless, though.
2018-06-11 18:57:00 -04:00
Augustin Cavalier
a287df1c5b efi: Fix bad mode changes from previous commit. 2018-06-11 17:40:38 -04:00
Jessica Hamilton
86b12d85c7 efi: move various init before call to main().
* With the previous commit, we can now move functions that require
  calling mmu_map_physical_memory to where they should have been
  originally. This also allows the SMP safe mode menu entries to
  be properly generated, now that smp_init is called prior to
  main().

Change-Id: I05ddca5273b11cb4846021664c1ea2cf8ba723b7
2018-06-11 15:17:40 +12:00
Jessica Hamilton
b2d0b3699e efi: redo mmu_map_physical_address to not require allocations.
* mmu_map_physical_address will get called prior to calling main()
  which leaves us without a heap, malloc, and new. Instead, use
  the kernel args physical allocated range array, and then
  convert to our allocated memory region type on-demand.

Change-Id: I265fd165ef7143681e8e40c3686fda1a583c20dc
2018-06-11 15:17:39 +12:00
Augustin Cavalier
8845ad353d bootloader: Update copyright years.
We've definitely changed the bootloader a good amount since 2014.
2018-06-09 22:25:33 -04:00
Augustin Cavalier
98a4ebbe3c efi: Actually add items to safemode menu.
The call to smp_... is not working since it relies on gKernelArgs being
fully initialized, which it isn't at this stage in the EFI loader. Jessica
says that in order to have that happen, the heap would also need to be
initialized early, which it also is not.

At least you can now force a safe videomode, which is enough for me to
be able to test video drivers.
2018-06-09 22:21:21 -04:00
Jérôme Duval
bdd7dae89c kernel/x86_64: add a compatibility syscalls table.
* install syscall handlers in compatibility mode.
* copy the syscall entry in the compatibility commpage, ATM only for Intel
SYSENTER.
* copy the thread exit handler in the compatibility commpage.

Change-Id: Ic350799938815194377d8a4560cb106fe7366cc6
2018-06-05 17:13:08 +00:00
Jérôme Duval
8088f452ff efi: fix loader build. 2018-06-03 18:14:32 +02:00
Jérôme Duval
499712a9ec device_manager: IORequest: use user_memcpy() to access a user buffer.
* should fix #14164, but the case can't be reproduced easily it seems.

Change-Id: I636db93cc1efe2784b2530dced6a900fbfe3dce8
2018-05-31 11:55:18 +00:00
Jérôme Duval
9e75e900da kernel: use non-deprecated signatures for new/delete operators.
add posix_memalign(), needed for c++17.
2018-05-28 20:49:15 +02:00
Jérôme Duval
b3e749b0c1 kernel,libroot,boot: remove c++11 and gnu++11 flags.
* c++14 is the default with current GCC
* remove pragmas for x86intrin.h
2018-05-28 18:54:22 +02:00
waddlesplash
77d1e4fd44 kernel: TARGET_PACKAGING_ARCH not HAIKU_ARCH for present compiler arch.
HAIKU_ARCH is CPU architecture. Sorry for the noise...
2018-05-22 20:41:52 -04:00
Adrien Destugues
8bca37d604 vfs: Bind flock locks to file descriptors
* File locks created by flock should only apply for the file descriptor
  that was used to lock the file. Another fd on the same file should then
  be denied access (calling flock should fail).
* fcntl based locks, however, are in a separate namespace and are global
  to a team.
* This issue was found when running webkitpy test suite, and should close
  ticket #13795.
* Don't use session or team as comparison in release_advisory_lock(), as
  that information might not be available anymore (e.g. when called from
  Team::~Team()). This fixes #14121.

Change-Id: I9efb96cfcefe7e72b0060220c635a665e7e643cc
Co-authored-by: Axel Dörfler <axeld@pinc-software.de>
2018-05-22 20:29:21 +00:00
Jérôme Duval
fc48586b9b kernel/libroot: use compiler built-in for rdtsc().
* spares two MOV instructions.
* the warning is fixed upstream:
2bbcec1f88
2018-05-22 17:48:02 +02:00
Augustin Cavalier
3acaf25e8f kernel: Disable rtl-stv1 optimization on GCC 7.
See inline comment and accompanying ticket.
2018-05-21 20:52:11 -04:00
Jérôme Duval
8ac3d98578 x86_64: use the compiler built-in for cpuid. 2018-05-21 15:28:55 +02:00
Alexander von Gluck IV
172c944a5b kernel/kernel_cpp: Change nothrow_t syntax for gcc6+
* Fix for explicit constructor change.
  https://github.com/gcc-mirror/gcc/commit/a3f25f0f

Change-Id: I330ad9c3bff1d7f3e0284f3dcda86e17d974c57d
2018-05-20 15:44:32 -05:00
Alexander von Gluck IV
95daec1061 u-boot: Generate boot.scr for mmc
* This gives us a solid automatic entry point to u-boot
* A uEnv.txt specifies the fdt file name
* This should work on any modern u-boot for most architectures
* Non-mmc targets will likely need some work

Change-Id: I9a00316a213a15e85d3f2e18574d64920d9bdb76
2018-05-19 20:04:50 -05:00
Jérôme Duval
95ed3b4432 kernel/x86_64: add signal handler compat code.
* x86_64_signal_handler_compat is a dump of x86 x86_signal_frame_function().
* the x86 compiler should be used to produce this code, which ends up in the
commpage.

Change-Id: I03da02c376f67ff83dbaba9bcb144da726463996
2018-05-18 15:19:41 +00:00
Jérôme Duval
db9b70ee54 kernel: add a compatibility commpage on x86_64.
* x86 uses a commpage with 32-bit addresses, incompatible with the one used for
x86_64. For this reason, a compatibility commpage is needed to support a 32-bit
userland on x86_64.
* define ADDRESS_TYPE as a macro for addr_t (default) or uint32 (for the 32-bit
commpage).
* team_create_thread_start_internal() will use clone_commpage_area() with
KERNEL_USER_DATA_BASE or clone_commpage_compat_area() with
KERNEL_USER32_DATA_BASE, to setup the correct commpage.
* real_time_clock (in compatibility mode) also updates the compatibility
commpage with real time data.

Change-Id: I61605077ce0beabab4439ef54edd1eae26f26fd2
2018-05-18 05:11:07 +00:00
Jérôme Duval
a553e95d85 kernel: support elf32 on x86_64.
* define ELF32_COMPAT to enable ELF32 macros.
* add a flag ELF_LOAD_USER_IMAGE_TEST_EXECUTABLE to only check the format.
It will be used by load_image_internal() to check which mode to use when
loading an image.
* in arch_elf_relocate_rel(), switch to elf_addr instead of addr_t, which
would be the wrong size for elf32 on x86_64.
* the ELF compat loader reuses the relevant parts of elf.cpp and arch_elf.cpp,
excluding for instance load_kernel_add_on() or dump functions.

Change-Id: Ifa47334e5adefd45405a823a3accbd12eee5b116
2018-05-15 10:29:00 +00:00
Jérôme Duval
496080235a kernel/x86_64: add ia32 syscall entry and commpage syscall code.
* only for Intel sysenter/sysexit.
* the entry function processes stack arguments as follows:
    we look up the syscall in the table, find the number of arguments.
    reserve place on the stack for the arguments.
    copy arguments on the stack
    pop register arguments
    call the syscall function
    place the return value in ax and dx registers.
* TODO: we need to store the arguments somewhere for the post-syscall tracing.
* the thread exit stub is 32-bit, for the time being use hexadecimal instructions.

Change-Id: Ie5c502eb596d4fa7613d238de80643566bc19ed8
2018-05-15 10:27:18 +00:00
Jérôme Duval
27b32ee02c kernel/x86_64: adjust descriptors tables for compatibility mode.
* also adjust BOOT_GDT_SEGMENT_COUNT for x86, the definition is used by the
boot loader.
* add some 32-bit definitions.
* add a UserTLSDescriptor class, this will be used by 32-bit threads.

Change-Id: I5b1d978969a1ce97091a16c9ec2ad7c0ca831656
2018-05-15 10:27:02 +00:00
Jérôme Duval
0032be820b kernel/x86: asm offsets for the extended syscall table.
the x86_64 compat syscall entry needs size and offset of parameters to
handle them correctly to the syscall function. struct extended_syscall_info
and struct syscall_parameter_info provide parameter count, size and offsets.

Change-Id: I7e5c7b6e19e757b28b43c3b3419b7071fae321f8
2018-05-09 18:24:32 +00:00
Jérôme Duval
33dc8de507 kernel: remove incorrect inline and static keywords for syscalls. 2018-05-06 16:27:47 +00:00
Jérôme Duval
2aaad308b8 runtime_loader: enable elf32 on x86_64, elf64 on x86.
use x86 as default sSearchPathSubDir in compatibility mode.
use the generic memset/memcpy when x86_64 is the primary arch.

Change-Id: Ib464c308ff97f7ae2482ef4c037de1b1bb2bf61b
2018-05-05 09:37:49 +00:00
Jérôme Duval
51dfedd76b libroot_x86: use the generic memset/memcpy when x86_64 is the primary arch.
the standard x86 implementation uses the commpage, which is difficult to setup. we could
also use the C++11 version instead.

Change-Id: I4be7e3466082ff2c91bc32bef377a664ce65f3fc
2018-05-05 09:37:16 +00:00
Jessica Hamilton
f599721237 bootloader/efi: remove partition before adding to new list.
* A Node/Partition cannot be member of two lists at once. This
  resolves an issue where a partition cannot be found later
  due to corruption of a NodeList.
2018-05-05 14:14:35 +12:00
Jessica Hamilton
bb96d47d9b Revert "efi: force boot menu to show."
This reverts commit 3ceaa03c60.
2018-05-05 14:14:21 +12:00
Jessica Hamilton
3ceaa03c60 efi: force boot menu to show. 2018-05-05 14:11:26 +12:00
Alexander von Gluck IV
dd485ed444 elf: Add aarch64 and riscv defines
* Add some additional defines as well.

Change-Id: I0a40f6b80a634ddaf83a8c22b9726a6e1f49bd34
2018-05-04 18:32:33 +00:00
Jérôme Duval
1894e9b6a7 Add runtime_loader in secondary bootstrap packages.
add grist to runtime_loader source files.

Change-Id: I09c58b5cc1d57034632df99b4fb3c80e3ff49e3e
2018-05-02 16:46:02 +00:00
Axel Dörfler
7750fdcf18 vfs: _user_flock() did not use FS advisory locking calls
* The kernel's advisory locking implemenation must not be used if the
  file system has its own (ie. network file systems).
* Added ASSERT to free_vnode() that assures there is no locking left;
  I recently had a lot of them around.
2018-04-22 15:13:29 +02:00
Fredrik Holmqvist
58c99ce4d4 malloc_referenced adds +1 to int32 pointer so use its release 2018-04-22 12:47:30 +02:00
Jérôme Duval
dde876f9f8 kernel: pae paging: align *TableEntry() with 64bit paging
use SetTableEntry() in PutPageTableInPageDir() and PutPageTableEntryInTable().
2018-04-21 10:06:51 +00:00
Jérôme Duval
03df8bfcf2 kernel: vm: reduce stack usage in swap_init_post_modules().
* avoid a struct copy in PartitionScorer.
* reduce stack usage in get_mount_point().

Change-Id: I60a3161ba39e9a50eaae972b7ff5b4a26d6292fa
2018-04-18 12:37:02 +00:00
Jérôme Duval
1fb59be1d1 Fix some usages of BStackOrHeapArray.
Validates the buffer with IsValid() before actually using it. Thanks Rene!
2018-04-16 14:30:34 +00:00
Jérôme Duval
48c1ae929e libroot: avoid excessive stack usage in __find_directory()
create_path() is inlined in __find_directory().
2018-04-11 23:44:22 +00:00
Michael Lotz
a113ad395f Cleanup: Remove debug leftover introduced in hrev51871. 2018-04-06 21:28:33 +02:00
Michael Lotz
9c4845e767 kernel: Implement wait info count limit in wait_for_objects.
Since wait_for_objects can wait on sems, threads and ports in addition
to FDs, limiting to RLIMIT_NOFILES as in the select/poll case does not
work. Since space is allocated for the wait objects in kernel memory,
limiting their number to a valid range is still desireable.

The limit is now placed at the sum of max sem, thread and port count
plus RLIMIT_NOFILES.

This also fixes a signed vs. unsigned comparison warning in
check_max_fds introduced in hrev51866.
2018-04-06 21:20:11 +02:00
Michael Lotz
c101b57682 kernel: Implement FD limit check for select/poll.
The amount of FDs that can be selected/polled needs to be limited by
the RLIMIT_NOFILES.
2018-04-04 00:09:23 +02:00
Michael Lotz
321372e3ef kernel: Make size argument to create_area_etc() size_t.
It was limited to a uint32 and could for example be overflown by the
slab MemoryManager that uses size_t on a 64 bit system.

This aligns the signature with create_area() that already uses size_t
for the size argument.

Note that the function is currently private, so the impact should be
limited.
2018-04-04 00:07:59 +02:00
Jérôme Duval
e1ceb339a0 kernel: override access control in user_[un]block_thread()...
when reading/writing the wait_status in userland. fixes #14067.
2018-04-03 22:42:14 +02:00
Alexander von Gluck IV
3b60bc6b9b openfirmware/ppc: A few minor fixes and extra debugging
* Show old page table location and provide more feedback
* 16 int32 * 0x10000000 > sizeof(int32), fix to uint32

Change-Id: Ib68c34f5d3c6bfa1da53241e6586c07e4e494750
2018-03-13 21:35:22 -05:00
Alexander von Gluck IV
3a747315b2 stdlib: Add common bsd mkstemps function
Change-Id: I8c54f4b42e8b41f9a769b8b53f074a307b1a054c
2018-02-26 21:46:25 +00:00
Xiang Fan
a9388f6d39 kernel: vfs: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the vnode does not have select().

Bug: 13965
2018-02-26 10:44:22 +00:00
Xiang Fan
f3b05a74bb kernel: devfs: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the device does not have Select().

Bug: 13965
2018-02-26 10:44:22 +00:00
Xiang Fan
8a38c1fdc2 kernel: fd: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the filesystem does not explicitly provide an fd_select() override.

Bug: 13965
2018-02-26 10:44:22 +00:00
Jérôme Duval
4bd0c1066b runtime_loader: add hybrid support. 2018-02-25 08:29:51 +01:00