Commit Graph

15665 Commits

Author SHA1 Message Date
jhb
f227573925 MFC 271048:
Always seek back to the beginning of a regular directory, even if the
previous seek location was 0.  Without this, readdir() would see
dd_loc of zero and call getdirentries() which would start reading
entries at the current seek location of the directory ignoring the
first batch of entries.  Also, rewinddir() should always seek so that
it reads the directory from the beginning to get updated entries.

PR:		192935
Approved by:	re (gjb)
2014-09-08 14:45:58 +00:00
emaste
261ad5a21c MFC UEFI loader
This MFC consists of the following SVN revisions:
  258741 261568 261603 261668 263115 263117 263968 264078 264087 264088
  264092 264095 264115 264132 264208 264261 264262 264263 264319 265028
  265057 268974

Detailed commit messages:

r258741: Note that libstand is 32-bit on amd64 and powerpc64

r261568: Build libstand as a 64-bit library on amd64

  The 32-bit bootloaders now link against libstand.a in
  sys/boot/libstand32, so there is no need to force /usr/lib/libstand.a
  to be 32-bit.

r261603: Don't force efi to a 32-bit build on amd64

r261668: Build libstand as a 64-bit library on ppc64

  The 32-bit bootloaders now link against libstand.a in
  sys/boot/libstand32, so there is no need to force /usr/lib/libstand.a
  to be 32-bit.

  This is equivalent to r261568 for amd64.

r263115: Add amd64 EFI headers

r263117: Connect 64-bit boot ficl to the build

  It is not yet used, but this will ensure it doesn't get broken.

r263968: Use EFI types for EFI values (silences warnings).

  EFI UINTN is actually a 64-bit type on 64-bit processors.

r264078: Put each source file on a separate line

  This will simplify rebasing the amd64 UEFI patch set.

r264087: Build boot/ficl as 64-bit library on amd64

  The 32-bit bootloaders on amd64 now use the 32-bit version in ficl32,
  as is done with libstand32.  The native 64-bit ficl will be used by the
  upcoming UEFI loader.

r264088: Merge efilib changes from projects/uefi

  r247216: Add the ability for a device to have an "alias" handle.

  r247379: Fix network device registration.

  r247380: Adjust our load device when we boot from CD under UEFI.

    The process for booting from a CD under UEFI involves adding a FAT
    filesystem containing your loader code as an El Torito boot image.
    When UEFI detects this, it provides a block IO instance that points
    at the FAT filesystem as a child of the device that represents the CD
    itself. The problem being that the CD device is flagged as a "raw
    device" while the boot image is flagged as a "logical partition".
    The existing EFI partition code only looks for logical partitions and
    so the CD filesystem was rendered invisible.

    To fix this, check the type of each block IO device. If it's found to
    be a CD, and thus an El Torito boot image, look up its parent device
    and add that instead so that the loader will then load the kernel from
    the CD filesystem.  This is done by using the handle for the boot
    filesystem as an alias.

    Something similar to this will be required for booting from other media
    as well as the loader will live in the EFI system partition, not on the
    partition containing the kernel.

  r247381: Remove a scatalogical debug printf that crept in.

r264092: Add -fPIC for amd64

r264095: Support UEFI booting on amd64 via loader.efi

  This is largely the work from the projects/uefi branch, with some
  additional refinements.  This is derived from (and replaces) the
  original i386 efi implementation; i386 support will be restored later.

  Specific revisions of note from projects/uefi:

  r247380:

    Adjust our load device when we boot from CD under UEFI.

    The process for booting from a CD under UEFI involves adding a FAT
    filesystem containing your loader code as an El Torito boot image.
    When UEFI detects this, it provides a block IO instance that points at
    the FAT filesystem as a child of the device that represents the CD
    itself. The problem being that the CD device is flagged as a "raw
    device" while the boot image is flagged as a "logical partition". The
    existing EFI partition code only looks for logical partitions and so
    the CD filesystem was rendered invisible.

    To fix this, check the type of each block IO device. If it's found to
    be a CD, and thus an El Torito boot image, look up its parent device
    and add that instead so that the loader will then load the kernel from
    the CD filesystem.  This is done by using the handle for the boot
    filesystem as an alias.

    Something similar to this will be required for booting from other
    media as well as the loader will live in the EFI system partition, not
    on the partition containing the kernel.

  r246231:

    Add necessary code to hand off from loader to an amd64 kernel.

  r246335:

    Grab the EFI memory map and store it as module metadata on the kernel.

    This is the same approach used to provide the BIOS SMAP to the kernel.

  r246336:

    Pass the ACPI table metadata via hints so the kernel ACPI code can
    find them.

  r246608:

    Rework copy routines to ensure we always use memory allocated via EFI.

    The previous code assumed it could copy wherever it liked. This is not
    the case. The approach taken by this code is pretty ham-fisted in that
    it simply allocates a large (32MB) buffer area and stages into that,
    then copies the whole area into place when it's time to execute. A more
    elegant solution could be used but this works for now.

  r247214:

    Fix a number of problems preventing proper handover to the kernel.

    There were two issues at play here. Firstly, there was nothing
    preventing UEFI from placing the loader code above 1GB in RAM. This
    meant that when we switched in the page tables the kernel expects to
    be running on, we are suddenly unmapped and things no longer work. We
    solve this by making our trampoline code not dependent on being at any
    given position and simply copying it to a "safe" location before
    calling it.

    Secondly, UEFI could allocate our stack wherever it wants. As it
    happened on my PC, that was right where I was copying the kernel to.
    This did not cause happiness. The solution to this was to also switch
    to a temporary stack in a safe location before performing the final
    copy of the loaded kernel.

  r246231:

    Add necessary code to hand off from loader to an amd64 kernel.

  r246335:

    Grab the EFI memory map and store it as module metadata on the kernel.

    This is the same approach used to provide the BIOS SMAP to the kernel.

  r246336:

    Pass the ACPI table metadata via hints so the kernel ACPI code can
    find them.

  r246608:

    Rework copy routines to ensure we always use memory allocated via EFI.

    The previous code assumed it could copy wherever it liked. This is not
    the case. The approach taken by this code is pretty ham-fisted in that
    it simply allocates a large (32MB) buffer area and stages into that,
    then copies the whole area into place when it's time to execute. A more
    elegant solution could be used but this works for now.

  r247214:

    Fix a number of problems preventing proper handover to the kernel.

    There were two issues at play here. Firstly, there was nothing
    preventing UEFI from placing the loader code above 1GB in RAM. This
    meant that when we switched in the page tables the kernel expects to
    be running on, we are suddenly unmapped and things no longer work. We
    solve this by making our trampoline code not dependent on being at any
    given position and simply copying it to a "safe" location before
    calling it.

    Secondly, UEFI could allocate our stack wherever it wants. As it
    happened on my PC, that was right where I was copying the kernel to.
    This did not cause happiness. The solution to this was to also switch
    to a temporary stack in a safe location before performing the final
    copy of the loaded kernel.

  r247216:

    Use the UEFI Graphics Output Protocol to get the parameters of the
    framebuffer.

