Commit Graph

6744 Commits

Author SHA1 Message Date
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
Kacper Kasper
e0c304f798 efi: fix 64-bit build. 2018-02-23 22:23:51 +01:00
Jérôme Duval
bec80c1ced white space cleanup 2018-02-10 19:34:43 +01:00
Jérôme Duval
718d7149b1 white space cleanup 2018-02-10 16:15:37 +01:00
Jérôme Duval
401fb209ea kernel: use x2apic on hypervisor, or if already enabled.
* this can be disabled per safe mode setting.
2018-02-04 19:08:53 +01:00
Jérôme Duval
ac690cf148 glue: correctly support different architectures.
* use MergeObject even if we don't need the merged object: the rule does what
is needed and is standardly used for instance in libroot.so.
* add a grist to source files for the bootstrap glue.
2018-01-31 22:57:56 +01:00
Andreas Faerber
0ae2a0c4d7 Fix device type check
B_DEVICE_TYPE is a 16-bit numeric ID.
2018-01-31 20:26:11 +00:00
Jérôme Duval
9dd4d2dd05 kernel: support for Intel SMAP and SMEP on x86_64.
SMAP will generated page faults when the kernel tries to access user pages unless overriden.
If SMAP is enabled, the override instructions are written where needed in memory with
binary "altcodepatches".
Support is enabled by default, might be disabled per safemode setting.

Change-Id: Ife26cd765056aeaf65b2ffa3cadd0dcf4e273a96
2018-01-30 20:05:39 +00:00
Jérôme Duval
857d600ae1 Add missing libroot stub on x86 (different from x86_64). 2018-01-29 17:47:41 +01:00
Jérôme Duval
1603eec4a4 kernel: vm: allow mmapping of the last page of the userspace. 2018-01-27 17:15:52 +01:00
Jérôme Duval
13daa9299e Fix initial stack alignment on 64-bit systems.
gcc does re-align the stack in the main() function prologue, however,
we still need to set the right alignment for other cases: thread entry,
.init and .fini code that is executed before main() is called or after
it has returned, and signal handlers which may use a separate stack.

Part of #10509
2018-01-24 07:59:55 +00:00
Jérôme Duval
34cdda1dd5 kernel: x86: enable writes before patching.
Follow up for commit a2021292d4.
Binary patching would otherwise fail after the kernel text area
becomes read-only.
2018-01-23 17:59:41 +01:00
Jérôme Duval
483c45843d kernel: x86: add some more cpuid flags. 2018-01-15 20:18:43 +01:00
Jérôme Duval
a2021292d4 kernel: Binary code patches on x86.
This will be used to support SMAP.

Sponsored-by:	https://liberapay.com/korli
2018-01-14 13:20:38 +01:00
Jérôme Duval
9409021432 kernel: x86: add cpuid feature 7 flags. 2018-01-13 09:33:47 +01:00
Andrew Aldridge
f6d25a3a81 strtod: Do not consume "x" in incomplete hex input
Adapted from upstream glibc commits:
* 405698e946dbed472491f85867eb511eb080e05a
* 43b9d657408fbf47a47934f9e7c84ed87f7f5a18

Fixes #13949
2018-01-12 16:45:14 +00:00
Jérôme Duval
bbb5a50f9b kernel: debug: map the frame_buffer for the kernel only. 2018-01-11 19:59:10 +01:00
Jérôme Duval
51051c56d3 kernel: wait_for_objects: read the user sigmask with user_memcpy() 2018-01-08 22:19:07 +01:00
Jérôme Duval
9fbffea6f4 kernel: vfs: don't use the attribute name user buffer directly.
instead copy the name on the stack.
2018-01-07 23:33:04 +01:00
Jérôme Duval
ff678dd91b kernel: image: _get_next_image_info shouldn't use a user buffer directly
_user_get_next_image_info() now copies the cookie on the stack, calls
_get_next_image_info() and copy back the cookie to the user buffer.
2018-01-07 22:57:41 +01:00
Jérôme Duval
6e28d80927 kernel: port: check USE_USER_COPY flag before masking it.
writev_port_etc() used memcpy() instead of user_memcpy() for user buffers.
The branch was even left out silently as an optimization on gcc5.
2018-01-07 22:41:39 +01:00
Jérôme Duval
da8f9c86bd kernel: disk_device_manager: no return in method returning void 2018-01-06 21:38:16 +01:00
Jérôme Duval
4644c7cc92 kernel: disk_device_manager: clean user interface
* avoid assignment in if statements
* use boolean conditions
* use copy_from_user_value/copy_to_user_value instead of user_memcpy
* no functional changes except user buffer addresses check in:
_user_get_next_disk_device_id(), _user_get_disk_system_info(),
_user_get_next_disk_system_info(), _user_find_disk_system()
* remove TODO "Add user address checks and check return values of user_memcpy()!".
2018-01-06 21:38:16 +01:00
Jérôme Duval
9572fa7340 kernel: signal: check user buffer addresses...
in _user_set_signal_mask(), _user_sigaction(), _user_sigsuspend(), _user_set_signal_stack().
2018-01-06 17:15:18 +01:00
Jérôme Duval
b68d872bdb kernel: apm: check buffer parameter in apm_control syscall 2018-01-06 16:11:32 +01:00
Jérôme Duval
9c18398fe4 kernel: system_info: correctly check the user buffer...
before writing.
2018-01-06 12:05:20 +01:00
François Revol
4069b740e5 pthread: assign handle argument before resuming the created thread
It's not specified by POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_create.html
"There is no requirement on the implementation that the ID of the
created thread be available before the newly created thread starts executing."

However I've run into it with MPD which assumed this, probably because
of Linux:
https://github.com/MusicPlayerDaemon/MPD/issues/188

It doesn't hurt anyway.
2018-01-06 05:07:43 +01:00
Michael Lotz
0a7f661ae2 kernel: Fix scheduler tracing formats and priority field type.
* Use format macros for printing to fix priting on 64 bit.
* Use int32 for all priority fields, some of them were truncated.
2018-01-05 22:48:56 +01:00
Michael Lotz
3084a7000f Cleanup: Remove one trailing whitespace. 2018-01-05 22:48:56 +01:00
Jérôme Duval
e46e9fee6b vfs: check userland buffers before reading them. 2018-01-03 21:15:30 +01:00
ohnx
7766c048b3 libroot: Fix possible typo in printf_size.c
It appears as if there is a typo in printf_size.c; it makes
no sense to compare an unitialized variable in such a way.
Since `info->width` is referenced later on in the variable
assignment, it seems possible that the intended statement
was to place the larger of the values between `info->width`
and `info->prec` into `width`.

