]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
3 years agoTODO(drop): aarch64: morello: CPU feature detection for Morello arm/morello/v1
Carlos Eduardo Seo [Fri, 13 Nov 2020 19:33:07 +0000 (16:33 -0300)] 
TODO(drop): aarch64: morello: CPU feature detection for Morello

Initial detection of Arm Morello architecture from the HWCAP2 bit and CPU
identification from MIDR_EL0.

TODO: not needed?
- lp64 does not have to detect
- purecap can assume morello

3 years agoTODO(gprof): aarch64: morello: add gprof profiling support to asm
Szabolcs Nagy [Wed, 13 Jul 2022 14:22:10 +0000 (15:22 +0100)] 
TODO(gprof): aarch64: morello: add gprof profiling support to asm

Assembly prologue code with mcount call for gprof instrumentation.

TODO: untested, likely needs further runtime updates too.

3 years agoTODO(sprof): cheri: disable profiling shared libraries
Szabolcs Nagy [Thu, 12 May 2022 08:05:30 +0000 (09:05 +0100)] 
TODO(sprof): cheri: disable profiling shared libraries

This is needed now to avoid referencing abort in ld.so.

TODO: Fixing shared library profiling for capabilities requires
type fixes so capabilities are not stored into shared memory
(maybe purecap layout can match the lp64 one and then no file format
and external tooling change is required.)
TODO: Proper fix also depends on _dl_runtime_profile plt entry

3 years agoTODO(audit): aarch64: morello: add _dl_runtime_profile entry
Szabolcs Nagy [Wed, 13 Jul 2022 15:01:24 +0000 (16:01 +0100)] 
TODO(audit): aarch64: morello: add _dl_runtime_profile entry

Required for LD_AUDIT PLT hooks and shared library profiling.

incomplete, untested.

TODO: needs La_aarch64* layout definition for morello
TODO: needs to save c9 for vararg abi

3 years agoTODO(pldd): cheri: elf: fix pldd to compile for purecap abi
Carlos Eduardo Seo [Tue, 5 Jul 2022 22:09:03 +0000 (22:09 +0000)] 
TODO(pldd): cheri: elf: fix pldd to compile for purecap abi

Adjust types in the E(*) structs to support capabilities.

TODO: purecap pldd should refuse to deal with lp64 and ELF32 processes.
the code for the 32bit case should be disabled.
TODO: a correct fix requires support for all abis that can run on the
same system (purecap, lp64 and ELF32 too).

3 years agocheri: Update libc.abilist for getauxptr
Carlos Eduardo Seo [Tue, 12 Jul 2022 20:16:53 +0000 (20:16 +0000)] 
cheri: Update libc.abilist for getauxptr

Updates libc.abilist files for getauxptr to version 2.37.

3 years agocheri: elf: Fix tst-auxv for Morello
Carlos Eduardo Seo [Thu, 23 Jun 2022 18:27:55 +0000 (15:27 -0300)] 
cheri: elf: Fix tst-auxv for Morello

3 years agoTODO(api): cheri: misc: Implement new function getauxptr for CHERI capabilities
Carlos Eduardo Seo [Wed, 18 May 2022 00:52:09 +0000 (00:52 +0000)] 
TODO(api): cheri: misc: Implement new function getauxptr for CHERI capabilities

New function to return values from the auxiliary vector as
capabilities. This is the same as implemented by other C libraries.

TODO: agree about exact semantics across libcs

3 years agoTODO(uapi): aarch64: morello: add HWCAP2_MORELLO
Szabolcs Nagy [Wed, 13 Jul 2022 12:49:00 +0000 (13:49 +0100)] 
TODO(uapi): aarch64: morello: add HWCAP2_MORELLO

TODO: the value will change

3 years agosupport: Fix TEST_COMPARE for uintptr_t.
Carlos Eduardo Seo [Mon, 27 Jun 2022 21:27:50 +0000 (21:27 +0000)] 
support: Fix TEST_COMPARE for uintptr_t.

TEST_COMPARE should allow comparison between two capability values.

3 years agocheri: stdio-common: add support for printing CHERI capabilities
Carlos Eduardo Seo [Thu, 7 Jul 2022 18:46:43 +0000 (18:46 +0000)] 
cheri: stdio-common: add support for printing CHERI capabilities

This adds a new modifier %#p for printing capability information
according to the CHERI C Programming guide:

https://github.com/CTSRD-CHERI/cheri-c-programming/wiki/Displaying-Capabilities

