dragonfly.git
9 years agokernel/usb4bsd: Add the urndis(4) driver for Remote NDIS device support.
Sascha Wildner [Mon, 7 Jul 2014 09:44:51 +0000 (11:44 +0200)]
kernel/usb4bsd: Add the urndis(4) driver for Remote NDIS device support.

Aka USB tethering.

Taken-from: FreeBSD
Tested-by: Yellow Rabbit <yrabbit@sdf.lonestar.org>
9 years agoacpica: Clean up the config header a bit.
Sascha Wildner [Mon, 7 Jul 2014 09:08:48 +0000 (11:08 +0200)]
acpica: Clean up the config header a bit.

9 years agopaths.h: Add path to ifconfig.
Nuno Antunes [Tue, 24 Jun 2014 02:43:40 +0000 (03:43 +0100)]
paths.h: Add path to ifconfig.

9 years agodrm/i915: Reduce ring code differences with Linux
François Tigeot [Mon, 7 Jul 2014 06:01:58 +0000 (08:01 +0200)]
drm/i915: Reduce ring code differences with Linux

* Factorize somme common code sequences to __wait_seqno()

* Change locking in get/put irq functions

9 years agovkernel64 - Make operational again after bootstrap changes
Matthew Dillon [Mon, 7 Jul 2014 05:53:19 +0000 (22:53 -0700)]
vkernel64 - Make operational again after bootstrap changes

* vkernel64's need the same cpu_idle_restore() fix that x86-64 got to
  properly handle pending migrations on the BSP at bootstrap time.
  (this occurs due to the way initclocks_other() works now).

* Add a warning/reminder in param.h regarding increasing MAXCPU beyond 256.

9 years agorpc: Remove empty FreeBSD ID.
Sascha Wildner [Mon, 7 Jul 2014 05:31:29 +0000 (07:31 +0200)]
rpc: Remove empty FreeBSD ID.

9 years agobuild - Fix vkernel64 build
Matthew Dillon [Mon, 7 Jul 2014 05:16:51 +0000 (22:16 -0700)]
build - Fix vkernel64 build

* Fix build due to missing declaration from recent commit.

9 years agoRPC: remove some extraneous $id$ lines.
Justin C. Sherrill [Sun, 6 Jul 2014 23:10:44 +0000 (19:10 -0400)]
RPC: remove some extraneous $id$ lines.

9 years agoRPC: replace Sun license with 3-clause BSD license.
hrs [Mon, 25 Nov 2013 19:04:36 +0000 (19:04 +0000)]
RPC: replace Sun license with 3-clause BSD license.

Original commit message:
"Replace Sun RPC license in TI-RPC library with a 3-clause BSD license,
with the explicit permission of Sun Microsystems in 2009."

Taken-from: FreeBSD
Cherry-picked-from: http://svnweb.freebsd.org/base?view=revision&revision=258578

9 years agoboot - Fix timecount issues with some BIOSes
Matthew Dillon [Sun, 6 Jul 2014 19:49:22 +0000 (12:49 -0700)]
boot - Fix timecount issues with some BIOSes

* Some BIOSes do not correctly read RTC which means there is no timecount
  at boot time. The system boots immediately without giving the user a
  chance to choose a menu option. This patch gets rid of the annoying issue.
  It has no effect on systems that work properly.

Reported-by: peeter bug #2696
Taken-from: FreeBSD

9 years agokernel - extend cpus past 64 - fixes and adjustments
Matthew Dillon [Sun, 6 Jul 2014 19:27:04 +0000 (12:27 -0700)]
kernel - extend cpus past 64 - fixes and adjustments

* Reorder the SMP cpu boot code to remove a great deal of lock contention.
  The APs must still loop waiting for the BSP to adjust the stage, but
  they no longer need to hold a token or spinlock so startup under emulation
  is considerably faster.

* Do not initialize our systimer periodics on each target cpu from the
  idle thread bootstrap.  Previously with the MP lock held the locks acquired
  during this initialization were serialized and could not block.  Now
  that cpu startup runs mostly concurrently, that is no longer the
  case.

  Instead, systimer periodics are handled by process 0 as a post-smp-startup
  call.

* statclock() now uses sys_cputimer() directly to calculate the delta time.

* The TSC is now implemented as sys_cputimer before any systimer periodics
  (particularly statclock()) are set-up, allowing the system to take control
  away from the i8254 earlier.

* Clean up struct lwkt_ipiq.  Remove the 'lwkt_ipiq' typedef.  Calculate
  allocation sizes separately.

* Add a new loader.conf tunable, hw.tsc_cputimer_force.  If set to 1 and
  a TSC is present, the system will force invariant and mpsync operation
  and always use the TSC as the cputimer (primarily useful for qemu).

* Remove unnecessary kmem_alloc() of the globaldata structure.  We are
  using a static array now.  This access was wasting memory for a long
  time.

* Make the boot stack bigger for the APs.

9 years agokernel - remove debugging
Matthew Dillon [Sun, 6 Jul 2014 19:21:17 +0000 (12:21 -0700)]
kernel - remove debugging

* Remove debugging for sip->subsystem.

Reminded-by: swildner
9 years agokernel - extend cpus past 64 - fixes
Matthew Dillon [Sun, 6 Jul 2014 19:19:18 +0000 (12:19 -0700)]
kernel - extend cpus past 64 - fixes

* qemu testing.  Kernel can get stuck due to there not being enough
  pre-allocated vm_map_entry structures.  Increase MAX_MAPENT for booting
  from 2048 to (SMP_MAXCPU * 32 + 1024), which should hopefully be enough.

* During early booting, the ZONE_SPECIAL flag is not yet set in
  mapentzone_store.zflags.  Add code to set the flag early.