Fixes CID 609431.

korli: Patch applied in cddfcf2f87
was incomplete. This patch completes with what upstream did in 2004:
fa5753eede.patch

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2018-01-03 19:42:55 +01:00
Michael Lotz
36ef138ce5 kernel: Implement WEXITED for waitid.
Previously dead teams were always returned (as needed for wait/waitpid).
Using waitid it should however be possible to omit the WEXITED flag to
only get stopped (WUNTRACED | WSTOPPED) or continued (WCONTINUED) teams.

Adjust the other caller of the _kern_wait_for_child syscall, used by the
various less specific wait* functions, to always include WEXITED. This
avoids having to special case waitid in the syscall interface or with an
extra flag.

Add a check to ensure that any of these flags is set to avoid the now
possible case of nothing being specified. This fails with B_BAD_VALUE
(EINVAL) as on other systems.
2018-01-03 01:52:52 +01:00
Michael Lotz
63e2d20137 kernel: Treat WSTOPPED synonymous to WUNTRACED.
On other systems their values are usually aliased. We defined them as
two different values, but didn't handle WSTOPPED anywhere. The check
is now simply extended to cover both bits.
2018-01-03 01:22:53 +01:00
Michael Lotz
afe8d6621d kernel: Avoid double lock in wait_for_child with child == team.
When wait_for_child was called with a child argument equal to the
current team, the team was locked again to check if it was a child of
itself.

This is now handled the same way as on other systems, where this case
results in ECHILD (and not EINVAL).
2018-01-03 01:10:29 +01:00
Fredrik Holmqvist
1446507ce3 Remove the code to force ACPI to shutdown on CPU0
It was discussed and introduced based on docs that some systems
need this to shutdown properly. I can find no mention of this in
ACPICA or ACPI docs.
This needs to be re-evalutad, as all my shutdowns been successful
after disabling it and I can't locate where this info came from
or if it actually helped.

See 1316462ab0 for original commit
and bug 12306 on current shutdown issue.
2017-12-31 17:43:31 +01:00
Augustin Cavalier
04c3bd6cf1 Team: Defer adding the team to parent and hash until just before starting.
Previously I had intended to take the simpler route and just lock the
already-inserted team before setting the io_context (as in prior commits),
but after hearing some reports from users that some other seemingly
unrelated KDLs had possibly cleared up after the first iteration of
that fix, I decided to go with this route instead.

Now we do not insert the team into the parent and hash and send the
notification until just before the team's main thread is actually started;
i.e. we now initialize not only io_context but also the team's args, VM
address space, and user data (and if creation of any of these fails
we do not inset the team into the hash at all.)

Since the team structure was not locked at all while this initialization
was taking place, any number of race-dependent bugs could have been
caused by this on multicore systems.
2017-12-19 22:47:31 -05:00
Augustin Cavalier
4ecdf1e195 team: Only lock while actually setting io_context, not while creating it.
Thanks Ingo for the review!
2017-12-19 20:51:01 -05:00
Augustin Cavalier
11b65332b4 kernel/team: Lock the team while modifying the io_context.
Second part of the fix for #13861. Thanks Ingo for the review!
2017-12-17 22:27:44 -05:00
Augustin Cavalier
019828aba7 VFS: Add proper locking of the team structure in disconnect_mount_or_vnode_fds.
The KDL in #13861 was apparently caused by a NULL io_context. I read over
the Team code and have applied the following fixes here as a result:

  1. A NULL io_context is entirely possible, as implied by the NULL check
     before deinitializing it in Team's destructor, so account for that.

  2. Team objects have a class-wide lock which must be acquired before
     directly accessing class members, so use that here.

