Commit Graph

1121 Commits

Author SHA1 Message Date
Jeremy Soller 2aa4d8caf5 Merge remote-tracking branch 'origin/aarch64-rebase' into riscv64 2021-05-03 20:52:59 -06:00
Jeremy Soller 17c261553b Fixes for building x86_64 2021-05-03 20:43:18 -06:00
Jeremy Soller dfdb562e6b Use RMM PhysicalAddress 2021-05-03 20:33:31 -06:00
Jeremy Soller 9f0532b1d5 Remove unused flags from old EntryFlags 2021-05-03 17:29:55 -06:00
Jeremy Soller b9448274fc Switch to using RMM PageFlags 2021-05-03 17:28:08 -06:00
Jeremy Soller 826180659c Update rmm and syscall 2021-05-03 17:16:59 -06:00
Jeremy Soller ff8cb8abe8 Enforce must_use 2021-05-03 15:02:32 -06:00
Jeremy Soller dd0616cc8f Use RMM for TLB flushing 2021-05-03 12:42:16 -06:00
Jeremy Soller 29460e0bff Use RMM for some arch-specific paging functions 2021-05-03 12:14:49 -06:00
Jeremy Soller ad39568fe9 Fix unwrapping stack when there are kernel addresses (and there always are) 2021-05-02 19:53:31 -06:00
4lDO2 af17eeec3a Give schemes a dangling address for empty slices.
This allows schemes to avoid checking the length against zero before
constructing a slice from pointer+len that the kernel gave.
Additionally, the address is now non-canonical on x86, meaning that
userspace will fail instead of continuing with UB, if they would ever
forget to check the length.
2021-04-29 07:40:50 -06:00
Jeremy Soller 73c77d756d Print context name in exception 2021-04-28 21:15:21 -06:00
Jeremy Soller 37e6951501 Print CPU and PID when exception occurs 2021-04-28 20:59:52 -06:00
Jeremy Soller d331f72f2a Use UTF-8 for all paths 2021-04-28 20:06:07 -06:00
Jeremy Soller 8fcd375bd9 Switch Context::grants to RwLock 2021-04-28 20:04:27 -06:00
Jeremy Soller 41bea0086f Switch Context::actions to RwLock 2021-04-28 20:03:29 -06:00
Jeremy Soller 83dea72a50 Switch Context::files to RwLock 2021-04-28 20:03:25 -06:00
Jeremy Soller c7aba8fdfd Switch Context::cwd to using RwLock 2021-04-28 20:03:18 -06:00
Jeremy Soller a9bee0bbdc Require UTF-8 for context name 2021-04-28 20:03:12 -06:00
Jeremy Soller b26c3e0ae9 Make context name a RwLock 2021-04-28 20:03:05 -06:00
Jeremy Soller f90033e0e1 Use PHYS_OFFSET instead of KERNEL_OFFSET to refer to the physmap 2021-04-13 20:38:54 -06:00
Jeremy Soller afca4da382 Update syscall 2021-04-13 19:34:38 -06:00
Jeremy Soller 959a917ba2 Update RMM 2021-04-13 19:34:27 -06:00
Jeremy Soller 5fe8dcf6af Merge branch 'chown-perms' into 'master'
UserScheme: permission check EUID and EGID before proceeding with chown

See merge request redox-os/kernel!176
2021-03-21 13:02:41 +00:00
Joshua Abraham ee6493d02e UserScheme: permission check EUID and EGID before proceeding with chown
Fixes redox#1327.
2021-03-20 20:42:02 -05:00
Jeremy Soller 47048102ef Fix typo in ContextList 2021-03-02 19:57:44 -07:00
Jeremy Soller b8e47f6b8f Merge branch 'fix-invalid-grant-state' into 'master'
Fix "Grant should not exist" errors.

See merge request redox-os/kernel!174
2021-03-02 13:30:03 +00:00
4lDO2 031496ff0d Fix "Grant should not exist" errors.
This is done by making sure that when empty() is called on a context,
the grants Arc will be replaced with a new unused Arc, hence
decrementing the refcount. Previously this was only done when the
context was actually reaped, but since there is no guarantee as far as I
am aware about when this must happen, the grants could be completely
leaked, leading to the error.
2021-02-27 15:36:12 +01:00
Jeremy Soller f873fc7e1a Merge branch '4lDO2/kernel-use_gs_for_tls' 2021-02-23 09:21:00 -07:00
Jeremy Soller ba330ffc9a Merge branch 'fix-utf8-userspace-ub' into 'master'
Give schemes a dangling address for empty slices, fixing UB in userspace