9 years agoFix VKERNEL/i386 build.
Sascha Wildner [Sun, 6 Jul 2014 09:06:28 +0000 (11:06 +0200)]
Fix VKERNEL/i386 build.

9 years agoCorrect math and limerick.
Justin C. Sherrill [Sun, 6 Jul 2014 02:39:43 +0000 (22:39 -0400)]
Correct math and limerick.

Seen in FreeBSD just recently:
http://svnweb.freebsd.org/base?view=revision&revision=268295
And NetBSD 14 years ago:
http://cvsweb.netbsd.org/bsdweb.cgi/src/games/fortune/datfiles/fortunes2.diff?r1=1.6&r2=1.7&only_with_tag=MAIN

9 years agokernel: Fix KTR compilation.
Sascha Wildner [Sat, 5 Jul 2014 20:41:12 +0000 (22:41 +0200)]
kernel: Fix KTR compilation.

9 years agodrm/i915: Add i915_gem_check_wedge()
François Tigeot [Sat, 5 Jul 2014 19:16:08 +0000 (21:16 +0200)]
drm/i915: Add i915_gem_check_wedge()

From Linux 3.8.13

9 years agokernel/i386: Fix buildkernel.
Sascha Wildner [Sat, 5 Jul 2014 15:58:17 +0000 (17:58 +0200)]
kernel/i386: Fix buildkernel.

9 years agodrm/i915: Sync intel_ringbuffer.h with Linux 3.8.13
François Tigeot [Sat, 5 Jul 2014 15:24:25 +0000 (17:24 +0200)]
drm/i915: Sync intel_ringbuffer.h with Linux 3.8.13

9 years agodrm/i915: intel_iic.c really is intel_i2c.c
François Tigeot [Sat, 5 Jul 2014 11:40:21 +0000 (13:40 +0200)]
drm/i915: intel_iic.c really is intel_i2c.c

* Rename it.

* With this commit, all drm/i915 files finally have the same names as their
  counterparts in the official Linux driver.

9 years agodrm/i915: i915_debug.c really is i915_debugfs.c
François Tigeot [Sat, 5 Jul 2014 11:37:06 +0000 (13:37 +0200)]
drm/i915: i915_debug.c really is i915_debugfs.c

Rename it.

9 years agobuild - Add missing symbol for vkernel64 build
Matthew Dillon [Sat, 5 Jul 2014 05:04:40 +0000 (22:04 -0700)]
build - Add missing symbol for vkernel64 build

* Add symbols required to support access to the GD_OTHER_CPUS field,
  which vkernel64's assembly now needs.

9 years agokernel - Refactor cpumask_t to extend cpus past 64, part 2/2
Matthew Dillon [Fri, 4 Jul 2014 19:59:15 +0000 (12:59 -0700)]
kernel - Refactor cpumask_t to extend cpus past 64, part 2/2

* Expand SMP_MAXCPU from 64 to 256 (64-bit only)

* Expand cpumask_t from 64 to 256 bits

* Refactor the C macros and the assembly code.

* Add misc cpu_pauses()s and do a bit of work on the boot sequencing.

9 years agodrm: Use the Linux completion API
François Tigeot [Fri, 4 Jul 2014 11:54:05 +0000 (13:54 +0200)]
drm: Use the Linux completion API

9 years agodrm: Add a linux/completion.h implementation
François Tigeot [Fri, 4 Jul 2014 09:54:40 +0000 (11:54 +0200)]
drm: Add a linux/completion.h implementation

* The drm/i915 code expect completion to be a struct containing a
  counter named 'done' and a wait queue named 'wait'

* It also expects this wait queue to be a struct containing a spinlock
  named 'lock'. Adjust the implementation in linux/wait.h accordingly.

9 years agokernel: Unbreak vkernel64 build.
Nuno Antunes [Fri, 4 Jul 2014 08:03:36 +0000 (09:03 +0100)]
kernel: Unbreak vkernel64 build.

9 years agolibradius(3): Sync with FreeBSD head.
Nuno Antunes [Fri, 4 Jul 2014 05:59:13 +0000 (06:59 +0100)]
libradius(3): Sync with FreeBSD head.

Here is a summary of the changes.

* Added rad_request_authenticator() which returns the Request-Authenticator
  relevant to the most recently received RADIUS response.

* Added rad_server_secret() which returns the Shared Secret relevant to the
  most recently received RADIUS response.

* Added rad_demangle() for demangling user-passwords (needed for MS-CHAPv1
  MPPE-keys).

* Added rad_demangle_mppe_key() for demangling mppe-keys (needed for
  MPPE-keys).

* Added some typecasts for avoiding compiler warnings.

* Fix: better handle wrong usage of the lib (if the programmer has not called
  rad_create_request() but rad_put_*(), then a weird error message was
  returned).

* Added a new function for putting the Message-Authenticator.

* Verify the Message-Authenticator, if it was found inside a response packet
  and silently drop the packet, if the validation failed.

* Implicitly put the Message-Authenticator, if the EAP-Message attribute was
  added.

* Added some missing defines.

* Add simple embedded RADIUS server support to libradius, by extending existing
  API, keeping backward compatibility.

* Add binding support.

* Alphabetically sort MLINKS in the Makefile.

* Various other bugfixes.

Taken-from: FreeBSD (with small adjustments)

9 years agokernel/netgraph7: Build fix.
Sascha Wildner [Fri, 4 Jul 2014 05:13:00 +0000 (07:13 +0200)]
kernel/netgraph7: Build fix.