r264115: Fix printf format mismatches

r264132: Connect sys/boot/amd64 to the build

r264208: Do not build the amd64 UEFI loader with GCC

  The UEFI loader causes buildworld to fail when building with (in-tree)
  GCC, due to a typedef redefinition.  As it happens the in-tree GCC
  cannot successfully build the UEFI loader anyhow, as it does not support
  __attribute__((ms_abi)).  Thus, just avoid trying to build it with GCC,
  rather than disconnecting it from the build until the underlying issue
  is fixed.

r264261: Correct a variable's type for 64-bit Ficl

  FICL_INT is long.

r264262: Fix printf args for 64-bit archs

r264263: Add explicit casts to quiet warnings in libefi

r264319: Fix EFI loader object tree creation on 9.x build hosts

  Previously ${COMPILER_TYPE} was checked in sys/boot/amd64, and the efi
  subdirectory was skipped altogether for gcc (since GCC does not support
  a required attribute).  However, during the early buildworld stages
  ${COMPILER_TYPE} is the existing system compiler (i.e., gcc on 9.x build
  hosts), not the compiler that will eventually be used.  This caused
  "make obj" to skip the efi subdirectory.  In later build stages
  ${COMPILER_TYPE} is "clang", and then the efi loader would attempt to
  build in the source directory.

r265028 (dteske): Disable the beastie menu for EFI console ...

  which doesn't support ANSI codes (so things like `at-xy', `clear', and
  other commands don't work making it impossible to generate a living
  menu).

r265057 (nwhitehorn): Turn off various fancy instruction sets...

  as well as deduplicate some options.  This makes the EFI loader build
  work with CPUTYPE=native in make.conf on my Core i5.

r268974 (sbruno): Supress clang warning for FreeBSD printf %b and %D formats

Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2014-09-04 21:01:10 +00:00
emaste
ae111330ce MFC r269077 (sbruno): libstand qdivrem warning fixes
libstand's qdivrem.c assumes that sizeof(int) == sizeof(long), this is not
  true on amd64 I'm not quite positive this is the "correct" solution for
  this but it does seem to compile and shut up the spew of warnings when
  compiling libstand for userboot.

  Add two _Static_asserts() so that in the future somebody will get a compile
  failure if an architecture develops that violates the assumptions of this
  code. (strongly suggested by jmg)

  Change commetns to indicate int types instead of long.  (noted by ian in
  phabric review)

  Phabric:    https://phabric.freebsd.org/D443
2014-09-04 20:49:11 +00:00
emaste
2c0d103cf1 MFC r261591 (nwhitehorn):
Make libstand setjmp work for both 64- and 32-bit ABIs.
2014-09-04 20:21:30 +00:00
ngie
5706da73b7 MFC r270145:
Replace DPADD with DPSRCS to fix "make checkdpadd"

  Phabric: D625
  Approved by: jmmv (mentor)
  Reviewed by: dim
  PR: 192734
2014-09-01 02:53:32 +00:00
ngie
b7b1b100cc MFC r266650, r267172 (both by jmmv):
r266650:

  Change libatf-c and libatf-c++ to be private libraries.

  We should not be leaking these interfaces to the outside world given
  that it's much easier for third-party components to use the devel/atf
  package from ports.

  As a side-effect, we can also drop the ATF pkgconfig and aclocal files
  from the base system.  Nothing in the base system needs these, and it
  was quite ugly to have to get them installed only so that a few ports
  could build.  The offending ports have been fixed to depend on
  devel/atf explicitly.

  Reviewed by:  bapt

r267172:

  Homogenize libatf-* version numbers with upstream.

  The libatf-* major version numbers in FreeBSD were one version ahead of
  upstream because, when atf was first imported into FreeBSD, the upstream
  numbers were not respected.  This is just confusing and bound to cause
  problems down the road.

  Fix this by taking advantage of the fact that libatf-* are now private
  and that atf is not yet built by default.  However, and unfortunately, a
  clean build is needed for tests to continue working once "make
  delete-old-libs" has been run; hence the note in UPDATING.

Phabric: D701
Approved by: jmmv (maintainer, mentor)
2014-08-31 23:09:23 +00:00
ume
8b5c391a35 MFC r270215: Add missing break. 2014-08-30 10:29:47 +00:00
ume
82bd2f3628 MFC r269873:
Fix broken pointer overflow check ns_name_unpack()

Many compilers may optimize away the overflow check `msg + l < msg',
where `msg' is a pointer and `l' is an integer, because pointer
overflow is undefined behavior in C.

