1. 10 Mar, 2021 1 commit
    • Alex Richardson's avatar
      Arch64: Clear VFP state on execve() · 953a7d7c
      Alex Richardson authored
      I noticed that many of the math-related tests were failing on AArch64.
      After a lot of debugging, I noticed that the floating point exception flags
      were not being reset when starting a new process. This change resets the
      VFP inside exec_setregs() to ensure no VFP register state is leaked from
      parent processes to children.
      
      This commit also moves the clearing of fpcr that was added in 65618fdd
      from fork() to execve() since that makes more sense: fork() can retain
      current register values, but execve() should result in a well-defined
      clean state.
      
      Reviewed By:	andrew
      MFC after:	1 week
      Differential Revision: https://reviews.freebsd.org/D29060
      953a7d7c
  2. 01 Mar, 2021 1 commit
  3. 08 Feb, 2021 1 commit
  4. 03 Feb, 2021 1 commit
  5. 19 Jan, 2021 2 commits
  6. 08 Jan, 2021 1 commit
    • mhorne's avatar
      arm64: remove pcb_pc · 5f66d5a3
      mhorne authored
      The program counter field in the PCB is written in exactly one place,
      makectx(), upon entry to the debugger. For threads other than curthread,
      its value will be empty, or bogus. Rather than writing to this field in
      more places, it can be removed in favor of using the value in the link
      register.
      
      To make this clearer, pcb->pcb_x[30] is renamed to pcb->pcb_lr, similar
      to what already exists in struct trapframe. Also, prefer lr to x30 in
      assembly, as it better conveys intention.
      
      This improves PC_REGS() for kdb_thread != curthread. It is required for
      a functional gdb(4) stub, fixing the output of `info threads`, in
      particular.
      
      The space occupied by pcb_pc is retained, for compatibility with kgdb.
      
      Reviewed by:	markj, jhb
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D27720
      5f66d5a3
  7. 15 Sep, 2020 1 commit
  8. 03 Nov, 2019 1 commit
    • Alan Cox's avatar
      Utilize ASIDs to reduce both the direct and indirect costs of context · 50e3ab6b
      Alan Cox authored
      switching.  The indirect costs being unnecessary TLB misses that are
      incurred when ASIDs are not used.  In fact, currently, when we perform a
      context switch on one processor, we issue a broadcast TLB invalidation that
      flushes the TLB contents on every processor.
      
      Mark all user-space ("ttbr0") page table entries with the non-global flag so
      that they are cached in the TLB under their ASID.
      
      Correct an error in pmap_pinit0().  The pointer to the root of the page
      table was being initialized to the root of the kernel-space page table
      rather than a user-space page table.  However, the root of the page table
      that was being cached in process 0's md_l0addr field correctly pointed to a
      user-space page table.  As long as ASIDs weren't being used, this was
      harmless, except that it led to some unnecessary page table switches in
      pmap_switch().  Specifically, other kernel processes besides process 0 would
      have their md_l0addr field set to the root of the kernel-space page table,
      and so pmap_switch() would actually change page tables when switching
      between process 0 and other kernel processes.
      
      Implement a workaround for Cavium erratum 27456 affecting ThunderX machines.
      (I would like to thank andrew@ for providing the code to detect the affected
      machines.)
      
      Address integer overflow in the definition of TCR_ASID_16.
      
      Setup TCR according to the PARange and ASIDBits fields from
      ID_AA64MMFR0_EL1.  Previously, TCR_ASID_16 was unconditionally set.
      
      Modify build_l1_block_pagetable so that lower attributes, such as ATTR_nG,
      can be specified as a parameter.
      
      Eliminate some unused code.
      
      Earlier versions were tested to varying degrees by: andrew, emaste, markj
      
      MFC after:	3 weeks
      Differential Revision:	https://reviews.freebsd.org/D21922
      50e3ab6b
  9. 30 Oct, 2019 1 commit
    • Andrew Turner's avatar
      Allow exceptions to be masked when in userspace · 739e4482
      Andrew Turner authored
      We may want to mask exceptions when in userspace. This was previously
      impossible as threads are created with all exceptions unmasked and
      signals expected userspace to mask any. Fix these by copying the
      mask state on thread creation and allow exceptions to be masked on
      signal return, as long as they don't change.
      
      Sponsored by:	DARPA, AFRL
      739e4482
  10. 16 Mar, 2019 2 commits
    • Konstantin Belousov's avatar
      amd64 KPTI: add control from procctl(2). · fd8d844f
      Konstantin Belousov authored
      Add the infrastructure to allow MD procctl(2) commands, and use it to
      introduce amd64 PTI control and reporting.  PTI mode cannot be
      modified for existing pmap, the knob controls PTI of the new vmspace
      created on exec.
      
      Requested by:	jhb
      Reviewed by:	jhb, markj (previous version)
      Tested by:	pho
      Sponsored by:	The FreeBSD Foundation
      MFC after:	1 week
      Differential revision:	https://reviews.freebsd.org/D19514
      fd8d844f
    • Konstantin Belousov's avatar
      amd64: Add md process flags and first P_MD_PTI flag. · 6f1fe330
      Konstantin Belousov authored
      PTI mode for the process pmap on exec is activated iff P_MD_PTI is set.
      
      On exec, the existing vmspace can be reused only if pti mode of the
      pmap matches the P_MD_PTI flag of the process.  Add MD
      cpu_exec_vmspace_reuse() callback for exec_new_vmspace() which can
      vetoed reuse of the existing vmspace.
      
      MFC note: md_flags change struct proc KBI.
      
      Reviewed by:	jhb, markj
      Tested by:	pho
      Sponsored by:	The FreeBSD Foundation
      MFC after:	1 week
      Differential revision:	https://reviews.freebsd.org/D19514
      6f1fe330
  11. 13 Jan, 2019 1 commit
  12. 11 Jan, 2019 1 commit
    • Andrew Turner's avatar
      Fix the location of td->td_frame at the top of the kernel stack. · 80e21aab
      Andrew Turner authored
      In cpu_thread_alloc we would allocate space for the trap frame at the top of
      the kernel stack. This is just below the pcb, however due to a missing cast
      the pointer arithmetic would use the pcb size, not the trapframe size. As
      the pcb is larger than the trapframe this is safe, however later in cpu_fork
      we include the case leading to the two disagreeing on the location.
      
      Fix by using the same arithmetic in both locations.
      
      Found by:	An early KASAN patch
      Sponsored by:	DARPA, AFRL
      80e21aab
  13. 22 Oct, 2018 1 commit
  14. 25 Jun, 2018 1 commit
  15. 10 Jun, 2018 1 commit
  16. 22 Aug, 2017 1 commit
  17. 24 Apr, 2017 1 commit
  18. 14 Oct, 2016 1 commit
  19. 10 Aug, 2016 1 commit
  20. 16 Jun, 2016 1 commit
    • Konstantin Belousov's avatar
      Update comments for the MD functions managing contexts for new · 5c2cf818
      Konstantin Belousov authored
      threads, to make it less confusing and using modern kernel terms.
      
      Rename the functions to reflect current use of the functions, instead
      of the historic KSE conventions:
        cpu_set_fork_handler -> cpu_fork_kthread_handler (for kthreads)
        cpu_set_upcall -> cpu_copy_thread (for forks)
        cpu_set_upcall_kse -> cpu_set_upcall (for new threads creation)
      
      Reviewed by:	jhb (previous version)
      Sponsored by:	The FreeBSD Foundation
      MFC after:	1 week
      Approved by:	re (hrs)
      Differential revision:	https://reviews.freebsd.org/D6731
      5c2cf818
  21. 11 May, 2016 1 commit
  22. 31 Mar, 2016 1 commit
    • Andrew Turner's avatar
      Add support for 4 level pagetables. The userland address space has been · f2f21faf
      Andrew Turner authored
      increased to 256TiB. The kernel address space can also be increased to be
      the same size, but this will be performed in a later change.
      
      To help work with an extra level of page tables two new functions have
      been added, one to file the lowest level table entry, and one to find the
      block/page level. Both of these find the entry for a given pmap and virtual
      address.
      
      This has been tested with a combination of buildworld, stress2 tests, and
      by using sort to consume a large amount of memory by sorting /dev/zero. No
      new issues are known to be present from this change.
      
      Reviewed by:	kib
      Obtained from:	ABT Systems Ltd
      Relnotes:	yes
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D5720
      f2f21faf
  23. 09 Feb, 2016 1 commit
  24. 04 Feb, 2016 1 commit
  25. 27 Jan, 2016 1 commit
  26. 03 Aug, 2015 1 commit
  27. 31 Jul, 2015 1 commit
  28. 30 Jul, 2015 1 commit
  29. 05 Jul, 2015 1 commit
  30. 15 Apr, 2015 1 commit
  31. 13 Apr, 2015 1 commit
    • Andrew Turner's avatar
      Bring in the start of the arm64 kernel. · e5acd89c
      Andrew Turner authored
      This is only the minimum set of files needed to boot in qemu. As such it is
      missing a few things.
      
      The bus_dma code is currently only stub functions with a full implementation
      from the development tree to follow.
      
      The gic driver has been copied as the interrupt framework is different. It
      is expected the two drivers will be merged by the arm intrng project,
      however this will need to be imported into the tree and support for arm64
      would need to be added.
      
      This includes code developed by myself, SemiHalf, Ed Maste, and Robin
      Randhawa from ARM. This has been funded by the FreeBSD Foundation, with
      early development by myself in my spare time with assistance from Robin.
      
      Differential Revision:	https://reviews.freebsd.org/D2199
      Reviewed by:	emaste, imp
      Relnotes:	yes
      Sponsored by:	The FreeBSD Foundation
      e5acd89c