9 years agokernel - Refactor cpumask_t to extend cpus past 64, part 1/2
Matthew Dillon [Fri, 4 Jul 2014 03:07:27 +0000 (20:07 -0700)]
kernel - Refactor cpumask_t to extend cpus past 64, part 1/2

* 64-bit systems only.  32-bit builds use the macros but cannot be expanded
  past 32 cpus.

* Change cpumask_t from __uint64_t to a structure.  This commit implements
  one 64-bit sub-element (the next one will implement four for 256 cpus).

* Create a CPUMASK_*() macro API for non-atomic and atomic cpumask
  manipulation.  These macros generally take lvalues as arguments, allowing
  for a fairly optimal implementation.

* Change all C code operating on cpumask's to use the newly created CPUMASK_*()
  macro API.

* Compile-test 32 and 64-bit.  Run-test 64-bit.

* Adjust sbin/usched, usr.sbin/powerd.  usched currently needs more work.

9 years ago<sys/sysctl.h>: Put the access argument in parentheses.
Sascha Wildner [Thu, 3 Jul 2014 18:32:47 +0000 (20:32 +0200)]
<sys/sysctl.h>: Put the access argument in parentheses.

9 years ago<sys/sysctl.h>: Indentation fixes (nothing functional).
Sascha Wildner [Thu, 3 Jul 2014 18:28:49 +0000 (20:28 +0200)]
<sys/sysctl.h>: Indentation fixes (nothing functional).

9 years ago<sys/sysctl.h>: Remove CTLFLAGs which we don't handle.
Sascha Wildner [Thu, 3 Jul 2014 18:24:53 +0000 (20:24 +0200)]
<sys/sysctl.h>: Remove CTLFLAGs which we don't handle.

To not give the wrong impression that we do (just because code compiles).

The removal of CTLFLAG_CAP{RD,WR} was discussed with joris.

While here, remove SYSCTL_ASSERT_TYPE which was doing nothing for us.

9 years agodrm/ttm: remove linux_compat.c from conf/files too
Joris Giovannangeli [Thu, 3 Jul 2014 18:18:35 +0000 (20:18 +0200)]
drm/ttm: remove linux_compat.c from conf/files too

9 years agodrm/ttm - stabilizing pass, misc bug fixes
Matthew Dillon [Thu, 3 Jul 2014 18:04:07 +0000 (11:04 -0700)]
drm/ttm - stabilizing pass, misc bug fixes

* hold the vblank_time_lock around mod_timer() calls in drm_vblank_put()
  (in drm_irq.c).  This should help protect against reentrancy races on
  vblank_time_lock() which can result in a corrupted callout structure.

  (possibly fixes crash).

* Add TTM_BO_PRIV_FLAG_ACTIVE to flag the implied reference on the
  ttm_buffer_object (bo) structure instead of assuming that the implied
  reference is always present in ttm_bo_release().

  Only do final cleanup operations with the implied ref.  This saves us
  from ref/deref races which could result in multiple 1->0, 0->1 transitions
  (might not be possible any more with the covering lock around
  ttm_bo_release(), but do it anyway for safety).

  (fixes crash).

* Unconditionally clear *bo in radeon_bo_unref().

* Unconditionally zero memory when allocating the bo in radeon_sa_bo_new()
  to ensure that unused fields are zerod.

* For now, always use cpu 0 for the task queue.  This fixes races/corruption
  related to mycpuid changing and causing the wrong taskqueue_thread[] to
  be specified vs prior calls.  (fixes crash).

* Make sure *p_bo is NULL in ttm_bo_create() in the failure path.

* NULL out glob->dummy_read_page after freeing the page.

* Zero the temporary ttm_buffer_object in ttm_buffer_object_transfer()
  to ensure that the last release does not double-free non-retained fields
  (fixes double frees and related crashes).

* Make sure that *obj_res is NULL in ttm_bo_mmap_single() in the failure path.

* Fix spin-lock reversal in ttm_shrink() (fixes crash).

* Fix TTM memory initialization limits.  Use the vm.dma_reserved count to
  determine how much DMAable memory TTM can play with instead of assuming
  4GB.

* Remove double-lock in ttm_release_base() (fixes deadlock).

* Protect the 1->0 transition on the ttm_base_object structure with its
  lock to avoid races (fixes crash).

* Properly dispose of contig-allocated pages using vm_page_free_contig().
  ttm_vm_page_free() was previously improperly using vm_page_free() which
  has the effect of removing the page from the contig pool (fixes OOM).

* vm_page_grab() with VM_ALLOC_RETRY requires that VM_ALLOC_NORMAL also
  be specified (fixes crash).

9 years agodrm/ttm: convert rb_tree back to tree(3) and fix a few races
Joris Giovannangeli [Thu, 3 Jul 2014 17:58:20 +0000 (19:58 +0200)]
drm/ttm: convert rb_tree back to tree(3) and fix a few races

 * remove the linux compat rbtree for now and use tree(3)

 * change a few locks not converted from freebsd porting

 * check that the refcount is still 0 before destroying the object after
   acquiring the lock, because we might have raced another ref.

9 years agokernel: Fix some -Wundef warnings.
Sascha Wildner [Wed, 2 Jul 2014 08:10:37 +0000 (10:10 +0200)]
kernel: Fix some -Wundef warnings.

9 years agokernel - Fix PF tables (SMP work)
Matthew Dillon [Tue, 1 Jul 2014 23:28:47 +0000 (16:28 -0700)]
kernel - Fix PF tables (SMP work)

* SMP work broke pf_table.c to some degree due to the use of globals
  to store temporary data.  The concurrency could cause table lookups
  to return an incorrect match or mismatch.

* Change pfr_sin, pfr_sin6, and pfr_mask to local variables.

