Commit Graph

6744 Commits

Author SHA1 Message Date
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
e6c9be767b sparc: interrupt management functions
Change-Id: Icc689cc0cc0075fbccdad23f77cfa53b1f32df3c
Reviewed-on: https://review.haiku-os.org/c/1107
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
PulkoMandy
5f49c55851 m68k: simplify a Jamfile.
I'm copypasting a lot from this, so I may as well clean it up while I'm
at it.

Change-Id: I9288c087abbf95475f980b5539f2fd19fad7f775
Reviewed-on: https://review.haiku-os.org/c/1136
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-03 20:56:20 +00:00
Augustin Cavalier
fb1dd50ee7 kernel/fs: Make fs_mount::lock a mutex instead of a recursive_lock.
Solves a TODO.
2019-02-25 16:11:08 -05:00
PulkoMandy
6f7d94a13d vm: fix stack erase when printing 64bit value
Getting 64 bytes of data in a 32 bit variable is a bad idea

Change-Id: I760e1cfb996a9be053dbc50d6610b3e865cde65d
Reviewed-on: https://review.haiku-os.org/c/1096
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-02-23 23:50:37 +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
aa5cb68bc6 kernel/fs: NULL is a valid buffer to pass to ioctl().
Another bug exposed by hrev52905. Discovered because Expander was
not displaying archive contents anymore.
2019-02-21 22:12:32 -05:00
Augustin Cavalier
03d1fd2b7e kernel/elf: Ignore PT_EH_FRAME for kernel add-ons.
We do the same thing in runtime_loader. Silences a lot
of warnings.
2019-02-21 17:06:09 -05:00
François Revol
d18fe1c54c loader: disable scaling on nvidia VESA BIOS
cf. https://patchwork.kernel.org/patch/7113461/

Change-Id: I3f564bd1037aeb4b539f495d57397446ae14e5ed
2019-02-21 05:28:56 +01:00
François Revol
38c4c8bfa9 kernel: fix mount arguments checks from userland
Since NULL is not considered a user address anymore, we must check for
it first.

This fixes the "mount: Bad address" error after hrev52905.

Change-Id: If60ea58bb81b6c35c6bf27ecfa9b29bd7a25d8aa
2019-02-21 03:14:23 +01:00
Augustin Cavalier
10aa58d7c3 kernel/vm: Make sure the base address is larger than fBase.
This is technically only a functional change following the previous
commit, which unconditionally made sure the address was larger than
the base except for B_EXACT_ADDRESS. Essentially this makes sure
that if an address is passed which is smaller than the base is
passed in, it won't immediately fail just by being too small.

Checked against BeOS (0x0 passed to create_area with B_BASE_ADDRESS
succeeds, and returns 0x2000 consistently.) This is also needed
to not break userland initialization following the next commit.
2019-02-20 15:33:32 -05:00
Augustin Cavalier
836a9548e0 kernel/vm: Remove VM86-related address space hacks.
VM86 was removed in 2012, so these are no longer needed.
The USER_BASE vs. USER_BASE_ANY distinction still seems like a
potentially useful one, though, so I've left all those changes in.
2019-02-20 13:28:25 -05:00
Augustin Cavalier
13c4bc94ca kernel: Undo changes to pinned threads and blocking.
This reverts commit 58ed2965d0.
This reverts commit 055d49b1fd.

I was mistaken, it is perfectly legal to block a pinned thread.
It seems we'll need some other way to detect invalid context
switches.
2019-02-20 10:34:18 -05:00
Augustin Cavalier
055d49b1fd kernel/x86: Pin the current thread before calling interrupt handlers.
int_io_* functions do not touch the thread state, but we already have
it here as we will modify its contents later, so it makes more sense
to set this flag here.

This is mostly only relevant following the previous commit, i.e.
finding interrupt handlers that brokenly try to context-switch.
2019-02-19 21:38:15 -05:00
Augustin Cavalier
58ed2965d0 kernel: Panic on attempts to block a pinned thread.
Preventing "normal" context switches caused by a time interrupt
is the primary reason for pinning threads. "thread_block" and friends,
however, cause an explicit context switch and will not return until
another thread unblocks us.

Calling these while a thread is pinned is thus undefined behavior,
and so we should just panic in the case anyone attempts to do so.
2019-02-19 21:35:39 -05:00
ahenriksson
8497a2cc28 vfs: functions to change a vnode busy status and ID
The kernel version is only partially tested.