First part of the fix for #13861.
2017-12-17 22:27:44 -05:00
Mason X
8a4744fbe4 Catch integer overflow in calloc (Fixes #13820)
calloc, when multiplying to find the true size of memory desired
by a user, will occasionally overflow if the numbers are too
large. This commit makes calloc ensure that the multiplication
does not overflow by dividing the result by one of the numbers,
and checking to ensure that the result is equal to the other
number. If there is overflow, it is treated as an OOM error.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-12-17 17:02:09 -05:00
Augustin Cavalier
bfc37fd122 libroot/posix/stdio: Remove unused portions.
We use glibc's versions of these functions.
2017-12-17 13:55:13 -05:00
Augustin Cavalier
efdaac9c08 kernel/convertutf: Fix file mode. 2017-12-10 12:07:23 -05:00
hyche
1750cd1e92 block_cache: Implement cache_has_block_in_transaction function that will check the existence of block in one specific transaction.
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-12-10 11:02:56 -05:00
Adrien Destugues
6a028821b6 x86 glue code: keep stack aligned.
The glue code pushed 12 bytes to the stack, breaking the 16-byte stack
alignment requirement. This would be fixed by the main() prologue from
gcc, but all "init" and "fini" code (static/global constructors/ destructors)
would run with a misaligned stack.

This was already fixed for x86_64 in hrev49731. Note that the fix here
is slightly different, the pointer is realigned after it is saved to EBP
and the function epilogue restores it from EBP, so no changes to crtn.S are
needed.
2017-12-10 09:23:22 +01:00
Augustin Cavalier
8b222e6272 IORequest: NULL check does not belong in method body.
Found by Clang's -Wtautological-undefined-compare.
2017-12-03 13:44:16 -05:00
Augustin Cavalier
bf77c15232 kernel/vm: Correct virtual function declarations.
The base VMCache class changed to the generic_ types with their
introduction in in *2011* (435c43f591),
but these classes were never properly adapted. These functions should not
be called here (they panic() -- but the base class only returns B_ERROR,
so that is a difference at least.)

Found by Clang's -Woverloaded-virtual.
2017-12-02 21:42:50 -05:00
Rene Gollent
dfc46d83b7 runtime_loader: Fix #13799.
- Don't remove .eh_frame in the linker scripts, as this saves little
  space in practice, and results in debug binaries of the runtime loader
  not being properly debuggable due to missing canonical frame
  information.
2017-12-02 15:41:41 -05:00
Augustin Cavalier
30c9d3c0cc kernel: Correct class/struct mixups.
Almost certainly harmless. Spotted by Clang.
2017-12-01 20:27:15 -05:00
Jérôme Duval
6ac3a280f4 Add ZstdCompressionAlgorithm.
* kernel lib is decompress only (like zlib).
* expand compression_test for zstd.
2017-11-24 21:35:49 +01:00
Julian Harnath
5c821d1200 SystemProfiler: prevent nested wake-up of profiler thread
* When SystemProfiler::_MaybeNotifyProfilerThreadLocked() is called
  and the conditions are right, it will lock the thread's scheduler
  spinlock and unblock it. Internally, the unblock will enqueue the
  thread into the run queue, which causes a ThreadEnqueuedInRunQueue
  event for SystemProfiler. Since the conditions haven't changed, it
  now went into _MaybeNotifyProfilerThreadLocked again (this time
  from the profiler thread context). In there, it will try to lock
  the profiler thread's scheduling spinlock, which is already locked
  by the other thread (which is firmly sleeping). Deadlock, KDL.

* Before unblocking the profiler thread, unset fWaitingProfilerThread
  so that further events will not try to unblock it again.
2017-11-24 18:22:14 +01:00
Alexander von Gluck IV
eb81dec460 kernel/u-boot: Add a few missed fdt compat's for omap uart 2017-11-23 10:25:18 -06:00
Augustin Cavalier
df9bc792e0 runtime_loader: Set sSearchPathSubDir on first image, not on app image.
Under normal conditions this will behave identically. But when using LD_PRELOAD
or the like, some shared objects (and dependencies) are loaded before the
app image is, and on the secondary arch on hybrid builds, will fail to load
any of their dependencies due to sSearchPathSubDir not being set.

Fixes #12214, which had plagued users of libroot_debug for a long time now.
2017-11-22 17:55:36 +01:00
François Revol
dd1454bd96 Defer calling arch_debug_console_init_settings
when we can actually read driver settings :-)
2017-11-20 18:16:54 +01:00
Alexander von Gluck IV
2dce5eecef build/arm: Correct missing sources in search
* Group into local var to prevent recurrence.
2017-11-20 09:36:56 -06:00
Alexander von Gluck IV
a42249db2d arm: Add 8250 omap variant uart driver
* Untested, someone with an omap3,4,5 could though.
2017-11-20 09:16:58 -06:00
François Revol
0835170c80 Actually use the serial port and speed from the kernel settings
Turns out we just reused the already set values, disregarding the new ones.
2017-11-20 11:44:43 +01:00
Alexander von Gluck IV
f6c47144a6 kernel/uart: Refinements to irq and FIFO management 2017-11-18 13:20:53 -06:00
Jérôme Duval
f57e467bd8 Update libroot stubs. 2017-11-18 17:28:06 +01:00
Jérôme Duval
edfefa187b libroot/posix: remove useless keyword extern. 2017-11-18 17:28:06 +01:00
Alexander von Gluck IV
1d3d336a97 libbsd: Move lutimes to bsd compat
* Rework be149e8ccf since lutimes isn't posix
2017-11-17 14:27:26 -06:00
Augustin Cavalier
7d8eb4d7f9 time: Address review comments.
* Use ENOSYS not B_DONT_DO_THAT (thanks korli)
 * Use unsigned long not uint64 (thanks axeld)
2017-11-16 20:53:14 +01:00
Jérôme Duval
0e9000201f POSIX: shm_open: set the FD_CLOEXEC file descriptor flag...
on the new file descriptor.
Fixes #13774.
2017-11-16 16:46:37 +01:00
Alexander von Gluck IV
be149e8ccf libroot/posix: Add lutimes for better posix compatibility
* Didn't exist on BeOS, but exists most other places.
* Update times of a file, not following symbolic links.
2017-11-16 00:38:54 -06:00
Augustin Cavalier
9a50e01ea6 set_real_time_clock: Change parameter from uint32 to uint64.
This should have been done along with the time_t change, but I forgot
to check this then.

Technically this breaks ABI against BeOS, but:
  1. BeOS used an int32, so we'd already slightly broken ABI here
  2. Only one thing at HaikuArchives (VMwareAddons) and one recipe at HaikuPorts
     (samba) uses this function at all.

If it turns out some critical BeOS app uses this, then I guess we can enclose
GCC2 guards around it, but since I can't find any evidence of that, I'm
pushing it without them for now.
2017-11-15 18:28:04 +01:00
Augustin Cavalier
a7c323c633 libroot/time: set_timezone is deprecated and does nothing, so don't return B_OK. 2017-11-15 18:11:33 +01:00
Augustin Cavalier
304f594da1 De-wire net_stack_cleanup from boot/loader/main.cpp
This reverts commit 2960780faa.
Sorry for the noise; I thought I'd run a compile but apparently it was
only a partial one.

It seems that the netboot core is linked into the main bootloader
no matter the build configuration, which means that since this one
function was called, the linker tried to resolve all the other symbols
from that static library. Which of course failed.
2017-11-13 21:17:45 +01:00
Andreas Faerber
2960780faa Wire up net_stack_cleanup()
The NetStack.h header is currently not usable from C code. So while
net_stack_init() is called from platform code, we cannot call
net_stack_cleanup() from OpenFirmware's platform_start_kernel().
Thus call it directly from main()'s cleanup TODO, having assured
that the function is a no-op when no network stack was initialized.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-11-13 16:48:26 +01:00
Andreas Faerber
ce6fdd33ef Detach UDP sockets on cleanup
The UDP service does not own the UDP sockets. When shutting down,
inform the bound sockets that the service is no longer available.
This allows subsequent method calls to error out cleanly.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-11-13 16:48:09 +01:00
Andreas Faerber
74077e46e1 Add net_stack_cleanup()
Add a cleanup function net_stack_cleanup() that calls a new NetStack::ShutDown() method.
Make sure this method works even if the network stack was never initialized.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-11-13 16:47:27 +01:00
Andreas Faerber
9037351c6c Don't double-free the Ethernet interface
It is currently done in both ~EthernetService() and ~NetStack().

