1. 06 Feb, 2018 31 commits
    • Jeff Roberson's avatar
      Use per-domain locks for vm page queue free. Move paging control from · e2068d0b
      Jeff Roberson authored
      global to per-domain state.  Protect reservations with the free lock
      from the domain that they belong to.  Refactor to make vm domains more
      of a first class object.
      Reviewed by:    markj, kib, gallatin
      Tested by:      pho
      Sponsored by:   Netflix, Dell/EMC Isilon
      Differential Revision:  https://reviews.freebsd.org/D14000
    • Gleb Smirnoff's avatar
    • Gleb Smirnoff's avatar
      Fix boot_pages calculation for machines that don't have UMA_MD_SMALL_ALLOC. · ae941b1b
      Gleb Smirnoff authored
      o Call uma_startup1() after initializing kmem, vmem and domains.
      o Include 8 eight VM startup pages into uma_startup_count() calculation.
      o Account for vmem_startup() and vm_map_startup() preallocating pages.
      o Account for extra two allocations done by kmem_init() and vmem_create().
      o Hardcode the place of execution of vm_radix_reserve_kva(). Using SYSINIT
        allowed several other SYSINITs to sneak in before it, thus bumping
        requirement for amount of boot pages.
    • Mark Felder's avatar
      Refactor cleanvar to remove shell expansion vulnerability · 330d6283
      Mark Felder authored
      If any process creates a directory named "-P" in /var/run or
      /var/spool/lock it will cause the purgedir function to start to rm -r /.
      Simplify a lot of complicated shell logic by leveraging find(1).
      Reviewed by:	allanjude
      MFC after:	3 days
      Differential Revision:	https://reviews.freebsd.org/D13778
    • Scott Long's avatar
      Cache the value of the request and reply frame size since it's used quite · 96410703
      Scott Long authored
      a bit in the normal operation of the driver.  Covert it to represent bytes
      instead of 32bit words.  Fix what I believe to be is a bug in this respect
      with the Tri-mode cards.
      Sponsored by:	Netflix
    • Mark Felder's avatar
      Fix firstboot fs mount logic · 1ce07411
      Mark Felder authored
      The firstboot logic has an error which causes the filesystem to be
      mounted readonly even though root_rw_mount=YES. This fixes the error to
      ensure that the root filesystem is mounted rw as expected after the run
      of the firstboot scripts.
      Reviewed by:	imp
      MFC after:	3 days
      Differential Revision:	https://reviews.freebsd.org/D14226
    • Bjoern A. Zeeb's avatar
      Remove a trailing whitspace. · 6b9159b9
      Bjoern A. Zeeb authored
    • Mark Johnston's avatar
    • John Baldwin's avatar
      Use a workaround to compile the crt init functions correctly with clang. · a1d39c53
      John Baldwin authored
      The MIPS assembly parser treats forward-declared local symbols as global
      symbols.  This results in CALL16 relocations being used against local
      (private) symbols which then fail to resolve when linking binaries.
      Add .local to force the init and fini functions to be treated as local as
      a workaround.
      Submitted by:	sbruno
      Sponsored by:	DARPA / AFRL
    • Mark Johnston's avatar
      Simplify synchronization read error handling. · 0d02f6c2
      Mark Johnston authored
      Since synchronization reads are performed by submitting a request to
      the external mirror provider, we know that the request returns with an
      error only when gmirror was unable to read a copy of the block from any
      mirror. Thus, there is no need to retry the request from the
      synchronization error handler.
      Tested by:	pho
      MFC after:	2 weeks
      Sponsored by:	Dell EMC Isilon
    • Alexander Motin's avatar
      Fix queue length reporting in mps(4) and mpr(4). · 62a09ee9
      Alexander Motin authored
      Both drivers were found to report CAM bigger queue depth then they really
      can handle.  It made them later under high load with many disks return
      some of submitted requests back with CAM_REQUEUE_REQ status for later
      Reviewed by:	scottl
      MFC after:	1 week
      Sponsored by:	iXsystems, Inc.
      Differential Revision:	https://reviews.freebsd.org/D14215
    • Kenneth D. Merry's avatar
      Diagnostic buffer fixes for the mps(4) and mpr(4) drivers. · e2997a03
      Kenneth D. Merry authored
      In mp{r,s}_diag_register(), which is used to register diagnostic
      buffers with the mp{r,s}(4) firmware, we allocate DMAable memory.
      There were several issues here:
       o No checking of the bus_dmamap_load() return value.  If the load
         failed or got deferred, mp{r,s}_diag_register() continued on as if
         nothing had happened.  We now check the return value and bail
         out if it fails.
       o No waiting for a deferred load callback.  bus_dmamap_load()
         calls a supplied callback when the mapping is done.  This is
         generally done immediately, but it can be deferred.
         mp{r,s}_diag_register() did not check to see whether the callback
         was already done before proceeding on.  We now sleep until the
         callback is done if it is deferred.
       o No call to bus_dmamap_sync(... BUS_DMASYNC_PREREAD) after the
         memory is allocated and loaded.  This is necessary on some
         platforms to synchronize host memory that is going to be updated
         by a device.
      Both drivers would also panic if the firmware was reinitialized while
      a diagnostic buffer operation was in progress.  This fixes that problem
      as well.  (The driver will reinitialize the firmware in various
      circumstances, but the problem I ran into was that the firmware would
      generate an IOC Fault due to a PCIe error.)
      	Add a new structure, struct mpr_busdma_context, that is
      	used for deferred busdma load callbacks.
      	Add a prototype for mp{r,s}_memaddr_wait_cb().
      	Add a new busdma callback function, mp{r,s}_memaddr_wait_cb().
      	This provides synchronization for callers that want to
      	wait on a deferred bus_dmamap_load() callback.
      	In bus_dmamap_register(), add a call to bus_dmamap_sync()
      	with the BUS_DMASYNC_PREREAD flag set after an allocation
      	is loaded.
      	Also, check the return value of bus_dmamap_load().  If it
      	fails, bail out.  If it is EINPROGRESS, wait for the
      	callback to happen.  We use an interruptible sleep (msleep
      	with PCATCH) and let the callback clean things up if we get
      	In mpr_diag_read_buffer() and mps_diag_read_buffer(), call
      	bus_dmamap_sync(..., BUS_DMASYNC_POSTREAD) before copying
      	the data out to make sure the data is in stable storage.
      	In mp{r,s}_post_fw_diag_buffer() and
      	mp{r,s}_release_fw_diag_buffer(), check the reply to see
      	whether it is NULL.  It can be NULL (and the command non-NULL)
      	if the controller gets reinitialized while we're waiting for
      	the command to complete but the driver structures aren't
      	reallocated.  The driver structures generally won't be
      	reallocated unless there is a firmware upgrade that changes
      	one of the IOCFacts.
      	When freeing diagnostic buffers in mp{r,s}_diag_register()
      	and mp{r,s}_diag_unregister(), zero/NULL out the buffer after
      	freeing it.  This will prevent a duplicate free in some
      Sponsored by:	Spectra Logic
      Reviewed by:	mav, scottl
      MFC after:	1 week
      Differential Revision:	D13453
    • Alex Richardson's avatar
      crossbuild: Make the CHECK_TIME variable work on Linux · 95eff7c0
      Alex Richardson authored
      Linux /usr/bin/find doesn't understand the -mtime -0s flag.
      Instead create a temporary file and compare that file's mtime to
      sys/sys/param.h to check whether the clock is correct.
      Reviewed By:	jhb, imp
      Approved By:	jhb (mentor)
      Differential Revision: https://reviews.freebsd.org/D14157
    • Alex Richardson's avatar
      Don't hardcode /usr/bin as the path for mktemp in build tools · fb1df203
      Alex Richardson authored
      It won't work e.g. when crossbuilding from Ubuntu Linux as mktemp is in
      /bin there.
      Reviewed By:	bdrewery
      Approved By:	jhb (mentor)
      Differential Revision: https://reviews.freebsd.org/D13937
    • Alex Richardson's avatar
      Allow compiling usr.bin/find on Linux and Mac · c3a6ea5b
      Alex Richardson authored
      When building FreeBSD the makefiles invoke find with various flags such as
      `-s` that aren't supported in the native /usr/bin/find. To fix this I
      build the FreeBSD version of find and use that when crossbuilding.
      Inserting lots if #ifdefs in the code is rather ugly but I don't see a
      better solution.
      Reviewed By:	brooks (mentor)
      Approved By:	jhb (mentor)
      Differential Revision: https://reviews.freebsd.org/D13306
    • Alex Richardson's avatar
      Make mips_postboot_fixup work when building the kernel with clang+lld · e911aac7
      Alex Richardson authored
      The compiler/linker can align fake_preload anyway it would like. When
      building the kernel with gcc+bfd this always happened to be a multiple of 8.
      When I built the kernel with clang and linked with lld fake_preload
      happened to only be aligned to 4 bytes which caused a an ADDRS trap because
      the compiler will emit sd instructions to store to this buffer.
      Reviewed By:	jhb, imp
      Approved By:	jhb (mentor)
      Differential Revision: https://reviews.freebsd.org/D14018
    • Dmitry Marakasov's avatar
      - Document new ${name}_limits rc.conf option · 52d7a78f
      Dmitry Marakasov authored
      Approved by:	cy
      MFC after:	2 weeks (along with 328331 which introduced this option)
      Differential Revision:	https://reviews.freebsd.org/D14028
    • Kyle Evans's avatar
      dtb/allwinner: Add sun7i-a20-lamobo-r1.dts (Banana Pi R1) · a123333f
      Kyle Evans authored
      FreeBSD boots on this board, but the ethernet switch is not currently
      supported, resulting in no ethernet.
      A U-Boot port will be added once the ethernet switch is at least basically
      supported, but we add its DTS to the build here to lower the barrier-to-boot
      while work is underway.
    • Baptiste Daroussin's avatar
      Remove libreadline from the source tree, all consumers but gdb · 8134347f
      Baptiste Daroussin authored
      has been switched to libedit long ago, libreadline was built as an
      internallib for a while and kept only for gdbtui which was broken using
      Since gdb has been mostly deorbitted in all arches, gdbtui was only installed
      on arm and sparc64, given it has been removed, gdb has been switched to use
      libedit, no consumers are left for libreadline. Thus this removal
    • Baptiste Daroussin's avatar
    • Baptiste Daroussin's avatar
    • Baptiste Daroussin's avatar
      Remove gdbtui, it was already not installed on every arches · a2739731
      Baptiste Daroussin authored
      only installed on arm and sparc64.
      It is the only bits that keeps us having libreadline in base
      The rest of gdb can be switched to libedit and will be in another
    • Adrian Chadd's avatar
      [arswitch] Implement the switch MAC address fetch API. · 2ba4bf8f
      Adrian Chadd authored
      The placeholders are here for some future "set" MAC address API.
      * AR9340 switch
      * AR8327 switch
    • Adrian Chadd's avatar
    • Adrian Chadd's avatar
      [etherswitch] add initial support for potentially configuring and fetching the switch MAC address. · 15bd1a86
      Adrian Chadd authored
      Switches that originate their own frames (eg obvious ones like Pause frames)
      need a MAC address to use to send those frames from.
      This API will hopefully begin to allow that to be configurable.
    • Scott Long's avatar
      Fix a case where a request frame can be composed that requires 2 or more · 4b07a560
      Scott Long authored
      SGList elements, but there's only enough space in the request frame for
      either 1 element or a chain frame pointer.  Previously, the code would
      hit the wrong case, add the SGList element, but then fail to add the
      chain frame due to lack of space.  Re-arrange the code to catch this case
      earlier and handle it.
      Sponsored by:	Netflix
    • Scott Long's avatar
      Return a C errno for cam_periph_acquire(). · 99e7a4ad
      Scott Long authored
      There's no compelling reason to return a cam_status type for this
      function and doing so only creates confusion with normal C
      coding practices. It's technically an API change, but the periph API
      isn't widely used. No efffective change to operation.
      Reviewed by:	imp, mav, ken
      Sponsored by:	Netflix
      Differential Revision:	D14063
    • Bryan Venteicher's avatar
      Correct structure name used in bus_map_resource(9) example · 87dda4ed
      Bryan Venteicher authored
      Reviewed by:	jhb
      MFC after:	1 week
      Differential Revision:	https://reviews.freebsd.org/D14188
    • Gleb Smirnoff's avatar
      Followup on r302393 by cperciva, improving calculation of boot pages required · f4bef67c
      Gleb Smirnoff authored
      for UMA startup.
      o Introduce another stage of UMA startup, which is entered after
        vm_page_startup() finishes. After this stage we don't yet enable buckets,
        but we can ask VM for pages. Rename stages to meaningful names while here.
        Enabling page alloc earlier allows us to dramatically reduce number of
        boot pages required. What is more important number of zones becomes
        consistent across different machines, as no MD allocations are done before
        the BOOT_PAGEALLOC stage. Now only UMA internal zones actually need to use
        startup_alloc(), however that may change, so vm_page_startup() provides
        its need for early zones as argument.
      o Introduce uma_startup_count() function, to avoid code duplication. The
        functions calculates sizes of zones zone and kegs zone, and calculates how
        many pages UMA will need to bootstrap.
        It counts not only of zone structures, but also of kegs, slabs and hashes.
      o Hide uma_startup_foo() declarations from public file.
      o Provide several DIAGNOSTIC printfs on boot_pages usage.
      o Bugfix: when calculating zone of zones size use (mp_maxid + 1) instead of
        mp_ncpus. Use resulting number not only in the size argument to zone_ctor()
        but also as args.size.
      Reviewed by:		imp, gallatin (earlier version)
      Differential Revision:	https://reviews.freebsd.org/D14054
    • Kirk McKusick's avatar
      Occasional cylinder-group check-hash errors were being reported on · 47806d1b
      Kirk McKusick authored
      systems running with a heavy filesystem load. Tracking down this
      bug was elusive because there were actually two problems. Sometimes
      the in-memory check hash was wrong and sometimes the check hash
      computed when doing the read was wrong. The occurrence of either
      error caused a check-hash mismatch to be reported.
      The first error was that the check hash in the in-memory cylinder
      group was incorrect. This error was caused by the following
      sequence of events:
      - We read a cylinder-group buffer and the check hash is valid.
      - We update its cg_time and cg_old_time which makes the in-memory
        check-hash value invalid but we do not mark the cylinder group dirty.
      - We do not make any other changes to the cylinder group, so we
        never mark it dirty, thus do not write it out, and hence never
        update the incorrect check hash for the in-memory buffer.
      - Later, the buffer gets freed, but the page with the old incorrect
        check hash is still in the VM cache.
      - Later, we read the cylinder group again, and the first page with
        the old check hash is still in the VM cache, but some other pages
        are not, so we have to do a read.
      - The read does not actually get the first page from disk, but rather
        from the VM cache, resulting in the old check hash in the buffer.
      - The value computed after doing the read does not match causing the
        error to be printed.
      The fix for this problem is to only set cg_time and cg_old_time as
      the cylinder group is being written to disk. This keeps the in-memory
      check-hash valid unless the cylinder group has had other modifications
      which will require it to be written with a new check hash calculated.
      It also requires that the check hash be recalculated in the in-memory
      cylinder group when it is marked clean after doing a background write.
      The second problem was that the check hash computed at the end of the
      read was incorrect because the calculation of the check hash on
      completion of the read was being done too soon.
      - When a read completes we had the following sequence:
        - bufdone()
        -- b_ckhashcalc (calculates check hash)
        -- bufdone_finish()
        --- vfs_vmio_iodone() (replaces bogus pages with the cached ones)
      - When we are reading a buffer where one or more pages are already
        in memory (but not all pages, or we wouldn't be doing the read),
        the I/O is done with bogus_page mapped in for the pages that exist
        in the VM cache. This mapping is done to avoid corrupting the
        cached pages if there is any I/O overrun. The vfs_vmio_iodone()
        function is responsible for replacing the bogus_page(s) with the
        cached ones. But we were calculating the check hash before the
        bogus_page(s) were replaced. Hence, when we were calculating the
        check hash, we were partly reading from bogus_page, which means
        we calculated a bad check hash (e.g., because multiple pages have
        been mapped to bogus_page, so its contents are indeterminate).
      The second fix is to move the check-hash calculation from bufdone()
      to bufdone_finish() after the call to vfs_vmio_iodone() so that it
      computes the check hash over the correct set of pages.
      With these two changes, the occasional cylinder-group check-hash
      errors are gone.
      Submitted by: David Pfitzner <dpfitzner@netflix.com>
      Reviewed by: kib
      Tested by: David Pfitzner
    • Konstantin Belousov's avatar
      Move signal trampolines out of locore.s into separate source file. · 5370a081
      Konstantin Belousov authored
      Similar to other arches, the move makes the subject of locore.s only
      the kernel startup.
      Sponsored by:	The FreeBSD Foundation
      MFC after:	1 week
  2. 05 Feb, 2018 9 commits