Change-Id: I9a2f6c78087154ab137eadbced99062a8a2dd688
Reviewed-on: https://review.haiku-os.org/c/918
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-02-19 18:44:43 +00:00
Augustin Cavalier
c62142a72b kernel: Add missing NULL check to _user_xsi_semget.
Private semaphores will have a key of -1, but IPC_PRIVATE is 0,
meaning it is possible to wind up here and get a NULL semaphoreSet
if someone passes us an argument of -1.

Reported on Twitter.
2019-02-18 23:24:28 -05:00
Augustin Cavalier
c054900882 kernel: Sanity-check interrupts in snooze().
This didn't trigger any panics on my bare-metal dev install when tested,
but it might explain some easily-reproducible hardlocks (i.e. can't
even drop to KDL via emergency keys) I was seeing on other machines.
2019-02-17 14:36:16 -05:00
Augustin Cavalier
1eededf17f kernel: Only sanity-check interrupts in switch_sem_etc under KDEBUG.
"are_interrupts_enabled()" is a "relatively" expensive function, so avoiding
it makes sense. This is the same way it's done elsewhere in sem.cpp, as well
as for mutexes and condition variables also.
2019-02-17 14:34:36 -05:00
Augustin Cavalier
eff1e73cef shared: Merge BOpenHashTable in; remove OpenTracker's OpenHashTable.
The HashMap and HashSet classes are copied from userlandfs. The
HashMap one works as-is as it's already used in userlandfs; the
HashSet does not even compile yet.

Change-Id: I1deabb54deb3f289e266794ce618948b60be58c0
Reviewed-on: https://review.haiku-os.org/c/1041
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-02-15 00:34:36 +00:00
Augustin Cavalier
f167d21adc runtime_loader: Use a RecursiveLocker instead of manually unlocking.
No functional change intended.
2019-02-11 16:35:33 -05:00
Jérôme Duval
f33f4868fe posix_spawn: add posix_spawn_file_actions_add[f]chdir_np.
see http://austingroupbugs.net/view.php?id=1208
and https://sourceware.org/bugzilla/show_bug.cgi?id=17405

* also free paths in posix_spawn_file_actions_destroy().

Change-Id: I8bed848154025bd5a25322bdc4c25aa417f86ec6
Reviewed-on: https://review.haiku-os.org/c/1010
Reviewed-by: Rene Gollent <rene@gollent.com>
2019-02-06 16:39:33 +00:00
Jérôme Duval
af61539918 posix_spawn: add POSIX_SPAWN_SETSID.
see http://austingroupbugs.net/view.php?id=1044

Change-Id: I9ae4fe07ea0fa7e20eb9a1d8c64e971e7353bcff
Reviewed-on: https://review.haiku-os.org/c/1008
Reviewed-by: Rene Gollent <rene@gollent.com>
2019-02-04 19:21:30 +00:00
ahenriksson
b9256c155b disk_device_manager: implement KFileSystem::Resize()
Change-Id: I122a3881b0d0a8febc23c9751d5e32018c26da5e
Reviewed-on: https://review.haiku-os.org/c/920
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-02-04 16:37:35 +00:00
Augustin Cavalier
fa03522846 libroot: Revert changes to hide BeOS-only functions.
I wasn't thinking correctly when I made the previous change --
init_term_dyn is compiled into all applications, and so these
functions need to remain in order to not break them.
2019-02-02 18:09:28 -05:00
Augustin Cavalier
15a4183640 libroot: Move some BeOS-only API calls behind _BEOS_R5_COMPATIBLE_.
This is defined by our build system on GCC2 only, so they will now
be excluded under all other architectures.
2019-02-02 14:36:26 -05:00
Augustin Cavalier
06d77ca653 libnetwork: Remove not-so-useful printf.
We don't really need to see in syslog when an application is
running in R5 compatibility mode.
2019-02-02 14:20:16 -05:00
Augustin Cavalier
8270254464 libnetwork: Rename find_own_image() to set_own_image_location().
Thanks Axel for the review!
2019-02-02 14:01:30 -05:00
Augustin Cavalier
67ef9f72fc network: Utilize image_id argument to initialize_before.
We don't need to search for our own image_id, we already have it now,
so just use it.
2019-02-01 20:33:41 -05:00
Augustin Cavalier
c5e4e4ffb4 headers/kernel: Include declarations of initialization functions in image.h.
No "real" functional change, but this causes GCC7 to throw errors when
these functions are declared without the image_id argument, which
in some files they were (as this commit repairs.)

