aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-10-27cheri: Implement 128-bit atomicsSzabolcs Nagy
Arm Morello requires 128-bit atomics.
2022-10-27cheri: elf: Use elfptr_t in _dl_protect_relroSzabolcs Nagy
Derive the start of the relro area from the RW capability of the dso.
2022-10-27cheri: fix static linking TLS setupCarlos Eduardo Seo
Use the per module RW capability to access the TLS initimage. The bounds are not restricted for now.
2022-10-27cheri: elf: elfptr_t fixes for preinit/init/fini arraySzabolcs Nagy
According to the ELF spec: "Each element of this array is a pointer to a function to be executed by the dynamic linker." "Note that the address of a function need not be the same as a pointer to a function as defined by the processor supplement." so these should be accessed via uintptr_t type instead of ElfW(Addr) and the pointers are derived from the RX pointer of the elf module.
2022-10-27cheri: Setup RX, RW capabilities for static linkingSzabolcs Nagy
At least tls image access requires RX capability of the main link_map.
2022-10-27cheri: elf: add dl_{rx,rw}_ptr to derive addresses within a mapSzabolcs Nagy
To derive pointers within a module from the per module RX and RW caps.
2022-10-27cheri: elf: add an RW capability to link_mapSzabolcs Nagy
For each module keep an RX and an RW root capability. Use the existing l_map_start for RX (covering all load segments) and add l_rw_start for RW (covering all writable load segments). For relocation processing, we also need individual RW ranges to decide which objects need to be derived from RW and RX capabilities. In practice most modules have exactly one RW segment and it's unlikely that any module needs more than four distinct ranges to tightly cover the RW mappings. Only added on CHERI targets so always has to be used behind ifdef.
2022-10-27cheri: elf: elfptr_t l_map_start in link_map structSzabolcs Nagy
Use a capability for the load segment start that covers all load segments so pointers can be derived from it. It should have RX permission and a separate capability used for writable pointers.
2022-10-27cheri: Introduce elfptr_t int type that can hold pointersSzabolcs Nagy
Use elfptr_t when ElfW(Addr) represents a runtime pointer (may be dereferenced or pointers may be derived from it).
2022-10-27cheri: fix __minimal_mallocSzabolcs Nagy
The linker created _end symbol does not have the right bounds, so don't try to reuse leftover memory at the end of the .data section.
2022-10-27cheri: fix static linking early allocationSzabolcs Nagy
Store mmap result to intptr_t instead of long.
2022-10-27cheri: don't use dl_random for pointer manglingSzabolcs Nagy
Pointer mangling cannot be supported on capability architectures. And there is not enough bytes in dl_random for 128 bit pointers. Stack guard is still loaded from dl_random: stack protection is unlikely to be useful on a capability architecture, but it works.
2022-10-27aarch64: morello: add purecap start codeSzabolcs Nagy
Written in C so the self relocation code in crt1.o is easier to maintain. The purecap ELF entry is special: passes separate argc, argv, envp, auxv in registers instead of on the stack. For each module there will be separate RW and RX capabilities that cover the writable and all load segments respectively. The relative reloc processing code is prepared for such separate capabilities. The static link detection (for self relocation) is not ideal, it relies on relocations that don't work in PIC, so it is ifdefed out for Scrt1.o. (Currently adrp of undefined weak symbol is not fixed up by the linker to be 0 so we use movz to detect the presence of __rela_dyn_start.)
2022-10-27cheri: change __libc_start_main prototypeSzabolcs Nagy
The prototype of __libc_start_main is changed to void __libc_start_main (int main (int, char **, char **, void *), int argc, char **argv, char **envp, void *auxv, void rtld_fini (void), void *sp); so envp is passed down separately and the unused init, fini args are dropped.
2022-10-27aarch64: morello: purecap crti.S and crtn.SCarlos Eduardo Seo
Purecap ABI versions of crti.S and crtn.S.
2022-10-27cheri: aarch64: Add header for CHERI permissionsCarlos Eduardo Seo
New file containing the capability permission bits. The capability permission bits are defined in the Arm Architecture Reference Manual Suplement- Morello for A-Profile Architecture: https://developer.arm.com/documentation/ddi0606/latest
2022-10-27cheri: elf: use elfptr_t for auxv parsingSzabolcs Nagy
2022-10-27cheri: elf: Adjust Elf64_auxv_t for capabilitiesSzabolcs Nagy
The Elf64_auxv_t needs to be adjusted for the new capability size.
2022-10-27cheri: elf: Add new AT_* auxv type definitionsCarlos Eduardo Seo
Follows the morello pure capability user ABI of linux.
2022-10-27elf: add EF_AARCH64_CHERI_PURECAPSzabolcs Nagy
2022-10-27elf: add Arm Morello relocations to elf.hCarlos Eduardo Seo
2022-10-27TODO(uapi): narrow capability in mmap and mremapSzabolcs Nagy
This is a temporary workaround. length is rounded up to pagesize and don't use exact bound (bounds will be larger if exact value is not representable). capability permissions are roughly emulated too. TODO: kernel should do this
2022-10-27TODO(uapi): aarch64: morello: add HWCAP2_MORELLOSzabolcs Nagy
TODO: this is the value in the 5.18 kernel, will change later.
2022-10-27TODO(uapi): aarch64: morello: use non-ifunc gettimeofdaySzabolcs Nagy
TODO: Remove this once morello has vdso gettimeofday.
2022-10-27TODO(uapi): aarch64: morello: make brk always failSzabolcs Nagy
TODO: drop this once linux brk always fails.
2022-10-27TODO(uapi): cheri: fix clone_argsSzabolcs Nagy
Current clone_args does not support 128 bit pointers. TODO: the fix is incomplete (missing clone3 abi checks) and has to be aligned with purecap clone3 struct layout.
2022-10-27aarch64: morello: define PROT_MAXSzabolcs Nagy
Specifies the prot flags a mapping may gain via mprotect or MAP_FIXED. On CHERI targets this is used to get capability with more permissions than the original mmap protection would imply.
2022-10-27aarch64: morello: fix missing variadic argument in fcntlSzabolcs Nagy
In fcntl va_arg is currently used even if the caller did not pass any variadic arguments. This is undefined behaviour and does not work with the Morello purecap ABI, so use a helper macro. When the argument is missing, the result of the helper macro is arbitrary as it will be ignored by the kernel, we just have to ensure it does not cause a runtime crash.
2022-10-27aarch64: morello: add prctl with correct vararg handlingSzabolcs Nagy
prctl is a variadic function and on morello args that were not passed cannot be accessed so the generic code does not work.
2022-10-27aarch64: morello: fix vforkSzabolcs Nagy
No need to set the child stack to sp, 0 means the parent stack is used. This avoids purecap specific ifdefs in vfork.
2022-10-27aarch64: morello: add purecap syscall supportCarlos Eduardo Seo
Support the Morello Linux purecap syscall ABI. The macro definitions are moved to a morello specific sysdep.h to avoid cluttering the aarch64 one.
2022-10-27aarch64: fix VDSO setup to only apply to known ABIsSzabolcs Nagy
New syscall ABI requires different VDSO support code.
2022-10-27TODO(api): cheri: fix syscall return typeSzabolcs Nagy
TODO: this affects API (syscall return type is long) so breaks portability and requires doc updates.
2022-10-27aarch64: morello: string: memcpySzabolcs Nagy
from arm optimized-routines morello branch.
2022-10-27aarch64: morello: string: memsetSzabolcs Nagy
memset from arm optimized-routines morello branch.
2022-10-27aarch64: morello: string: dummy c memcmpSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c memchrSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c memrchrSzabolcs Nagy
2022-10-27aarch64: morello: purecap rawmemchrCarlos Eduardo Seo
Modified rawmemchr to support Arm Morello Capabilities.
2022-10-27aarch64: morello: string: dummy c strchrnulSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c strlenSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c strnlenSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c strcpy and stpcpySzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c strcmpSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c strncmpSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c strchrSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c strrchrSzabolcs Nagy
2022-10-27aarch64: morello: string: dummy c strspnSzabolcs Nagy
avoids out of bound access of the generic implementation.
2022-10-27aarch64: morello: string: dummy c strcspnSzabolcs Nagy
avoids out of bounds access of the generic implementation.
2022-10-27aarch64: morello: update sysdep.h for purecap ABICarlos Eduardo Seo
Add macro definitions for purecap ABI in sysdep.h.