Commit Graph

2336 Commits

Author SHA1 Message Date
Augustin Cavalier
c2cbf95810 kernel: Add and fix ownership checks in mutex_destroy and mutex_transfer.
* mutex_destroy() only checked wether or not there were waiters,
   not if the lock itself was presently held by another thread.
   Now we do, which should make #15015 panic much earlier instead
   of trying to use freed memory.
 * mutex_transfer_lock() and recursive_lock_transfer_lock() did
   not check that the calling thread actually owned the lock.
   Now it does, which should trigger asserts if anyone tries
   to do this.
2019-05-02 16:07:39 -04:00
Alexander von Gluck IV
40fcf16358 kernel/riscv64: Add missing kernel_arg ranges to get build going.
Change-Id: Idf549a5e4d01e6dc8949ec1252296337e5ef970c
Reviewed-on: https://review.haiku-os.org/c/1380
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-04-05 14:29:23 +00:00
PulkoMandy
fea91fdc77 sparc: pci bus manager
Copied from PPC with the hooks for Apple hardware removed.
To be completed with the actual PCI bus implementation for Sun machines.
This is where we start doing machine specific stuff, apparently.

Change-Id: I06af4de9621e9d40593d153642478d928083e49a
Reviewed-on: https://review.haiku-os.org/c/1364
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-04-04 20:31:25 +00:00
PulkoMandy
e8f58ba4be sparc: fix bootloader build
- Add various missing jamfiles
- Add required implementation stubs
- Update openfirmware jamfiles for multiboot support
- Update linker rules for sparc loader

Change-Id: I2d06c7a4d33827f58d82946687003f9a0dcb1b7d
Reviewed-on: https://review.haiku-os.org/c/1329
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-04-04 20:31:25 +00:00
Alexander von Gluck IV
566e253f24 kernel: Fill remaining riscv64 architecture headers 2019-04-04 09:09:49 -05:00
Alexander von Gluck IV
5e06ebe141 kernel/arch/riscv64: Correct some architecture headers 2019-04-04 09:09:38 -05:00
Alexander von Gluck IV
45b21f00ce riscv64: Drop duplicate KERNEL_LOAD_BASE 2019-04-04 09:09:34 -05:00
PulkoMandy
3bfbec8336 sparc: More missing defines in platform headers
* Kernel is 64 bit, and we won't need a 32bit load base.

Change-Id: I729bab01c8f71083002db061e153b0e5052b9a1c
Reviewed-on: https://review.haiku-os.org/c/1326
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
2019-03-30 15:23:15 +00:00
Augustin Cavalier
fcf0b31fb9 bootloader: Add the network endianness macros to NetDefs.h.
This file contains all the protocol- and interface-related
definitions, so this seems to be where they belong.

Required following previous commits.
2019-03-26 21:51:42 -04:00
Andreas Faerber
e1b41d44a3 boot loader: Wire up net_stack_cleanup()
Add a platform cleanup hook before starting the kernel. The openfirmware
and PXE loaders clean up their network stack there, while the other
loaders currently do nothing.

This closes ticket #6166

Change-Id: I34765892dfd9b2310c6af97c9ff7d414afae49e5
Reviewed-on: https://review.haiku-os.org/c/50
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-26 20:25:19 +00:00
Jérôme Duval
9e1ce8ed92 kernel: tweak USER_SIZE.
Change-Id: Id0a4ad785bbd195e425dd32ca891dc4525bb3e18
Reviewed-on: https://review.haiku-os.org/c/1151
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-05 22:38:49 +00:00
PulkoMandy
a7c23bb4a9 kernel/arch/sparc: stubs to get the kernel to link
Add empty implementation of timer, elf, vm, debugger support, to let the
kernel link.

Also add the kernel linker script.

Change-Id: If0795fa6554aea3df1ee544c25cc4832634ffd78
Reviewed-on: https://review.haiku-os.org/c/1108
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-03 20:56:20 +00:00
PulkoMandy
c1566b1555 sparc: more platform headers
Previous commit adding these was merged very quickly, so here's one
more...