This change is largely inconsequential on x86, but on callee-cleanup-args
targets, leaving out the argument would probably cause stack corruption.
2019-02-01 20:30:39 -05:00
Augustin Cavalier
475172337b headers/kernel: Move B_WAIT_TILL_LOADED to a syscall header.
It is only used as an argument to _kern_load_image directly, not to
any of the load_image functions in image.h, so it belongs in a syscall-
specific header like other such constants.

No functional change intended.
2019-02-01 19:45:56 -05:00
Augustin Cavalier
32d4274178 kernel/team: Use a rw_spinlock to guard the sTeamsHash.
Virtually identical to my prior change to sThreadsHash.
2019-01-31 20:09:10 -05:00
Augustin Cavalier
5796ecc706 kernel/thread: Add proper permissions checks.
* Add a utility thread_check_permissions(), which takes the target
   thread, the calling thread, and whether or not this is a "kernel" call,
   and then returns whether the target thread may be legally modified.
 * Refactor all calls that operate by sending a signal to the thread
   into a single thread_send_signal() utility function, which now uses
   thread_check_permissions() appropriately.
 * Manually add the permissions checks to other functions as needed.

Solves a bunch of decade+-old TODOs.
2019-01-31 20:05:39 -05:00
Augustin Cavalier
d745129c7a kernel: Mark TeamThreadTable::GetIterator() const.
We use it only while holding a "read" lock, so it must be.
2019-01-31 20:03:28 -05:00
Alexander von Gluck IV
cf77ef1857 haiku_loader: Toss iSCSITarget, add TCP stack to loader.
* This iSCSI implementation only worked on PPC big-endian atm.
* We're pretty sure iSCSI support in haiku_loader doesn't make
  much sense anymore. iPXE on (on arm,x86,etc EFI/BIOS platforms)
  supports iSCSI boot of disks.
* Haiku could use a iSCSI driver add-on, but it would exist much
  higher up and likely use standard drivers vs bare-minimum iSCSI
  target impementations.
* Leaving TCP and adding to all arches since it could make sense
  for haiku's native network disk subsystem or network debugging?

Change-Id: Ic181b93a1d8ffd77f69e00e372b44b79abbddb42
Reviewed-on: https://review.haiku-os.org/c/899
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-01-28 16:47:08 +00:00
Augustin Cavalier
354b60af29 runtime_loader: Rework static initialization handling.
Previously, static initializers were just in ".ctors", which was handled
by GCC's crtbeginS, and that was injected in-between crti and crtn. Now,
however, binutils puts static initializers into init_array/fini_array by
default, which runtime_loader handles, but of course as initialize_after and
terminate_after are supposed to be called *after* all static initializers
are called; and since runtime_loader called init_array after _init, they
were not.

Now, we get rid of the __haiku_init_before/etc. functions, and move their
functionality inside runtime_loader. This is a "soft" ABI breakage,
which is mitigated by adding another ABI breakage (runtime_loader now
returns NULL for the initialize_before/etc. symbols, as otherwise
old applications would have their initialize_before/etc. called twice;
once by runtime_loader, and then once by __haiku_init_before/etc.)

I don't see or know of any reason why an application would want to
get those symbols at runtime, though, so this shouldn't have any
adverse effects.

Change-Id: I42344c63f69c6f8ef260f6c3ca30202b6dfb153e
Reviewed-on: https://review.haiku-os.org/c/907
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-01-28 16:37:28 +00:00
Andreas Faerber
9091349139 Add syslog output support to bootloader
Broadcast console output as syslog debug messages, stripped of trailing newlines.
Disabled by default.

Patch from #6168.

Change-Id: I1754381477dcde00bdcfa4482017daf5eb682cd3
Reviewed-on: https://review.haiku-os.org/c/912
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2019-01-27 16:51:32 +00:00
Augustin Cavalier
79456ebd5b libroot: Fix build under GCC 7. 2019-01-22 23:56:59 -05:00
Augustin Cavalier
2b4b201847 libroot: Call abort() only if a signal handler is installed.
Preserving the assert failure message in debug reports is desirable,
so if possible we should do so, not just print it to stderr. So
now we reuse the same trick from abort() directly.