See merge request redox-os/kernel!172
2021-02-23 16:17:30 +00:00
4lDO2 ad58ca1de6 Give schemes a dangling address for empty slices.
This allows schemes to avoid checking the length against zero before
constructing a slice from pointer+len that the kernel gave.
Additionally, the address is now non-canonical on x86, meaning that
userspace will fail instead of continuing with UB, if they would ever
forget to check the length.
2021-02-20 17:20:30 +01:00
4lDO2 bdc925d275 Use GS for TLS!
Previously, the kernel used the regular FS segment for Thread-Local
Storage. The problem however, is that userspace code also uses FS for
TLS, meaning that the kernel would have to switch the FS segment between
user and kernel, _upon every syscall_. This is obviously suboptimal for
performance (especially with fast syscalls such as futex, nanosleep, or
yield).

I had to search LLVM for hours, just to find out that the insertion of
the memory load with FS was actually done in the linker, so I added a
flag for that.

I haven't done any proper benchmarking, but the boot process seems to
have gotten much faster!
2021-02-17 14:44:45 +01:00
Jeremy Soller a283160c14 Merge branch 'sysretq-fix2' into 'master'
FIX: Forbid lower-half noncanonical addresses too.

See merge request redox-os/kernel!170
2021-02-17 13:32:26 +00:00
4lDO2 1988583e23 Forbid lower-half noncanonical addresses too. 2021-02-17 13:00:07 +01:00
Jeremy Soller 98af1405e6 Merge branch 'sysretq-fix' into 'master'
Fix mistyped instructions in sysretq

See merge request redox-os/kernel!169
2021-02-15 19:12:05 +00:00
4lDO2 a4b3af34a5 Use correct jump instruction. 2021-02-15 20:05:00 +01:00
4lDO2 c19581282d Use the correct add instruction when popping CS. 2021-02-15 20:02:35 +01:00
Jeremy Soller 2a9b7a0fc8 Merge branch 'sysretq' into 'master'
Use faster sysretq when returning from system calls

See merge request redox-os/kernel!168
2021-02-15 18:59:19 +00:00
4lDO2 8eb58891aa Simplify sysretq code. 2021-02-15 19:53:49 +01:00
4lDO2 5b2df9f504 Document why usermode() can omit rcx check. 2021-02-15 19:53:49 +01:00
4lDO2 ff33090fd0 Check whether RCX is canonical in sysretq. 2021-02-15 19:53:41 +01:00
4lDO2 a183953ee8 Motivate usage of the IST without SWAPGS involved. 2021-02-15 19:53:37 +01:00
4lDO2 a3583a10ce Only swapgs when leaving/entering userspace code. 2021-02-15 19:53:37 +01:00
4lDO2 05db0f5977 Temporarily fix sysretq by swapping gs 4 times.
In order words, it swaps gs both directly at the start of the syscall
handler, then swaps it back, and the at the end of the syscall handler.
I cannot tell for sure why this is necessary, but probably since some
interrupt handler will execute swapgs in the wrong order or something.
2021-02-15 19:53:37 +01:00
4lDO2 1a8016b985 Give NMI, #DF, and #MC handlers a special stack.
This is done by allocating an extra 64 KiB per CPU, and putting it in
the Interrupt Stack Table.
2021-02-15 19:53:37 +01:00
4lDO2 5a638691e0 Treat GS as always pointing to TSS in kernel space. 2021-02-15 19:53:37 +01:00
4lDO2 c913c3be80 Use sysretq in usermode(). 2021-02-15 19:53:24 +01:00
4lDO2 a8dc3fcaf1 Begin using sysretq in the system call handler. 2021-02-15 19:53:01 +01:00
Jeremy Soller 6db78cce24 Use UTF-8 for all paths 2021-02-14 13:45:03 -07:00
Jeremy Soller 11b5e2fe59 Merge branch 'switch_to_safer' into 'master'
Prevent possible UB, and use naked functions correctly.

See merge request redox-os/kernel!167
2021-02-13 22:42:18 +00:00