9 years agokernel: remove layer of indirection for ether_input()
Franco Fichtner [Sun, 29 Jun 2014 19:36:01 +0000 (21:36 +0200)]
kernel: remove layer of indirection for ether_input()

Mop up after the recent changes by pulling the old switcheroo
on ether_input_pkt(), effectively renaming the function to
ether_input().  Also updates comments accordingly.

9 years agokernel - add vm_contig_avail_pages() API
Matthew Dillon [Tue, 1 Jul 2014 17:23:36 +0000 (10:23 -0700)]
kernel - add vm_contig_avail_pages() API

* Add a function which DRM can query to determine how much more-easily-DMAd
  memory is available from our contiguous memmory pool, instead of assuming
  that it can gobble all 4GB of 'low' memory before it tries to swap.

* This memory is typically set in /boot/loader.conf, like this:

  vm.dma_reserved=256m

  The default is ~16MB at the moment so users will generally want to increase
  it.

9 years agodmesg - Add -ff feature
Matthew Dillon [Tue, 1 Jul 2014 15:52:16 +0000 (08:52 -0700)]
dmesg - Add -ff feature

* Add a feature whereby if -f is specified twice (-ff), dmesg will
  not sleep() in its monitoring loop and will instead live loop.
  This feature is intended only to help debug crashing kernel situations
  and should not be used for normal dmesg monitoring.

9 years agokernel - Fix several taskqueue livelocks
Matthew Dillon [Tue, 1 Jul 2014 15:39:29 +0000 (08:39 -0700)]
kernel - Fix several taskqueue livelocks

* Taskqueue was trying to issue callout_*() operations with a spin-lock
  held on callouts associated with other cpus.  This can livelock the
  system.

* Unlock the taskqueue spinlock when messing with callout_*() operations.

* Fixes an indefinite spin lock panic from drm/ttm.

9 years agokernel: switch newer drivers back to if_input()
Franco Fichtner [Sun, 29 Jun 2014 18:34:13 +0000 (20:34 +0200)]
kernel: switch newer drivers back to if_input()

Restore the if_input() invoke.  This is needed to reenable
tapping into if_input through drivers like netmap(4).

Reviewed by: sephe

9 years agokernel: make pktinfo and cpuid native to ip_input()
Franco Fichtner [Sun, 29 Jun 2014 17:05:32 +0000 (19:05 +0200)]
kernel: make pktinfo and cpuid native to ip_input()

In order to remove ether_input_pkt(), switch the prototype
of if_input() and adjust all callers.  While there, consolidate
the style of the invoke.

Suggested and reviewed by: sephe

9 years agokernel/acpi: Use device_printf() in a few places.
Sascha Wildner [Tue, 1 Jul 2014 14:23:56 +0000 (16:23 +0200)]
kernel/acpi: Use device_printf() in a few places.

9 years agoinet: Make ip fragments reassemble queue per-cpu and lockless MPSAFE
Sepherosa Ziehau [Tue, 1 Jul 2014 12:49:26 +0000 (20:49 +0800)]
inet: Make ip fragments reassemble queue per-cpu and lockless MPSAFE

9 years agokernel - Fix bug in cdev_pager_allocate() that was messing up gem/ttm
Matthew Dillon [Tue, 1 Jul 2014 08:06:20 +0000 (01:06 -0700)]
kernel - Fix bug in cdev_pager_allocate() that was messing up gem/ttm

* cdev_pager_allocate() was assuming that the passed vm_object handle
  was a cdev_t and populating a field in it, but that is not always the case.
  Fix the case.

* This solves RBTREE corruption in drm/ttm.

Reported-by: Joris Giovannangeli
9 years agoadd posix semaphore test suite
Nicolas Thery [Mon, 30 Jun 2014 18:57:35 +0000 (20:57 +0200)]
add posix semaphore test suite

Port FreeBSD test suite, remove tests specific to FreeBSD
implementation, and modify tests that do not comply with the standard.

A next step could be to integrate this test in dfregress(8).

Obtained-from:   FreeBSD
Reviewed-by: joris@giovannangeli.fr
9 years agolibc - bail out on invalid sem_open(3) flags
Nicolas Thery [Mon, 30 Jun 2014 18:57:27 +0000 (20:57 +0200)]
libc - bail out on invalid sem_open(3) flags

Preventing now callers from passing invalid flags prevents compatibility
issue should new flags be added to sem_open(3) in future standard
revisions.

Reviewed-by: joris@giovannangeli.fr
9 years agolibc - change SEM_VALUE_MAX
Nicolas Thery [Mon, 30 Jun 2014 18:57:03 +0000 (20:57 +0200)]
libc - change SEM_VALUE_MAX

sem_getvalue(3) requires a signed int count so change SEM_VALUE_MAX to INT_MAX.

Reviewed-by: joris@giovannangeli.fr
9 years agokernel/acpi: Stop installing default address space handlers explicitly.
Sascha Wildner [Tue, 1 Jul 2014 04:01:10 +0000 (06:01 +0200)]
kernel/acpi: Stop installing default address space handlers explicitly.

Since ACPICA 20040427 this is no longer necessary since it is part of
AcpiEnableSubsystem(). It is not supported and has led to problems.

See http://svnweb.freebsd.org/base?view=revision&revision=212993

9 years agokernel/acpica: Add tunables for editing the _OSI string list.
Sascha Wildner [Tue, 1 Jul 2014 03:09:17 +0000 (05:09 +0200)]
kernel/acpica: Add tunables for editing the _OSI string list.

ACPICA has a built-in list of supported _OSI strings. A query on any of
those strings returns TRUE. It is meant to help the ASL code determine
which OS it is dealing with. See AcpiDefaultSupportedInterfaces[] in
utosi.c for the full list.

