]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
4 years agoDon't display trailing '.' in _dcvt
Keith Packard [Wed, 18 Dec 2019 06:00:49 +0000 (22:00 -0800)]
Don't display trailing '.' in _dcvt

In the two helper functions that _dcvt calls for 'f' and 'e' mode, if
there are no digits to display after the decimal point, don't add one.

Signed-off-by: Keith Packard <keithp@keithp.com>
4 years agoFix gcvt to always show 'ndigits' of precision
Keith Packard [Wed, 18 Dec 2019 16:49:06 +0000 (08:49 -0800)]
Fix gcvt to always show 'ndigits' of precision

Leading zeros after the decimal point should not count
towards the 'ndigits' limit.

This makes gcvt match glibc and the posix gcvt man page.

Signed-off-by: Keith Packard <keithp@keithp.com>
4 years agoFix fcvt to only show 'ndigit' past decimal
Keith Packard [Wed, 18 Dec 2019 16:49:05 +0000 (08:49 -0800)]
Fix fcvt to only show 'ndigit' past decimal

Even if the number is really small and this means showing *no* digits.
This makes newlib match glibc, and the fcvt posix man page.

Signed-off-by: Keith Packard <keithp@keithp.com>
4 years agoCygwin: pty: Fix a bug regarding ESC[?3h and ESC[?3l handling.
Takashi Yano [Wed, 18 Dec 2019 16:07:33 +0000 (01:07 +0900)]
Cygwin: pty: Fix a bug regarding ESC[?3h and ESC[?3l handling.

- Midnight commander (mc) does not work after the commit
  1626569222066ee601f6c41b29efcc95202674b7 as reported in
  https://www.cygwin.com/ml/cygwin/2019-12/msg00173.html.
  This patch fixes the issue.

4 years agodoc: Untabify python scripts used for making man pages
Jon Turney [Mon, 16 Dec 2019 19:28:59 +0000 (19:28 +0000)]
doc: Untabify python scripts used for making man pages

These scripts fail with a TabError exception if 'python' is python3, as
mixing tabs and spaces in indentation is forbidden in python3.

4 years agoCygwin: Bump DLL version to 3.1.2
Corinna Vinschen [Wed, 18 Dec 2019 09:48:10 +0000 (10:48 +0100)]
Cygwin: Bump DLL version to 3.1.2

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoCygwin: add 3.1.1 release text belatedly
Corinna Vinschen [Wed, 18 Dec 2019 09:47:43 +0000 (10:47 +0100)]
Cygwin: add 3.1.1 release text belatedly

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoCygwin: autoload: Add missing GetProcessGroupAffinity/GetThreadGroupAffinity cygwin-3_1_1-release
Corinna Vinschen [Tue, 17 Dec 2019 15:44:54 +0000 (16:44 +0100)]
Cygwin: autoload: Add missing GetProcessGroupAffinity/GetThreadGroupAffinity

Both functions were introduce with Windows 7 only, so we need to
autoload them for the sake of Vista/2008.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoSet __IEEE_LITTLE_ENDIAN for _XTENSA_EL__ (ESP32)
Keith Packard [Mon, 16 Dec 2019 21:56:11 +0000 (13:56 -0800)]
Set __IEEE_LITTLE_ENDIAN for _XTENSA_EL__ (ESP32)

Signed-off-by: Keith Packard <keithp@keithp.com>
4 years agoReturn EINVAL for illegal base in strtol
Keith Packard [Mon, 16 Dec 2019 21:55:30 +0000 (13:55 -0800)]
Return EINVAL for illegal base in strtol

Signed-off-by: Keith Packard <keithp@keithp.com>
4 years agoCygwin: Bump DLL version to 3.1.1
Corinna Vinschen [Mon, 16 Dec 2019 20:09:50 +0000 (21:09 +0100)]
Cygwin: Bump DLL version to 3.1.1

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoCygwin: add strtold fix to release message cygwin-3_1_0-release
Corinna Vinschen [Mon, 16 Dec 2019 15:39:17 +0000 (16:39 +0100)]
Cygwin: add strtold fix to release message

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agostrtold: set errno to ERANGE on underflow per POSIX
Bruno Haible [Mon, 16 Dec 2019 14:11:47 +0000 (15:11 +0100)]
strtold: set errno to ERANGE on underflow per POSIX

https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtod.html

4 years agoCygwin: ilogbl: Make sure to return FP_ILGB0 on zero input
Corinna Vinschen [Mon, 16 Dec 2019 09:50:17 +0000 (10:50 +0100)]
Cygwin: ilogbl: Make sure to return FP_ILGB0 on zero input

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoMSP430: Support new msp430-elfbare target
Jozef Lawrynowicz [Mon, 25 Nov 2019 21:17:41 +0000 (21:17 +0000)]
MSP430: Support new msp430-elfbare target

Update the target triplet glob used when configuring for msp430 to
support a new msp430-elfbare target being added to gcc.

4 years agoImplement the unlink system call for the moxie simulator.
Anthony Green [Sat, 14 Dec 2019 10:27:38 +0000 (05:27 -0500)]
Implement the unlink system call for the moxie simulator.

Corresponding support for this was just added to the gdb moxie simulator.
Unlink support is required by the GCC testsuite.

4 years agoFix setjmp/longjmp for the moxie port.
Anthony Green [Fri, 13 Dec 2019 18:08:06 +0000 (13:08 -0500)]
Fix setjmp/longjmp for the moxie port.

These functions needs to save and restore the stack frame, because
that's where the return address is stored.

4 years agoCygwin: document the last bugfix
Ken Brown [Tue, 10 Dec 2019 13:45:17 +0000 (08:45 -0500)]
Cygwin: document the last bugfix

4 years agoCygwin: symlink_info::check: avoid assertion failure
Ken Brown [Mon, 9 Dec 2019 12:27:18 +0000 (07:27 -0500)]
Cygwin: symlink_info::check: avoid assertion failure

On certain error conditions there is a code snippet that checks
whether the last component of the path has a trailing dot or space or
a leading space.  Skip this check if the last component is empty,
i.e., if the path ends with a backslash.  This avoids an assertion
failure if the trailing backslash is the only backslash in the path,
as is the case for a DOS drive 'X:\'.

Addresses: https://cygwin.com/ml/cygwin/2019-12/msg00016.html

4 years agolibm: switch sf_log1p from double error routines to float
Keith Packard [Fri, 29 Nov 2019 19:23:20 +0000 (11:23 -0800)]
libm: switch sf_log1p from double error routines to float

sf_log1p was using __math_divzero and __math_invalid, which
drag in a pile of double-precision code. Switch to using the
single-precision variants. This also required making those
available in __OBSOLETE_MATH mode.

Signed-off-by: Keith Packard <keithp@keithp.com>
4 years agoCygwin: /proc/[PID]/stat to pull process priority correctly
Anton Lavrentiev via cygwin-patches [Sun, 1 Dec 2019 03:58:14 +0000 (22:58 -0500)]
Cygwin: /proc/[PID]/stat to pull process priority correctly

Fix to prior commit 5fa9a0e7 to address https://cygwin.com/ml/cygwin/2019-08/msg00082.html

4 years agonewlib/libc/include/sys/features.h: update __STDC_ISO_10646__
Brian Inglis [Tue, 26 Nov 2019 15:34:42 +0000 (08:34 -0700)]
newlib/libc/include/sys/features.h: update __STDC_ISO_10646__

newlib wide char conversion functions were updated to
Unicode 11 on 2019-01-12
update standard symbol __STDC_ISO_10646__ to
Unicode 11 release date 2018-06-05 for Cygwin

4 years agoCygwin: pty: Convert CamelCase names to snake_case names.
Takashi Yano [Fri, 15 Nov 2019 23:27:24 +0000 (08:27 +0900)]
Cygwin: pty: Convert CamelCase names to snake_case names.

4 years agonewlib: fix fseek optimization with SEEK_CUR
Bastien Bouclet [Sat, 9 Nov 2019 16:28:04 +0000 (17:28 +0100)]
newlib: fix fseek optimization with SEEK_CUR

The call to fflush was invalidating the read buffer, preventing relative
seeks to positions that would have been inside the read buffer from
being optimized. The call to srefill would then re-read mostly the same
data that was initially in the read buffer.

4 years agoCygwin: pty: Trigger redraw screen if ESC[?3h or ESC[?3l is sent.
Takashi Yano [Wed, 13 Nov 2019 10:49:29 +0000 (19:49 +0900)]
Cygwin: pty: Trigger redraw screen if ESC[?3h or ESC[?3l is sent.

- Pseudo console clears console screen buffer if ESC[?3h or ESC[?3l
  is sent. However, xterm/vt100 does not clear screen. This cause
  mismatch between real screen and console screen buffer. Therefore,
  this patch triggers redraw screen in that situation so that the
  synchronization is done on the next execution of native app.
  This solves the problem reported in:
  https://www.cygwin.com/ml/cygwin-patches/2019-q4/msg00116.html

4 years agoCygwin: console: Revise the code checking if the console is legacy.
Takashi Yano [Tue, 12 Nov 2019 18:04:59 +0000 (03:04 +0900)]
Cygwin: console: Revise the code checking if the console is legacy.

- Accessing shared_console_info before initializing causes access
  violation in checking if the console is legacy mode. This patch
  fixes this issue. This solves the problem reported in:
  https://www.cygwin.com/ml/cygwin-patches/2019-q4/msg00099.html

4 years agoCygwin: pty: Use redraw screen instead of clear screen.
Takashi Yano [Tue, 12 Nov 2019 13:00:23 +0000 (22:00 +0900)]
Cygwin: pty: Use redraw screen instead of clear screen.

- Previously, pty cleared screen at startup for synchronization
  between the real screen and console screen buffer for pseudo
  console. With this patch, instead of clearing screen, the screen
  is redrawn when the first native program is executed after pty
  is created. In other words, synchronization is deferred until
  the native app is executed. Moreover, this realizes excluding
  $TERM dependent code.

4 years agoregtool: allow /proc/registry{,32,64}/ registry path prefix
Brian Inglis [Mon, 11 Nov 2019 17:29:00 +0000 (10:29 -0700)]
regtool: allow /proc/registry{,32,64}/ registry path prefix

The user can supply the registry path prefix /proc/registry{,32,64}/ to
use path completion.

4 years agoStash reent marker in upper bits of s1 on AMD GCN
Kwok Cheung Yeung [Thu, 7 Nov 2019 22:46:41 +0000 (14:46 -0800)]
Stash reent marker in upper bits of s1 on AMD GCN

s[0:3] contain a descriptor used to set up the initial value of the
stack, but only the lower 48 bits of s[0:1] are currently used.
The reent marker is currently set in s3, but by stashing it in the
upper 16 bits of s[0:1] instead, s3 can be freed up for other purposes.

4 years agoCygwin: Doc change to note stackdump limit patch
Mark Geisert [Fri, 8 Nov 2019 00:14:05 +0000 (16:14 -0800)]
Cygwin: Doc change to note stackdump limit patch

4 years agoCygwin: Raise dumpstack frame limit to 32
Mark Geisert [Fri, 8 Nov 2019 00:13:34 +0000 (16:13 -0800)]
Cygwin: Raise dumpstack frame limit to 32

Create a #define for the limit and raise it from 16 to 32.

4 years agoCygwin: console, pty: Prevent error in legacy console mode.
Takashi Yano [Wed, 6 Nov 2019 16:29:29 +0000 (01:29 +0900)]
Cygwin: console, pty: Prevent error in legacy console mode.

4 years agoCygwin: pty: Change how to determine if running as service or not.
Takashi Yano [Wed, 6 Nov 2019 12:08:43 +0000 (21:08 +0900)]
Cygwin: pty: Change how to determine if running as service or not.

4 years agoCygwin: document console helper patch
Corinna Vinschen [Tue, 5 Nov 2019 10:57:24 +0000 (11:57 +0100)]
Cygwin: document console helper patch

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoCygwin: fix quoting when starting invisible console process
Corinna Vinschen [Tue, 5 Nov 2019 10:29:02 +0000 (11:29 +0100)]
Cygwin: fix quoting when starting invisible console process

fhandler_console::create_invisible_console_workaround() does not use the
lpApplicationName parameter and neglects to quote its command name on
lpCommandLine in the call to CreateProcessW.

Given CreateProcessW's brain-dead method to evaluate the application
path given on the command line, this opens up a security problem if
Cygwin is installed into a path with spaces in it.

Fix this by using the lpApplicationName parameter and quoting of the
application path in the lpCommandLine parameter (used as argv[0] in
the called console helper.

For extended paranoia, make the argument string array big enough to
fit full 64 bit pointer values into it.  Handles usually only use
the lower 32 bit, but better safe than sorry.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoCygwin: devices: drop MAX_CONSOLES and fix FH_CONS_MAX
Corinna Vinschen [Mon, 4 Nov 2019 09:34:14 +0000 (10:34 +0100)]
Cygwin: devices: drop MAX_CONSOLES and fix FH_CONS_MAX

FH_CONS_MAX should refelect the fact that we allow 128 consoles, even if
it's unused.

Suggested-by: Achim Gratz <Stromeko@nexgo.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoMove timeval macros to <sys/time.h>
Sebastian Huber [Tue, 24 Sep 2019 06:34:35 +0000 (08:34 +0200)]
Move timeval macros to <sys/time.h>

In FreeBSD, NetBSD, and OpenBSD these macros are defined in
<sys/time.h>.

4 years agoSynchronize <sys/time.h> with FreeBSD
Sebastian Huber [Mon, 23 Sep 2019 10:02:11 +0000 (12:02 +0200)]
Synchronize <sys/time.h> with FreeBSD

This change is based on the FreeBSD commit:

Author: asomers <asomers@FreeBSD.org>
Date:   Mon Jul 30 15:46:40 2018 +0000

    Make timespecadd(3) and friends public

    The timespecadd(3) family of macros were imported from NetBSD back in
    r35029. However, they were initially guarded by #ifdef _KERNEL. In the
    meantime, we have grown at least 28 syscalls that use timespecs in some
    way, leading many programs both inside and outside of the base system to
    redefine those macros. It's better just to make the definitions public.

    Our kernel currently defines two-argument versions of timespecadd and
    timespecsub.  NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define
    three-argument versions.  Solaris also defines a three-argument version, but
    only in its kernel.  This revision changes our definition to match the
    common three-argument version.

    Bump _FreeBSD_version due to the breaking KPI change.

    Discussed with: cem, jilles, ian, bde
    Differential Revision:  https://reviews.freebsd.org/D14725

4 years agoSynchronize <sys/_timespec.h> with FreeBSD
Sebastian Huber [Tue, 24 Sep 2019 06:32:47 +0000 (08:32 +0200)]
Synchronize <sys/_timespec.h> with FreeBSD

4 years agoFix sbttons for values > 2s
imp [Sat, 13 Apr 2019 04:46:35 +0000 (04:46 +0000)]
Fix sbttons for values > 2s

Add test against negative times. Add code to cope with larger values
properly.

Discussed with: bde@ (quite some time ago, for an earlier version)

4 years agoCygwin: fix process parent/child relationship after execve
Corinna Vinschen [Sat, 2 Nov 2019 11:49:15 +0000 (12:49 +0100)]
Cygwin: fix process parent/child relationship after execve

Commit 5a0f2c00aa "Cygwin: fork/exec: fix child process permissions"
removed the PROCESS_DUP_HANDLE handle permission of the parent process
handle in the child to avoid a security problem.

It turned out that this broke the following scenario: If a process forks
and then the parent execs, the child loses the ability to register the
parent's death.  To wit, after the parent died the child process does
not set its own PPID to 1 anymore.

The current exec mechanism copies required handle values (handles to
keep contact to the child processes) into the child_info for the
about-to-be-exec'ed process.  The exec'ed process is supposed to
duplicate these handles.  This fails, given that we don't allow the
exec'ed process PROCESS_DUP_HANDLE access to the exec'ing process since
commit 5a0f2c00aa.

The fix is to avoid the DuplicateHandle calls in the exec'ed process.

This patch sets the affected handles to "inheritable" in the exec'ing
process at exec time.  The exec'ed process just copies the handle values
and resets handle inheritance to "non-inheritable".  The exec'ing
process doesn't have to reset handle inheritance, it exits after setting
up the exec'ed process anyway.

Testcase: $ ssh-agent /bin/sleep 3

ssh-agent forks and the parent exec's sleep.  After sleep exits, `ps'
should show ssh-agent to have PPID 1, and eventually ssh-agent exits.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
4 years agoFix libgloss being built for disabled multilibs
Jozef Lawrynowicz [Wed, 30 Oct 2019 14:35:21 +0000 (14:35 +0000)]
Fix libgloss being built for disabled multilibs

Target libraries are considered to be built for GCC's "host", not GCC's
"target".  The "host" variable must be set by configure scripts using
"config-ml.in" to determine multilib support, otherwise disabled
multilibs (specified as a configure argument with --disable-<multilib>)
will still be built for the subdirectories those configure scripts
reside in.

4 years agoCygwin: getpriority() consistent with process priority
Anton Lavrentiev via cygwin-patches [Wed, 30 Oct 2019 15:47:25 +0000 (11:47 -0400)]
Cygwin: getpriority() consistent with process priority

https://cygwin.com/ml/cygwin/2019-08/msg00122.html

4 years agoAdd PRU license to COPYING.NEWLIB and COPYING.LIBGLOSS
Jeff Johnston [Thu, 31 Oct 2019 19:09:07 +0000 (15:09 -0400)]
Add PRU license to COPYING.NEWLIB and COPYING.LIBGLOSS

4 years agoPRU: Align libmath to PRU ABI
Dimitar Dimitrov [Sun, 11 Mar 2018 20:15:05 +0000 (22:15 +0200)]
PRU: Align libmath to PRU ABI

The TI proprietary toolchain uses nonstandard names for some math
library functions. In order to achieve ABI compatibility between
GNU and TI toolchains, add support for the TI function names.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
4 years agoFix some generated files
Jeff Johnston [Thu, 31 Oct 2019 18:52:04 +0000 (14:52 -0400)]
Fix some generated files

4 years agoInitial PRU port for libgloss and newlib
Dimitar Dimitrov [Sun, 11 Mar 2018 20:23:26 +0000 (22:23 +0200)]
Initial PRU port for libgloss and newlib

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
4 years agoMSP430: Add missing build rule for unlink() to libgloss Makefile
Jozef Lawrynowicz [Thu, 24 Oct 2019 15:12:24 +0000 (16:12 +0100)]
MSP430: Add missing build rule for unlink() to libgloss Makefile

4 years agoCygwin: Provide more COM devices
Achim Gratz [Tue, 22 Oct 2019 17:52:40 +0000 (19:52 +0200)]
Cygwin: Provide more COM devices

Provide for 128 COM devices since Windows likes to create lots of these
over time (one per identifiable device and USB port).

4 years agoCygwin: spawnvp, spawnvpe: fail if executable is not in $PATH
Ken Brown [Wed, 9 Oct 2019 20:06:02 +0000 (20:06 +0000)]
Cygwin: spawnvp, spawnvpe: fail if executable is not in $PATH

Call find_exec with the FE_NNF flag to enforce a NULL return when the
executable isn't found in $PATH.  Convert NULL to "".  This aligns
spawnvp and spawnvpe with execvp and execvpe.

4 years agoCygwin: pty: Change the timing of clear screen.
Takashi Yano [Wed, 16 Oct 2019 12:34:09 +0000 (21:34 +0900)]
Cygwin: pty: Change the timing of clear screen.

4 years agoCygwin: pty: Avoid detach console in the process running as service.
Takashi Yano [Wed, 16 Oct 2019 12:34:08 +0000 (21:34 +0900)]
Cygwin: pty: Avoid detach console in the process running as service.

4 years agoriscv/sys/fenv.h: Add missing extern for fe_dfl_env_p
Joel Sherrill [Wed, 9 Oct 2019 16:00:45 +0000 (11:00 -0500)]
riscv/sys/fenv.h: Add missing extern for fe_dfl_env_p

4 years agoAdd patch from Joel Sherrill for i386 and x86_64 fenv support
Jeff Johnston [Tue, 8 Oct 2019 20:57:37 +0000 (16:57 -0400)]
Add patch from Joel Sherrill for i386 and x86_64 fenv support

4 years agoCygwin: mkdir and rmdir: treat drive names specially
Ken Brown [Fri, 27 Sep 2019 18:00:52 +0000 (14:00 -0400)]
Cygwin: mkdir and rmdir: treat drive names specially

If the directory name has the form 'x:' followed by one or more
slashes or backslashes, and if there's at least one backslash, assume
that the user is referring to 'x:\', the root directory of drive x,
and don't strip the backslash.

Previously all trailing slashes and backslashes were stripped, and the
name was treated as a relative file name containing a literal colon.

Addresses https://cygwin.com/ml/cygwin/2019-08/msg00334.html.

4 years agoCygwin: document recent changes to format_proc_cpuinfo
Ken Brown [Mon, 7 Oct 2019 20:06:28 +0000 (16:06 -0400)]
Cygwin: document recent changes to format_proc_cpuinfo

4 years agofhandler_proc.cc(format_proc_cpuinfo): or model extension bits
Brian Inglis [Mon, 7 Oct 2019 16:23:07 +0000 (10:23 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): or model extension bits

or model extension bits into model high bits instead of adding
arithmetically like family extension.

4 years agofhandler_proc.cc(format_proc_cpuinfo): comment flags not reported
Brian Inglis [Mon, 7 Oct 2019 16:23:06 +0000 (10:23 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): comment flags not reported

Comment out flags not reported by Linux in cpuinfo, although some
flags may not be used at all by Linux.

4 years agofhandler_proc.cc(format_proc_cpuinfo): add feature flags
Brian Inglis [Mon, 7 Oct 2019 16:23:05 +0000 (10:23 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): add feature flags

Add 99 feature flags including AVX512 extensions, AES, SHA with 20
cpuid calls.

4 years agofhandler_proc.cc(format_proc_cpuinfo): use feature test print macro
Brian Inglis [Mon, 7 Oct 2019 16:23:04 +0000 (10:23 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): use feature test print macro

Add feature test print macro that makes feature, bit, and flag text
comparison and checking easier.  Handle as common former Intel only
feature flags also supported on AMD.  Change order and some flag names
to agree with current Linux.

4 years agofhandler_proc.cc(format_proc_cpuinfo): add microcode
Brian Inglis [Mon, 7 Oct 2019 16:23:03 +0000 (10:23 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): add microcode

Add microcode from Windows registry Update Revision REG_BINARY.

4 years agofhandler_proc.cc(format_proc_cpuinfo): add bogomips
Brian Inglis [Mon, 7 Oct 2019 16:23:02 +0000 (10:23 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): add bogomips

Add bogomips which has been cpu MHz*2 since Pentium MMX.

4 years agofhandler_proc.cc(format_proc_cpuinfo): round cpu MHz
Brian Inglis [Mon, 7 Oct 2019 16:23:01 +0000 (10:23 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): round cpu MHz

Round cpu MHz to correct Windows and match Linux cpuinfo.

4 years agofhandler_proc.cc(format_proc_cpuinfo): fix AMD physical cores count
Brian Inglis [Mon, 7 Oct 2019 16:23:00 +0000 (10:23 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): fix AMD physical cores count

Fix AMD physical cores count documented as core_info low byte + 1.

4 years agofhandler_proc.cc(format_proc_cpuinfo): fix cpuid level count
Brian Inglis [Mon, 7 Oct 2019 16:22:59 +0000 (10:22 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): fix cpuid level count

Fix cpuid level count as number of non-zero leafs excluding sub-leafs.

4 years agofhandler_proc.cc(format_proc_cpuinfo): fix cache size
Brian Inglis [Mon, 7 Oct 2019 16:22:58 +0000 (10:22 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): fix cache size

Fix cache size return code handling and make AMD/Intel code common.

4 years agoAllow verifying _REENT_CHECK macros memory allocation
Jeff Johnston [Mon, 7 Oct 2019 19:29:33 +0000 (15:29 -0400)]
Allow verifying _REENT_CHECK macros memory allocation

- change sys/reent.h to replace _REENT_CHECK_DEBUG with
  _REENT_CHECK_VERIFY which when set asserts that any memory
  allocated is non-NULL and calls __assert_func directly
- add new --enable-newlib-reent-check-verify configure option
- add support for configure.host to specify default for
  newlib_reent_check_verify
- add _REENT_CHECK_VERIFY macro support to acconfig.h and newlib.hin

4 years agoOptimize epilogue sequence for architectures with POP interworking.
Christos Gentsos [Mon, 7 Oct 2019 13:38:14 +0000 (14:38 +0100)]
Optimize epilogue sequence for architectures with POP interworking.

ARMv5 and above supports arm/thumb interworking using POP, so we can
improve the exit sequence in this case.

4 years agoPrevent NULL ptr accesses due to Balloc out of memory
Jeff Johnston [Fri, 4 Oct 2019 21:01:03 +0000 (17:01 -0400)]
Prevent NULL ptr accesses due to Balloc out of memory

- add new eBalloc macro to mprec.h which calls Balloc and
  aborts if Balloc fails due to out of memory
- change mprec.c functions that use Balloc without checking to use eBalloc instead
- fix dtoa.c to use eBalloc

4 years agoCygwin: Fix signal handling issue introduced by PTY related change.
Takashi Yano [Thu, 3 Oct 2019 10:43:37 +0000 (19:43 +0900)]
Cygwin: Fix signal handling issue introduced by PTY related change.

- After commit 41864091014b63b0cb72ae98281fa53349b6ef77, there is a
  regression in signal handling reported in
  https://www.cygwin.com/ml/cygwin/2019-10/msg00010.html. This patch
  fixes the issue.

4 years agoDocument the last bug fix
Ken Brown [Fri, 27 Sep 2019 17:36:45 +0000 (13:36 -0400)]
Document the last bug fix

4 years agoCygwin: normalize_win32_path: improve error checking
Ken Brown [Wed, 25 Sep 2019 18:18:18 +0000 (14:18 -0400)]
Cygwin: normalize_win32_path: improve error checking

If the source path starts with the Win32 long path prefix '\\?\' or
the NT object directory prefix '\??\', require the prefix to be
followed by 'UNC\' or '<drive letter>:\'.  Otherwise return EINVAL.

This fixes the assertion failure in symlink_info::check that was
reported here:

  https://cygwin.com/ml/cygwin/2019-09/msg00228.html

That assertion failure was caused by normalize_win32_path returning a
path with no backslashes when the source path was '\\?\DRIVE'.

4 years agoCygwin: pty: Fix PTY so that cygwin setup shows help with -h option.
Takashi Yano [Thu, 26 Sep 2019 10:52:46 +0000 (19:52 +0900)]
Cygwin: pty: Fix PTY so that cygwin setup shows help with -h option.

- After commit 169d65a5774acc76ce3f3feeedcbae7405aa9b57, cygwin
  setup fails to show help message when -h option is specified, as
  reported in https://cygwin.com/ml/cygwin/2019-09/msg00248.html.
  This patch fixes the problem.

4 years agoAdd SIOCGIFDOWNREASON.
kib [Tue, 17 Sep 2019 18:49:13 +0000 (18:49 +0000)]
Add SIOCGIFDOWNREASON.

The ioctl(2) is intended to provide more details about the cause of
the down for the link.

Eventually we might define a comprehensive list of codes for the
situations.  But interface also allows the driver to provide free-form
null-terminated ASCII string to provide arbitrary non-formalized
information.  Sample implementation exists for mlx5(4), where the
string is fetched from firmware controlling the port.

Reviewed by: hselasky, rrs
Sponsored by: Mellanox Technologies
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D21527

4 years agoAdd kernel-side support for in-kernel TLS.
jhb [Tue, 27 Aug 2019 00:01:56 +0000 (00:01 +0000)]
Add kernel-side support for in-kernel TLS.

KTLS adds support for in-kernel framing and encryption of Transport
Layer Security (1.0-1.2) data on TCP sockets.  KTLS only supports
offload of TLS for transmitted data.  Key negotation must still be
performed in userland.  Once completed, transmit session keys for a
connection are provided to the kernel via a new TCP_TXTLS_ENABLE
socket option.  All subsequent data transmitted on the socket is
placed into TLS frames and encrypted using the supplied keys.

Any data written to a KTLS-enabled socket via write(2), aio_write(2),
or sendfile(2) is assumed to be application data and is encoded in TLS
frames with an application data type.  Individual records can be sent
with a custom type (e.g. handshake messages) via sendmsg(2) with a new
control message (TLS_SET_RECORD_TYPE) specifying the record type.

At present, rekeying is not supported though the in-kernel framework
should support rekeying.

KTLS makes use of the recently added unmapped mbufs to store TLS
frames in the socket buffer.  Each TLS frame is described by a single
ext_pgs mbuf.  The ext_pgs structure contains the header of the TLS
record (and trailer for encrypted records) as well as references to
the associated TLS session.

KTLS supports two primary methods of encrypting TLS frames: software
TLS and ifnet TLS.

Software TLS marks mbufs holding socket data as not ready via
M_NOTREADY similar to sendfile(2) when TLS framing information is
added to an unmapped mbuf in ktls_frame().  ktls_enqueue() is then
called to schedule TLS frames for encryption.  In the case of
sendfile_iodone() calls ktls_enqueue() instead of pru_ready() leaving
the mbufs marked M_NOTREADY until encryption is completed.  For other
writes (vn_sendfile when pages are available, write(2), etc.), the
PRUS_NOTREADY is set when invoking pru_send() along with invoking
ktls_enqueue().

A pool of worker threads (the "KTLS" kernel process) encrypts TLS
frames queued via ktls_enqueue().  Each TLS frame is temporarily
mapped using the direct map and passed to a software encryption
backend to perform the actual encryption.

(Note: The use of PHYS_TO_DMAP could be replaced with sf_bufs if
someone wished to make this work on architectures without a direct
map.)

KTLS supports pluggable software encryption backends.  Internally,
Netflix uses proprietary pure-software backends.  This commit includes
a simple backend in a new ktls_ocf.ko module that uses the kernel's
OpenCrypto framework to provide AES-GCM encryption of TLS frames.  As
a result, software TLS is now a bit of a misnomer as it can make use
of hardware crypto accelerators.

Once software encryption has finished, the TLS frame mbufs are marked
ready via pru_ready().  At this point, the encrypted data appears as
regular payload to the TCP stack stored in unmapped mbufs.

ifnet TLS permits a NIC to offload the TLS encryption and TCP
segmentation.  In this mode, a new send tag type (IF_SND_TAG_TYPE_TLS)
is allocated on the interface a socket is routed over and associated
with a TLS session.  TLS records for a TLS session using ifnet TLS are
not marked M_NOTREADY but are passed down the stack unencrypted.  The
ip_output_send() and ip6_output_send() helper functions that apply
send tags to outbound IP packets verify that the send tag of the TLS
record matches the outbound interface.  If so, the packet is tagged
with the TLS send tag and sent to the interface.  The NIC device
driver must recognize packets with the TLS send tag and schedule them
for TLS encryption and TCP segmentation.  If the the outbound
interface does not match the interface in the TLS send tag, the packet
is dropped.  In addition, a task is scheduled to refresh the TLS send
tag for the TLS session.  If a new TLS send tag cannot be allocated,
the connection is dropped.  If a new TLS send tag is allocated,
however, subsequent packets will be tagged with the correct TLS send
tag.  (This latter case has been tested by configuring both ports of a
Chelsio T6 in a lagg and failing over from one port to another.  As
the connections migrated to the new port, new TLS send tags were
allocated for the new port and connections resumed without being
dropped.)

ifnet TLS can be enabled and disabled on supported network interfaces
via new '[-]txtls[46]' options to ifconfig(8).  ifnet TLS is supported
across both vlan devices and lagg interfaces using failover, lacp with
flowid enabled, or lacp with flowid enabled.

Applications may request the current KTLS mode of a connection via a
new TCP_TXTLS_MODE socket option.  They can also use this socket
option to toggle between software and ifnet TLS modes.

In addition, a testing tool is available in tools/tools/switch_tls.
This is modeled on tcpdrop and uses similar syntax.  However, instead
of dropping connections, -s is used to force KTLS connections to
switch to software TLS and -i is used to switch to ifnet TLS.

Various sysctls and counters are available under the kern.ipc.tls
sysctl node.  The kern.ipc.tls.enable node must be set to true to
enable KTLS (it is off by default).  The use of unmapped mbufs must
also be enabled via kern.ipc.mb_use_ext_pgs to enable KTLS.

KTLS is enabled via the KERN_TLS kernel option.

This patch is the culmination of years of work by several folks
including Scott Long and Randall Stewart for the original design and
implementation; Drew Gallatin for several optimizations including the
use of ext_pgs mbufs, the M_NOTREADY mechanism for TLS records
awaiting software encryption, and pluggable software crypto backends;
and John Baldwin for modifications to support hardware TLS offload.

Reviewed by: gallatin, hselasky, rrs
Obtained from: Netflix
Sponsored by: Netflix, Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D21277

4 years agoRename IPPROTO 33 from SEP to DCCP
thj [Thu, 8 Aug 2019 11:43:09 +0000 (11:43 +0000)]
Rename IPPROTO 33 from SEP to DCCP

IPPROTO 33 is DCCP in the IANA Registry:
https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

IPPROTO_SEP was added about 20 years ago in r33804. The entries were added
straight from RFC1700, without regard to whether they were used.

The reference in RFC1700 for SEP is '[JC120] <mystery contact>', this is an
indication that the protocol number was probably in use in a private network.

As RFC1700 is no longer the authoritative list of internet numbers and that
IANA assinged 33 to DCCP in RFC4340, change the header to the actual
authoritative source.

Reviewed by: Richard Scheffenegger, bz
Approved by: bz (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21178

4 years agoThis commit updates rack to what is basically
rrs [Wed, 10 Jul 2019 20:40:39 +0000 (20:40 +0000)]
This commit updates rack to what is basically

being used at NF as well as sets in some of the groundwork for
committing BBR. The hpts system is updated as well as some other needed
utilities for the entrance of BBR. This is actually part 1 of 3 more
needed commits which will finally complete with BBRv1 being added as a
new tcp stack.

Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D20834

4 years agoAdd an external mbuf buffer type that holds
jhb [Sat, 29 Jun 2019 00:48:33 +0000 (00:48 +0000)]
Add an external mbuf buffer type that holds

multiple unmapped pages.

Unmapped mbufs allow sendfile to carry multiple pages of data in a
single mbuf, without mapping those pages.  It is a requirement for
Netflix's in-kernel TLS, and provides a 5-10% CPU savings on heavy web
serving workloads when used by sendfile, due to effectively
compressing socket buffers by an order of magnitude, and hence
reducing cache misses.

For this new external mbuf buffer type (EXT_PGS), the ext_buf pointer
now points to a struct mbuf_ext_pgs structure instead of a data
buffer.  This structure contains an array of physical addresses (this
reduces cache misses compared to an earlier version that stored an
array of vm_page_t pointers).  It also stores additional fields needed
for in-kernel TLS such as the TLS header and trailer data that are
currently unused.  To more easily detect these mbufs, the M_NOMAP flag
is set in m_flags in addition to M_EXT.

Various functions like m_copydata() have been updated to safely access
packet contents (using uiomove_fromphys()), to make things like BPF
safe.

NIC drivers advertise support for unmapped mbufs on transmit via a new
IFCAP_NOMAP capability.  This capability can be toggled via the new
'nomap' and '-nomap' ifconfig(8) commands.  For NIC drivers that only
transmit packet contents via DMA and use bus_dma, adding the
capability to if_capabilities and if_capenable should be all that is
required.

If a NIC does not support unmapped mbufs, they are converted to a
chain of mapped mbufs (using sf_bufs to provide the mapping) in
ip_output or ip6_output.  If an unmapped mbuf requires software
checksums, it is also converted to a chain of mapped mbufs before
computing the checksum.

Submitted by: gallatin (earlier version)
Reviewed by: gallatin, hselasky, rrs
Discussed with: ae, kp (firewalls)
Relnotes: yes
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616

4 years agoConvert all IPv4 and IPv6 multicast memberships
hselasky [Tue, 25 Jun 2019 11:54:41 +0000 (11:54 +0000)]
Convert all IPv4 and IPv6 multicast memberships

into using a STAILQ instead of a linear array.

The multicast memberships for the inpcb structure are protected by a
non-sleepable lock, INP_WLOCK(), which needs to be dropped when
calling the underlying possibly sleeping if_ioctl() method. When using
a linear array to keep track of multicast memberships, the computed
memory location of the multicast filter may suddenly change, due to
concurrent insertion or removal of elements in the linear array. This
in turn leads to various invalid memory access issues and kernel
panics.

To avoid this problem, put all multicast memberships on a STAILQ based
list. Then the memory location of the IPv4 and IPv6 multicast filters
become fixed during their lifetime and use after free and memory leak
issues are easier to track, for example by: vmstat -m | grep multi

All list manipulation has been factored into inline functions
including some macros, to easily allow for a future hash-list
implementation, if needed.

This patch has been tested by pho@ .

Differential Revision: https://reviews.freebsd.org/D20080
Reviewed by: markj @
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoExtend mmap/mprotect API to specify the max page
brooks [Thu, 20 Jun 2019 18:24:16 +0000 (18:24 +0000)]
Extend mmap/mprotect API to specify the max page

protections.

A new macro PROT_MAX() alters a protection value so it can be OR'd with
a regular protection value to specify the maximum permissions.  If
present, these flags specify the maximum permissions.

While these flags are non-portable, they can be used in portable code
with simple ifdefs to expand PROT_MAX() to 0.

This change allows (e.g.) a region that must be writable during run-time
linking or JIT code generation to be made permanently read+execute after
writes are complete.  This complements W^X protections allowing more
precise control by the programmer.

This change alters mprotect argument checking and returns an error when
unhandled protection flags are set.  This differs from POSIX (in that
POSIX only specifies an error), but is the documented behavior on Linux
and more closely matches historical mmap behavior.

In addition to explicit setting of the maximum permissions, an
experimental sysctl vm.imply_prot_max causes mmap to assume that the
initial permissions requested should be the maximum when the sysctl is
set to 1.  PROT_NONE mappings are excluded from this for compatibility
with rtld and other consumers that use such mappings to reserve
address space before mapping contents into part of the reservation.  A
final version this is expected to provide per-binary and per-process
opt-in/out options and this sysctl will go away in its current form.
As such it is undocumented.

Reviewed by: emaste, kib (prior version), markj
Additional suggestions from: alc
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D18880

4 years agoSome devices take undesired actions when RTS and
shurd [Wed, 12 Jun 2019 18:07:04 +0000 (18:07 +0000)]
Some devices take undesired actions when RTS and

DTR are asserted. Some development boards for example will reset on DTR,
and some radio interfaces will transmit on RTS.

This patch allows "stty -f /dev/ttyu9.init -rtsdtr" to prevent
RTS and DTR from being asserted on open(), allowing these devices
to be used without problems.

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D20031

4 years agoFix mismatch from r342379.
pfg [Sun, 23 Dec 2018 20:51:13 +0000 (20:51 +0000)]
Fix mismatch from r342379.

4 years agogai_strerror() - Update string error messages according to RFC 3493.
pfg [Sun, 23 Dec 2018 18:15:48 +0000 (18:15 +0000)]
gai_strerror() - Update string error messages according to RFC 3493.

Error messages in gai_strerror(3) vary largely among OSs.

For new software we largely replaced the obsoleted EAI_NONAME and
with EAI_NODATA but we never updated the corresponding message to better
match the intended use. We also have references to ai_flags and ai_family
which are not very descriptive for non-developer end users.

Bring new new error messages based on informational RFC 3493, which has
obsoleted RFC 2553, and make them consistent among the header adn
manpage.

MFC after: 1 month
Differentical Revision: D18630

4 years agoDocument the last change
Ken Brown [Tue, 24 Sep 2019 19:31:17 +0000 (15:31 -0400)]
Document the last change

4 years agoCygwin: rmdir: fail if last component is a symlink, as on Linux
Ken Brown [Sun, 22 Sep 2019 15:33:34 +0000 (11:33 -0400)]
Cygwin: rmdir: fail if last component is a symlink, as on Linux

If the last component of the directory name is a symlink followed by a
slash, rmdir now fails, following Linux but not POSIX, even if the
symlink resolves to an existing empty directory.

mkdir was similarly changed in 2009 in commit
52dba6a5c45e8d8ba1e237a15213311dc11d91fb.  Modify a comment to clarify
the purpose of that commit.

Addresses https://cygwin.com/ml/cygwin/2019-09/msg00221.html.

4 years agoCygwin: remove old cruft from path_conv::check
Ken Brown [Sat, 21 Sep 2019 17:09:09 +0000 (13:09 -0400)]
Cygwin: remove old cruft from path_conv::check

Prior to commit b0717aae, path_conv::check had the following code:

      if (strncmp (path, "\\\\.\\", 4))
        {
          /* Windows ignores trailing dots and spaces in the last path
             component, and ignores exactly one trailing dot in inner
             path components. */
          char *tail = NULL;
          [...]
          if (!tail || tail == path)
            /* nothing */;
          else if (tail[-1] != '\\')
            {
              *tail = '\0';
          [...]
        }

Commit b0717aae0 intended to disable this code, but it inadvertently
disabled only part of it.  In particular, the declaration of the local
tail variable was in the disabled code, but the following remained:

          if (!tail || tail == path)
            /* nothing */;
          else if (tail[-1] != '\\')
            {
              *tail = '\0';
          [...]
        }

[A later commit removed the disabled code.]

The tail variable here points into a string different from path,
causing that string to be truncated under some circumstances.  See

  https://cygwin.com/ml/cygwin/2019-09/msg00001.html

for more details.

This commit fixes the problem by removing the leftover code
that was intended to be removed in b0717aae.

4 years agoCygwin: Fix incorrect TTY for non-cygwin process.
Takashi Yano [Fri, 20 Sep 2019 03:04:36 +0000 (12:04 +0900)]
Cygwin: Fix incorrect TTY for non-cygwin process.

- After commit d4045fdbef60d8e7e0d11dfe38b048ea2cb8708b, the TTY
  displayed by ps command is incorrect if the process is non-cygwin
  process. This patch fixes this issue.

4 years agoCygwin: console: Make console input work in GDB and strace.
Takashi Yano [Fri, 20 Sep 2019 21:10:35 +0000 (06:10 +0900)]
Cygwin: console: Make console input work in GDB and strace.

- After commit 2232498c712acc97a38fdc297cbe53ba74d0ec2c, console
  input cause error in GDB or strace. This patch fixes this issue.

4 years agoCygwin: pty: Add missing guard when PTY is in the legacy mode.
Takashi Yano [Wed, 18 Sep 2019 14:29:21 +0000 (23:29 +0900)]
Cygwin: pty: Add missing guard when PTY is in the legacy mode.

4 years agoCygwin: pty: Add charset conversion for console apps in legacy PTY.
Takashi Yano [Wed, 18 Sep 2019 14:29:20 +0000 (23:29 +0900)]
Cygwin: pty: Add charset conversion for console apps in legacy PTY.

4 years agoCygwin: pty: Unify the charset conversion codes into a function.
Takashi Yano [Wed, 18 Sep 2019 14:29:19 +0000 (23:29 +0900)]
Cygwin: pty: Unify the charset conversion codes into a function.

4 years agoCygwin: pty: Make GDB work again on pty.
Takashi Yano [Wed, 18 Sep 2019 14:29:18 +0000 (23:29 +0900)]
Cygwin: pty: Make GDB work again on pty.

4 years agoCygwin: pty: Avoid potential segfault in PTY code when ppid = 1.
Takashi Yano [Wed, 18 Sep 2019 14:29:17 +0000 (23:29 +0900)]
Cygwin: pty: Avoid potential segfault in PTY code when ppid = 1.

4 years agoCygwin: console: Revive Win7 compatibility.
Takashi Yano [Wed, 18 Sep 2019 20:49:55 +0000 (05:49 +0900)]
Cygwin: console: Revive Win7 compatibility.

- The commit fca4cda7a420d7b15ac217d008527e029d05758e broke Win7
  compatibility. This patch fixes the issue.

4 years agoCygwin: document last change
Ken Brown [Sun, 15 Sep 2019 17:40:12 +0000 (13:40 -0400)]
Cygwin: document last change

4 years agowinsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument
Achim Gratz [Sun, 15 Sep 2019 16:28:21 +0000 (18:28 +0200)]
winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument

Adresses the problem reported here:

  https://cygwin.com/ml/cygwin/2019-09/msg00141.html

4 years agoCygwin: pty: Use autoload feature for pseudo console system calls.
Takashi Yano [Sun, 15 Sep 2019 10:55:44 +0000 (19:55 +0900)]
Cygwin: pty: Use autoload feature for pseudo console system calls.

- The autoload feature is used rather than GetModuleHandle(),
  GetProcAddress() for CreatePseudoConsole(), ResizePseudoConsole()
  and ClosePseudoConsole().

4 years agoCygwin: pty: Correct typos that do not fit the coding style.
Takashi Yano [Sun, 15 Sep 2019 04:36:23 +0000 (13:36 +0900)]
Cygwin: pty: Correct typos that do not fit the coding style.

4 years agoCygwin: pty: Change the timing of clearing screen.
Takashi Yano [Sun, 15 Sep 2019 04:05:53 +0000 (13:05 +0900)]
Cygwin: pty: Change the timing of clearing screen.

- The code which clears screen is moved from reset_switch_to_pcon()
  to fixup_after_exec() because it seems not too early even at this
  timing.

4 years agoCygwin: pty: Use system NLS function instead of PTY's own one.
Takashi Yano [Sun, 15 Sep 2019 04:05:52 +0000 (13:05 +0900)]
Cygwin: pty: Use system NLS function instead of PTY's own one.

- Since calling system __loadlocale() caused execution error,
  PTY used its own NLS function. The cause of the error has been
  found, the corresponding code has been rewritten using system
  function.

This page took 0.075438 seconds and 5 git commands to generate.