A %#p option in printf will display:

  <address> [<permissions>,<base>-<top>] (<attr>)

   * address: Virtual address of capability displayed as a hexadecimal
     value with a 0x prefix.
   * permissions: Zero or more of the following characters:
      r: LOAD permission
      w: STORE permission
      x: EXECUTE permission
      R: LOAD_CAP permission
      W: STORE_CAP permission
      E: EXECUTIVE permission (Morello only)
   * base: Lower bound of capability displayed as a hexadecimal value
     with a 0x prefix.
   * top: Upper bound of capability plus 1 displayed as a hexadecimal
     value with a 0x prefix.
   * attr: Zero or more of the following comma-separated attributes. If
     none of the attributes are present, this field is omitted (along
     with the enclosing parentheses/brackets).
      invalid: Capability's tag is clear.
      sentry: Capability is a sealed entry.
      sealed: Capability is sealed with a type other than the sealed
              entry object type.

A %p option in printf will display the capability value (address) normally.

3 years agocheri: nptl: Check user provided stack for PCS constraints
Carlos Eduardo Seo [Thu, 17 Mar 2022 23:51:32 +0000 (20:51 -0300)] 
cheri: nptl: Check user provided stack for PCS constraints

In pthread_attr_setstack fail with EINVAL if the input stack does not
meet the PCS constraints.

3 years agoTODO(uapi): cheri: Fix sigevent ABI
Szabolcs Nagy [Thu, 16 Jun 2022 14:37:31 +0000 (15:37 +0100)] 
TODO(uapi): cheri: Fix sigevent ABI

TODO: depends on kernel sigevent definition update.

3 years agoTODO(morello): cheri: fix posix timers
Szabolcs Nagy [Tue, 19 Apr 2022 14:18:56 +0000 (15:18 +0100)] 
TODO(morello): cheri: fix posix timers

We need to distinguish timerids that are small integers returned by
the kernel and timerids that are pointers to struct timer. The existing
pointer tagging does not work for CHERI because of the pointer shift.

Simply use the top bit without shift to tag pointers. This still relies
on the top byte ignore of aarch64 (the top byte does not affect the
capability representation) and that pointers are not tagged for other
reasons (like HWASAN).

TODO: this is morello specific and does not work for generic cheri.

3 years agoTODO(api): cheri: elfptr_t in public api for unwinder
Szabolcs Nagy [Wed, 13 Apr 2022 08:27:08 +0000 (09:27 +0100)] 
TODO(api): cheri: elfptr_t in public api for unwinder

TODO: needs agreement across cheri libcs

3 years agoTODO(l_addr): cheri: rtld: elfptr_t fix in rtld.c program header processing
Szabolcs Nagy [Thu, 7 Apr 2022 09:08:51 +0000 (10:08 +0100)] 
TODO(l_addr): cheri: rtld: elfptr_t fix in rtld.c program header processing

TODO: depends on l_addr design

3 years agoTODO(l_addr): aarch64: morello: dynamic linking support
Szabolcs Nagy [Tue, 29 Mar 2022 14:24:38 +0000 (15:24 +0100)] 
TODO(l_addr): aarch64: morello: dynamic linking support

Add morello specific dl-machine.h.

Add morello dynamic relocation processing support for purecap ABI.
Only support R_AARCH64_NONE, R_AARCH64_ABS64 and R_AARCH64_RELATIVE
dynamic relocs from the lp64 abi. This required several APIs to
change ElfW(Addr) to uintptr_t including in generic code (where
elfptr_t used to cover both traditional and capability abis).

RELATIVE and IRELATIVE relocs use a helper function to construct a
capability.  Also fixed the IRELATIVE handling for static linking.

Use new machine routines on morello for load address computation so it
is a valid capability:

 void *elf_machine_runtime_dynamic (void)
 uintptr_t elf_machine_load_address_from_args (void *)

The ld.so load address is either AT_BASE or if it is invoked as a
command then derived from AT_PHDR or _DYNAMIC (pcc).

ELF_MACHINE_START_ADDRESS is updated to turn the ElfW(Addr) user entry
into a capability based on l_addr.

TODO: __tls_get_addr should return a bounded pointer.
(in case traditional tls is defined for morello)

note: tls_index struct that is used for trad tls is changed for morello.
(this is abi once trad tls is defined for morello)