Use a safe precondition test `l >= eom - msg' instead.

Reference:
https://android-review.googlesource.com/#/c/50570/

Requested by:	pfg
Obtained from:	NetBSD (CVS rev. 1.10)
2014-08-30 10:25:41 +00:00
ume
7642dd9269 MFC r269867:
Update our stub resolver to final version of libbind
(libbind-6.0).

Obtained from:  ISC
2014-08-30 10:16:25 +00:00
ume
80004c0874 MFC r269865:
Bring the md5 functions into libc for internal use only.
It is required to support ID randomization for our stub
resolver.
2014-08-30 09:55:38 +00:00
ngie
fb8a509f8e MFC r270519:
Fix "make checkdpadd" for lib/libc when MK_SSP != no

 Add LIBSSP_NONSHARED to bsd.libnames.mk and append LIBSSP_NONSHARED to DPADD in
 lib/libc when MK_SSP != no

 Approved by: rpaulo (mentor)
 Phabric: D675 (as part of a larger diff)
 PR: 192728
2014-08-28 19:59:04 +00:00
markj
385503e19f MFC r265255, r270506:
Allow "a.out" as an alias for the executable if no other matching entries
are found.
2014-08-27 19:51:42 +00:00
ngie
3d2bab33aa MFC r270180:
r269906:

 Add missing BSD.tests.dist entry for lib/libutil to unbreak installworld with
 MK_TESTS == no

 Phabric: D555
 Approved by: jmmv (mentor, implicit)
 Pointyhat to: ngie

r269904:

 Integrate lib/libutil into the build/kyua

 Remove the .t wrappers

 Rename all of the TAP test applications from test-<test> to
 <test>_test to match the convention described in the TestSuite
 wiki page

 humanize_number_test.c:

 - Fix -Wformat warnings with counter variables
 - Fix minor style(9) issues:
 -- Header sorting
 -- Variable declaration alignment/sorting in main(..)
 -- Fit the lines in <80 columns
 - Fix an off by one index error in the testcase output [*]
 - Remove unnecessary `extern char * optarg;` (this is already provided by
   unistd.h)

 Phabric: D555
 Approved by: jmmv (mentor)
 Obtained from: EMC / Isilon Storage Division [*]
 Submitted by: Casey Peel <cpeel@isilon.com> [*]
 Sponsored by: EMC / Isilon Storage Division
2014-08-27 18:25:14 +00:00
hselasky
9883e5972f MFC r270133:
Add more USB class codes.
2014-08-27 14:17:15 +00:00
gjb
05de13180a - Update stable/10 to 10.1-PRERELEASE now that the
code slush is in effect.  (Forgotten on the 22nd.)
- Set the 10.1 as the .Fx mdoc(7) default.
- Update the TARGET_TRIPLE and BUILD_TRIPLE for clang(1)
  to reflect 10.1.

Approved by:	re (implicit)
Sponsored by:	The FreeBSD Foundation
2014-08-26 15:31:56 +00:00
des
db46c7fe73 MFH (r267127): don't send User-Agent if HTTP_USER_AGENT is empty 2014-08-24 14:04:20 +00:00
des
1df0cac7e1 MFH (r268888): fix false negative for empty groups
PR:		109416

MFH (r268890): add support for "account" facility
PR:		115164
2014-08-23 11:40:40 +00:00
des
ce304e0b36 MFH (r269115): remove useless getpwnam() call 2014-08-23 11:34:56 +00:00
ngie
a6a5f3526a MFC r270144:
Add LIBCRYPT to DPADD, remove LDFLAGS from LDADD, and sort the Makefile variables

 This fixes "make checkdpadd"

 Phabric: D620
 Approved by: jmmv (mentor)
 PR: 192729
2014-08-23 02:24:47 +00:00
tuexen
9db28b75f0 MFC r269945:
Add support for the SCTP_PR_STREAM_STATUS and SCTP_PR_ASSOC_STATUS
socket options. This includes managing the correspoing stat counters.
Add the SCTP_DETAILED_STR_STATS kernel option to control per policy
counters on every stream. The default is off and only an aggregated
counter is available. This is sufficient for the RTCWeb usecase.
2014-08-22 20:26:20 +00:00
tuexen
fcd4ba9eaa MFC r269858:
Add support for the SCTP_AUTH_SUPPORTED and SCTP_ASCONF_SUPPORTED
socket options. Add also a sysctl to control the support of ASCONF.
2014-08-22 20:22:12 +00:00
tuexen
85630ed213 MFC r269527:
Add support for the SCTP_RECONFIG_SUPPORTED and the corresponding
sysctl controlling the negotiation of the RE-CONFIG extension.
2014-08-22 20:16:26 +00:00
tuexen
5a4252e3c4 MFC r269481:
Add support for the SCTP_PKTDROP_SUPPORTED socket option and
the corresponding sysctl variable.
The default is off, since the specification is not an RFC yet.
2014-08-22 20:08:50 +00:00
tuexen
94e8309da0 MFC r269475:
Add SCTP socket option SCTP_NRSACK_SUPPORTED to control the
NRSACK extension. The default will still be off, since it
it not an RFC (yet).
Changing the sysctl name will be in a separate commit.
2014-08-22 20:05:09 +00:00
tuexen
b33760ea4b MFC r269448:
Add support for the SCTP_PR_SUPPORTED socket option as specified in
http://tools.ietf.org/html/draft-ietf-tsvwg-sctp-prpolicies
Add also a sysctl controlling the default of the end-points.
2014-08-22 20:01:35 +00:00
tuexen
a4786844b5 MFC r269436, r269445:
Cleanup the ECN configuration handling and provide an SCTP socket
option for controlling ECN on future associations and get the
status on current associations.
A simialar pattern will be used for controlling SCTP extensions in
upcoming commits.
2014-08-22 19:57:39 +00:00
ngie
9f72d19a82 MFC r270116:
Fix typo in lib/atf/libatfc++/Makefile

 LIBATFC should be LIBATF_C; this was missed in the initial import
 (r241823)

 PR: 192731
 MFC after: 3 days
 Phabric: D619
 Approved by: rpaulo (mentor)
2014-08-21 17:36:42 +00:00
ngie
71a15c49c9 MFC r269534:
Integrate lib/libmp into the build/kyua

  - Remove the .t wrapper
  - Fix -Wreturn-type warnings with clang

  This change has been tested on amd64/i386

  Phabric: D530
  Reviewed by: jmmv
  Approved by: jmmv (co--mentor)
  MFC after: 2 weeks
  Sponsored by: EMC / Isilon Storage Division

MFC note: src.opts.mk in the original commit was changed to
          bsd.own.mk.
2014-08-21 17:32:38 +00:00
ian
c4195049f5 MFC r266473,267331,267511:
Use an intermediate target to associate with _SUBDIR which is marked .MAKE
  this allows make -n to do tree walks as expected without
  doing anything else (as intended).
  Use prefix _sub. to help avoid conflict with any real target.

  Put the test suite in its own tests.txz distribution file.
  Force all the contents of /usr/tests to go into a separate distribution
  file so that users of binary releases can easily choose to not install

  Create a mechanism for providing fine-grained build order dependencies
  during SUBDIR_PARALLEL builds.  This augments the coarse .WAIT mechanism,
  which is still useful if you've got a situation such as "almost everything
  depends on A and B".
2014-08-19 23:33:51 +00:00
grehan
5d455a50f5 MFC r267921, r267934, r267949, r267959, r267966, r268202, r268276,
r268427, r268428, r268521, r268638,	r268639, r268701, r268777,
    r268889, r268922, r269008, r269042,	r269043, r269080, r269094,
    r269108, r269109, r269281, r269317,	r269700, r269896, r269962,
    r269989.

Catch bhyve up to CURRENT.

Lightly tested with FreeBSD i386/amd64,	Linux i386/amd64, and
OpenBSD/amd64. Still resolving an	issue with OpenBSD/i386.

Many thanks to jhb@ for	all the	hard work on the prior MFCs !

r267921 - support the "mov r/m8, imm8" instruction
r267934 - document options
r267949 - set DMI vers/date to fixed values
r267959 - doc: sort cmd flags
r267966 - EPT misconf post-mortem info
r268202 - use correct flag for event index
r268276 - 64-bit virtio capability api
r268427 - invalidate guest TLB when cr3 is updated, needed for TSS
r268428 - identify vcpu's operating mode
r268521 - use correct offset in guest logical-to-linear translation
r268638 - chs value
r268639 - chs fake values
r268701 - instr emul operand/address size override prefix support
r268777 - emulation for legacy x86 task switching
r268889 - nested exception support
r268922 - fix INVARIANTS build
r269008 - emulate instructions found in the OpenBSD/i386 5.5 kernel
r269042 - fix fault injection
r269043 - Reduce VMEXIT_RESTARTs in task_switch.c
r269080 - fix issues in PUSH emulation
r269094 - simplify return values from the inout handlers
r269108 - don't return -1 from the push emulation handler
r269109 - avoid permanent sleep in vm_handle_hlt()
r269281 - list VT-x features in base kernel dmesg
r269317 - Mark AHCI fatal errors as not completed
r269700 - Support PCI extended config space in bhyve
r269896 - Minor cleanup
r269962 - use max guest memory when creating IOMMU domain
r269989 - fix interrupt mode names
2014-08-19 01:20:24 +00:00
ache
e3bbb42f27 MFC: r269875
According to opie code and even direct mention in opie(4) challenge buffer
size must be OPIE_CHALLENGE_MAX + 1, not OPIE_CHALLENGE_MAX

Reviewed by:    des
2014-08-18 03:06:49 +00:00
ache
2090706028 Direct commit to stable/10 reflecting r269961 because the rest can't be
merged.

Bump version because challenge buffer size changed.
2014-08-18 02:42:23 +00:00
dim
197183e80f MFC r269954:
Stop telling people to directly report llvm or clang bugs upstream,
point them to the FreeBSD bug tracker instead, since we use our own
patches.
2014-08-17 13:12:07 +00:00
grehan
46d28d66fb MFC r267311, r267330, r267811, r267884
Turn on interrupt window exiting unconditionally when an ExtINT is being
injected into the guest.

Add helper functions to populate VM exit information for rendezvous and
astpending exits.

Provide APIs to directly get 'lowmem' and 'highmem' size directly.

Expose the amount of resident and wired memory from the guest's vmspace
2014-08-17 01:23:52 +00:00
grehan
7a365d2c05 MFC r267216
Add ioctl(VM_REINIT) to reinitialize the virtual machine state maintained
by vmm.ko. This allows the virtual machine to be restarted without having
to destroy it first.
2014-08-17 01:00:42 +00:00
grehan
e83027edbb MFC r266933
Activate vcpus from bhyve(8) using the ioctl VM_ACTIVATE_CPU instead of doing
it implicitly in vmm.ko.
2014-08-17 00:52:07 +00:00
kib
9cb3300d88 MFC r269909:
Add a knob LIBPTHREAD_BIGSTACK_MAIN, which instructs libthr to leave
the whole RLIMIT_STACK-sized region of the kernel-allocated stack as
the stack of main thread.
2014-08-16 08:38:53 +00:00
kib
6f9f1bcfb8 MFC r269908:
Style.
2014-08-16 08:37:13 +00:00
pfg
ae3a2a5c84 MFC r268924:
Update fflush(3) to return success on a read-only stream.

This is done for compliance with SUSv3. The changes cause
no secondary effects in the gnulib tests (we pass them).

Obtained from:	Apple Inc. (Libc 997.90.3 with changes)
Reviewed by:	bde
Phabric:	D440
2014-08-16 01:29:49 +00:00
pfg
885e369762 MFC r269901:
Minor style tweaks.

Obtained from:	OpenBSD (CVS rev. 1.7)
2014-08-16 01:03:51 +00:00
pfg
b9f92aa016 MFC r269695:
Const-ify character string

Obtained from:  Apple Inc. (Libc 997.90.3)
MFC after:	3 days
2014-08-16 01:00:37 +00:00
pfg
cc4d94d41f MFC r269015:
fparseln(3): Update from NetBSD sources.

-fix a condition so that fparseln() doesn't report spurious empty lines
 eg after 2 comment lines, or on EOF after a single comment line
-no escape character means no escaped characters

modify the previous fix so that no pointless realloc()s are done in
the case of multiple empty continuation lines, and comment the code
to make the logics obvious.

fparseln is now part of libc in NetBSD so this changes the previous
revision numbering.

Obtained from:	NetBSD (CVS Rev. 1.6-1.7)
2014-08-16 00:54:56 +00:00
jhb
cabf1ab5da MFC 268531,269079,269204:
Fix various edge cases with rewinddir(), seekdir(), and telldir():
- In the unionfs case, opendir() and fdopendir() read the directory's full
  contents and cache it.  This cache is not refreshed when rewinddir() is
  called, so rewinddir() will not notice updates to a directory.  Fix this
  by splitting the code to fetch a directory's contents out of
  __opendir_common() into a new _filldir() function and call this from
  rewinddir() when operating on a unionfs directory.
- If rewinddir() is called on a directory opened with fdopendir() before
  any directory entries are fetched, rewinddir() will not adjust the seek
  location of the backing file descriptor.  If the file descriptor passed
  to fdopendir() had a non-zero offset, the rewinddir() will not rewind to
  the beginning.  Fix this by always seeking back to 0 in rewinddir().
  This means the dd_rewind hack can also be removed.
- Add missing locking to rewinddir()
- POSIX says that passing a location returned by telldir() to seekdir()
  after an intervening call to rewinddir() is undefined, so reclaim any
  pending telldir() cookies in the directory when rewinddir() is called.
- If telldir() is called immediately after a call to seekdir(), POSIX
  requires the return value of telldir() to equal the value passed to
  seekdir().  The current seekdir code with SINGLEUSE enabled breaks
  this case as each call to telldir() allocates a new cookie.  Instead,
  remove the SINGLEUSE code and change telldir() to look for an existing
  cookie for the directory's current location rather than always creating
  a new cookie.

PR:		121656
2014-08-14 20:20:21 +00:00
dim
3cca469e52 MFC r269750:
In r268463, I misplaced a return in demangle(), causing the function to
erroneously skip symbols that were not mangled at all.  Fix this by
moving the return into the preceding if block.

While here, simplify the code by letting __cxa_demangle() allocate the
needed space for the demangled symbol.  This also fixes a memory leak,
which would occur whenever __cxa_demangle() failed.

Reported by:	pgj
PR:		base/191981
2014-08-12 17:56:48 +00:00
ian
a08c00a48a MFC r268993, r268893, r268994, plus partial r264070, r264082
Fix C++ exception handling for ARM EABI.

 Just the part of r264070 that creates the FBSD_1.4 namespace in libc
 is hand-applied, and then r264082 which creates the Versions.def entry
 is MFC'd.
2014-08-10 22:26:29 +00:00
markj
4eeea9f0c4 MFC r265308:
If the traced process stops because it received a signal, libproc needs
to ensure that the signal is forwarded when proc_continue() is called.
2014-08-09 15:00:03 +00:00
markj
104ac38f14 MFC r265629, r265630
MFC r265629:
Handle the different event types properly in rd_event_addr(). In particular,
with r265456 _r_debug_postinit can be used for RD_POSTINIT events. rtld(1)
uses r_debug_state for dl state transitions, so we use its address for
RD_DLACTIVITY events.

MFC r265630:
Fix the rd_event_addr prototype and slightly clarify the use of the "event"
parameter.
2014-08-08 14:53:01 +00:00
ache
da0a5df9dc MFC: r269116
In the "Too many open files" edge cases don't try to preserve old
number for non-std* descriptors, but close old file and retry.

Obtained from:  inspired by Apple's change from pfg@
2014-08-06 10:38:06 +00:00
ache
2d3901a5e0 MFC: r268997
For "a"-mode files and rewind/fseek + fwrite combination return meaningful
value now, like Apple does, but avoid their __sflush physical write
performance degradation as much as possible.
2014-08-06 10:33:43 +00:00
dim
bde3467611 MFC r269125:
In r232153, libarchive 3.0.3 was imported, replacing the archive_hash.h
header with archive_crypto_private.h, and its ARCHIVE_HASH_xxx macros
were renamed to ARCHIVE_CRYPTO_xxx.

Rename these macros in lib/libarchive/config_freebsd.h, to re-enable the
hashes for libarchive again.  This affects the mtree format writer, and
the xar format reader and writer modules.

This also requires changes in the library order for statically linking
rescue, otherwise ld would complain about redefined symbols.  Thanks to
jkim for pointing out the solution.

Reviewed by:	kientzle
2014-08-04 14:56:49 +00:00
pfg
503271002c MFC r268945:
Fix hdestroy() compliance issue.

The hcreate(3) implementation and related functions we inherited
from NetBSD used to free() the key value, something that is not
supported by the standard implementation.

This would cause a segmentation fault when attempting to run
the examples from the opengroup and linux manpages.

There is no need to bump the __FreeBSD_version as we have
always claimed XPG4.2 compliance but if some reference is
required, the bump for r269484 can be used.

Reference:
http://bugs.dragonflybsd.org/issues/1398
2014-08-04 00:51:57 +00:00
pfg
1ae0bcf0e8 MFC r268066:
regex(3): Add support for \< and \> word delimiters

Solaris and other OSs have support for \< and \> as word
delimiters in utilities like sed(1). These are useful to
have for general compatiblity with Solaris but should be
avoided for portability with other systems, including the
traditional BSDs.

Bump __FreeBSD_version as this is likely to affect some
userland utilities.

Reference:
https://www.illumos.org/issues/516

PR:		bin/153257
Obtained from:	Illumos
2014-08-03 18:39:11 +00:00
pfg
4edbce8b34 MFC r269124:
strftime() xlocale cleanups.

Replace fprintf_l with fputs when output is unformatted.
Use locale_t in _conv() since it was using sprintf (now sprintf_l)
Use locale_t on _yconv() since it calls _conv()

Obtained from:	Apple Inc. (Libc 997.90.3)
CR:		D482
Reviewed by:	theraven
2014-08-03 18:31:52 +00:00
pfg
5c8726d1b2 MFC r268926, r268930, r268983:
Use a correct errno in freopen.
Use EBADF instead of EINVAL when working around incorrect O_ACCMODE.

Adjust errno on failed prepwrite.

rewind: always clear error indicator as required by POSIX.

Obtained from:	Apple Inc. (Libc 997.90.3)
Phabric:	D442
2014-08-03 18:28:10 +00:00
pfg
eabfc5bd75 MFC r268867, r268878:
Use more consistent type for optlen in getsourcefilter()

Proposed by:	bde
2014-08-03 18:03:00 +00:00
marcel
aef52ec818 MFC 264162: Accept RFC 2292 option values so that RFC 2292 compliant
programs that are unaware of RFC 3542 can construct control messages.

Obtained from:	Juniper Networks, Inc.
2014-08-03 02:24:52 +00:00
marcel
b37299ed78 MFC 264161: Handle the fact that the getlogin_basic() function can return
a 0 status with a NULL pointer for the login name (result).

Obtained from:	Juniper Networks, Inc.
2014-08-03 01:51:48 +00:00
marcel
b0acb5134f MFC 259910, 260023, 260028, 260600 & 260701:
o   Fix "kptdir is itself virtual" error, caused by having the kptdir in PBVM.
o   Allow building a cross libkvm for ia64.
o   Add support for virtual cores (aka minidumps).
o   We don't have to worry about page sizes when working on virtual cores.
o   Handle truncation of the size returned by _kvm_kvatop().
2014-08-02 22:25:24 +00:00
markj
7c889ea487 MFC r265276:
Fix a typo.
2014-07-29 22:29:31 +00:00
markj
cf4dd8790b MFC r268446:
Fix a typo.
2014-07-29 21:15:26 +00:00
des
fe6d937978 MFH (r266114, r266138): upgrade to latest ldns and unbound
MFH (r266139-r266143, r266145, r266149, r266150): fix props
MFH (r266179, r266180, r266193, r266238, r266777): misc cleanup
MFH (r266863): create and use /var/unbound/conf.d
MFH (r268839): import unblock-lan-zones patch from upstream
MFH (r268840): fix reverse lookups on private networks
MFH (r268883): avoid spamming source tree during build

PR:		190739 (for r268883)
2014-07-29 20:57:38 +00:00
pfg
26a3b70214 MFC r269016:
Fix mismatch.
2014-07-26 02:41:18 +00:00
ian
d599f4ba1e MFC r261530
Set the malloc alignment to 64 bytes on platforms that use the U-Boot API
  device drivers.  Recent versions of u-boot run with the MMU enabled, and
  require DMA-based I/O to be aligned to cache line boundaries.
2014-07-25 23:12:22 +00:00
pfg
414a4cb931 MFC r268985, r269001:
Avoid possible cast degradation.

Assign iov_len first, avoiding the cast to uio_resid
(int in stdio) from degrading the value.

Small cosmetical fix while here.
2014-07-25 03:24:00 +00:00
kevlo
0320ab1784 MFC r268643:
Document that listen(2) can fail with EDESTADDRREQ.
2014-07-24 05:59:32 +00:00
emaste
aa794b38fe MFC r262528: Update LLDB snapshot to upstream r202189
Highlights include (upstream revs in parens):

  - Improvements to the remote GDB protocol client
    (r196610, r197579, r197857, r200072, and others)

  - Bug fixes for big-endian targets
    (r196808)

  - Initial support for libdispatch (GCD) queues in the debuggee
    (r197190)

  - Add "step-avoid-libraries" setting
    (r199943)

  - IO subsystem improvements (including initial work on a curses gui)
    (r200263)

  - Support hardware watchpoints on FreeBSD
    (r201706)

  - Improved unwinding through hand-written assembly functions
    (r201839)

  - Handle DW_TAG_unspecified_parameters for variadic functions
    (r202061)

  - Fix Ctrl+C interrupting a running inferior process
    (r202086, r202154)

  - Various bug fixes for memory leaks, LLDB segfaults, the C++ demangler,
    ELF core files, DWARF debug info, and others.

Sponsored by:	DARPA, AFRL
2014-07-23 19:35:02 +00:00
emaste
68543b825e MFC r261799: Add bounds check for pteindex / pdeindex to amd64 kvm_minidump 2014-07-23 14:29:28 +00:00
pfg
797038915a MFC r268928:
Const-ify a character string.

Obtained from:	Apple Inc. (Libc 997.90.3)
2014-07-23 02:55:03 +00:00
jhb
ce450da430 MFC 266424,266476,266524,266573,266595,266626,266627,266633,266641,266642,
266708,266724,266934,266935,268521:
Emulation of the "ins" and "outs" instructions.

Various fixes for translating guest linear addresses to guest physical
addresses.
2014-07-22 04:39:16 +00:00
jhb
c1fe945ebd MFC 266125:
Implement a PCI interrupt router to route PCI legacy INTx interrupts to
the legacy 8259A PICs.
2014-07-22 03:14:37 +00:00
pfg
f5657a9f1c MFC r268644:
libc/stdlib: Minor cleanups to code originating in NetBSD

Mostly ANSIfication and typos.

Obtained from:	NetBSD
2014-07-21 22:47:59 +00:00
pfg
832f667130 MFC r268642:
libc/gen: small updates to code originating at OpenBSD

arc4random.c
- CVS rev. 1.22
Change arc4random_uniform() to calculate ``2**32 % upper_bound'' as
``-upper_bound % upper_bound''. Simplifies the code and makes it the
same on both ILP32 and LP64 architectures, and also slightly faster on
LP64 architectures by using a 32-bit remainder instead of a 64-bit
remainder.
- CVS rev. 1.23
Spacing

readpassphrase.c
-CVS rev. v 1.24
most obvious unsigned char casts for ctype

Obtained from:	OpenBSD
2014-07-21 22:37:33 +00:00
jhb
e6b48465b7 MFC 264353,264509,264768,264770,264825,264846,264988,265114,265165,265365,
265941,265951,266390,266550,266910:
Various bhyve fixes:
- Don't save host's return address in 'struct vmxctx'.
- Permit non-32-bit accesses to local APIC registers.
- Factor out common ioport handler code.
- Use calloc() in favor of malloc + memset.
- Change the vlapic timer frequency to be in the ballpark of contemporary
  hardware.
- Allow the guest to read the TSC via MSR 0x10.
- A VMCS is always inactive when it exits the vmx_run() loop.  Remove
  redundant code and the misleading comment that suggest otherwise.
- Ignore writes to microcode update MSR.  This MSR is accessed by RHEL7
  guest.
  Add KTR tracepoints to annotate wrmsr and rdmsr VM exits.
- Provide an alias for the userboot console and name it 'comconsole'.
- Use EV_ADD to create an mevent and EV_ENABLE to enable it.
- abort(3) the process in response to a VMEXIT_ABORT.
- Don't include the guest memory segments in the bhyve(8) process core dump.
- Make the vmx asm code dtrace-fbt-friendly.
- Allow vmx_getdesc() and vmx_setdesc() to be called for a vcpu that is in
  the VCPU_RUNNING state.
- Enable VMX in the IA32_FEATURE_CONTROL MSR if it not enabled and the MSR
  isn't locked.
2014-07-21 19:08:02 +00:00
jhb
888f6511e3 MFC 263780,264516,265062,265101,265203,265364:
Add an ioctl to suspend a virtual machine (VM_SUSPEND).

Add logic in the HLT exit handler to detect if the guest has put all vcpus
to sleep permanently by executing a HLT with interrupts disabled.

When this condition is detected the guest with be suspended with a reason of
VM_SUSPEND_HALT and the bhyve(8) process will exit.

This logic can be disabled via the tunable 'hw.vmm.halt_detection'.
2014-07-21 02:39:17 +00:00
bapt
d4cd64d84a MFC: r267376
Add a zlib pkg-config file (more and more ports requires it)

Approved by:	delphij
2014-07-20 00:32:22 +00:00
bapt
63350d40ce MFC: r267131, r267132, r267133, r268493, r268671
Use NULL instead of 0 (Patch by Sascha Wildner <saw at online.de> for Dragonfly)
Remove unnecessary semicolons (Patch by Sascha Wildner <saw at online.de> for Dragonfly)
Add support for arbitrary http requests [1]
Support EAGAIN in fetch_writev

Submitted by:	Alex Hornung <alex at alexhornung.com> [1]
Reviewed by:	des
2014-07-20 00:29:41 +00:00
bapt
6f718e3669 MFC: r263648, r264789, r266636
This brings:
- schema validation
- xpath-like interface for ucl objects

Adapt pkg(7) to the new libucl API
2014-07-19 23:44:57 +00:00
jhb
3da9c304ee MFC 259942,262274,263035,263054,263211,263744,264179,264324,264468,264631,
264648,264650,264651,266572,267558:
Flesh out the AT PIC and 8254 PIT emulations and move them into the kernel.
2014-07-19 22:06:46 +00:00
pfg
c62a7a5557 MFC r268569:
strfmon: reduce unnecessary snprintf.

No need for the snprintf/asprintf dance; use fixed width formats.

Obtained from:	NetBSD (CVS rev. 1.8)
2014-07-19 15:12:38 +00:00
pfg
30eedb40f8 MFC r268502:
Sync some (mostly cosmetical) changes from NetBSD

Makefile,v 1.37
tc1.c v 1.3
Rename TEST/test.c tc1.c

common.c,v 1.23
pass lint on _LP64.

emacs.c,v 1.22
pass lint on _LP64.

filecomplete.h,v 1.8
mv NetBSD ID back from 1.9 as we don't
have the widecharacter support.

prompt.c,v 1.14
prompt.h,v 1.9
term.h,v 1.20
read.h,v 1.6
Update NetBSD version strings

sys.h,v 1.12
Misc sun stuff.

tty.c 1.31
handle EINTR in the termios operations
Allow a single process to control multiple ttys (for pthreads using _REENTRANT)
using multiple EditLine objects.
pass lint on _LP64.
Don't depend on side effects inside an assert

Obtained from:	NetBSD
2014-07-17 02:14:25 +00:00
dim
082dc1af3f MFC r268463:
In libproc, avoid calling __cxa_demangle(), and thus depending on either
libcxxrt or libsupc++, if WITHOUT_CXX is defined. [1]

Noticed by:	sbruno

[1] However, on stable/10 this is more accurately described by
WITHOUT_GNUCXX, so I've changed the test to that instead.
2014-07-16 21:04:31 +00:00
kib
369fe04016 MFC r268467:
Implement sysconf(_SC_GETGR_R_SIZE_MAX) and sysconf(_SC_GETPW_R_SIZE_MAX).
2014-07-16 08:52:44 +00:00
wblock
f454bd908f MFC r267618:
Fix syntax error.
2014-07-15 22:44:10 +00:00
pfg
8bbbab8fb3 MFC r268272:
minor perf enhancement for UTF-8

Reduce some duplicate code.

Reference:
https://www.illumos.org/issues/628

Obtained from:	Illumos
2014-07-12 17:39:13 +00:00
delphij
a8fc83ae7c MFC r267897: MFV r267843:
Update file/libmagic to 5.19.
2014-07-11 00:00:00 +00:00
kib
8674b3c2aa MFC r268212:
Note that most errors are possible for all syscalls from utimes(2)
family.  Minor wording corrections.
2014-07-10 09:09:37 +00:00
pluknet
48775398f2 MFC r268393: [mdoc] Fix previous. 2014-07-08 13:16:03 +00:00
ache
51242982da MFC 267756:
Merge intermediate OpenBSD v1.25 changes (almost identical to ours)
to reduce diff and bump OpenBSD patch level to v1.26.
2014-07-07 05:31:50 +00:00
pfg
19e2403cf6 MFC r267745, r268268:
getopt(3): recognize option:: as GNU extension for "optional options".

Also ANSIfy a function declaration.

While here update the OpenBSD patch level in getopt_long.c as we
already have the corresponding change.

Obtained from:	NetBSD
MFC after:	2 weeks
2014-07-07 02:47:41 +00:00
pluknet
0d8378f52b MFC r267909: Document EINVAL.
PR:		191382
2014-07-03 17:35:01 +00:00
ume
e6568c7ce0 MFC r267912, r267915:
- Exclude loopback address rather than loopback interface.
- style(9)

Spotted by:	melifaro
2014-07-03 15:56:30 +00:00
ume
1af4339c2a MFC r267800:
Exclude IPv4 address from doing longest match.
It prevented DNS based load balancing.
2014-06-30 16:53:12 +00:00
delphij
ab99acf70d MFC r267378:
Fix path for zlib examples, this have no runtime effect and was
overlooked when I was doing zlib update.
2014-06-30 16:31:28 +00:00
pfg
99efb6c39e MFC r267627:
strptime: add support for %t and %n

Posix strptime() requires support for %t and %n, which were added
to the illumos port.  Curiously we were skipping white spaces by
default in most other cases making %t meaningless.

We now skip spaces in the case of the %e specifier as strftime(3)
explicitly adds a space for the single digit case.

Reference:
http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html

PR:		173421
Obtained from:	Illumos (Rev. a11c1571b6942161b0186d0588609448066892c2)
2014-06-30 14:52:40 +00:00
pluknet
b39fb82c62 MFC r261140:
Add MLINK for fdclosedir.3 to directory.3 and sort fdopendir(3) entry.
2014-06-27 09:11:24 +00:00
kib
15d33955d2 MFC r267630:
Add MAP_EXCL flag for mmap(2).
2014-06-26 08:30:08 +00:00
kib
b371ec04aa MFC r267629:
Tidy up code of the wrapper.
2014-06-26 08:27:01 +00:00
ume
ec8b74659a MFC r267616, 267640:
Retooling addrconfig() to exclude addresses on loopback interfaces
when looking for configured addresses.
This change is based upon the code from the submitter, and made
following changes:
- Exclude addresses assigned on interfaces which are down, like NetBSD
  does.
- Exclude addresses assigned on interfaces which are ifdisabled.

Use SOCK_CLOEXEC.

PR:		190824
Submitted by:	Justin McOmie
2014-06-25 17:10:26 +00:00
pfg
f1ff231dba MFC r267601:
stdtime: style(9) fixes.

Obtained from:	illumos
2014-06-23 15:03:51 +00:00
pfg
fac80b6943 MFC r267544:
Update license to strptime(3) implementation.

Our strptime(3) implementation was the base for the illumos
implementation and after contacting the author, Kevin Rudy
stated the code is under a 2-Clause BSD License [1]

After reviewing our local changes to the file in question,
the FreeBSD Foundation has agreed that their contributions
to this file are not required to carry clause 3 or 4 so
the file can be relicensed as in Illumos [2].

References:

[1] https://www.illumos.org/issues/357
[2] Illumos Revision:		13222:02526851ba75

Approved:	core (jhb)
Approved:	FreeBSD Foundation (emaste)
2014-06-20 15:43:58 +00:00