Since NetStack is where it's added and where an explicit accessor function is provided,
choose that location.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-11-13 16:46:32 +01:00
Jérôme Duval
4bb883d9bf posix_spawn(): use MAX_SIGNAL_NUMBER instead of NSIG.
* fish now works with posix_spawn().
2017-11-04 17:25:42 +01:00
Jérôme Duval
04dabcfdf3 posix_spawn(): close the pipe read fd in the parent.
* also enable close-on-exec for the eventually dupped pipe write fd in the child.
2017-11-03 23:13:49 +01:00
jua
1769813948 x86-64: handle stack fault for non-canonical address access
* With the amd64 architecture, the stack fault exception got a new
  meaning: it is raised when an instruction tries to access a
  non-canonical address, and the stack is referenced in the
  instruction (e.g. by its addressing mode).
  So unlike on x86, this is not a fatal exception and shouldn't
  trigger a KDL -- instead, it is to be treated like a general
  protection fault, terminating the team which caused it.

* Fixes #13744
2017-11-02 18:55:03 +01:00
Jérôme Duval
87e6718233 POSIX: have sysconf(_SC_OPEN_MAX) return the rlimit value.
* we use this value in posix_spawn_file_actions_adddup2() for instance, ninja then
fails with "Bad file descriptor".
2017-11-01 13:07:11 +01:00
Alexander von Gluck IV
403baf656d u-boot: mmc single case volume label
* Makes parsing slightly easier in tools like rune-image.
* Mixed case introduces some extra encoding the WIP Rust
  FAT driver doesn't support (yet)
2017-10-18 11:43:54 -05:00
Jérôme Duval
a295d3f46e wait4(): retrieve dead team entries usage information.
* This adds a parameter to the wait_for_child syscall. I extended the test case
to show the actual retrieved information.
* fix #13546
2017-10-10 17:20:46 +02:00
Augustin Cavalier
6aff37d1c7 Move SHA256 class to libroot instead of linking libshared into libroot.
Discussed with PulkoMandy and on the haiku-commits mailing list.

Thanks to @jessicah for compile-testing and fixing 2 small issues I missed.
2017-10-03 20:18:26 -04:00
Jérôme Duval
2976cf85a4 libroot.so: make first parameter of dladdr() const.
This follows up on a mail from 2011:
https://www.freelists.org/post/haiku-development/Changing-dladdr-to-take-const-void-for-first-parameter
2017-09-15 23:09:24 +02:00
Jérôme Duval
ccd42320c4 libroot: add posix_spawn(). 2017-09-12 19:42:57 +02:00
Jérôme Duval
31e6a56fb3 kernel/fs: fix warning on x86_64. 2017-08-24 18:01:12 +02:00
Jérôme Duval
26740b2889 POSIX: F_DUPFD_CLOEXEC support (POSIX.1-2008).
* fix #12187.
2017-08-24 17:54:50 +02:00
Jérôme Duval
c35666602f libroot: mktemp.c: fix gcc5 warnings. 2017-08-13 22:32:39 +02:00
Philippe Houdoin
22b7e29bc6 libroot: mktemp.c: use rand_r() and set seed only on first call
This avoid to break caller's own srand() and having the same seed
if called twice very quickly.
Thanks david.given for a better fix for #13660.
2017-08-10 10:33:41 +00:00
Philippe Houdoin
c7a3a80cc6 libroot: make mktemp() more random
... by seeding rand() with process id, user id and current time.
This fix #13660
2017-08-09 19:33:36 +00:00
Philippe Houdoin
2a081b42a9 fifo: revert broken fix 2017-08-03 16:53:17 +00:00
Philippe Houdoin
65abebfaa7 fifo: wakeup readers not checking POLLHUP/B_SELECT_DISCONNECTED
For readers waiting in select() or simply in read(),
B_SELECT_DISCONNECTED notification didn't wake them anymore.
Now, cascade notifications to be sure to wake them, either
on POLLHUP, POOLERR/B_SELECT_ERROR or, at worst, from read().