This commit adds two tunables, hw.acpi.{install,remove}_interface,
for adding to and removing from that list. Their contents are comma
separated and leading white space is ignored.

Examples:

# Add "FreeBSD" to the list of supported _OSI strings,
# i.e. _OSI("FreeBSD") from ASL will return TRUE.
#
hw.acpi.install_interface="FreeBSD"

# Remove "Windows 2000" and "Windows 2001" from the list
# of supported _OSI strings, i.e. _OSI("Windows 2000") and
# _OSI("Windows 2001") from ASL will return FALSE.
#
hw.acpi.remove_interface="Windows 2000, Windows 2001"

Taken-from: FreeBSD

9 years agokernel - Move CPUMASK_LOCK out of the cpumask_t
Matthew Dillon [Mon, 30 Jun 2014 19:27:59 +0000 (12:27 -0700)]
kernel - Move CPUMASK_LOCK out of the cpumask_t

* Add cpulock_t (a 32-bit integer on all platforms) and implement
  CPULOCK_EXCL as well as space for a counter.

* Break-out CPUMASK_LOCK, add a new field to the pmap (pm_active_lock)
  and do the process vmm (p_vmm_cpulock) and implement the mmu interlock
  there.

  The VMM subsystem uses additional bits in cpulock_t as a mask counter
  for implementing its interlock.

  The PMAP subsystem just uses the CPULOCK_EXCL bit in pm_active_lock for
  its own interlock.

* Max cpus on 64-bit systems is now 64 instead of 63.

* cpumask_t is now just a pure cpu mask and no longer requires all-or-none
  atomic ops, just normal bit-for-bit atomic ops.  This will allow us to
  hopefully extend it past the 64-cpu limit soon.

9 years agobuild - Add additional CFLAGS
Matthew Dillon [Mon, 30 Jun 2014 19:20:41 +0000 (12:20 -0700)]
build - Add additional CFLAGS

* Add additional CFLAGS that are expected to be needed in later revs
  of the compiler.  These are not needed at the moment.

9 years agoSet CR4.OSFXSR before probing the mxcsr mask
Markus Pfeiffer [Mon, 30 Jun 2014 16:29:15 +0000 (17:29 +0100)]
Set CR4.OSFXSR before probing the mxcsr mask

This fixes Bug #2691

Reported-By: Antonio Huete Jiménez <tuxillo@quantumachine.net>
9 years agokernel - Fix nfs server-side shutdown race
Matthew Dillon [Sun, 29 Jun 2014 18:08:05 +0000 (11:08 -0700)]
kernel - Fix nfs server-side shutdown race

* Fix issues where slp->ns_so is being accessed during or after the socket
  has been zapped.  The zap code actually closes the fp and destroys the
  socket so this race results in a use-after-free and can cause a panic
  on the NFS server.

* Zapping now shuts the socket down but does not close/destroy it.  The
  socket will be destroyed when the last ref on slp (aka nfssvc_sock)
  is dropped.

* Re-check SLP_VALID in a few more places after potentially blocking.
  Other situations that might block are handled by the change in the
  zap code.

9 years agoFix buildworld.
Sascha Wildner [Sun, 29 Jun 2014 14:57:33 +0000 (16:57 +0200)]
Fix buildworld.

Due to adding a struct lock to struct pf_state in one of the recent
pf(4) commits, we have to define _KERNEL_STRUCTURES in everything
which includes pfvar.h.

9 years agoinpcb: Rework insertion of local group
Sepherosa Ziehau [Sun, 29 Jun 2014 12:33:38 +0000 (20:33 +0800)]
inpcb: Rework insertion of local group

Mainly to take possible malloc(9) blocking into consideration.  This
prepares tokenizing inpcb lists and tables for udp.

9 years agokernel - Fix pf-based NAT
Matthew Dillon [Sun, 29 Jun 2014 06:46:43 +0000 (23:46 -0700)]
kernel - Fix pf-based NAT

* NAT may not always be able to select a translated addr/port that is
  compatible with the source addr/port.  In this situation return packets
  from the translated target won't be able to find the state structure.

  This occurs if static-port is used or if the port range is insufficent
  for PF to be able to find a hash-compatible addr/port.

  This also occurs for UDP because the toeplitz hash does not appear to
  include a port (so there's nothing PF NAT can do to make it
  hash-compatible).

* In situations where PF believes a translation is not hash-compatible,
  the pf_state_key will be placed on a global RBTREE instead of the
  cpu-localized RBTREE.  This tree is checked and modified with a separate
  lock (shared when doing lookups, exclusive when doing adjustments).

  The nominal pf_find_state*() code will now check the global RBTREE if the
  state cannot be found in the localized tree.

* Modifications to the pf_state structure are now exclusively locked to
  handle the case where a state structure might be used by multiple cpu's
  at the same time.  This can only occur for translations such as NAT.

* The TCP code is not allowed to destroy state on connection reuse unless
  the state is cpu-local.  If it is not cpu-local the TCP code will mark
  the state for an immediate purge (within the next second).

* Add a TSO flag check to pf_route(), which is called via NAT.  Locally
  originated packets may have been built with TSO.  For PF NAT, we can
  only assume that the target interface will be compatible and allow the
  packet through (not try to fragment it, which won't work well anyway for
  TCP packets).

9 years agokernel/pf: Check size of long at compile time (fixes i386 build).
Sascha Wildner [Sat, 28 Jun 2014 20:10:48 +0000 (22:10 +0200)]
kernel/pf: Check size of long at compile time (fixes i386 build).

9 years agokernel - add toeplitz_piecemeal_addr/port()
Matthew Dillon [Sat, 28 Jun 2014 16:38:38 +0000 (09:38 -0700)]
kernel - add toeplitz_piecemeal_addr/port()

