1. May 17, 2023
  2. May 03, 2023
    • Mark Goncharov's avatar
      [GCC]: Fix fence.i bug (#296) · 54de960a
      Mark Goncharov authored
      There are many issues: 260, 285, 287 has to be solved
      
      This workaround helps to add neccessary zicsr and
      zifencei for cssr and fence.i accordingly.
      54de960a
  3. May 02, 2023
  4. Mar 28, 2023
  5. Jan 06, 2023
  6. Aug 06, 2022
  7. May 01, 2022
  8. Apr 21, 2022
  9. Apr 11, 2022
    • Andrew Waterman's avatar
      Handle unimplemented syscalls gracefully · ca69d69a
      Andrew Waterman authored
      We previously kernel-panicked because that made it more obvious when a
      syscall implementation was missing.  These days, it's more common that
      the C library will do something sensible in response to returning -ENOSYS.
      Favor that approach to avoid frustrating users.
      ca69d69a
  10. Apr 09, 2022
  11. Feb 18, 2022
  12. Feb 09, 2022
  13. Feb 08, 2022
  14. Jan 29, 2022
    • Andrew Waterman's avatar
      Merge branch 'compnerd-virtualize' · fb77b0c2
      Andrew Waterman authored
      fb77b0c2
    • Saleem Abdulrasool's avatar
      pk: thwart an attempt from the compiler to optimize · 1d6f1bd0
      Saleem Abdulrasool authored
      The memory manager maintains the first free page as the page after the
      `_end` synthetic emitted by the linker.  This value is stored in a
      translation unit local variable.  This value is only ever written to
      from `init_early_alloc` which is static and only ever invoked from
      `pk_vm_init`.  Furthermore, the value that `first_free_page` is ever set
      to is computed as a rounding of the _address_ of `_end`.  Because the
      address of the symbol cannot change during execution of a normal
      program, this is effectively a constant, making the computed value a
      "constant" which can be re-materialized.  Now, with the knowledge that
      the value is effectively a constant that can be re-materialized and the
      fact that the value is ever written to at a single position, we can
      simply re-materialize the value if it was ever changed in
      `free_page_addr`.  This will allow the 8-byte value to be truncated to
      1-byte.
      
      Now, we can inline `__early_pgalloc_align`, and because the combination
      of `__early_alloc` and `__early_pgalloc_align` is small, we can inline
      that again at the two sites locally.  This changes the
      `__augment_page_freelist` to re-materialize the constant when needed for
      the allocation.
      
      The re-materialization however uses a pc-relative addressing, which now
      computes a different value than expected - the address has become a VA
      rather than a PA.  This results in the address computed by
      `free_page_addr` (which is the result of the `__early_pgalloc_align`) to
      be a virtual address after the relocation, which then propagates through
      `__early_alloc` to the value in `__augment_page_freelist`, which is then
      consumed by `__page_alloc`, which will treat the now VA as a PA and
      perform an additional translation to a VA.
      
      Mark the value as `volatile` to indicate that the value must be read at
      all points to thwart the size optimization of the compiler resulting in
      a mis-compilation resulting in the eventual invalid memory access during
      the `memset` that follows the allocation.
      
      Thanks to @nzmichaelh for the help in tracking this down!
      1d6f1bd0
  15. Jan 10, 2022
    • Andrew Waterman's avatar
      fix file leak · 387e54a5
      Andrew Waterman authored
      Eliminate excess reference count when associating fd with file.
      
      Fixes #258
      387e54a5
  16. Nov 23, 2021
  17. Sep 21, 2021
  18. Sep 15, 2021
  19. Aug 28, 2021
    • Saleem Abdulrasool's avatar
      pk: correct the handling of SYS_getcwd (#250) · 2f3e6f53
      Saleem Abdulrasool authored
      `SYS_getcwd` is different from `getcwd` in that the return value is < 0
      on failure otherwise it is the length of the string.  The proxy kernel
      was treating 0 as success and all other values as error.  As a result,
      we would never return a valid value for `getcwd`.
      
      The following program now executes properly with the Proxy Kernel:
        ```c
        #include <stdio.h>
        #include <stdlib.h>
        #include <unistd.h>
      
        #include <linux/limits.h>
      
        int main(int argc, char **argv) {
          unsigned char buffer[PATH_MAX + 1] = {0};
          if (getcwd(buffer, PATH_MAX))
            printf("cwd: %s\n", buffer);
          return EXIT_SUCCESS;
        }
        ```
      2f3e6f53
  20. Aug 12, 2021
  21. Aug 05, 2021
  22. Jun 17, 2021
  23. May 18, 2021
  24. May 08, 2021
    • Andrew Waterman's avatar
      pk: make breakpoints fatal · 4f1e3355
      Andrew Waterman authored
      Resolves #216
      4f1e3355
    • Saleem Abdulrasool's avatar
      machine: correct some additional cases of UB (#246) · e8d15a48
      Saleem Abdulrasool authored
      Use of asm aliased register variables in local scope can only be used
      for extended assembly parameters.  This changes the few instances of
      this in the floating point emulation to use the GNU extended assembly
      syntax to access the `tp` register.  This ensures that we do not rely on
      undefined behaviour.  This was uncovered when building the Proxy kernel
      with clang and LLVM.
      e8d15a48
    • Saleem Abdulrasool's avatar
      machine: fix a case of undefined behaviour with SP handling (#245) · 5450c2f7
      Saleem Abdulrasool authored
      The use of `asm` for register aliasing is supported in two different
      contexts:
      - local variables (including GNU expression statements) where it may
        only be used for specifying registers for input and output operands to
        extended `asm` syntax.
      
        c.f. https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html#Local-Register-Variables
      
      - global variables where it may be used to observe the contents of a
        register.
      
        c.f. https://gcc.gnu.org/onlinedocs/gcc/Global-Register-Variables.html#Global-Register-Variables
      
      The two options here is to either to hoist the variable out into a
      global variable, but then it should not be in a header due to fears of
      ODR in case the optimizer does not inline it away, and thus becomes a
      bit more tricky.  The alternative that this change actually adopts is to
      explicitly use a move to copy the value out via the GNU extended
      assembly syntax.
      
      With this change, it is now possible to build the Proxy Kernel
      completely with clang/LLVM and link with LLD.  The generated kernel also
      runs under SPIKE and behaves as expected in a simple smoke test (without
      any executable prints the expected message, and runs a trivial RVV
      example).
      5450c2f7
  25. May 07, 2021
    • Saleem Abdulrasool's avatar
      machine: manually perform assembler relaxation (#244) · 23f1834f
      Saleem Abdulrasool authored
      This is an equivalent rewrite of the existing code.  When building with
      gas, the `bltu` would implicitly get relaxed to the `bgeu` + `j`.  This
      relaxation is required as the `init_other_hart` is not guaranteed to be
      addressable in 12-bits.  When building with the LLVM IAS instead of gas
      we fail to link as the branch is not relaxed.  This change enables LLVM
      to build and link this code with the LLVM IAS and lld.
      23f1834f
  26. May 06, 2021