See #7859 for details.
2017-08-03 11:48:02 +00:00
Philippe Houdoin
216574f371 fifo: fix #7859 2017-08-01 18:37:38 +00:00
Jérôme Duval
6c9e01265b pthread_rwlock: use a mutex for process-private locks.
* instead of a benaphore.
* define PTHREAD_RWLOCK_INITIALIZER.
* adjust Init(), Destroy(), StructureLock() and StructureUnlock().
2017-07-27 18:33:53 +02:00
hyche
9f9ba0bdc1 btrfs_shell: Support AVLTree 2017-07-25 09:34:46 +07:00
Axel Dörfler
a1eceb4610 rootfs: directories must not be opened writable.
* Also added support for O_DIRECTORY while at it.
* This fixes bug #13573.
2017-07-20 10:10:20 +02:00
Jérôme Duval
2d4d0f0ac1 Revert "vfs.cpp: Fix gcc6 crash."
This reverts commit 5b55f6dba9.
2017-07-12 17:36:24 +02:00
Alexander von Gluck IV
0cc293cf32 raspberrypi_arm: Drop old Raspberry Pi 1 boot loader.
* We transitioned to u-boot quite some time ago
* We also are dropping < ARMv7 support
2017-07-11 14:39:13 -05:00
Murai Takashi
5b55f6dba9 vfs.cpp: Fix gcc6 crash.
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2017-07-11 17:24:07 +02:00
Alexander von Gluck IV
a01d0e5ae5 arm: Enable mmu tracing. (We're going to need it for a while) 2017-07-10 15:16:55 -05:00
Alexander von Gluck IV
aba7320584 u-boot/arm: Add missing floppyboot to mmc 2017-07-10 14:53:04 -05:00
Alexander von Gluck IV
f5d7446b5b u-boot: Correct loader base naming 2017-07-10 13:34:29 -05:00
Alexander von Gluck IV
1b3c81feeb u-boot: Fix mmc build without target boards 2017-07-10 09:02:56 -05:00
Alexander von Gluck IV
1e82d7bd25 kernel/arm: Work out more board_config's via fdt 2017-07-10 08:19:44 -05:00
Alexander von Gluck IV
e40cea64bd u-boot/arm: Initial steps to drop target board requirements 2017-07-09 22:51:50 -05:00
Alexander von Gluck IV
855fc5a0d3 platform/u-boot: Build all fdt's and include in u-boot mmc
* Eventually BoardSetups and target boards will go away.
* Include all known fdt's in the mmc image
* This gets us closer to target board-less arm
* Changing hardware is as simple as plugging a new fdt
  into u-boot's startup script.
* Drop my original rpi1 work.  We're targetting ARMv7
  minimum.
2017-07-09 22:19:51 -05:00
Alexander von Gluck IV
144e404b2d libroot/ppc: Add missing stack_trace 2017-07-04 19:28:13 -05:00
Alexander von Gluck IV
b3d3ee5a2f libroot/ppc: Stub out emitted GCC atomics on ppc32
* gcc will emit 64-bit (_8) atomic functions on 32-bit
  powerpc architectures. This stubs them out for now
  with a warning.
* We could do more here, but i'm just getting PPC
  bootstrapped to get the nightly builds going again.
* We could also just completely drop PPC.. but it was
  pretty close pre-pm... so I'd hate to lose that work.
2017-07-03 13:05:47 -05:00
Alexander von Gluck IV
9c8119e02c kernel/smp: Add a comment for some obsecure knowledge
* I was ready to rip this out until PulkoMandy set me stright.
* Add a comment so others understand the impact here.
2017-07-03 09:43:07 -05:00
Alexander von Gluck IV
7f47ae44c2 openfirmware: Fix build post get_boot_partitions changes
* Thanks jessicah!
2017-07-02 22:57:53 -05:00
Pedro Pinto
856da1f3ff Add missing include with Partition class definition
* Fixes a compilation error while compiling the u-boot loader for
  the ARM platform.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-06-23 17:30:27 -04:00
Augustin Cavalier
6ad3d25212 real_time_clock: Change _user_{get|set}_timezone argument to int32.
Both the user-mode syscalls.h and the kernel-mode one define it
as an int32, not a time_t, and as it's a timezone offset not
an actual time, there's no reason it needs to be one.
2017-06-06 17:38:17 -04:00
Augustin Cavalier
affb4e25fe runtime_loader: Remove EXEMODE hack.
This reverts commit 6af29d4f83.
I'll have a look at our buildbot config and see if it needs fixing.
2017-05-28 12:42:12 -04:00
Augustin Cavalier
6af29d4f83 runtime_loader: Ensure EXEMODE is set.
Stopgap solution for #12373.
2017-05-26 15:31:55 -04:00
James Woodcock
d7b12f71ea kernel/fs: Fix permissions on symlinks in root directory.
Various symbolic links (/bin, for example) in the root directory have
no read, write or execute permissions. This prevents non-privileved users
from logging in.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
Fixes #13530.
2017-05-26 15:10:18 -04:00
Rahul Jain
7ce3cbfbe8 "fail-safe video mode" is confusing.
The same wording was used for two unrelated things: using the VESA
driver, and forcing a specific resolution. Relabel the menu items to
make it clear that they are not related.

fixes #8887

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2017-05-25 11:46:02 +02:00
Alexander von Gluck IV
d8219f96da bootloader/bios: Add tracing of real-mode bios interrupt calls 2017-05-24 08:18:54 -05:00
Alexander von Gluck IV
9d9f76edff bootloader/hpet: Fix tracing on x86_64 2017-05-23 21:54:10 -05:00
Jessica Hamilton
f286626cd0 pxe_ia32: add missing include for boot::Partition 2017-05-17 23:21:40 +12:00
Jessica Hamilton
e888217124 loader: fetch all potential boot partitions for boot device.
This allows the loader to skip BFS partitions that don't contain
a bootable system. Useful when you have a BFS data partition that
comes before the system partition when iterated over.

Currently, only the UEFI loader actually returns more than one
possible partition.
2017-05-17 12:51:09 +12:00
Axel Dörfler
655aae6a79 KPathTest: Fix build for GCC 5.
* Also fixed a warning in KPath.
* Sorry, again!
2017-04-30 18:17:51 +02:00
Axel Dörfler
16825fd976 VFS: Pass on NULL for NULL paths, if allowed.
* Uses the new KPath::LAZY_ALLOC feature.
* This closes ticket #9625.
2017-04-30 17:37:17 +02:00
Axel Dörfler
e9843da357 KPath: Added LAZY_ALLOC flag.
* This allows KPath to not allocate a buffer when initialized
  without path.
* Added test cases for this.
* Added test for LockBuffer().
* Enhanced tests to allow building them in debug mode.
* Moved calling vfs_normalize_path() into own private method.
* Improved error codes; B_NO_MEMORY is now only returned if the
  allocation actually failed.
* If used with LAZY_ALLOC, Path() and LockBuffer() are now allowed
  to return a NULL path.
2017-04-30 17:14:45 +02:00
Axel Dörfler
f94671c33d KPath.Adopt(): Fixed path length.
* Issue was hidden due to inappropriate test values; changed test
  to uncover it.
2017-04-30 17:13:45 +02:00
Axel Dörfler
eac83fb33e KPath: Replaced booleans with flags field.
* No functional change intended; I chose the flags in a way that it
  should still work even if I missed a reference.
2017-04-30 17:13:39 +02:00
Axel Dörfler
e1b4aed0cb KPath: Fixed Normalize() return code, changed Leaf().
* Normalize() now returns the error code that vfs_normalize_path()
  returns.
* Leaf() now returns "" instead of "/" for the root. It's not used
  outside of KPath.
* Adapted RemoveLeaf() to deal with this correctly.
* "KPath = string" no longer changes the buffer size.
* Added missing operator tests for =, ==, and !=.
2017-04-30 17:13:33 +02:00
Axel Dörfler
4be518758d KPath.Adopt() fixed incorrect path/buffer length.
* The other object was left in an inconsistent state.
* This lets the unit test for Adopt() pass.
2017-04-29 19:03:16 +02:00
Axel Dörfler
3582d4fe85 Minor style cleanup. 2017-04-29 14:37:56 +02:00
Jessica Hamilton
10a1d9102e bootloader/efi: use B_PAGE_SIZE 2017-04-25 00:06:01 +00:00
Augustin Cavalier
17f5ac9149 libroot: Restore exit() call after debugger().
Thanks PulkoMandy for the review.
2017-04-14 18:29:29 -04:00
Augustin Cavalier
a5d208c7d6 libroot: abort() should behave like a crash, not just a 'failure' exit.
Calling debugger() means that the crash dialog will be shown, and so
users will not be left wondering why an app just spontenously disappeared.
2017-04-14 16:07:02 -04:00
Adrien Destugues
743088d40b Fix users of PAGE_SIZE
- Replaced by B_PAGE_SIZE where possible
- Enabled the _XOPEN_SOURCE feature define otherwise
2017-04-13 21:32:08 +02:00
Axel Dörfler
99ccb18d97 Kernel IOBuffer: Fixed potential memory leak.
* IOBuffer::FreeVirtualVecCookie() did not put the last physical page
  back. This was only an issue in case GetNextVirtualVec() wasn't
  iterated through the end, for example in case of an error.
* Fixed the condition when to put back a physical page; the current
  solution will also work with the generic page mapper implementation.
* This fixes the low hanging fruits of Ingo's comment in #5777.
2017-04-06 23:31:48 +02:00
Axel Dörfler
742b85c1f1 vfs: Let new_vnode() and publish_vnode() wait for busy vnodes.
* Both functions need to wait when encountering a busy vnode, in order
  not to create a race condition in combination with get_vnode().
* This should fix both #5262, and #9839.
* I did not implement Ingo's suggestion to burden the file systems with
  solving the problem for the following reasons:
  - I think the file system interface should be as simple as possible.
  - I can't think of a possible locking issue at least for BFS.
  - The solution on the file system side would look pretty similar to
    what the VFS already does or has to do (minus controlling the locking
    directly), so it would cause quite a functional duplication.
2017-04-02 14:30:45 +02:00
Alexander von Gluck IV
d8ce1a9fad x86/irq_routing: Convert panic into warning. Solves #13388
* Solves #13388 and likely a bunch of other bug reports.
* While this *is* an issue that can potentially be serious,
  there really isn't a risk of data loss or a system
  instability, only broken PCI devices. Show warning and
  keep going.
2017-03-20 14:10:14 -05:00
Alexander von Gluck IV
8eee7007cf x86/irq_routing: More tracing around fill_pci_info_for_entry 2017-03-19 17:44:11 -05:00
Alexander von Gluck IV
acdfec1189 x86/irq_routing: Improve trace information 2017-03-19 16:29:11 -05:00
Augustin Cavalier
59bdca5dd4 kernel/x86/arch_int: Style fixes.
Thanks Axel for the review.
2017-02-27 18:14:26 -05:00
Augustin Cavalier
0414166a29 kernel/x86/arch_int: Move cast after NULL check.
Spotted by Lioncash (via IRC). No functional change intended.
2017-02-25 15:28:25 -05:00
Lioncash
7c6caa8939 load_driver_settings: Add missing kernel_args_free() call to load_driver_settings_file()
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-02-25 15:16:07 -05:00
Jérôme Duval
85566e032d posix: add _POSIX_SEM_NSEMS_MAX.
* have _SC__SEM_NSEMS_MAX return _POSIX_SEM_NSEMS_MAX, a per team limit
instead of the global limit.
2017-02-21 20:17:16 +01:00
Jérôme Duval
0bec83a85a pthread: add const for pthread_mutex*_get*()
according to the spec. Fixes #13324.
* code style clean up.
2017-02-21 20:05:02 +01:00
Jérôme Duval
4f10ef40b9 pthread: check parameters for pthread_barrierattr_*pshared().
* fixes #13323.
2017-02-21 20:05:02 +01:00
Jérôme Duval
90acbbfecb pthread: have pthread_setschedparam return 0 on success.
* fixes #13299.
2017-02-14 20:48:43 +01:00
Augustin Cavalier
b6f76ebe71 s/OpenBeOS License/MIT License/ universally, as they're the same thing.
Fixes #8681.
2017-02-09 22:09:56 -05:00
Freeman Lou
aa3083e086 Style fixes to various parts of the system.
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

This patch was never applied after GSoC 2012. Rebase the parts that
still apply so we can close the ticket.

Fixes #9490.
2017-01-29 22:47:28 +01:00
Andrew Aldridge
f31b1a2faf Implement scrypt-based password hashing
Signed-off-by: Axel Dörfler <axeld@pinc-software.de>
2017-01-17 23:09:04 +01:00
Jessica Hamilton
92b9c8649b MultibyteToWchar: correctly handle UTF-16 surrogate pairs.
* Whilst in WcharToMultibyte, we correctly convert our UTF-32
  wchar characters to multibyte, the same wasn't done in
  MultibyteToWchar. Now, if we detect a leading surrogate,
  we'll re-read the multibyte sequence with space for a UTF-16
  pair, which allows U16_GET to correctly convert the UTF-16
  byte sequence into the needed UTF-32 codepoint.

Fixes #13184.
2017-01-12 06:39:55 +13:00
Jessica Hamilton
d2423e4b3c ICUCtypeData.cpp: format string fixes for tracing. 2017-01-12 03:33:11 +13:00
Jessica Hamilton
079ab7f0b1 ICU add-on: validate mbState->converter before attempting to close.
This resolves crashes in gawk with multibyte support.

Fixes #12515, #13103.
2017-01-12 03:33:04 +13:00
Jessica Hamilton
3d870da3cb UEFI: leave runtime memory identity mapped.
* We don't have kernel/userspace access to UEFI at this point
  either, and with some firmware, if we don't keep the
  runtime memory identity mapped, then the loader dies. This
  will fix booting on such machines, and shouldn't have any
  impact on already working machines.
2017-01-08 21:43:53 +13:00
Jessica Hamilton
6b4cbec040 UEFI: identify the boot partition to check that it's valid.
* Also modified EFI::Header to return the efi_table_header so
  that we can compare it to boot device partition table.
2017-01-07 21:26:25 +13:00
Jessica Hamilton
42e718f041 UEFI: improve boot support in devices.cpp
* Maintain a list of all MESSAGING_DEVICE_PATH and
  MEDIA_DEVICE_PATH handles, so we can avoid adding devices
  multiple times.
* Split up platform_add_boot_device() into separate functions
  for better readability (add_cd_devices, add_boot_device_for_image,
  etc.).
2017-01-07 21:26:23 +13:00
Jessica Hamilton
35b38c392e loader: get_boot_file_system() iterate over all devices found.
* This is useful for UEFI, as we can then add the device that
  contains the UEFI loader, as well as all CD devices. As a
  result, if the device with the UEFI loader doesn't contain
  a bootable BFS partition, it will then attempt the same for
  CD devices.
2017-01-07 21:25:23 +13:00
Jessica Hamilton
445b080ea3 UEFI: support selecting video resolution & vesa settings file. 2017-01-07 15:39:35 +13:00
Fredrik Holmqvist
1d8306654a Rewrote device handling in EFI boot-loader
This allows me to find and boot disks and cds(*)
platform_add_boot_device tries to find the disk of the EFI partition
As on other platforms if boot disk isn't found platform_add_block_devices
will be called.
platform_add_block_devices will find all block devices that arn't partitions as
they are handled by Haiku already.
Currently first found suitable partition will be selected.

TODO:
 * pass in partition UUID's as boot-loader arg to setup boot for
any partition.
 * Better cd detection
 * Better disk_identifier

*) vfs_boot.cpp is very restrictive when it comes to booting cds.
It either do very Anyboot check where boot partition should be at offset 0,
which isn't true for EFI. In my case it's not even on that disk.
Or it only allow data session partition types.
This is currently failing as the Anyboot partition type is BFS.
2017-01-06 19:43:08 +01:00
Fredrik Holmqvist
57b59d47c5 memset was done twice 2017-01-06 19:39:58 +01:00
Murai Takashi
57db30a752 find_paths.cpp: fix memory leak
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

