1. 14 Jan, 2022 1 commit
  2. 22 Nov, 2021 1 commit
  3. 14 May, 2019 1 commit
  4. 30 Jan, 2019 1 commit
    • Konstantin Belousov's avatar
      i386: Merge PAE and non-PAE pmaps into same kernel. · 9a527560
      Konstantin Belousov authored
      Effectively all i386 kernels now have two pmaps compiled in: one
      managing PAE pagetables, and another non-PAE. The implementation is
      selected at cold time depending on the CPU features. The vm_paddr_t is
      always 64bit now. As result, nx bit can be used on all capable CPUs.
      Option PAE only affects the bus_addr_t: it is still 32bit for non-PAE
      configs, for drivers compatibility. Kernel layout, esp. max kernel
      address, low memory PDEs and max user address (same as trampoline
      start) are now same for PAE and for non-PAE regardless of the type of
      page tables used.
      Non-PAE kernel (when using PAE pagetables) can handle physical memory
      up to 24G now, larger memory requires re-tuning the KVA consumers and
      instead the code caps the maximum at 24G. Unfortunately, a lot of
      drivers do not use busdma(9) properly so by default even 4G barrier is
      not easy. There are two tunables added: hw.above4g_allow and
      hw.above24g_allow, the first one is kept enabled for now to evaluate
      the status on HEAD, second is only for dev use.
      i386 now creates three freelists if there is any memory above 4G, to
      allow proper bounce pages allocation. Also, VM_KMEM_SIZE_SCALE changed
      from 3 to 1.
      The PAE_TABLES kernel config option is retired.
      In collaboarion with: pho
      Discussed with:	emaste
      Reviewed by:	markj
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential revision:	https://reviews.freebsd.org/D18894
  5. 23 May, 2018 1 commit
  6. 13 Apr, 2018 1 commit
    • Konstantin Belousov's avatar
      i386 4/4G split. · d86c1f0d
      Konstantin Belousov authored
      The change makes the user and kernel address spaces on i386
      independent, giving each almost the full 4G of usable virtual addresses
      except for one PDE at top used for trampoline and per-CPU trampoline
      stacks, and system structures that must be always mapped, namely IDT,
      GDT, common TSS and LDT, and process-private TSS and LDT if allocated.
      By using 1:1 mapping for the kernel text and data, it appeared
      possible to eliminate assembler part of the locore.S which bootstraps
      initial page table and KPTmap.  The code is rewritten in C and moved
      into the pmap_cold(). The comment in vmparam.h explains the KVA
      There is no PCID mechanism available in protected mode, so each
      kernel/user switch forth and back completely flushes the TLB, except
      for the trampoline PTD region. The TLB invalidations for userspace
      becomes trivial, because IPI handlers switch page tables. On the other
      hand, context switches no longer need to reload %cr3.
      copyout(9) was rewritten to use vm_fault_quick_hold().  An issue for
      new copyout(9) is compatibility with wiring user buffers around sysctl
      handlers. This explains two kind of locks for copyout ptes and
      accounting of the vslock() calls.  The vm_fault_quick_hold() AKA slow
      path, is only tried after the 'fast path' failed, which temporary
      changes mapping to the userspace and copies the data to/from small
      per-cpu buffer in the trampoline.  If a page fault occurs during the
      copy, it is short-circuit by exception.s to not even reach C code.
      The change was motivated by the need to implement the Meltdown
      mitigation, but instead of KPTI the full split is done.  The i386
      architecture already shows the sizing problems, in particular, it is
      impossible to link clang and lld with debugging.  I expect that the
      issues due to the virtual address space limits would only exaggerate
      and the split gives more liveness to the platform.
      Tested by: pho
      Discussed with:	bde
      Sponsored by:	The FreeBSD Foundation
      MFC after:	1 month
      Differential revision:	https://reviews.freebsd.org/D14633
  7. 06 Apr, 2018 1 commit
    • Brooks Davis's avatar
      Move most of the contents of opt_compat.h to opt_global.h. · 6469bdcd
      Brooks Davis authored
      opt_compat.h is mentioned in nearly 180 files. In-progress network
      driver compabibility improvements may add over 100 more so this is
      closer to "just about everywhere" than "only some files" per the
      guidance in sys/conf/options.
      Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
      sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
      is created on all architectures.
      Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
      set of compiled files.
      Reviewed by:	kib, cem, jhb, jtl
      Sponsored by:	DARPA, AFRL
      Differential Revision:	https://reviews.freebsd.org/D14941
  8. 20 Nov, 2017 1 commit
    • 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.
  9. 04 Nov, 2017 1 commit
  10. 28 Sep, 2017 1 commit
    • Konstantin Belousov's avatar
      A different fix for the issue from r323722. · 34921658
      Konstantin Belousov authored
      Split the handlers for pop of invalid selectors from the trap frame
      into usermode and kernel variants.  Usermode handler is kept as is, it
      restores the already loaded parts of the trap frame and jumps to set
      up a signal delivery to the user process.
      New kernel part of the handler emulates IRET treatment of the segments
      which would violate access right.  It loads NUL selector in the
      segment register which load causes the fault, and then continues the
      return to interrupted kernel code.  Since invalid selectors in the
      segment registers in the kernel mode can only exist while kernel still
      enters or exits from userspace, we only zero invalid userspace
      selectors.  If userspace tries to use the segment register, it gets a
      signal, as if the processor segment descriptor cache was reloaded.
      Reported by:	Maxime Villard <max@m00nbsd.net>
      Suggested and reviewed by:	bde
      Sponsored by:	The FreeBSD Foundation
      MFC after:	1 week
  11. 30 Jul, 2017 1 commit
  12. 17 Apr, 2017 1 commit
  13. 27 Mar, 2017 1 commit
    • Andriy Gapon's avatar
      revert r315959 because it causes build problems · 978f3da1
      Andriy Gapon authored
      The change introduced a dependency between genassym.c and header files
      generated from .m files, but that dependency is not specified in the
      make files.
      Also, the change could be not as useful as I thought it was.
      Reported by:	dchagin, Manfred Antar <null@pozo.com>, and many others
  14. 25 Mar, 2017 1 commit
    • Andriy Gapon's avatar
      specific end of interrupt implementation for AMD Local APIC · a7b4c009
      Andriy Gapon authored
      The change is more intrusive than I would like because the feature
      requires that a vector number is written to a special register.
      Thus, now the vector number has to be provided to lapic_eoi().
      It was readily available in the IO-APIC and MSI cases, but the IPI
      handlers required more work.
      Also, we now store the VMM IPI number in a global variable, so that it
      is available to the justreturn handler for the same reason.
      Reviewed by:	kib
      MFC after:	6 weeks
      Differential Revision: https://reviews.freebsd.org/D9880
  15. 28 Feb, 2017 1 commit
    • 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
  16. 28 Jan, 2017 1 commit
  17. 17 Sep, 2016 1 commit
    • Bruce Evans's avatar
      Remove all kernel uses of pcb_psl, but keep in in the struct to · 1d3c0fa7
      Bruce Evans authored
      preserve the ABI and API for applications.  It was removed in the port
      to amd64, but was remained as garbage giving a micro-pessimization and
      spurious single-step traps on i386.
      pcb_psl was intended to be used just to do a context switch of PSL_I,
      but this context switch was null in most or all versions, and
      mis-switching of PSL_T was done instead.
      Some history:
      - in 386BSD-0.0, cpu_switch() ran at splhigh() and splhigh() did too
        much interrupt disabling, so interrupts were hard-disabled across
        cpu_switch() and too many other places
      - in 386BSD-0.0-patchkit through FreeBSD-4 and FreeBSD-5 before
        SMPng, splhigh() did soft interrupt masking, and cpu_switch() was
        excessively cautious and did a cli at the start and a sti at the
        end to hard-disable interrupts across the switch
      - SMPng replaced the spl's and cli's by spinlocks (just sched_lock?),
        so interrupts were hard-disabled across cpu_switch() and too many
        other places again
      - initial attempts to fix this intended to restore some soft
        interrupt disabling, but to support variations in this cpu_switch()
        used pushfl/popfl into pcb_psl to avoid hard-coding the assumption
        that the initial and final states have PSL_I enabled.  But the
        version with soft interrupt disabling wasn't used for long, or was
        never committed, (except I always used my different version of it
        for UP) so the pushfl/popl and pcb_psl to hold them have been doing
        less than nothing for about 14 years.
  18. 10 Aug, 2015 1 commit
    • Konstantin Belousov's avatar
      Make kstack_pages a tunable on arm, x86, and powepc. On i386, the · edc82223
      Konstantin Belousov authored
      initial thread stack is not adjusted by the tunable, the stack is
      allocated too early to get access to the kernel environment. See
      TD0_KSTACK_PAGES for the thread0 stack sizing on i386.
      The tunable was tested on x86 only.  From the visual inspection, it
      seems that it might work on arm and powerpc.  The arm
      USPACE_SVC_STACK_TOP and powerpc USPACE macros seems to be already
      incorrect for the threads with non-default kstack size.  I only
      changed the macros to use variable instead of constant, since I cannot
      On arm64, mips and sparc64, some static data structures are sized by
      KSTACK_PAGES, so the tunable is disabled.
      Sponsored by:	The FreeBSD Foundation
      MFC after:	2 week
  19. 04 Aug, 2015 1 commit
  20. 30 Apr, 2015 1 commit
    • John Baldwin's avatar
      Remove support for Xen PV domU kernels. Support for HVM domU kernels · ed95805e
      John Baldwin authored
      remains.  Xen is planning to phase out support for PV upstream since it
      is harder to maintain and has more overhead.  Modern x86 CPUs include
      virtualization extensions that support HVM guests instead of PV guests.
      In addition, the PV code was i386 only and not as well maintained recently
      as the HVM code.
      - Remove the i386-only NATIVE option that was used to disable certain
        components for PV kernels.  These components are now standard as they
        are on amd64.
      - Remove !XENHVM bits from PV drivers.
      - Remove various shims required for XEN (e.g. PT_UPDATES_FLUSH, LOAD_CR3,
      - Remove duplicate copy of <xen/features.h>.
      - Remove unused, i386-only xenstored.h.
      Differential Revision:	https://reviews.freebsd.org/D2362
      Reviewed by:	royger
      Tested by:	royger (i386/amd64 HVM domU and amd64 PVH dom0)
      Relnotes:	yes
  21. 09 Feb, 2015 1 commit
    • Konstantin Belousov's avatar
      Add x2APIC support. Enable it by default if CPU is capable. The · 4c918926
      Konstantin Belousov authored
      hw.x2apic_enable tunable allows disabling it from the loader prompt.
      To closely repeat effects of the uncached memory ops when accessing
      registers in the xAPIC mode, the x2APIC writes to MSRs are preceeded
      by mfence, except for the EOI notifications.  This is probably too
      strict, only ICR writes to send IPI require serialization to ensure
      that other CPUs see the previous actions when IPI is delivered.  This
      may be changed later.
      In vmm justreturn IPI handler, call doreti_iret instead of doing iretd
      inline, to handle corner conditions.
      Note that the patch only switches LAPICs into x2APIC mode. It does not
      enables FreeBSD to support > 255 CPUs, which requires parsing x2APIC
      MADT entries and doing interrupts remapping, but is the required step
      on the way.
      Reviewed by:	neel
      Tested by:	pho (real hardware), neel (on bhyve)
      Discussed with:	jhb, grehan
      Sponsored by:	The FreeBSD Foundation
      MFC after:	2 months
  22. 02 Nov, 2014 1 commit
    • John Baldwin's avatar
      MFamd64: Add support for extended FPU states on i386. This includes · 824fc460
      John Baldwin authored
      support for AVX on i386.
      - Similar to amd64, move the FPU save area out of the PCB and instead
        store saved FPU state in a variable-sized buffer after the PCB on the
      - To support the variable PCB location, alter the locore code to only use
        the bottom-most page of proc0stack for init386().  init386() returns
        the correct stack pointer to locore which adjusts the stack for thread0
        before calling mi_startup().
      - Don't bother setting cr3 in thread0's pcb in locore before calling
        init386().  It wasn't used (init386() overwrote it at the end) and
        it doesn't work with the variable-sized FPU save area.
      - Remove the new-bus attachment from npx.  This was only ever useful for
        external co-processors using IRQ13, but those have not been supported
        for several years.  npxinit() is now called much earlier during boot
        (init386()) similar to amd64.
      - Implement PT_{GET,SET}XSTATE and I386_GET_XFPUSTATE.
      - npxsave() is now only called from context switch contexts so it can
        use XSAVEOPT.
      Differential Revision:	https://reviews.freebsd.org/D1058
      Reviewed by:	kib
      Tested on:	FreeBSD/i386 VM under bhyve on Intel i5-2520
  23. 22 Aug, 2013 1 commit
  24. 18 May, 2012 1 commit
    • Mitsuru IWASAKI's avatar
      Add SMP/i386 suspend/resume support. · e3fd0bc1
      Mitsuru IWASAKI authored
      Most part is merged from amd64.
      - i386/acpica/acpi_wakecode.S
      Replaced with amd64 code (from realmode to paging enabling code).
      - i386/acpica/acpi_wakeup.c
      Replaced with amd64 code (except for wakeup_pagetables stuff).
      - i386/include/pcb.h
      - i386/i386/genassym.c
      Added PCB new members (CR0, CR2, CR4, DS, ED, FS, SS, GDT, IDT, LDT
      and TR) needed for suspend/resume, not for context switch.
      - i386/i386/swtch.s
      Added suspendctx() and resumectx().
      Note that savectx() was not changed and used for suspending (while
      amd64 code uses it).
      BSP and AP execute the same sequence, suspendctx(), acpi_wakecode()
      and resumectx() for suspend/resume (in case of UP system also).
      - i386/i386/apic_vector.s
      Added cpususpend().
      - i386/i386/mp_machdep.c
      - i386/include/smp.h
      Added cpususpend_handler().
      - i386/include/apicvar.h
      - kern/subr_smp.c
      - sys/smp.h
      Added IPI_SUSPEND and suspend_cpus().
      - i386/i386/initcpu.c
      - i386/i386/machdep.c
      - i386/include/md_var.h
      - pc98/pc98/machdep.c
      Moved initializecpu() declarations to md_var.h.
      MFC after:	3 days
  25. 18 Jul, 2011 1 commit
    • Attilio Rao's avatar
      - Remove the eintrcnt/eintrnames usage and introduce the concept of · 521ea19d
      Attilio Rao authored
        sintrcnt/sintrnames which are symbols containing the size of the 2
      - For amd64/i386 remove the storage of intr* stuff from assembly files.
        This area can be widely improved by applying the same to other
        architectures and likely finding an unified approach among them and
        move the whole code to be MI. More work in this area is expected to
        happen fairly soon.
      No MFC is previewed for this patch.
      Tested by:	pluknet
      Reviewed by:	jhb
      Approved by:	re (kib)
  26. 25 Apr, 2011 1 commit
    • Rick Macklem's avatar
      Fix the experimental NFS client so that it does not bogusly · 7c208ed6
      Rick Macklem authored
      set the f_flags field of "struct statfs". This had the interesting
      effect of making the NFSv4 mounts "disappear" after r221014,
      since NFSMNT_NFSV4 and MNT_IGNORE became the same bit.
      Move the files used for a diskless NFS root from sys/nfsclient
      to sys/nfs in preparation for them to be used by both NFS
      clients. Also, move the declaration of the three global data
      structures from sys/nfsclient/nfs_vfsops.c to sys/nfs/nfs_diskless.c
      so that they are defined when either client uses them.
      Reviewed by:	jhb
      MFC after:	2 weeks
  27. 01 Nov, 2010 1 commit
  28. 19 Oct, 2010 1 commit
  29. 29 Jul, 2010 1 commit
    • Jung-uk Kim's avatar
      MFamd64: r210615 · 994ce54d
      Jung-uk Kim authored
      Fix another fallout from r208833.  savectx() is used to save CPU context
      for crash dump (dumppcb) and kdb (stoppcbs).  For both cases, we cannot
      have a valid pointer in pcb_save.  This should restore the previous
  30. 30 Jun, 2009 1 commit
  31. 29 Dec, 2008 1 commit
    • Kip Macy's avatar
      merge 186535, 186537, and 186538 from releng_7_xen · 3a6d1fcf
      Kip Macy authored
       - merge in latest xenbus from dfr's xenhvm
       - fix race condition in xs_read_reply by converting tsleep to mtx_sleep
       unmask evtchn in bind_{virq, ipi}_to_irq
       - remove code for handling case of not being able to sleep
       - eliminate tsleep - make sleeps atomic
  32. 12 Dec, 2008 1 commit
  33. 19 Oct, 2008 1 commit
  34. 15 Aug, 2008 1 commit
  35. 16 May, 2008 1 commit
  36. 23 Nov, 2007 1 commit
  37. 17 Sep, 2007 2 commits
    • Peter Wemm's avatar
      Fix an undefined symbol that as/ld neglected to flag as a problem. It · 8bff6a11
      Peter Wemm authored
      was used in assembler code in such a way that no unresolved relocation
      records were generated, so ld didn't flag the problem.   You can see
      this with an 'nm' of the kernel.  There will be 'U MAXCPU' on SMP systems.
      The impact of this is that the intrcount/intrnames arrays do not have
      the intended amount of space reserved.  This could lead to interesting
      problems due to the arrays being present in the middle of kernel code.
      An overflow would be rather interesting as executable code would be used
      as per-cpu incrementing interrupt counters.
      This fixes it for now by exporting MAXCPU to the assembler.  A better fix
      might be to define these data structures in C - they're only referenced
      in the kernel from C code these days anyway.
      Approved by:  re (kensmith)
    • Jeff Roberson's avatar
      - Move all of the PS_ flags into either p_flag or td_flags. · b61ce5b0
      Jeff Roberson authored
       - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or
         previously the sched_lock.  These bugs have existed for some time.
       - Allow swapout to try each thread in a process individually and then
         swapin the whole process if any of these fail.  This allows us to move
         most scheduler related swap flags into td_flags.
       - Keep ki_sflag for backwards compat but change all in source tools to
         use the new and more correct location of P_INMEM.
      Reported by:	pho
      Reviewed by:	attilio, kib
      Approved by:	re (kensmith)
  38. 17 Jul, 2007 1 commit
  39. 06 Jun, 2007 1 commit