1. 10 Jan, 2022 1 commit
  2. 31 Dec, 2021 1 commit
  3. 05 Aug, 2021 1 commit
    • Ka Ho Ng's avatar
      Add vnode_pager_purge_range(9) KPI · de2e1529
      Ka Ho Ng authored
      This KPI is created in addition to the existing vnode_pager_setsize(9)
      KPI. The KPI is intended for file systems that are able to turn a range
      of file into sparse range, also known as hole-punching.
      
      Sponsored by:	The FreeBSD Foundation
      Reviewed by:	kib
      Differential Revision:	https://reviews.freebsd.org/D27194
      de2e1529
  4. 17 Aug, 2020 2 commits
    • markj's avatar
      Remove the VM map zone. · db0b2039
      markj authored
      Today, the zone is only used to allocate a trio of kernel maps: the
      kernel map itself, and the exec and pipe submaps.  Maps for user
      processes are dynamically allocated but are embedded in the vmspace
      structure, which is allocated from its own zone.  Make the
      aforementioned kernel maps statically allocated and get rid of the zone.
      
      While here, remove a stale comment above vmspace_alloc() and change the
      names of locks initialized in vm_map_init() to match vmspace_zinit().
      
      Reported by:	alc
      Reviewed by:	alc, kib
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D26052
      db0b2039
    • Mark Johnston's avatar
      Remove the VM map zone. · 7dd979df
      Mark Johnston authored
      Today, the zone is only used to allocate a trio of kernel maps: the
      kernel map itself, and the exec and pipe submaps.  Maps for user
      processes are dynamically allocated but are embedded in the vmspace
      structure, which is allocated from its own zone.  Make the
      aforementioned kernel maps statically allocated and get rid of the zone.
      
      While here, remove a stale comment above vmspace_alloc() and change the
      names of locks initialized in vm_map_init() to match vmspace_zinit().
      
      Reported by:	alc
      Reviewed by:	alc, kib
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D26052
      7dd979df
  5. 26 Apr, 2020 2 commits
    • markj's avatar
      Use a single VM object for kernel stacks. · 4b7a0ef9
      markj authored
      Previously we allocated a separate VM object for each kernel stack.
      However, fully constructed kernel stacks are cached by UMA, so there is
      no harm in using a single global object for all stacks.  This reduces
      memory consumption and makes it easier to define a memory allocation
      policy for kernel stack pages, with the aim of reducing physical memory
      fragmentation.
      
      Add a global kstack_object, and use the stack KVA address to index into
      the object like we do with kernel_object.
      
      Reviewed by:	kib
      Tested by:	pho
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D24473
      4b7a0ef9
    • Mark Johnston's avatar
      Use a single VM object for kernel stacks. · f13fa9df
      Mark Johnston authored
      Previously we allocated a separate VM object for each kernel stack.
      However, fully constructed kernel stacks are cached by UMA, so there is
      no harm in using a single global object for all stacks.  This reduces
      memory consumption and makes it easier to define a memory allocation
      policy for kernel stack pages, with the aim of reducing physical memory
      fragmentation.
      
      Add a global kstack_object, and use the stack KVA address to index into
      the object like we do with kernel_object.
      
      Reviewed by:	kib
      Tested by:	pho
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D24473
      f13fa9df
  6. 27 Sep, 2019 2 commits
    • kib's avatar
      Improve MD page fault handlers. · 95727078
      kib authored
      Centralize calculation of signal and ucode delivered on unhandled page
      fault in new function vm_fault_trap().  MD trap_pfault() now almost
      always uses the signal numbers and error codes calculated in
      consistent MI way.
      
      This introduces the protection fault compatibility sysctls to all
      non-x86 architectures which did not have that bug, but apparently they
      were already much more wrong in selecting delivered signals on
      protection violations.
      
      Change the delivered signal for accesses to mapped area after the
      backing object was truncated.  According to POSIX description for
      mmap(2):
         The system shall always zero-fill any partial page at the end of an
         object. Further, the system shall never write out any modified
         portions of the last page of an object which are beyond its
         end. References within the address range starting at pa and
         continuing for len bytes to whole pages following the end of an
         object shall result in delivery of a SIGBUS signal.
      
         An implementation may generate SIGBUS signals when a reference
         would cause an error in the mapped object, such as out-of-space
         condition.
      Adjust according to the description, keeping the existing
      compatibility code for SIGSEGV/SIGBUS on protection failures.
      
      For situations where kernel cannot handle page fault due to resource
      limit enforcement, SIGBUS with a new error code BUS_OBJERR is
      delivered.  Also, provide a new error code SEGV_PKUERR for SIGSEGV on
      amd64 due to protection key access violation.
      
      vm_fault_hold() is renamed to vm_fault().  Fixed some nits in
      trap_pfault()s like mis-interpreting Mach errors as errnos.  Removed
      unneeded truncations of the fault addresses reported by hardware.
      
      PR:	211924
      Reviewed by:	alc
      Discussed with:	jilles, markj
      Sponsored by:	The FreeBSD Foundation
      MFC after:	1 week
      Differential revision:	https://reviews.freebsd.org/D21566
      95727078
    • Konstantin Belousov's avatar
      Improve MD page fault handlers. · df08823d
      Konstantin Belousov authored
      Centralize calculation of signal and ucode delivered on unhandled page
      fault in new function vm_fault_trap().  MD trap_pfault() now almost
      always uses the signal numbers and error codes calculated in
      consistent MI way.
      
      This introduces the protection fault compatibility sysctls to all
      non-x86 architectures which did not have that bug, but apparently they
      were already much more wrong in selecting delivered signals on
      protection violations.
      
      Change the delivered signal for accesses to mapped area after the
      backing object was truncated.  According to POSIX description for
      mmap(2):
         The system shall always zero-fill any partial page at the end of an
         object. Further, the system shall never write out any modified
         portions of the last page of an object which are beyond its
         end. References within the address range starting at pa and
         continuing for len bytes to whole pages following the end of an
         object shall result in delivery of a SIGBUS signal.
      
         An implementation may generate SIGBUS signals when a reference
         would cause an error in the mapped object, such as out-of-space
         condition.
      Adjust according to the description, keeping the existing
      compatibility code for SIGSEGV/SIGBUS on protection failures.
      
      For situations where kernel cannot handle page fault due to resource
      limit enforcement, SIGBUS with a new error code BUS_OBJERR is
      delivered.  Also, provide a new error code SEGV_PKUERR for SIGSEGV on
      amd64 due to protection key access violation.
      
      vm_fault_hold() is renamed to vm_fault().  Fixed some nits in
      trap_pfault()s like mis-interpreting Mach errors as errnos.  Removed
      unneeded truncations of the fault addresses reported by hardware.
      
      PR:	211924
      Reviewed by:	alc
      Discussed with:	jilles, markj
      Sponsored by:	The FreeBSD Foundation
      MFC after:	1 week
      Differential revision:	https://reviews.freebsd.org/D21566
      df08823d
  7. 30 Oct, 2018 2 commits
    • markj's avatar
      Add malloc_domainset(9) and _domainset variants to other allocator KPIs. · f931b753
      markj authored
      Remove malloc_domain(9) and most other _domain KPIs added in r327900.
      The new functions allow the caller to specify a general NUMA domain
      selection policy, rather than specifically requesting an allocation from
      a specific domain.  The latter policy tends to interact poorly with
      M_WAITOK, resulting in situations where a caller is blocked indefinitely
      because the specified domain is depleted.  Most existing consumers of
      the _domain KPIs are converted to instead use a DOMAINSET_PREF() policy,
      in which we fall back to other domains to satisfy the allocation
      request.
      
      This change also defines a set of DOMAINSET_FIXED() policies, which
      only permit allocations from the specified domain.
      
      Discussed with:	gallatin, jeff
      Reported and tested by:	pho (previous version)
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D17418
      f931b753
    • Mark Johnston's avatar
      Add malloc_domainset(9) and _domainset variants to other allocator KPIs. · 9978bd99
      Mark Johnston authored
      Remove malloc_domain(9) and most other _domain KPIs added in r327900.
      The new functions allow the caller to specify a general NUMA domain
      selection policy, rather than specifically requesting an allocation from
      a specific domain.  The latter policy tends to interact poorly with
      M_WAITOK, resulting in situations where a caller is blocked indefinitely
      because the specified domain is depleted.  Most existing consumers of
      the _domain KPIs are converted to instead use a DOMAINSET_PREF() policy,
      in which we fall back to other domains to satisfy the allocation
      request.
      
      This change also defines a set of DOMAINSET_FIXED() policies, which
      only permit allocations from the specified domain.
      
      Discussed with:	gallatin, jeff
      Reported and tested by:	pho (previous version)
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D17418
      9978bd99
  8. 25 Aug, 2018 2 commits
    • alc's avatar
      Eliminate the arena parameter to kmem_free(). Implicitly this corrects an · 3799d78b
      alc authored
      error in the function hypercall_memfree(), where the wrong arena was being
      passed to kmem_free().
      
      Introduce a per-page flag, VPO_KMEM_EXEC, to mark physical pages that are
      mapped in kmem with execute permissions.  Use this flag to determine which
      arena the kmem virtual addresses are returned to.
      
      Eliminate UMA_SLAB_KRWX.  The introduction of VPO_KMEM_EXEC makes it
      redundant.
      
      Update the nearby comment for UMA_SLAB_KERNEL.
      
      Reviewed by:	kib, markj
      Discussed with:	jeff
      Approved by:	re (marius)
      Differential Revision:	https://reviews.freebsd.org/D16845
      3799d78b
    • Alan Cox's avatar
      Eliminate the arena parameter to kmem_free(). Implicitly this corrects an · 49bfa624
      Alan Cox authored
      error in the function hypercall_memfree(), where the wrong arena was being
      passed to kmem_free().
      
      Introduce a per-page flag, VPO_KMEM_EXEC, to mark physical pages that are
      mapped in kmem with execute permissions.  Use this flag to determine which
      arena the kmem virtual addresses are returned to.
      
      Eliminate UMA_SLAB_KRWX.  The introduction of VPO_KMEM_EXEC makes it
      redundant.
      
      Update the nearby comment for UMA_SLAB_KERNEL.
      
      Reviewed by:	kib, markj
      Discussed with:	jeff
      Approved by:	re (marius)
      Differential Revision:	https://reviews.freebsd.org/D16845
      49bfa624
  9. 21 Aug, 2018 2 commits
  10. 20 Aug, 2018 2 commits
  11. 18 Aug, 2018 5 commits
  12. 19 Jul, 2018 2 commits
    • markj's avatar
      Have preload_delete_name() free pages backing preloaded data. · 1810bcca
      markj authored
      On i386 and amd64, add a vm_phys segment for physical memory used to
      store the kernel binary and other preloaded data.  This makes it
      possible to free such memory back to the system once it is no longer
      needed, e.g., when a preloaded kernel module is unloaded.  Previously,
      it would have remained unused.
      
      Reviewed by:	kib, royger
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D16330
      1810bcca
    • Mark Johnston's avatar
      Have preload_delete_name() free pages backing preloaded data. · 483f692e
      Mark Johnston authored
      On i386 and amd64, add a vm_phys segment for physical memory used to
      store the kernel binary and other preloaded data.  This makes it
      possible to free such memory back to the system once it is no longer
      needed, e.g., when a preloaded kernel module is unloaded.  Previously,
      it would have remained unused.
      
      Reviewed by:	kib, royger
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D16330
      483f692e
  13. 13 Jun, 2018 2 commits
    • jtl's avatar
      Make UMA and malloc(9) return non-executable memory in most cases. · 8222f5cb
      jtl authored
      Most kernel memory that is allocated after boot does not need to be
      executable.  There are a few exceptions.  For example, kernel modules
      do need executable memory, but they don't use UMA or malloc(9).  The
      BPF JIT compiler also needs executable memory and did use malloc(9)
      until r317072.
      
      (Note that a side effect of r316767 was that the "small allocation"
      path in UMA on amd64 already returned non-executable memory.  This
      meant that some calls to malloc(9) or the UMA zone(9) allocator could
      return executable memory, while others could return non-executable
      memory.  This change makes the behavior consistent.)
      
      This change makes malloc(9) return non-executable memory unless the new
      M_EXEC flag is specified.  After this change, the UMA zone(9) allocator
      will always return non-executable memory, and a KASSERT will catch
      attempts to use the M_EXEC flag to allocate executable memory using
      uma_zalloc() or its variants.
      
      Allocations that do need executable memory have various choices.  They
      may use the M_EXEC flag to malloc(9), or they may use a different VM
      interfact to obtain executable pages.
      
      Now that malloc(9) again allows executable allocations, this change also
      reverts most of r317072.
      
      PR:		228927
      Reviewed by:	alc, kib, markj, jhb (previous version)
      Sponsored by:	Netflix
      Differential Revision:	https://reviews.freebsd.org/D15691
      8222f5cb
    • Jonathan T. Looney's avatar
      Make UMA and malloc(9) return non-executable memory in most cases. · 0766f278
      Jonathan T. Looney authored
      Most kernel memory that is allocated after boot does not need to be
      executable.  There are a few exceptions.  For example, kernel modules
      do need executable memory, but they don't use UMA or malloc(9).  The
      BPF JIT compiler also needs executable memory and did use malloc(9)
      until r317072.
      
      (Note that a side effect of r316767 was that the "small allocation"
      path in UMA on amd64 already returned non-executable memory.  This
      meant that some calls to malloc(9) or the UMA zone(9) allocator could
      return executable memory, while others could return non-executable
      memory.  This change makes the behavior consistent.)
      
      This change makes malloc(9) return non-executable memory unless the new
      M_EXEC flag is specified.  After this change, the UMA zone(9) allocator
      will always return non-executable memory, and a KASSERT will catch
      attempts to use the M_EXEC flag to allocate executable memory using
      uma_zalloc() or its variants.
      
      Allocations that do need executable memory have various choices.  They
      may use the M_EXEC flag to malloc(9), or they may use a different VM
      interfact to obtain executable pages.
      
      Now that malloc(9) again allows executable allocations, this change also
      reverts most of r317072.
      
      PR:		228927
      Reviewed by:	alc, kib, markj, jhb (previous version)
      Sponsored by:	Netflix
      Differential Revision:	https://reviews.freebsd.org/D15691
      0766f278
  14. 06 Feb, 2018 2 commits
  15. 12 Jan, 2018 2 commits
  16. 20 Nov, 2017 2 commits
    • pfg's avatar
      sys: further adoption of SPDX licensing ID tags. · 4736ccfd
      pfg authored
      Mainly focus on files that use BSD 3-Clause license.
      
      The Software Package Data Exchange (SPDX) group provides a specification
      to make it easier for automated tools to detect and summarize well known
      opensource licenses. We are gradually adopting the specification, noting
      that the tags are considered only advisory and do not, in any way,
      superceed or replace the license texts.
      
      Special thanks to Wind River for providing access to "The Duke of
      Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
      starting point.
      4736ccfd
    • Pedro F. Giffuni's avatar
      sys: further adoption of SPDX licensing ID tags. · 51369649
      Pedro F. Giffuni authored
      Mainly focus on files that use BSD 3-Clause license.
      
      The Software Package Data Exchange (SPDX) group provides a specification
      to make it easier for automated tools to detect and summarize well known
      opensource licenses. We are gradually adopting the specification, noting
      that the tags are considered only advisory and do not, in any way,
      superceed or replace the license texts.
      
      Special thanks to Wind River for providing access to "The Duke of
      Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
      starting point.
      51369649
  17. 20 Oct, 2017 2 commits
  18. 28 Feb, 2017 2 commits
    • imp's avatar
      Renumber copyright clause 4 · 7e6cabd0
      imp authored
      Renumber cluase 4 to 3, per what everybody else did when BSD granted
      them permission to remove clause 3. My insistance on keeping the same
      numbering for legal reasons is too pedantic, so give up on that point.
      
      Submitted by:	Jan Schaumann <jschauma@stevens.edu>
      Pull Request:	https://github.com/freebsd/freebsd/pull/96
      7e6cabd0
    • Warner Losh's avatar
      Renumber copyright clause 4 · fbbd9655
      Warner Losh authored
      Renumber cluase 4 to 3, per what everybody else did when BSD granted
      them permission to remove clause 3. My insistance on keeping the same
      numbering for legal reasons is too pedantic, so give up on that point.
      
      Submitted by:	Jan Schaumann <jschauma@stevens.edu>
      Pull Request:	https://github.com/freebsd/freebsd/pull/96
      fbbd9655
  19. 13 Feb, 2017 2 commits
    • kib's avatar
      Rework r313352. · 0dac2c59
      kib authored
      Rename kern_vm_* functions to kern_*.  Move the prototypes to
      syscallsubr.h.  Also change Mach VM types to uintptr_t/size_t as
      needed, to avoid headers pollution.
      
      Requested by:	alc, jhb
      Reviewed by:	alc
      Sponsored by:	The FreeBSD Foundation
      MFC after:	2 weeks
      Differential revision:	https://reviews.freebsd.org/D9535
      0dac2c59
    • Konstantin Belousov's avatar
      Rework r313352. · 496ab053
      Konstantin Belousov authored
      Rename kern_vm_* functions to kern_*.  Move the prototypes to
      syscallsubr.h.  Also change Mach VM types to uintptr_t/size_t as
      needed, to avoid headers pollution.
      
      Requested by:	alc, jhb
      Reviewed by:	alc
      Sponsored by:	The FreeBSD Foundation
      MFC after:	2 weeks
      Differential revision:	https://reviews.freebsd.org/D9535
      496ab053
  20. 11 Feb, 2017 2 commits
    • kib's avatar
      Change type of the prot parameter for kern_vm_mmap() from vm_prot_t to int. · 95e32f28
      kib authored
      This makes the code to pass whole word of the mmap(2) syscall argument
      prot to the syscall helper kern_vm_mmap(), which can validate all
      bits.  The change provides temporal fix for sys/vm/mmap_test
      mmap__bad_arguments, which was broken after r313352.
      
      PR:	216976
      Reported and tested by:	ngie
      Sponsored by:	The FreeBSD Foundation
      95e32f28
    • Konstantin Belousov's avatar
      Change type of the prot parameter for kern_vm_mmap() from vm_prot_t to int. · 1c2ad3e9
      Konstantin Belousov authored
      This makes the code to pass whole word of the mmap(2) syscall argument
      prot to the syscall helper kern_vm_mmap(), which can validate all
      bits.  The change provides temporal fix for sys/vm/mmap_test
      mmap__bad_arguments, which was broken after r313352.
      
      PR:	216976
      Reported and tested by:	ngie
      Sponsored by:	The FreeBSD Foundation
      1c2ad3e9