* Add two more inlines to help PF calculate matching cpus for NAT port
  scans.

9 years agoChmod 644 a few scripts in the tree.
Sascha Wildner [Sat, 28 Jun 2014 15:51:11 +0000 (17:51 +0200)]
Chmod 644 a few scripts in the tree.

As usual, 'make install' will take care about setting the wanted mode.

9 years agokernel/acpi: Solve ACPI_DEBUG_{CACHE,LOCKS,MEMMAP} building better.
Sascha Wildner [Sat, 28 Jun 2014 13:31:31 +0000 (15:31 +0200)]
kernel/acpi: Solve ACPI_DEBUG_{CACHE,LOCKS,MEMMAP} building better.

ACPICA 20140627 added a mechanism for having a platform dependent
header that is included _after_ ACPICA headers are included.

So we can now solve compilation with ACPI_DEBUG_{CACHE,LOCKS,MEMMAP}
by adding a new acdragonflyex.h header for the prototypes of the
debug flavors of AcpiOsReleaseObject(), AcpiOsAcquireLock(),
AcpiOsMapMemory() and AcpiOsUnmapMemory() instead of having to put
them into the vendor code (like I did in 3b92a84dc0def, which this
commit reverts).

9 years agokernel/acpi: Fix a kprintf for ACPI_DEBUG_MEMMAP.
Sascha Wildner [Sat, 28 Jun 2014 13:24:00 +0000 (15:24 +0200)]
kernel/acpi: Fix a kprintf for ACPI_DEBUG_MEMMAP.

9 years agovga_pci: Improve vga boot display detection.
Imre Vadasz [Fri, 27 Jun 2014 19:29:04 +0000 (21:29 +0200)]
vga_pci: Improve vga boot display detection.

* Check the "VGA Enable" bit on the parent bridge only if it is a
  PCI-to-PCI bridge.

* Always check the "I/O" and "Memory address space decoding" bits on the
  video card itself.

* Furthermore, vga_pci_attach() logs "Boot video device" if the card
  being attached is the Chosen One:
    vgapci0: <VGA-compatible display> [...]
    vgapci0: Boot video device

This is FreeBSD's r259579.

Tested-by: François Tigeot <ftigeot@wolfpond.org>
9 years agounlock_return.cocci: Add a check for ACPI_SERIAL_{BEGIN,END}.
Sascha Wildner [Sat, 28 Jun 2014 12:00:58 +0000 (14:00 +0200)]
unlock_return.cocci: Add a check for ACPI_SERIAL_{BEGIN,END}.

9 years agokernel/acpi_thinkpad: Unlock properly before returning.
Sascha Wildner [Sat, 28 Jun 2014 11:58:48 +0000 (13:58 +0200)]
kernel/acpi_thinkpad: Unlock properly before returning.

9 years agoacpi: Sync aapits Makefile with 20140627 ACPICA test suite.
Sascha Wildner [Sat, 28 Jun 2014 11:43:04 +0000 (13:43 +0200)]
acpi: Sync aapits Makefile with 20140627 ACPICA test suite.

9 years agokernel: Sync ACPICA with Intel's version 20140627.
Sascha Wildner [Sat, 28 Jun 2014 11:14:15 +0000 (13:14 +0200)]
kernel: Sync ACPICA with Intel's version 20140627.

* Various bug fixes and enhancements (see changes.txt).

* Use new local printf() like functions for the utilities.

* Use new AcpiLogError for portability.

This that are also changed/new but it don't affect DragonFly so far:

* Support for ACPICA generation within the EFI environment.

* New OSL file I/O interface.

* New global AcpiGbl_VerifyTableChecksum.

For a more detailed list, please see sys/contrib/dev/acpica/changes.txt.

9 years agokernel - merge fixes from FreeBSD
Matthew Dillon [Sat, 28 Jun 2014 03:06:02 +0000 (20:06 -0700)]
kernel - merge fixes from FreeBSD

* Merge 8159278dbd8e019, fixes to pf_get_sport().  Primarily fixes the state
  key used to check whether a port is in-use or not.  NAT could previously
  choose a port that was already in-use.

* bzero() the state key to ensure that uninitialized fields are zero,
  otherwise the RB_FIND is likely to fail.

* Cleanup the case where there is no port range or the protocol is not
  supported.  In this situation, sport must be replicated on the host.

9 years agopfctl - Change default keep-policy to bring more in-line with other BSDs
Matthew Dillon [Sat, 28 Jun 2014 02:05:33 +0000 (19:05 -0700)]
pfctl - Change default keep-policy to bring more in-line with other BSDs

* Change the default keep-policy to the equivalent of:

  set keep-policy keep state (pickups, sloppy)

* This is being done because without keep state PF is simply going to be
  too inefficient for any reasonable set of rules, and we no longer want
  to make users set the keep-policy line when keep state is already the
  default in other BSD systems.

* Note that we also set pickups and sloppy by default.  This allows the
  router and/or PF to be restarted and allows packet routing to change
  mid-stream without causing all active TCP connections to drop.  This
  may not be the default in other BSD systems but it should be.  Being
  ultra strict here to improve security against ICMP-based attacks removes
  too much flexibility to be appropriate.  Proper TCP implementations
  already do sequence space checks for RST packets.

9 years agokernel - Fix pf-based NAT
Matthew Dillon [Sat, 28 Jun 2014 01:02:26 +0000 (18:02 -0700)]
kernel - Fix pf-based NAT

* Concurrency work on PF broke NAT.  Fix NAT for IPV4 TCP.