arguably _dl_make_tlsdesc_dynamic should set up tlsinfo.ti_size too.
(but it's better to avoid changing the generic code)

TODO: use cheri auxv entries to derive ld.so capabilities, this will
      require separate RW and RX base pointers instead of single l_addr.
      AT_BASE will not be a capability covering ld.so.

3 years agoaarch64: rtld: avoid loading incompatible binaries
Szabolcs Nagy [Fri, 29 Apr 2022 13:02:17 +0000 (14:02 +0100)] 
aarch64: rtld: avoid loading incompatible binaries

Prevent lp64 ld.so loading purecap binaries.

3 years agoaarch64: morello: add lazy binding entry code
Szabolcs Nagy [Fri, 8 Jul 2022 15:35:35 +0000 (16:35 +0100)] 
aarch64: morello: add lazy binding entry code

3 years agoTODO(l_addr): cheri: rtld: elfptr_t fixes in dl-map-segments.h
Szabolcs Nagy [Thu, 7 Apr 2022 07:43:00 +0000 (08:43 +0100)] 
TODO(l_addr): cheri: rtld: elfptr_t fixes in dl-map-segments.h

Ensure map_end is derived from map_start.

Use stricter mmap bounds when using MAP_FIXED:
c->mapend is aligned up to pagesize, but the capability representing
the mapping has bounds that are not page aligned, so use c->dataend
that is the actual end bound of the loaded segment.

TODO: l_addr of a pde is 0 but it should cover the exe.
this will have to be fixed. (and must not use morello asm)

3 years agoTODO(incomplete): cheri: rtld: more elfptr_t in linkmap struct
Szabolcs Nagy [Thu, 7 Apr 2022 12:18:48 +0000 (13:18 +0100)] 
TODO(incomplete): cheri: rtld: more elfptr_t in linkmap struct

TODO: requires follwup patches to make sure all usage of the fields
preserve capabilities.

3 years agocheri: elf: fix pointer provenance of l_tls_initimage
Szabolcs Nagy [Thu, 7 Apr 2022 16:04:59 +0000 (17:04 +0100)] 
cheri: elf: fix pointer provenance of l_tls_initimage

3 years agocheri: rtld: fix _dl_start to return elfptr_t
Szabolcs Nagy [Wed, 20 Apr 2022 08:54:31 +0000 (09:54 +0100)] 
cheri: rtld: fix _dl_start to return elfptr_t

Functions returning a pointer to the user entry need to use an int type
that can represent pointers.

3 years agoaarch64: morello: rtld: add ld.so _start code
Szabolcs Nagy [Tue, 29 Mar 2022 15:30:33 +0000 (16:30 +0100)] 
aarch64: morello: rtld: add ld.so _start code

The purecap version of aarch64 dl-start.S. Note: self relocation of
ld.so is handled by the rtld bootstrap code.

3 years agoaarch64: morello: rtld: define DL_RO_DYN_SECTION
Szabolcs Nagy [Mon, 4 Apr 2022 16:59:20 +0000 (17:59 +0100)] 
aarch64: morello: rtld: define DL_RO_DYN_SECTION

The dynamic section cannot be relocated to hold pointers in place.

3 years agoaarch64: morello: fix ldconfig for purecap abi
Szabolcs Nagy [Fri, 15 Jul 2022 07:15:02 +0000 (08:15 +0100)] 
aarch64: morello: fix ldconfig for purecap abi

Add purecap ld cache flag. Add the purecap ld.so name to known names.
Handle lib64c system library paths. And set the purecap abi flag on
cache entries.

3 years agoaarch64: morello: disable the vpcs test
Szabolcs Nagy [Mon, 1 Mar 2021 11:01:40 +0000 (11:01 +0000)] 
aarch64: morello: disable the vpcs test

The asm code of the test is for lp64 ABI only.

3 years agoaarch64: morello: add purecap ucontext support
Carlos Eduardo Seo [Thu, 27 May 2021 20:49:20 +0000 (17:49 -0300)] 
aarch64: morello: add purecap ucontext support

Adjust ucontext layout for purecap ABI and add make/get/set/swapcontext
implementations accordingly.

Note: mcontext layout follows the linux sigcontext struct, in userspace
*context functions rely on the c registers stored in the extension area
and ignore the mcontext fields for x registers.

3 years agoaarch64: morello: add purecap setjmp/longjmp
Carlos Eduardo Seo [Mon, 5 Apr 2021 20:01:09 +0000 (17:01 -0300)] 
aarch64: morello: add purecap setjmp/longjmp

Similar to lp64 setjmp/longjmp, but handles capability registers.
Save q regs instead of d regs to simplify the offset computation.

3 years agocheri: malloc: avoid switch over uintptr_t
Szabolcs Nagy [Mon, 28 Mar 2022 12:57:10 +0000 (13:57 +0100)] 
cheri: malloc: avoid switch over uintptr_t

We should use a type that guarantees to represent all address bits.
In CHERI C this would be ptraddr_t, but we use unsigned long for now
not to cause regressions on other targets where this type is missing.

3 years agocheri: malloc: fix alignment logic in obstack
Szabolcs Nagy [Wed, 16 Mar 2022 14:07:04 +0000 (14:07 +0000)] 
cheri: malloc: fix alignment logic in obstack

If sizeof(ptrdiff_t) < sizeof(void*) the alignment logic was wrong
(incorrectly assumed that base was already sufficiently aligned).

Use more robust alignment logic: this one should work on any target.
Note: this is an installed header so it must be namespace clean and
portable.

3 years agocheri: malloc: use uintptr_t in alloc_buffer
Szabolcs Nagy [Wed, 16 Mar 2022 12:09:15 +0000 (12:09 +0000)] 
cheri: malloc: use uintptr_t in alloc_buffer

This is the right type as the values hold pointers.

3 years agocheri: malloc: align up without breaking capability in memalign
Szabolcs Nagy [Tue, 15 Mar 2022 09:54:59 +0000 (09:54 +0000)] 
cheri: malloc: align up without breaking capability in memalign

3 years agocheri: malloc: Disable pointer protection
Szabolcs Nagy [Wed, 7 Jul 2021 13:21:40 +0000 (14:21 +0100)] 
cheri: malloc: Disable pointer protection

Such arithmetic invalidates capabilities so this security measure does
not work for CHERI.

Note: the architecture makes it hard to corrupt pointers in malloc
metadata, but not impossible: current allocation bounds include the
metadata and capabilities are not revoked after free. These issues can
be fixed by a capability aware malloc.

3 years agocheri: malloc: use intptr_t to preserve capabilities
Carlos Eduardo Seo [Wed, 26 Jan 2022 19:00:13 +0000 (16:00 -0300)] 
cheri: malloc: use intptr_t to preserve capabilities

Avoid integer casts and arithmetics that invalidates capabilities.

3 years agocheri: fix invalid pointer use after realloc in localealias
Szabolcs Nagy [Fri, 18 Mar 2022 06:55:31 +0000 (06:55 +0000)] 
cheri: fix invalid pointer use after realloc in localealias

This code updates pointers to a reallocated buffer to point to the new
buffer.  It is not conforming (does arithmetics with freed pointers),
but it also creates invalid capabilities because the provenance is
derived from the original freed pointers instead of the new buffer.

Change the arithmetics so provenance is derived from the new buffer.
The conformance issue is not fixed.

3 years agocheri: fix pointer tagging in tsearch
Szabolcs Nagy [Mon, 12 Jul 2021 10:11:05 +0000 (11:11 +0100)] 
cheri: fix pointer tagging in tsearch

USE_MALLOC_LOW_BIT should work for capabilities too, but we need to
ensure that pointer provenance is right: the red/black flag is
computed as uintptr_t, but with uintptr_t | uintptr_t it's not clear
which side provides the provenance.

So use unsigned int type for the flag (which is the type used in case
of !USE_MALLOC_LOW_BIT anyway), then unsigned int | uintptr_t works.

The type of RED is corrected too to match unsigned int.

3 years agocheri: fix qsort for capabilities
Szabolcs Nagy [Mon, 12 Jul 2021 12:06:40 +0000 (13:06 +0100)] 
cheri: fix qsort for capabilities

On capability targets avoid copying pointers via unsigned long.

3 years agocheri: wctype: turn wctype_t into a pointer
Szabolcs Nagy [Thu, 17 Mar 2022 12:30:37 +0000 (12:30 +0000)] 
cheri: wctype: turn wctype_t into a pointer

Make wctype_t a pointer so dereferencing it works. wctrans_t is already
a pointer and used the same way.

Existing targets are not affected, only capability targets where this
is necessary.

3 years agocheri: rseq: remove const to avoid readonly permission
Szabolcs Nagy [Tue, 1 Mar 2022 09:44:14 +0000 (09:44 +0000)] 
cheri: rseq: remove const to avoid readonly permission

Using const on the definition does not work for a pure capability ABI:
the capability permissions when accessing the object will be read only.

Use a hack to hide the public declaration in the TU where the const
objects are initialized. (This should work on non-capability targets
too, but to err on the safe side only enable the hack on capability
targets.)

3 years agoaarch64: morello: nptl: fix thread pointer setup
Szabolcs Nagy [Wed, 13 Jul 2022 11:15:16 +0000 (12:15 +0100)] 
aarch64: morello: nptl: fix thread pointer setup

3 years agoaarch64: morello: nptl: fix pthread types for 128 bit pointers
Szabolcs Nagy [Wed, 13 Jul 2022 11:22:10 +0000 (12:22 +0100)] 
aarch64: morello: nptl: fix pthread types for 128 bit pointers

3 years agocheri: nptl: fix pthread_attr_t alignment
Szabolcs Nagy [Tue, 12 Jul 2022 12:09:02 +0000 (13:09 +0100)] 
cheri: nptl: fix pthread_attr_t alignment

Alignment of the public definition did not match the internal layout.
Ensure that the type is at least pointer aligned.

3 years agocheri: nptl: fix thread ID types for capabilities
Szabolcs Nagy [Wed, 13 Jul 2022 10:06:49 +0000 (11:06 +0100)] 
cheri: nptl: fix thread ID types for capabilities

3 years agocheri: Implement 128-bit atomics
Szabolcs Nagy [Tue, 8 Jun 2021 11:48:43 +0000 (12:48 +0100)] 
cheri: Implement 128-bit atomics

Arm Morello requires 128-bit atomics.

3 years agocheri: elf: Use elfptr_t in _dl_protect_relro
Szabolcs Nagy [Mon, 21 Jun 2021 09:51:05 +0000 (10:51 +0100)] 
cheri: elf: Use elfptr_t in _dl_protect_relro

start/end should be capabilities now that l_addr is a capability.

3 years agocheri: elf: elfptr_t fixes for preinit/init/fini array
Szabolcs Nagy [Thu, 7 Apr 2022 17:40:25 +0000 (18:40 +0100)] 
cheri: elf: elfptr_t fixes for preinit/init/fini array

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).