fixes #13136
2017-01-01 11:38:13 +01:00
Dmytro Shynkevych
0e0f49e799 libroot: Implemented pthread barriers
This is an implementation of pthread barriers pursuant to the relevant specification.

Barriers are essentially a special case of conditional variables,
such that all threads waiting on one are woken up when the number of
waiters reaches a number provided at the initialization of the barrier.
In view of that, this implementation mimics the implementation of pthread_cond,
except it is more specialized and self-contained.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2016-12-30 11:32:04 +01:00
Jessica Hamilton
d2e18d6462 efi/video.cpp: style fix. 2016-12-23 18:58:26 +13:00
Jessica Hamilton
4419d699ec partitioning: pass along reference to parent when uninitializing.
* Fixes problems with setting the partition name after uninitializing
  a partition in DriveSetup. Previously, UninitializeJob() was
  followed by SetStringJob(), but the kernel was updating the
  change counter for the parent partition when uninitializing a
  partition, leading to SetStringJob() having an incorrect change
  counter for the parent partition. Now the parent change counter
  will be correct when SetStringJob() runs.
2016-12-23 18:53:15 +13:00
Jessica Hamilton
4ff3f10852 UEFI: improve setting up of the framebuffer.
* Even if we get dropped into the boot menu, we still want
  to have the framebuffer enabled, else we never switch
  back into graphics mode.