Change-Id: I23c424db7631db1f0ec48e2d0ae47c8409ae6af2
Reviewed-on: https://review.haiku-os.org/c/1088
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-03 20:56:20 +00:00
Alexander von Gluck IV
05dda88dc1 headers/riscv64: Implement basic arch headers
Change-Id: I6bfbacb61eae84ffebc30c2565683348d684d88f
Reviewed-on: https://review.haiku-os.org/c/1063
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-02-26 14:50:35 +00:00
Adrien Destugues
5629675a32 sparc: add defines and minimum set of required files
Gets the stage0 bootstrap to run.
Imlementation is probably nonsense at this point.

Change-Id: I10876efbb54314b864c0ad951152757cdb2fd366
Reviewed-on: https://review.haiku-os.org/c/1061
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-02-23 16:30:50 +00:00
Augustin Cavalier
01796e78f4 kernel/x86: Re-introduce the 1MB lower barrier.
It was removed in 2008 to make VM86 work, which is now gone.

Fixes #14911.
2019-02-20 15:37:06 -05:00
Augustin Cavalier
6b0251e1bd syscall_args: Remove R5 compatibility hack. 2019-02-17 13:06:49 -05:00
Augustin Cavalier
58852727a3 BOpenHashTable: We need std::nothrow, so don't depend on others to include it.
Change-Id: Ibe21cef215a730f88eeea499c305a54ce397aeba
Reviewed-on: https://review.haiku-os.org/c/1039
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2019-02-13 10:29:24 +00:00
Augustin Cavalier
1c1efa6f2f kernel/x86: Use volatile in restore_interrupts.
We already use it in enable_interrupts, so we might as well
use it here too.
2019-01-07 22:12:36 -05:00
Rob Gill
6086986d30 kernel/x86: additional msr and cpuid items
Adds SSBD and L1TF related items

Change-Id: Iccea2bb9e057e0d011a18609212f175f9b5e678d
Reviewed-on: https://review.haiku-os.org/825
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2019-01-04 19:06:05 +00:00
Michael Lotz
13beda00d3 kernel: Fix race condition when waiting for load of new team.
There was no synchronization of the check of the done flag and the
waiting thread suspending to wait for it. It was therefore possible that
the new team both set the flag and triggered the wakeup of the waiting
thread in that time window, causing it to miss both the set flag and the
thread resumption.

Use a condition variable instead.

Fixes #13081.

Change-Id: I93c45db8dd773fe42b45c4b67153bcd39e200d3b
Reviewed-on: https://review.haiku-os.org/803
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-12-26 23:48:41 +00:00
Augustin Cavalier
08858e10fa kernel_cpp: Don't import all of the "std" namespace.
This file is included, directly or indirectly, by most of the
kernel-space C++ code, and so importing the entirety of "std"
seriously pollutes the global namespace.

So instead, just import "std::nothrow", which is the only thing
we really want in the global namespace. Tested on both GCC2
and GCC7 and seems to work just fine.

While I'm here, also update the include guards and copyright
header to match the standard format used elsewhere.
2018-12-10 19:44:07 -05:00
Augustin Cavalier
6b83d77fb7 smp: Make {acquire|release}_read_seqlock_inline cast explicitly.
Also fix braces.
2018-12-09 23:01:42 -05:00
Augustin Cavalier
86c12bf05b kernel: Initialize all fields of rw_lock in RW_LOCK_INITIALIZER.
Spotted by Clang.
2018-12-09 23:01:11 -05:00
Augustin Cavalier
47b079afc9 Debug.h: Implement a real STATIC_ASSERT on non-GCC2. 2018-08-22 19:19:54 -04: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
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
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
3a72e3ebee ARM64: Add initial kernel headers
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
aarch64 -> arm64 and coding style fixes by me.
2018-08-02 20:10:13 -04: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
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
Augustin Cavalier
9ac3062734 kernel: Small fixes for Clang. 2018-06-18 19:32:13 -04: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
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
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
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
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
c7c3973e09 kernel: generic user_memcpy now saves the old state.
fixes #14135.
2018-05-16 06:58:33 +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
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
3a764d6a12 kernel: x86: add some msr and cpuid features
* for arch capabilities.
* for spec ctrl and pred cmd.
2018-04-22 18:03:16 +02:00