Sorry for the extra noise; I should have combined these commits.
2019-01-22 22:02:59 -05:00
Augustin Cavalier
7282d46cef libroot: Style cleanups in assert.c. 2019-01-22 21:53:08 -05:00
Augustin Cavalier
f52bb5ce10 libroot: Call abort() instead of debugger() from assert().
As per the POSIX specification.

This gives the calling program a chance to catch the assertion. But
in the case where no signal handler is installed for SIGABRT, we
will call debugger() anyway and present as a crash as before.

Fixes #10295.
2019-01-22 21:50:17 -05:00
Augustin Cavalier
f22ee592d6 kernel/vfs: Fix shadowed variables.
The -Werror=uninitialized caught this, but I fixed it the wrong way
rather than looking at the code a little closer.

Should fix the strange bugs that cropped up after the first VFS patch.
2019-01-22 21:37:15 -05:00
Augustin Cavalier
3f77fdd1d2 kernel/vfs: Fix -Werror=maybe-uninitialized. 2019-01-22 12:47:07 -05:00
Leorize
cb0d3bd341 kernel/fs/vfs: add truncation check for user_strlcpy calls
**Lots** of syscalls here don't check if strlcpy truncated the user
supplied argument. This commit adds them where appropriate.

Closes #2642

Change-Id: Iff89055aeb3a1870c8baf327b60873ce85815cd7
Reviewed-on: https://review.haiku-os.org/c/890
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-01-22 17:00:05 +00:00
Leorize
b9c25b0d0e unistd: introduce nice()
This commit implements nice() as specified in POSIX.1-2008.

Fixes #4932.

Change-Id: Ibd8d4636d9e3a8adf0f26a081d5b1180f0cbb839
Reviewed-on: https://review.haiku-os.org/c/863
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-01-19 18:31:58 +00:00
Timothy Gu
8ae2e95643 libroot: add [gs]etpriority implementation
Implemented against POSIX-1.2013.

The implementation POSIX requirement thats setpriority() shall affect the
priority of all system scope threads only extends to POSIX threads. This
is implemented by modifying the default attributes for newly spawned
pthreads.

It is not possible to modify the default pthread attributes for different
processes with the current implementation, as default pthread attributes
are implemented in user-space. As a result, PRIO_PROCESS for which and 0
for who is the only supported combination for setpriority().

While it is possible to move the default attributes to the kernel, it
is chosen not to so as to keep the pthread implementation user-space only.

POSIX requires that lowering the nice value (increasing priority) can be
done only by processes with appropriate privileges. However, as Haiku
currently doesn't harbor any restrictions in setting the thread priority,
this is not implemented.

It is possible to have small precision errors when converting from Unix-
style thread priority to Be-style. For example, the following program
outputs "17" instead of the expected "18":

	#include <stdio.h>
	#include <sys/resource.h>

	int
	main()
	{
		setpriority(PRIO_PROCESS, 0, 18);
		printf("%d\n", getpriority(PRIO_PROCESS, 0));
		return 0;
	}

The underlying reason is because when you setpriority() both 18 and 19
are converted to the Be-style "2". This problem should not happen with
priority levels lower than or equal to 20, when the Be notation is more
precise than the Unix-style.

Done as a part of GCI 2014. Fixes #2817.

Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Co-authored-by: Leorize <leorize+oss@disroot.org>
Change-Id: Ie14f105b00fe8563d16b3562748e1c2e56c873a6
Reviewed-on: https://review.haiku-os.org/c/78
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-01-19 18:31:58 +00:00
Augustin Cavalier
a526bddb8d bootloader: Add missing NULL check. 2019-01-16 20:37:07 -05:00
Augustin Cavalier
1fef0f0fa8 bootloader: Use the already-detected filesystem module...
...rather than enumerating again. Solves a TODO (all filesystems
save tarfs and packagefs, which require special parameters and
of course will not be on standard "partitions", have implemented
the required function.)
2019-01-16 20:33:12 -05:00
Augustin Cavalier
20f6556bff kernel/x86: Backslash-escape trigraphs.
Fixes an instance of -Wtrigraphs.
2019-01-16 19:32:16 -05:00