2016-12-19 20:18:31 +13:00
Jérôme Duval
9969137ced fork(): Follow-up fix to 17b2a3cfc.
* Ingo rightly noticed that the defer_signals counter is reinitialized on
  thread's user area creation. Setting the flag THREAD_CREATION_FLAG_DEFER_SIGNALS
  indeed gives the expected behavior, deferring signals until undefer_signals() is
  called in the child thread. Thanks for the review and fix suggestion.
* Added a simple test showing the values of the defer_signals counter after fork().
2016-12-18 09:44:03 +01:00
Jessica Hamilton
941c240ab0 libroot/fork: fix gcc2 compilation. 2016-12-18 14:42:06 +13:00
Fredrik Holmqvist
9e487d8d74 UEFI: serial debugging support.
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-12-18 14:41:54 +13:00
Jérôme Duval
17b2a3cfcb fork(): Defer signals and lock the heaps while _kern_fork().
* Also defer signals while registering fork hooks.
* While malloc provides fork heap hooks which lock the heaps and unlock/reinit,
  malloc_debug provides empty hooks.
* Ideas suggested by Ingo, patch reviewed by him. Thanks a lot!
* Also call fork parent hooks on failure.
* Solve locks-up when combining multithreading and process forking, should help
  with #13111.
2016-12-17 21:11:15 +01:00
Henry Harrington
e2b610b4b3 UEFI: CR0.WP must be set before entering the kernel.
If WP is not enabled then the kernel can freely write to read-only user
pages, which breaks copy-on-write.

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-12-14 06:02:19 +13:00
Jessica Hamilton
b521a45ec2 Revert "vm: Try harder to allocate early physical pages."
This reverts commit 21e3ac6cf5,
which was accidentally applied twice, missed during rebase.

Originally applied in 601b2f7eda.
2016-12-13 22:24:12 +13:00
Jessica Hamilton
48494219eb Add a dumb framebuffer driver.
This is separate to the VESA driver, as the VESA driver requires
using the VBE BIOS. Under UEFI, we don't have the VBE BIOS, nor
are we able to switch modes after leaving UEFI Boot Services, so
a dumb framebuffer driver seemed like the easier way to approach
the problem.

The framebuffer & vesa drivers now test for the presence of the
VESA_MODES_BOOT_INFO boot item to distinguish between which driver
to use. Also added check for the VESA mode count to determine
whether to add the VESA_MODES_BOOT_INFO item.

UEFI video updated to explicitly zero out the VESA and EDID
boot data.
2016-12-13 21:41:10 +13:00
Michael Lotz
1f7e5bde38 kernel: Fix NULL dereference in ThreadTimeUserTimer::Schedule().
The SpinLocker was always initialized to fThread->time_lock even though
fThread may be NULL. This looks like a simple oversight as the rest of
the method handles fThread being NULL and the team variants of these
timers have very similar logic and do the NULL check as well.

