1. 27 Jun, 2021 5 commits
    • Alexander Richardson's avatar
      Fix InternalCallbackRec layout if pointers are bigger than 64 bits · 1d5bb760
      Alexander Richardson authored and Alan Coopersmith's avatar Alan Coopersmith committed
      
      
      When running `xeyes` via `SSH -X` on CHERI-RISC-V FreeBSD, I was getting
      a Bus Error (unaligned store) in the `cl->callback = callback;` line of
      _XtAddCallback. The `cl` variable (created using `ToList(icl)`) was only
      aligned to 8 bytes, but for CHERI-RISC-V pointer-type loads and stores
      require 16-byte alignment.
      
      In order to fix this, I added a C99 flexible array member to
      internalCallbackRec when compiling for C99 or newer. This ensures
      that sizeof(InternalCallbackRec) is 16 (since it now includes the
      required 12 byte padding up to the first XtCallbackRec). This also
      ensures that alignof(InternalCallbackRec) is 16, but that doesn't
      matter in this case since malloc() will always return a
      sufficiently-aligned pointer.
      
      I also changed ToList(p) to use the flexible array member directly
      when compiling for C99. This is not a functional change since it
      will evaluate to the same pointer, but it does add additional type
      checking and ensures that only a `InternalCallbackRec *` can be
      passed to the macro.
      Signed-off-by: Alexander Richardson's avatarAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
      1d5bb760
    • Alexander Richardson's avatar
      Fix XrmResource layout if pointers are bigger than long · f8c7069a
      Alexander Richardson authored and Alan Coopersmith's avatar Alan Coopersmith committed
      
      
      On CHERI-enabled architectures (e.g. Arm's Morello), pointers are twice
      the size of addresses (i.e. 128 bits for Morello, 64 bits for 32-bit
      RISC-V). However, XtArgVal is currently defined as long, so it cannot
      be used to store pointers on these architectures.
      
      Also add a _Static_assert() when compiling with C11 support to check
      that the offset of the last member matches that of XtResource.
      Signed-off-by: Alexander Richardson's avatarAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
      f8c7069a
    • Alexander Richardson's avatar
      Cast via intptr_t when converting integers to pointers · dd3e028d
      Alexander Richardson authored and Alan Coopersmith's avatar Alan Coopersmith committed
      
      
      I found these by compiling libXt with the CHERI Clang compiler, as it
      warns about conversions from integer to pointer that do not use intptr_t.
      Signed-off-by: Alexander Richardson's avatarAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
      dd3e028d
    • Alexander Richardson's avatar
      Use XtUIntPtr for integer types that can hold pointers · 38e89c85
      Alexander Richardson authored and Alan Coopersmith's avatar Alan Coopersmith committed
      
      
      Various Xt*Id types are integer types that are used to hold pointers.
      Use uintptr_t for standards-compliant conversion and to support
      architectures where long cannot hold pointers (e.g. CHERI).
      
      I found these by compiling libXt with the CHERI Clang compiler, as it
      warns about conversions from integer to pointer that do not use intptr_t.
      Signed-off-by: Alexander Richardson's avatarAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
      38e89c85
    • Alexander Richardson's avatar
      XtArgVal: Support architectures where pointers are bigger than long · cfa8e152
      Alexander Richardson authored and Alan Coopersmith's avatar Alan Coopersmith committed
      
      
      On CHERI-enabled architectures (e.g. Arm's Morello), pointers are twice
      the size of addresses (i.e. 128 bits for Morello, 64 bits for 32-bit
      RISC-V). However, XtArgVal is currently defined as long, so it cannot
      be used to store pointers on these architectures.
      
      This commit changes XtArgVal to use intptr_t instead, which should be
      long on most architectures but is larger for CHERI.
      It also introduces XtIntPtr/XtUIntPtr which will be used in follow-up
      changes. This commit should also help on LLP64 ABIs where long is 32
      bits but pointers are 64 bits.
      
      I am not sure what the compiler and C standard requirements are, so I've
      guarded the use of stdint.h with `#if __STDC_VERSION__ >= 199901L`.
      I've also added a _Static_assert() when compiling in C11 mode to
      statically verify that the XtArgVal type requirements are met.
      Signed-off-by: Alexander Richardson's avatarAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
      cfa8e152
  2. 16 Jun, 2021 1 commit
  3. 24 Jan, 2021 1 commit
  4. 05 Feb, 2020 1 commit
  5. 22 Dec, 2019 3 commits
  6. 16 Nov, 2019 1 commit
  7. 10 Nov, 2019 1 commit
  8. 09 Nov, 2019 3 commits
  9. 01 Aug, 2019 1 commit
  10. 14 Jul, 2019 23 commits