3 years agoTODO(l_addr): cheri: in static exe initialize l_addr to a zero capability
Szabolcs Nagy [Thu, 24 Jun 2021 12:29:19 +0000 (13:29 +0100)] 
TODO(l_addr): cheri: in static exe initialize l_addr to a zero capability

The base should be 0, but also a valid capability. Initialize to a zero
capability instead of relying on AT_BASE.

TODO: this is a hack. we will need stricter bounds and possibly separate
l_addr and bounds info.

3 years agocheri: elf: use elfptr_t for auxv parsing
Szabolcs Nagy [Mon, 14 Mar 2022 08:44:32 +0000 (08:44 +0000)] 
cheri: elf: use elfptr_t for auxv parsing

3 years agocheri: elf: Adjust Elf64_auxv_t for capabilities
Szabolcs Nagy [Thu, 10 Jun 2021 12:50:17 +0000 (13:50 +0100)] 
cheri: elf: Adjust Elf64_auxv_t for capabilities

The Elf64_auxv_t needs to be adjusted for the new capability size.

3 years agocheri: elf: make l_addr a capability
Szabolcs Nagy [Fri, 11 Jun 2021 07:24:29 +0000 (08:24 +0100)] 
cheri: elf: make l_addr a capability

l_addr should be a capability on Morello. This is synchronized with the
same variable in gdb.