* This is not a complete fix, the NAT must be able to select from a range
  of local ports to replace sport to properly map the NAT onto the same
  cpu that the originating packet was forwarded to.

* Not fixed for UDP yet.

9 years agokernel - Force manual hash calculation for IP fragments
Matthew Dillon [Fri, 27 Jun 2014 17:24:24 +0000 (10:24 -0700)]
kernel - Force manual hash calculation for IP fragments

* Hardware toeplitz hashes do not always distinguish IP fragments from
  full IP packets.  An IP fragment will typically have the
  (src,dst,srcport,dstport) in the first fragment, but will only have
  (src,dst) in the remaining fragments.  The HW might not understand this
  and generate hashes which prevent the fragments from being directed to
  the same cpu.

* Force a manual recalculation of the hash (ignore the HW hash) for any
  IP fragment.  That is, any IP packet with the IP_MF bit set or with a
  non-zero offset (masked by IP_OFFMASK).

* Direct all IP fragments to a target cpu based on the hash.  We previously
  directed all IP fragments to cpu 0.

* NOTE: The IP fragment handling code in the kernel is still serialized with
a lock.  This will be addressed in a later commit.  However, fragments
which are piped into PF will now be properly distributed across
available cpus.

Submitted-by: sephe
9 years agodrm/i915: Reorder function definitions in i915_gem.c
François Tigeot [Fri, 27 Jun 2014 06:57:55 +0000 (08:57 +0200)]
drm/i915: Reorder function definitions in i915_gem.c

* Reducing differences with Linux 3.8.13

* No functional changes

9 years agobuildworld - Add sync/sleep safety before mkinitrd
Matthew Dillon [Fri, 27 Jun 2014 04:04:09 +0000 (21:04 -0700)]
buildworld - Add sync/sleep safety before mkinitrd

* Try to mitigate a bug in earlier versions of DragonFly that can be
  triggered by mkinitrd's use of the VN device by ensuring that the world
  is synced to disk before running mkinitrd.

9 years agopf - make the bulk of PF concurrent under normal operation
Matthew Dillon [Fri, 27 Jun 2014 03:40:32 +0000 (20:40 -0700)]
pf - make the bulk of PF concurrent under normal operation

* state and ip fragment tables are now per-cpu.

* packet paths acquire pf_token shared instead of exclusive.  Packet
  processing runs concurrently.

* Any dynamic rules updates will run synchronously for now.

* State expiration from the pfpurge thread runs synchronously for now.
  More work can be done here.

* ioctl (and also pfsync) paths acquire pf_token exclusively.  That is,
  primarily pfctl commands.  This includes rules updates and state scans.
  More work can be done here.

9 years agopfctl - Fix pf_print_state
Matthew Dillon [Fri, 27 Jun 2014 02:19:30 +0000 (19:19 -0700)]
pfctl - Fix pf_print_state

* Fix a bug where the 'minutes' field in the expiration was not being
  calculated properly.

* Reformat the verbose output so it does not overflow 80 columns, and
  move the rule # printing up a little so it is not confusedly associated
  with the next entry.

9 years agonewsyslog(8): Remove a NULL-check-after-use and instead assert != NULL.
Sascha Wildner [Thu, 26 Jun 2014 20:21:56 +0000 (22:21 +0200)]
newsyslog(8): Remove a NULL-check-after-use and instead assert != NULL.

Taken-from: FreeBSD

9 years agoroute(8): Fix a sizeof bug.
Sascha Wildner [Thu, 26 Jun 2014 17:55:29 +0000 (19:55 +0200)]
route(8): Fix a sizeof bug.

9 years agoAlways check the limits of array index variables before using them.
Sascha Wildner [Thu, 26 Jun 2014 17:24:43 +0000 (19:24 +0200)]
Always check the limits of array index variables before using them.

9 years agonetmap: port if_transmit() to ifq_dispatch()
Franco Fichtner [Thu, 26 Jun 2014 17:10:27 +0000 (19:10 +0200)]
netmap: port if_transmit() to ifq_dispatch()

Suggested by: sephe

9 years agoinet: Handle IP fragments in netisr0
Sepherosa Ziehau [Thu, 26 Jun 2014 12:13:41 +0000 (20:13 +0800)]
inet: Handle IP fragments in netisr0

For packet whose hash is provided by hardware, the processing netisr
may not be netisr0.  Add a IP fragments check at the beginning of
ip_input(): if the current processing netisr is not netisr0 and the
packet is an IP fragment, then redispatch it to netisr0.

Discussed-with: dillon@

9 years agoNote need for most recent 3.6 possible before updating.
Justin C. Sherrill [Thu, 26 Jun 2014 03:47:00 +0000 (23:47 -0400)]
Note need for most recent 3.6 possible before updating.

9 years agoperror.1: Document which locale related env variables affect perror(1).
Sascha Wildner [Wed, 25 Jun 2014 19:29:09 +0000 (21:29 +0200)]
perror.1: Document which locale related env variables affect perror(1).

9 years agokernel/pci: Fix wrong checks for U4B presence.
Sascha Wildner [Wed, 25 Jun 2014 13:07:49 +0000 (15:07 +0200)]
kernel/pci: Fix wrong checks for U4B presence.

I messed this up when switching us to the new USB stack.

Thanks to Markus Pfeiffer for tracking down my mistake.

Reported-by: peeter
Dragonfly-bug: <http://bugs.dragonflybsd.org/issues/2686>

9 years agokernel/mrsas: Fix memset() size.
Sascha Wildner [Wed, 25 Jun 2014 11:59:34 +0000 (13:59 +0200)]
kernel/mrsas: Fix memset() size.