This fixes the last remaining KDL in the posixtestsuite.
2016-12-12 11:55:06 +01:00
Jessica Hamilton
25fa3b1b8a loader: fix defines affecting elf.cpp for other platforms 2016-11-14 23:46:10 +13:00
Jessica Hamilton
04f0d02a8f Jamfiles: fix TARGET_BOOT_PLATFORM tests to use = efi 2016-11-14 23:45:22 +13:00
Jessica Hamilton
f4ff9cb02c Merge branch 'uefi-support' 2016-11-14 03:21:59 +13:00
Nick Smallbone
a99a0c003d EFI: add support for SMP.
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 03:21:41 +13:00
Jessica Hamilton
ec239abcf5 EFI: implement mmu_map_physical_memory & mmu_free.
Also move cpu, acpi, hpet init into platform_start_kernel, as we
need an initialised heap for alllocating memory for recording
the mapped regions.
2016-11-14 03:21:41 +13:00
Jessica Hamilton
a7142a5037 EFI: add cpu.cpp from bios_ia32 2016-11-14 03:21:40 +13:00
Jessica Hamilton
a1d0102ee4 EFI: add support for HPET 2016-11-14 03:21:40 +13:00
Jessica Hamilton
6e6efaecdc EFI: add ACPI support
Also add support in the kernel to get the ACPI RSDP from the
bootloader, and pass onto the ACPI driver using get_boot_item.
2016-11-14 03:21:36 +13:00
Henry Harrington
82dcc31606 bootloader: Translate kernel args before adding them to kernel_args_range.
Chunks may be physically contiguous, but virtually disjoint. Adding
physical addresses may cause ranges to be merged incorrectly.

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 01:00:00 +13:00
Henry Harrington
21e3ac6cf5 vm: Try harder to allocate early physical pages.
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 01:00:00 +13:00
Henry Harrington
34a6dd6728 EFI: Initialize/load the GDT.
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 00:59:59 +13:00
Henry Harrington
b3215a6275 EFI: preliminary support for starting the kernel.
Enough to let the kernel to print hello, but not much beyond that.

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 00:59:56 +13:00
Jérôme Duval
33e68be479 Update libroot stubs. 2016-11-01 08:44:04 +01:00
Adrien Destugues
b5c858aa75 strptime: allow dates before 1900.
While struct tm makes things more confusing than they need to be,
nothing in the API prevents handling those. So let's just accept them.

Fixes some strange cases in the cookie test suite (with a cookie set to
expire in year 101 B.C.)
2016-10-30 20:23:43 +01:00
Adrien Destugues
4bc43f4368 style fix. 2016-10-30 09:17:00 +01:00
Jérôme Duval
58fb6344ae libroot: getlogin_r(): 32 is a valid length.
* also use LOGIN_NAME_MAX for the max length.
2016-10-29 22:39:32 +02:00
Adrien Destugues
61987fe7a2 runtime_loader: allow the ABI version symbol to be local.
Some libraries buildsystems (eg. zlib) somehow prevent the symbol from
being exported. We should fix that, but binaries with missing symbols
are already out there, so we need to handle them in any case.
2016-10-29 10:16:29 +02:00
Adrien Destugues
09c4bc5bd3 runtime_loader: fix getting ABI from gcc .comment
The format for the .comment string changed at some point, and this
fallback code would always fail for files built only with "new" versions
of gcc.

Also consider gcc 5 to be ABI version 4, since it is still compatible
with the old ABI (and provides a new one side by side).

See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
for infos on GCC ABI changes in GCC 5.
2016-10-23 22:23:06 +02:00
Ulrich Drepper
d2bd05420a glibc: (_IO_cleanup): Do not use locking when flushing ...
the buffers. Some thread might be using a stream.
2016-10-23 20:30:45 +02:00
François Revol
b1e2427d75 glibc: replace extern __inline with __extern_always_inline for ppc
As was done for x86 in hrev49774.
2016-10-22 15:53:57 +02:00
François Revol
72ddc912a6 PPC: make arch_framebuffer.h more like ARM version
Now the only difference is the physical address, which is returned as
phys_addr_t as should be.
2016-10-22 15:53:52 +02:00
François Revol
f4dc609dbe U-Boot: PPC: dump the start of the board_data struct
Not so useful but just in case...

Sadly, this struct is both compile-time and arch dependent :-(
2016-10-22 15:53:47 +02:00
François Revol
9e66f03165 U-Boot: PPC: Try to enable unaligned transfers
This however doesn't help with the 64bit float operations that
gcc emits when assigning the physical framebuffer address in kernel_args,
which is a packed struct...
2016-10-22 15:53:38 +02:00
François Revol
e57c83d9e4 U-Boot: PPC: make the shift calculation more obvious
It's the 11th bit, counting from the MSB, on the top 16 bits.
2016-10-22 15:53:24 +02:00
François Revol
1fe7e6711f PPC: call debug_uart_from_fdt with C++ linkage 2016-10-22 15:53:20 +02:00
François Revol
11642b7f2c PPC: arch_asm.S: style fix
Capitalize TODO & FIXME, gedit prefers those
2016-10-22 15:53:15 +02:00
François Revol
33c594f0c7 PPC: U-Boot: fix gUBootOS offset
Since the removal of some other variables we were overwriting some random function.
2016-10-22 15:53:07 +02:00
François Revol
ffb9ffb68d PPC: Use FUNCTION_END in arch_asm.S 2016-10-22 15:52:51 +02:00
François Revol
9d0098ec04 ppc/paging: Convert to new-style CPU management
* Aka, post-scheduler changes
* Luckily PPC paging code is very similar to x86 paging now
2016-10-22 15:52:46 +02:00
François Revol
f5f6d7e600 PPC: compile arch_exception*.S in cpu-specific objects 2016-10-22 15:52:38 +02:00
François Revol
8dc55498fa PPC: rename arch_exceptions_44x.S to arch_exceptions_440.S 2016-10-22 15:52:29 +02:00
François Revol
094525151d PPC: Split cpu-specific files into separate objects 2016-10-22 15:52:16 +02:00
François Revol
d66182742f PPC: Stub out 460 paging classes 2016-10-22 15:52:08 +02:00
François Revol
62caef87ce PPC: Restructure paging stuff to match other platforms
First attempt.

Totally untested.
2016-10-22 15:51:57 +02:00
Julian Harnath
b2ef1767a7 x86 kernel stack trace: make sure memcpy stays in bounds
* Commit 337c4ccf introduced usage of plain memcpy in
  get_next_frame_no_debugger(), when the frame is already
  known to be on the kernel stack. However, it also needs
  to check that the end of the frame is still within the
  stack bounds. Otherwise this can cause a KDL if bp does
  not point to a valid complete frame anymore and is
  near a page boundary. Although with commit e477b10c such
  cases should already be avoided, it's still safer to
  check this here in case of e.g. analyzing broken stacks.
2016-10-17 22:27:04 +02:00
Julian Harnath
e477b10cef x86 kernel stack trace: break when return address is zero
* No need to continue walking the stack when a zero return
  address is found, only bogus frames will follow

* Fixes KDLs seen when using the system profiler, due to
  a bug that will be fixed in the next commit...
2016-10-17 22:26:02 +02:00
Andreas Faerber
51777fe86c Revert r25895: Undo ppc linkhack workaround #6210 2016-10-16 12:52:02 -05:00