Use elfptr_t when ElfW(Addr) represents a runtime pointer that may be
dereferenced.

3 years agocheri: elf: Add new a_type entries
Carlos Eduardo Seo [Fri, 20 May 2022 14:39:29 +0000 (14:39 +0000)] 
cheri: elf: Add new a_type entries

The Morello Pure Capability kernel uABI defines new a_type entries:

https://git.morello-project.org/morello/kernel/linux/-/wikis/Morello-pure-capability-kernel-user-Linux-ABI-specification#auxiliary-vector-auxv

3 years agoelf: add EF_AARCH64_CHERI_PURECAP
Szabolcs Nagy [Fri, 29 Apr 2022 13:27:32 +0000 (14:27 +0100)] 
elf: add EF_AARCH64_CHERI_PURECAP

3 years agoelf: add Arm Morello relocations to elf.h
Carlos Eduardo Seo [Wed, 18 Nov 2020 20:22:25 +0000 (17:22 -0300)] 
elf: add Arm Morello relocations to elf.h

3 years agocheri: fix __minimal_malloc
Szabolcs Nagy [Tue, 1 Mar 2022 12:42:26 +0000 (12:42 +0000)] 
cheri: fix __minimal_malloc

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.

3 years agocheri: fix static linking TLS setup
Carlos Eduardo Seo [Wed, 9 Jun 2021 18:23:23 +0000 (15:23 -0300)] 
cheri: fix static linking TLS setup