9 years agoinpcb: Reorganize localgroup manages functions.
Sepherosa Ziehau [Sun, 22 Jun 2014 12:00:41 +0000 (20:00 +0800)]
inpcb: Reorganize localgroup manages functions.

This is in preparation for conditionally tokenize inpcb lists/tables.

9 years agoboot - Return proper sense from probe_keyboard()
Matthew Dillon [Tue, 24 Jun 2014 22:33:56 +0000 (15:33 -0700)]
boot - Return proper sense from probe_keyboard()

* The sense was reversed.  Return the proper sense.

Taken-From: FreeBSD

9 years agoboot - consistently reload v86.ctl/v86.addr (non-bug)
Matthew Dillon [Tue, 24 Jun 2014 22:32:09 +0000 (15:32 -0700)]
boot - consistently reload v86.ctl/v86.addr (non-bug)

* This is not a bug.  Be more consistent when loading the v86 structure,
  do not try to optimize out fields that are already loaded in distinct
  code sections.

9 years agoboot - Timeout seta20 for normal boots as well as for cd boots.
Matthew Dillon [Tue, 24 Jun 2014 22:29:47 +0000 (15:29 -0700)]
boot - Timeout seta20 for normal boots as well as for cd boots.

* Bring code from cdboot into boot1.S

* Also use a more correct segment:offset when trying to reboot.

Reported-by: karu.pruun (karu.pruun@gmail.com),
     Roman Neuhauser (neuhauser@sigpipe.cz)

9 years agoboot - Fix BIOS lockup due to H2 probe on small medias
Matthew Dillon [Tue, 24 Jun 2014 22:10:31 +0000 (15:10 -0700)]
boot - Fix BIOS lockup due to H2 probe on small medias

* Some BIOSes (found w/Intel atom D525 w/Foxconn mobo, AMIBIOS) will
  implode when asked to read a disk address beyond the EOM.  The HAMMER2
  probe tries to read a volume header at the 0, 2G, 4G, and 6G marks.
  This appears to blow up the BIOS when booting from USB media.

* To work around the problem, for now we do not proceed to test all four
  volume header offsets if the first one (at offset 0) does not have a
  HAMMER2 signature.

* Thanks to tm512 (Kyle Davis) for spending ~4+ hours helping us find
  the problem.

Reported-by: tm512 (Kyle Davis)
9 years agodrm/i915: fix notify_ring()
Johannes Hofmann [Mon, 23 Jun 2014 20:53:02 +0000 (22:53 +0200)]
drm/i915: fix notify_ring()

9 years agoauthor style fixes in manual pages
Franco Fichtner [Sat, 21 Jun 2014 14:16:50 +0000 (16:16 +0200)]
author style fixes in manual pages

9 years agodrm/i915: Sync intel_pm.c with Linux 3.8.13
François Tigeot [Sat, 21 Jun 2014 09:00:30 +0000 (11:00 +0200)]
drm/i915: Sync intel_pm.c with Linux 3.8.13

* Add a workaround for a hardware issue making the GPU get stuck at
  some particular frequency

* Add initialization code to enable Haswell power wells

* Little fixes and adjustements for various GPUs up to Haswell

9 years agokernel/vinum: Use %jx in a number of places instead of %llx.
Sascha Wildner [Fri, 20 Jun 2014 09:30:57 +0000 (11:30 +0200)]
kernel/vinum: Use %jx in a number of places instead of %llx.

9 years agokernel: Correct function names in comments.
Sascha Wildner [Fri, 20 Jun 2014 06:12:19 +0000 (08:12 +0200)]
kernel: Correct function names in comments.

9 years agofile: libmagic knows about libz now so drop the dependency
Franco Fichtner [Thu, 19 Jun 2014 12:28:14 +0000 (14:28 +0200)]
file: libmagic knows about libz now so drop the dependency

9 years agolibmagic: fix file identification
Franco Fichtner [Thu, 19 Jun 2014 12:10:26 +0000 (14:10 +0200)]
libmagic: fix file identification

Removes local modifications from contrib code and
fixes at least the following identification issue.

Before:

    # file /usr/src/bin/test/test.c
    /usr/src/bin/test/test.c: ASCII text

After:

    # file /usr/src/bin/test/test.c
    /usr/src/bin/test/test.c: C source, ASCII text

9 years agojscan(8): Remove dupdata() (no longer used since 36d6bdee113b682f2).
Sascha Wildner [Thu, 19 Jun 2014 09:28:23 +0000 (11:28 +0200)]
jscan(8): Remove dupdata() (no longer used since 36d6bdee113b682f2).

9 years agokernel - Fix rare ucred race
Matthew Dillon [Wed, 18 Jun 2014 18:47:45 +0000 (11:47 -0700)]
kernel - Fix rare ucred race

* In a threaded program if one thread is modifying the ucred, e.g.
  changing the uid or gid or something like that, and another thread
  enters a system call at the same time, the second thread can wind
  up trying to hold a stale ucred kfree()'d by the first thread.

* Very rare race on top of a ~2-instruction window.

* Fix the problem by obtaining proc->p_spin when updating the per-thread
  ucred cache (td->td_ucred) from p->p_ucred, as well as when replacing
  p_ucred.

  These fixes do NOT impose any critical-path overhead.  For the case where
  a thread already has the current p_ucred cached on entry to a system call,
  absolutely nothing needs to be done.

Reported-by: joris (Joris Giovannangeli)
9 years agosocket: so_pru_abort_oncpu -> so_pru_abort_direct
Sepherosa Ziehau [Wed, 18 Jun 2014 14:19:53 +0000 (22:19 +0800)]
socket: so_pru_abort_oncpu -> so_pru_abort_direct

No functional change.  It is consistent w/ other so_pru functions name.