Use l_addr provenance for TLS initimage.

3 years agocheri: fix static linking early allocation
Szabolcs Nagy [Mon, 18 Jul 2022 06:12:56 +0000 (07:12 +0100)] 
cheri: fix static linking early allocation

Store mmap result to intptr_t instead of long.

3 years agoTODO(gcc): cheri: work around a gcc bug in _dl_setup_stack_chk_guard
Szabolcs Nagy [Fri, 15 Jul 2022 18:33:23 +0000 (19:33 +0100)] 
TODO(gcc): cheri: work around a gcc bug in _dl_setup_stack_chk_guard

morello purecap gcc in some cases inlines 16byte memcpy as a capability
load, which is wrong if the source or dest may be unaligned.

stack guard only needs random for the address portion since only that
part is compared, so 8 byte is enough with 64 bit addresses, but the
current code is only right on little endian systems.

TODO: drop when gcc is fixed

3 years agocheri: don't use dl_random for pointer mangling
Szabolcs Nagy [Tue, 1 Mar 2022 17:36:12 +0000 (17:36 +0000)] 
cheri: don't use dl_random for pointer mangling

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.

3 years agoTODO(relro): cheri: make __attribute_relro a nop
Szabolcs Nagy [Thu, 10 Jun 2021 15:10:15 +0000 (16:10 +0100)] 
TODO(relro): cheri: make __attribute_relro a nop

relro does not work in the libc, because capabilities are readonly
even before the page protection is applied.

3 years agoTODO(ddc): aarch64: morello: purecap support in the CSU
Carlos Eduardo Seo [Thu, 18 Mar 2021 18:02:54 +0000 (15:02 -0300)] 
TODO(ddc): aarch64: morello: purecap support in the CSU

Purecap ABI versions of start.S, crti.S and crtn.S.

TODO: must not use ddc but caps from auxv
TODO: start.S: dynamic linked case is now detected by x0 != 0 (ld.so passes
__rtld_fini there), but the value of c0 on entry is not abi, just that
it has to be passed back to the libc start code in c5, so ideally the
linker should be fixed to reliably emit __rela_dyn_start when a static
exe must self relocate.

3 years agocheri: aarch64: Add header for CHERI permissions
Carlos Eduardo Seo [Mon, 18 Jul 2022 17:47:32 +0000 (14:47 -0300)] 
cheri: aarch64: Add header for CHERI permissions

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

3 years agoTODO(uapi): aarch64: morello: use non-ifunc gettimeofday
Szabolcs Nagy [Thu, 17 Mar 2022 10:09:46 +0000 (10:09 +0000)] 
TODO(uapi): aarch64: morello: use non-ifunc gettimeofday

TODO: Remove this once morello has vdso gettimeofday.

3 years agoTODO(uapi): aarch64: morello: make brk always fail
Szabolcs Nagy [Thu, 3 Jun 2021 09:05:53 +0000 (10:05 +0100)] 
TODO(uapi): aarch64: morello: make brk always fail

TODO: drop this once linux brk always fails.

3 years agoTODO(uapi): cheri: fix clone_args
Szabolcs Nagy [Mon, 2 Aug 2021 10:34:56 +0000 (11:34 +0100)] 
TODO(uapi): cheri: fix clone_args

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.

3 years agoaarch64: morello: fix missing variadic argument in fcntl
Szabolcs Nagy [Fri, 15 Jul 2022 13:10:53 +0000 (14:10 +0100)] 
aarch64: morello: fix missing variadic argument in fcntl

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.

3 years agoaarch64: morello: fix vfork
Szabolcs Nagy [Tue, 12 Jul 2022 10:13:57 +0000 (11:13 +0100)] 
aarch64: morello: fix vfork

No need to set the child stack to sp, 0 means the parent stack is used.
This avoids purecap specific ifdefs in vfork.

3 years agoaarch64: morello: add purecap syscall support
Carlos Eduardo Seo [Thu, 8 Apr 2021 15:49:27 +0000 (12:49 -0300)] 
aarch64: morello: add purecap syscall support

Support the Morello Linux purecap syscall ABI.  The macro definitions
are moved to a morello specific sysdep.h to avoid cluttering the
aarch64 one.

3 years agoaarch64: fix VDSO setup to only apply to known ABIs
Szabolcs Nagy [Wed, 11 May 2022 09:30:36 +0000 (10:30 +0100)] 
aarch64: fix VDSO setup to only apply to known ABIs

New syscall ABI requires different VDSO support code.

3 years agoTODO(api): cheri: fix syscall return type
Szabolcs Nagy [Thu, 14 Jul 2022 13:22:26 +0000 (14:22 +0100)] 
TODO(api): cheri: fix syscall return type

TODO: this affects API (syscall return type is long)
so breaks portability and requires doc updates.

3 years agoaarch64: morello: string: memcpy
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:58 +0000 (08:19 +0100)] 
aarch64: morello: string: memcpy

from arm optimized-routines morello branch.

3 years agoaarch64: morello: string: memset
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:43 +0000 (08:19 +0100)] 
aarch64: morello: string: memset

memset from arm optimized-routines morello branch.

3 years agoaarch64: morello: string: dummy c memcmp
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:36 +0000 (08:19 +0100)] 
aarch64: morello: string: dummy c memcmp

3 years agoaarch64: morello: string: dummy c memchr
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:31 +0000 (08:19 +0100)] 
aarch64: morello: string: dummy c memchr

3 years agoaarch64: morello: string: dummy c memrchr
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:47 +0000 (08:19 +0100)] 
aarch64: morello: string: dummy c memrchr

3 years agoaarch64: morello: purecap rawmemchr
Carlos Eduardo Seo [Mon, 12 Jul 2021 18:06:26 +0000 (15:06 -0300)] 
aarch64: morello: purecap rawmemchr

Modified rawmemchr to support Arm Morello Capabilities.

3 years agoaarch64: morello: string: dummy c strchrnul
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:53 +0000 (08:19 +0100)] 
aarch64: morello: string: dummy c strchrnul

3 years agoaarch64: morello: string: dummy c strlen
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:02 +0000 (08:19 +0100)] 
aarch64: morello: string: dummy c strlen

3 years agoaarch64: morello: string: dummy c strnlen
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:18 +0000 (08:19 +0100)] 
aarch64: morello: string: dummy c strnlen

3 years agoaarch64: morello: string: dummy c strcpy and stpcpy
Szabolcs Nagy [Tue, 26 Apr 2022 07:11:57 +0000 (08:11 +0100)] 
aarch64: morello: string: dummy c strcpy and stpcpy

3 years agoaarch64: morello: string: dummy c strcmp
Szabolcs Nagy [Tue, 26 Apr 2022 07:18:54 +0000 (08:18 +0100)] 
aarch64: morello: string: dummy c strcmp

3 years agoaarch64: morello: string: dummy c strncmp
Szabolcs Nagy [Tue, 15 Mar 2022 14:49:16 +0000 (14:49 +0000)] 
aarch64: morello: string: dummy c strncmp

3 years agoaarch64: morello: string: dummy c strchr
Szabolcs Nagy [Tue, 26 Apr 2022 07:18:43 +0000 (08:18 +0100)] 
aarch64: morello: string: dummy c strchr

3 years agoaarch64: morello: string: dummy c strrchr
Szabolcs Nagy [Tue, 26 Apr 2022 07:19:24 +0000 (08:19 +0100)] 
aarch64: morello: string: dummy c strrchr

3 years agoaarch64: morello: string: dummy c strspn
Szabolcs Nagy [Wed, 16 Mar 2022 10:58:57 +0000 (10:58 +0000)] 
aarch64: morello: string: dummy c strspn

avoids out of bound access of the generic implementation.

3 years agoaarch64: morello: string: dummy c strcspn
Szabolcs Nagy [Wed, 16 Mar 2022 10:59:17 +0000 (10:59 +0000)] 
aarch64: morello: string: dummy c strcspn

avoids out of bounds access of the generic implementation.

3 years agoaarch64: morello: update sysdep.h for purecap ABI
Carlos Eduardo Seo [Tue, 18 May 2021 20:24:34 +0000 (17:24 -0300)] 
aarch64: morello: update sysdep.h for purecap ABI

Add macro definitions for purecap ABI in sysdep.h.

3 years agoTODO(spec): cheri: __LP64__ is not defined for purecap ABI
Carlos Eduardo Seo [Wed, 26 Jan 2022 19:19:33 +0000 (16:19 -0300)] 
TODO(spec): cheri: __LP64__ is not defined for purecap ABI

TODO: there is no good ABI macro to check, for now we assume
__CHERI_PURE_CAPABILITY__ implies 64 bit long, 64 bit address and
128 bit pointer.

3 years agocheri: headers: Define {u}intptr_t and {u}intcap_t for CHERI
Szabolcs Nagy [Fri, 11 Jun 2021 11:52:26 +0000 (12:52 +0100)] 
cheri: headers: Define {u}intptr_t and {u}intcap_t for CHERI

The CHERI pure capability programming model for C requires special
definition of {u}intptr_t.

Only the pure capability model is supported for hosted compilation,
but for freestanding compilation there is limited support for other
(hybrid capability) programming models too, which require new
{u}intcap_t type definitions.

3 years agoaarch64: morello: use separate c++-types.data
Szabolcs Nagy [Tue, 12 Jul 2022 12:37:15 +0000 (13:37 +0100)] 
aarch64: morello: use separate c++-types.data

The c++ mangling ABI for intptr_t and pthread_t are different on
morello.

3 years agoaarch64: morello: use separate localplt data for morello
Szabolcs Nagy [Tue, 26 Apr 2022 08:09:18 +0000 (09:09 +0100)] 
aarch64: morello: use separate localplt data for morello

There is no longer PLT reference to matherr in libm.

3 years agoaarch64: morello: Add separate lp64 and morello linux abilists
Szabolcs Nagy [Fri, 8 Apr 2022 15:39:40 +0000 (16:39 +0100)] 
aarch64: morello: Add separate lp64 and morello linux abilists

The base symbol version is 2.36.

3 years agoaarch64: morello: Add purecap abi-variants on linux
Szabolcs Nagy [Fri, 8 Apr 2022 15:51:13 +0000 (16:51 +0100)] 
aarch64: morello: Add purecap abi-variants on linux

3 years agoaarch64: morello: configure change for purecap abi
Szabolcs Nagy [Fri, 8 Apr 2022 15:27:01 +0000 (16:27 +0100)] 
aarch64: morello: configure change for purecap abi

Detect default-abi and add aarch64-purecap make variable.

Purecap abi sets HIDDEN_VAR_NEEDS_DYNAMIC_RELOC and unsets
SUPPORT_STATIC_PIE.

3 years agoaarch64: morello: Use separate lp64 and morello sysdep directories
Szabolcs Nagy [Tue, 26 Apr 2022 14:29:04 +0000 (15:29 +0100)] 
aarch64: morello: Use separate lp64 and morello sysdep directories

Provide separate directories for lp64 and purecap abi related sysdep
functionality.

purecap may be better name than morello, but we started with morello
and that is more future compatible with alternative cheri-like
extensions on top of aarch64.

3 years agoaarch64: morello: add purecap support to build-many-glibcs.py
Szabolcs Nagy [Mon, 25 Apr 2022 09:52:12 +0000 (10:52 +0100)] 
aarch64: morello: add purecap support to build-many-glibcs.py

aarch64-linux-gnu compiler is a lp64,purecap multilib gcc and
supported glibc variants:

  aarch64-linux-gnu
  aarch64-linux-gnu-purecap
  aarch64-linux-gnu-purecap-nopie

aarch64-linux-gnu_purecap compiler is a default purecap gcc, with
supported glibc variants:

  aarch64-linux-gnu_purecap
  aarch64-linux-gnu_purecap-nopie

purecap libgomp and libitm builds fail so disabled for now.

3 years agoaarch64: Use fewer ifdefs in bits/fcntl.h
Szabolcs Nagy [Fri, 15 Jul 2022 07:42:53 +0000 (08:42 +0100)] 
aarch64: Use fewer ifdefs in bits/fcntl.h

This simplifies adding the Morello purecap abi target.

3 years agoaarch64: cleanup MOVL definition in sysdep.h
Szabolcs Nagy [Wed, 13 Jul 2022 13:48:59 +0000 (14:48 +0100)] 
aarch64: cleanup MOVL definition in sysdep.h

PTR_REG is for ILP32, there is no point using it under __LP64__.

3 years agolibio: adjust _IO_FILE / _IO_FILE_complete for 128 bit pointers
Szabolcs Nagy [Mon, 26 Jul 2021 19:31:38 +0000 (16:31 -0300)] 
libio: adjust _IO_FILE / _IO_FILE_complete for 128 bit pointers

The size of the reserved space has to be adjusted because it underflows
with 16 byte pointers.  With the new value there should be enough space
for 2 more pointers in the struct on CHERI targets.

3 years agocheri: Fix elf/tst-dlmodcount test
Szabolcs Nagy [Thu, 14 Apr 2022 17:34:26 +0000 (18:34 +0100)] 
cheri: Fix elf/tst-dlmodcount test

switch statement does not work for intptr_t, use a large int type
that's guaranteed to work.