Browse Source

Merge remote-tracking branch 'origin/freebsd/current/master' into hardened/current/master

Conflicts:
	sys/vm/vm_mmap.c (unresolved)
hardened/current/master
Shawn Webb 11 months ago
parent
commit
3431dee514
Signed by: Shawn Webb <shawn.webb@hardenedbsd.org> GPG Key ID: FF2E67A277F8E1FA
30 changed files with 501 additions and 96 deletions
  1. +1
    -0
      Makefile.inc1
  2. +5
    -5
      contrib/traceroute/traceroute.8
  3. +22
    -1
      lib/libc/sys/mmap.2
  4. +26
    -1
      lib/libc/sys/mprotect.2
  5. +3
    -1
      share/man/man9/Makefile
  6. +86
    -0
      share/man/man9/VOP_BMAP.9
  7. +2
    -2
      share/man/man9/VOP_REVOKE.9
  8. +23
    -7
      share/man/man9/sleep.9
  9. +3
    -2
      share/man/man9/sleepqueue.9
  10. +12
    -2
      share/man/man9/vm_map_protect.9
  11. +11
    -3
      share/mk/bsd.sys.mk
  12. +1
    -0
      share/timedef/Makefile
  13. +87
    -0
      share/timedef/zh_TW.Big5.src
  14. +18
    -14
      stand/efi/libefi/efinet.c
  15. +6
    -0
      stand/libsa/zfs/zfsimpl.c
  16. +13
    -0
      sys/kern/kern_synch.c
  17. +30
    -11
      sys/kern/subr_sleepqueue.c
  18. +1
    -1
      sys/kern/subr_taskqueue.c
  19. +7
    -1
      sys/kern/vfs_default.c
  20. +22
    -0
      sys/kern/vfs_vnops.c
  21. +8
    -0
      sys/sys/filio.h
  22. +8
    -0
      sys/sys/mman.h
  23. +4
    -0
      sys/sys/queue.h
  24. +1
    -0
      sys/sys/sleepqueue.h
  25. +1
    -0
      sys/sys/systm.h
  26. +6
    -3
      sys/ufs/ufs/ufs_bmap.c
  27. +42
    -5
      sys/vm/vm_mmap.c
  28. +29
    -29
      sys/vm/vm_page.c
  29. +6
    -0
      usr.bin/top/display.c
  30. +17
    -8
      usr.bin/top/machine.c

+ 1
- 0
Makefile.inc1 View File

@@ -2554,6 +2554,7 @@ NXBDIRS+= \
usr.bin/find \
usr.bin/grep \
usr.bin/gzip \
usr.bin/head \
usr.bin/id \
usr.bin/lex \
usr.bin/limits \

+ 5
- 5
contrib/traceroute/traceroute.8 View File

@@ -16,7 +16,7 @@
.\" $Id: traceroute.8,v 1.19 2000/09/21 08:44:19 leres Exp $
.\" $FreeBSD$
.\"
.Dd May 31, 2015
.Dd June 20, 2019
.Dt TRACEROUTE 8
.Os
.Sh NAME
@@ -32,7 +32,7 @@
.Op Fl m Ar max_ttl
.Op Fl P Ar proto
.Op Fl p Ar port
.Op Fl q Ar nqueries
.Op Fl q Ar nprobes
.Op Fl s Ar src_addr
.Op Fl t Ar tos
.Op Fl w Ar waittime
@@ -125,14 +125,14 @@ Traceroute hopes that nothing is listening on UDP ports (or UDP-Lite ports
if used by
.Nm
and supported by the peer)
.Em base + 1
.Em port + 1
to
.Em base + nhops * nprobes
.Em port + (max_ttl - first_ttl + 1) * nprobes
at the destination host (so an ICMP PORT_UNREACHABLE message will
be returned to terminate the route tracing). If something is
listening on a port in the default range, this option can be used
to pick an unused port range.
.It Fl q Ar nqueries
.It Fl q Ar nprobes
Set the number of probes per hop (default is 3,
unless
.Fl D

+ 22
- 1
lib/libc/sys/mmap.2 View File

@@ -28,7 +28,7 @@
.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95
.\" $FreeBSD$
.\"
.Dd June 22, 2017
.Dd June 20, 2019
.Dt MMAP 2
.Os
.Sh NAME
@@ -113,6 +113,22 @@ Pages may be written.
Pages may be executed.
.El
.Pp
In addition to these protection flags,
.Fx
provides the ability to set the maximum protection of a region allocated by
.Nm
and later altered by
.Xr mprotect 2 .
This is accomplished by
.Em or Ns 'ing
one or more
.Dv PROT_
values wrapped in the
.Dv PROT_MAX()
macro into the
.Fa prot
argument.
.Pp
The
.Fa flags
argument specifies the type of the mapped object, mapping options and
@@ -416,6 +432,11 @@ An invalid value was passed in the
.Fa prot
argument.
.It Bq Er EINVAL
The
.Fa prot
argument contains permissions which are not a subset of the specified
maximum permissions.
.It Bq Er EINVAL
An undefined option was set in the
.Fa flags
argument.

+ 26
- 1
lib/libc/sys/mprotect.2 View File

@@ -28,7 +28,7 @@
.\" @(#)mprotect.2 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
.Dd August 3, 2016
.Dd June 20, 2019
.Dt MPROTECT 2
.Os
.Sh NAME
@@ -65,6 +65,22 @@ The pages can be written.
.It Dv PROT_EXEC
The pages can be executed.
.El
.Pp
In addition to these protection flags,
.Fx
provides the ability to set the maximum protection of a region
(which prevents
.Nm
from upgrading the permissions).
This is accomplished by
.Em or Ns 'ing
one or more
.Dv PROT_
values wrapped in the
.Dv PROT_MAX()
macro into the
.Fa prot
argument.
.Sh RETURN VALUES
.Rv -std mprotect
.Sh ERRORS
@@ -78,6 +94,15 @@ The virtual address range specified by the
and
.Fa len
arguments is not valid.
.It Bq Er EINVAL
The
.Fa prot
argument contains unhandled bits.
.It Bq Er EINVAL
The
.Fa prot
argument contains permissions which are not a subset of the specified
maximum permissions.
.It Bq Er EACCES
The calling process was not allowed to change
the protection to the value specified by

+ 3
- 1
share/man/man9/Makefile View File

@@ -399,6 +399,7 @@ MAN= accept_filter.9 \
VOP_ADVLOCK.9 \
VOP_ALLOCATE.9 \
VOP_ATTRIB.9 \
VOP_BMAP.9 \
VOP_BWRITE.9 \
VOP_CREATE.9 \
VOP_FSYNC.9 \
@@ -1880,7 +1881,8 @@ MLINKS+=sleep.9 msleep.9 \
sleep.9 tsleep.9 \
sleep.9 tsleep_sbt.9 \
sleep.9 wakeup.9 \
sleep.9 wakeup_one.9
sleep.9 wakeup_one.9 \
sleep.9 wakeup_any.9
MLINKS+=sleepqueue.9 init_sleepqueues.9 \
sleepqueue.9 sleepq_abort.9 \
sleepqueue.9 sleepq_add.9 \

+ 86
- 0
share/man/man9/VOP_BMAP.9 View File

@@ -0,0 +1,86 @@
.\"-
.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
.\"
.\" Copyright (c) 2019 The FreeBSD Foundation
.\"
.\" This software was developed by BFF Storage Systems, LLC under sponsorship
.\" from the FreeBSD Foundation.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd June 19, 2019
.Dt VOP_BMAP 9
.Os
.Sh NAME
.Nm VOP_BMAP
.Nd Logical to physical block number conversion
.Sh SYNOPSIS
.In sys/param.h
.In sys/vnode.h
.Ft int
.Fn VOP_BMAP "struct vnode *vp" "daddr_t bn" "struct bufobj **bop" "daddr_t *bnp" "int *runp" "int *runb"
.Sh DESCRIPTION
This vnode call is used to lookup the physical block number of the file system's
underlying device where a given logical block of a file is stored.
Its arguments are:
.Bl -tag -width type
.It Fa vp
The vnode of the file.
.It Fa bn
Logical block number within the file identified by
.Fa vp .
.It Fa bop
Return storage for the buffer object associated with the file system's
underlying device.
.It Fa bnp
Return storage for the physical block number.
.It Fa runp
Return storage for the number of succeeding logical blocks that may be
efficiently read at the same time as the requested block.
This will usually be the number of logical blocks whose physical blocks are
contiguously allocated.
However a file system is free to define "efficient" as it see fit.
.It Fa runb
Like
.Fa runp
but for preceding rather than succeeding blocks.
.El
.Pp
Any of the return arguments may be
.Dv NULL
to indicate that the caller does not care about that information.
.Sh LOCKS
The vnode will be locked on entry and should remain locked on return.
.Sh RETURN VALUES
Zero is returned on success, otherwise an error code is returned.
.Sh SEE ALSO
.Xr vnode 9 ,
.Sh HISTORY
A
.Fn bmap
function first appeared in
.Bx 4.2 .
.Sh AUTHORS
This manual page was written by
.An Alan Somers .

+ 2
- 2
share/man/man9/VOP_REVOKE.9 View File

@@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 5, 2002
.Dd June 20, 2019
.Dt VOP_REVOKE 9
.Os
.Sh NAME
@@ -61,7 +61,7 @@ to signify that all access will be revoked; any other value is invalid.
.Sh LOCKS
The
.Fa vp
must be unlocked on entry, and will remain unlocked upon return.
must be exclusively locked on entry, and will remain locked upon return.
.Sh SEE ALSO
.Xr make_dev_alias 9 ,
.Xr vnode 9

+ 23
- 7
share/man/man9/sleep.9 View File

@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 4, 2018
.Dd June 19, 2019
.Dt SLEEP 9
.Os
.Sh NAME
@@ -38,7 +38,9 @@
.Nm pause_sbt ,
.Nm tsleep ,
.Nm tsleep_sbt ,
.Nm wakeup
.Nm wakeup ,
.Nm wakeup_one ,
.Nm wakeup_any
.Nd wait for events
.Sh SYNOPSIS
.In sys/param.h
@@ -70,6 +72,8 @@
.Fn wakeup "void *chan"
.Ft void
.Fn wakeup_one "void *chan"
.Ft void
.Fn wakeup_any "void *chan"
.Sh DESCRIPTION
The functions
.Fn tsleep ,
@@ -79,8 +83,9 @@ The functions
.Fn pause_sig ,
.Fn pause_sbt ,
.Fn wakeup ,
.Fn wakeup_one ,
and
.Fn wakeup_one
.Fn wakeup_any
handle event-based thread blocking.
If a thread must wait for an
external event, it is put to sleep by
@@ -252,9 +257,10 @@ function is a wrapper around
.Fn tsleep
that suspends execution of the current thread for the indicated timeout.
The thread can not be awakened early by signals or calls to
.Fn wakeup
.Fn wakeup ,
.Fn wakeup_one
or
.Fn wakeup_one .
.Fn wakeup_any .
The
.Fn pause_sig
function is a variant of
@@ -263,8 +269,8 @@ which can be awakened early by signals.
.Pp
The
.Fn wakeup_one
function makes the first thread in the queue that is sleeping on the
parameter
function makes the first highest priority thread in the queue that is
sleeping on the parameter
.Fa chan
runnable.
This reduces the load when a large number of threads are sleeping on
@@ -293,6 +299,16 @@ pay particular attention to ensure that no other threads wait on the
same
.Fa chan .
.Pp
The
.Fn wakeup_any
function is similar to
.Fn wakeup_one ,
except that it makes runnable last thread on the queue (sleeping less),
ignoring fairness.
It can be used when threads sleeping on the
.Fa chan
are known to be identical and there is no reason to be fair.
.Pp
If the timeout given by
.Fa timo
or

+ 3
- 2
share/man/man9/sleepqueue.9 View File

@@ -22,7 +22,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd September 22, 2014
.Dd June 19, 2019
.Dt SLEEPQUEUE 9
.Os
.Sh NAME
@@ -290,7 +290,8 @@ and
functions.
The
.Fn sleepq_signal
function awakens the highest priority thread sleeping on a wait channel while
function awakens the highest priority thread sleeping on a wait channel
(if SLEEPQ_UNFAIR flag is set, thread that went to sleep recently) while
.Fn sleepq_broadcast
awakens all of the threads sleeping on a wait channel.
The

+ 12
- 2
share/man/man9/vm_map_protect.9 View File

@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 19, 2003
.Dd June 20, 2019
.Dt VM_MAP_PROTECT 9
.Os
.Sh NAME
@@ -51,6 +51,11 @@ within the map
.Fa map
to
.Fa new_prot .
The value specified by
.Fa new_prot
may not include any protection bits that are not set in
.Va max_protection
on every entry within the range.
.Pp
If
.Fa set_max
@@ -59,7 +64,12 @@ is TRUE,
is treated as the new
.Va max_protection
setting for each underlying entry.
Otherwise, only the
Protection bits not included
.Fa new_prot
will be cleared from existing entries.
If
.Fa set_max
is FALSE only the
.Va protection
field is affected.
.Pp

+ 11
- 3
share/mk/bsd.sys.mk View File

@@ -234,7 +234,6 @@ DEBUG_FILES_CFLAGS?= -g
.if ${MK_WARNS} != "no"
CFLAGS+= ${CWARNFLAGS:M*} ${CWARNFLAGS.${COMPILER_TYPE}}
CFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
CFLAGS+= ${CWARNFLAGS.${.TARGET:T}}
.endif

CFLAGS+= ${CFLAGS.${COMPILER_TYPE}}
@@ -245,14 +244,23 @@ AFLAGS+= ${AFLAGS.${.TARGET:T}}
ACFLAGS+= ${ACFLAGS.${.IMPSRC:T}}
ACFLAGS+= ${ACFLAGS.${.TARGET:T}}
CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
CFLAGS+= ${CFLAGS.${.TARGET:T}}
CXXFLAGS+= ${CXXFLAGS.${.IMPSRC:T}}
CXXFLAGS+= ${CXXFLAGS.${.TARGET:T}}

LDFLAGS+= ${LDFLAGS.${LINKER_TYPE}}

# Only allow .TARGET when not using PROGS as it has the same syntax
# per PROG which is ambiguous with this syntax. This is only needed
# for PROG_VARS vars.
.if !defined(_RECURSING_PROGS)
.if ${MK_WARNS} != "no"
CFLAGS+= ${CWARNFLAGS.${.TARGET:T}}
.endif
CFLAGS+= ${CFLAGS.${.TARGET:T}}
CXXFLAGS+= ${CXXFLAGS.${.TARGET:T}}
LDFLAGS+= ${LDFLAGS.${.TARGET:T}}
LDADD+= ${LDADD.${.TARGET:T}}
LIBADD+= ${LIBADD.${.TARGET:T}}
.endif

.if defined(SRCTOP)
# Prevent rebuilding during install to support read-only objdirs.

+ 1
- 0
share/timedef/Makefile View File

@@ -129,6 +129,7 @@ LOCALES+= zh_CN.GBK
LOCALES+= zh_CN.UTF-8
LOCALES+= zh_CN.eucCN
LOCALES+= zh_HK.UTF-8
LOCALES+= zh_TW.Big5
LOCALES+= zh_TW.UTF-8



+ 87
- 0
share/timedef/zh_TW.Big5.src View File

@@ -0,0 +1,87 @@
# Warning: Do not edit. This file is automatically generated from the
# tools in /usr/src/tools/tools/locale. The data is obtained from the
# CLDR project, obtained from http://cldr.unicode.org/
# -----------------------------------------------------------------------------
#
# Short month names
 1月
 2月
 3月
 4月
 5月
 6月
 7月
 8月
 9月
10月
11月
12月
#
# Long month names (as in a date)
1月
2月
3月
4月
5月
6月
7月
8月
9月
10月
11月
12月
#
# Short weekday names
週日
週一
週二
週三
週四
週五
週六
#
# Long weekday names
星期日
星期一
星期二
星期三
星期四
星期五
星期六
#
# X_fmt
%H時%M分%S秒
#
# x_fmt
%Y/%m/%d
#
# c_fmt
%a %b/%e %T %Y
#
# AM/PM
上午
下午
#
# date_fmt
%Y年%_m月%e日 %A %X %Z
#
# Long month names (without case ending)
1月
2月
3月
4月
5月
6月
7月
8月
9月
10月
11月
12月
#
# md_order
md
#
# ampm_fmt
%I:%M:%S %p
# EOF

+ 18
- 14
stand/efi/libefi/efinet.c View File

@@ -108,6 +108,24 @@ efinet_match(struct netif *nif, void *machdep_hint)
static int
efinet_probe(struct netif *nif, void *machdep_hint)
{
EFI_SIMPLE_NETWORK *net;
EFI_HANDLE h;
EFI_STATUS status;

h = nif->nif_driver->netif_ifs[nif->nif_unit].dif_private;
/*
* Open the network device in exclusive mode. Without this
* we will be racing with the UEFI network stack. It will
* pull packets off the network leading to lost packets.
*/
status = BS->OpenProtocol(h, &sn_guid, (void **)&net,
IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE);
if (status != EFI_SUCCESS) {
printf("Unable to open network interface %d for "
"exclusive access: %lu\n", nif->nif_unit,
EFI_ERROR_CODE(status));
return (efi_status_to_errno(status));
}

return (0);
}
@@ -269,7 +287,6 @@ efinet_dev_init()
struct netif_dif *dif;
struct netif_stats *stats;
EFI_DEVICE_PATH *devpath, *node;
EFI_SIMPLE_NETWORK *net;
EFI_HANDLE *handles, *handles2;
EFI_STATUS status;
UINTN sz;
@@ -305,19 +322,6 @@ efinet_dev_init()
DevicePathSubType(node) != MSG_MAC_ADDR_DP)
continue;

/*
* Open the network device in exclusive mode. Without this
* we will be racing with the UEFI network stack. It will
* pull packets off the network leading to lost packets.
*/
status = BS->OpenProtocol(handles[i], &sn_guid, (void **)&net,
IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE);
if (status != EFI_SUCCESS) {
printf("Unable to open network interface %d for "
"exclusive access: %lu\n", i,
EFI_ERROR_CODE(status));
}

handles2[nifs] = handles[i];
nifs++;
}

+ 6
- 0
stand/libsa/zfs/zfsimpl.c View File

@@ -64,6 +64,12 @@ static const char *features_for_read[] = {
"org.illumos:skein",
"org.zfsonlinux:large_dnode",
"com.joyent:multi_vdev_crash_dump",
"com.delphix:spacemap_histogram",
"com.delphix:zpool_checkpoint",
"com.delphix:spacemap_v2",
"com.datto:encryption",
"org.zfsonlinux:allocation_classes",
"com.datto:resilver_defer",
NULL
};


+ 13
- 0
sys/kern/kern_synch.c View File

@@ -368,6 +368,19 @@ wakeup_one(void *ident)
kick_proc0();
}

void
wakeup_any(void *ident)
{
int wakeup_swapper;

sleepq_lock(ident);
wakeup_swapper = sleepq_signal(ident, SLEEPQ_SLEEP | SLEEPQ_UNFAIR,
0, 0);
sleepq_release(ident);
if (wakeup_swapper)
kick_proc0();
}

static void
kdb_switch(void)
{

+ 30
- 11
sys/kern/subr_sleepqueue.c View File

@@ -123,7 +123,7 @@ CTASSERT(powerof2(SC_TABLESIZE));
* c - sleep queue chain lock
*/
struct sleepqueue {
TAILQ_HEAD(, thread) sq_blocked[NR_SLEEPQS]; /* (c) Blocked threads. */
struct threadqueue sq_blocked[NR_SLEEPQS]; /* (c) Blocked threads. */
u_int sq_blockedcnt[NR_SLEEPQS]; /* (c) N. of blocked threads. */
LIST_ENTRY(sleepqueue) sq_hash; /* (c) Chain and free list. */
LIST_HEAD(, sleepqueue) sq_free; /* (c) Free queues. */
@@ -889,12 +889,14 @@ sleepq_init(void *mem, int size, int flags)
}

/*
* Find the highest priority thread sleeping on a wait channel and resume it.
* Find thread sleeping on a wait channel and resume it.
*/
int
sleepq_signal(void *wchan, int flags, int pri, int queue)
{
struct sleepqueue_chain *sc;
struct sleepqueue *sq;
struct threadqueue *head;
struct thread *td, *besttd;
int wakeup_swapper;

@@ -907,16 +909,33 @@ sleepq_signal(void *wchan, int flags, int pri, int queue)
KASSERT(sq->sq_type == (flags & SLEEPQ_TYPE),
("%s: mismatch between sleep/wakeup and cv_*", __func__));

/*
* Find the highest priority thread on the queue. If there is a
* tie, use the thread that first appears in the queue as it has
* been sleeping the longest since threads are always added to
* the tail of sleep queues.
*/
besttd = TAILQ_FIRST(&sq->sq_blocked[queue]);
TAILQ_FOREACH(td, &sq->sq_blocked[queue], td_slpq) {
if (td->td_priority < besttd->td_priority)
head = &sq->sq_blocked[queue];
if (flags & SLEEPQ_UNFAIR) {
/*
* Find the most recently sleeping thread, but try to
* skip threads still in process of context switch to
* avoid spinning on the thread lock.
*/
sc = SC_LOOKUP(wchan);
besttd = TAILQ_LAST_FAST(head, thread, td_slpq);
while (besttd->td_lock != &sc->sc_lock) {
td = TAILQ_PREV_FAST(besttd, head, thread, td_slpq);
if (td == NULL)
break;
besttd = td;
}
} else {
/*
* Find the highest priority thread on the queue. If there
* is a tie, use the thread that first appears in the queue
* as it has been sleeping the longest since threads are
* always added to the tail of sleep queues.
*/
besttd = td = TAILQ_FIRST(head);
while ((td = TAILQ_NEXT(td, td_slpq)) != NULL) {
if (td->td_priority < besttd->td_priority)
besttd = td;
}
}
MPASS(besttd != NULL);
thread_lock(besttd);

+ 1
- 1
sys/kern/subr_taskqueue.c View File

@@ -804,7 +804,7 @@ taskqueue_thread_enqueue(void *context)

tqp = context;
tq = *tqp;
wakeup_one(tq);
wakeup_any(tq);
}

TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, NULL,

+ 7
- 1
sys/kern/vfs_default.c View File

@@ -603,7 +603,13 @@ vop_stdgetwritemount(ap)
return (0);
}

/* XXX Needs good comment and VOP_BMAP(9) manpage */
/*
* If the file system doesn't implement VOP_BMAP, then return sensible defaults:
* - Return the vnode's bufobj instead of any underlying device's bufobj
* - Calculate the physical block number as if there were equal size
* consecutive blocks, but
* - Report no contiguous runs of blocks.
*/
int
vop_stdbmap(ap)
struct vop_bmap_args /* {

+ 22
- 0
sys/kern/vfs_vnops.c View File

@@ -1458,6 +1458,25 @@ vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred,
return (0);
}

/* generic FIOBMAP2 implementation */
static int
vn_ioc_bmap2(struct file *fp, struct fiobmap2_arg *arg, struct ucred *cred)
{
struct vnode *vp = fp->f_vnode;
daddr_t lbn = arg->bn;
int error;

vn_lock(vp, LK_SHARED | LK_RETRY);
#ifdef MAC
error = mac_vnode_check_read(cred, fp->f_cred, vp);
if (error == 0)
#endif
error = VOP_BMAP(vp, lbn, NULL, &arg->bn, &arg->runp,
&arg->runb);
VOP_UNLOCK(vp, 0);
return (error);
}

/*
* File table vnode ioctl routine.
*/
@@ -1481,6 +1500,9 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
if (error == 0)
*(int *)data = vattr.va_size - fp->f_offset;
return (error);
case FIOBMAP2:
return (vn_ioc_bmap2(fp, (struct fiobmap2_arg*)data,
active_cred));
case FIONBIO:
case FIOASYNC:
return (0);

+ 8
- 0
sys/sys/filio.h View File

@@ -40,6 +40,7 @@
#ifndef _SYS_FILIO_H_
#define _SYS_FILIO_H_

#include <sys/types.h>
#include <sys/ioccom.h>

/* Generic file-descriptor ioctl's. */
@@ -62,6 +63,13 @@ struct fiodgname_arg {
/* Handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge. */
#define FIOSEEKDATA _IOWR('f', 97, off_t) /* SEEK_DATA */
#define FIOSEEKHOLE _IOWR('f', 98, off_t) /* SEEK_HOLE */
struct fiobmap2_arg {
int64_t bn;
int runp;
int runb;
};
/* Get the file's bmap info for the logical block bn */
#define FIOBMAP2 _IOWR('f', 99, struct fiobmap2_arg)

#ifdef _KERNEL
#ifdef COMPAT_FREEBSD32

+ 8
- 0
sys/sys/mman.h View File

@@ -55,6 +55,14 @@
#define PROT_READ 0x01 /* pages can be read */
#define PROT_WRITE 0x02 /* pages can be written */
#define PROT_EXEC 0x04 /* pages can be executed */
#if __BSD_VISIBLE
#define _PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)
#define PROT_EXTRACT(prot) ((prot) & _PROT_ALL)

#define _PROT_MAX_SHIFT 16
#define PROT_MAX(prot) ((prot) << _PROT_MAX_SHIFT)
#define PROT_MAX_EXTRACT(prot) (((prot) >> _PROT_MAX_SHIFT) & _PROT_ALL)
#endif

/*
* Flags contain sharing type and options.

+ 4
- 0
sys/sys/queue.h View File

@@ -829,6 +829,10 @@ struct { \
#define TAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))

#define TAILQ_PREV_FAST(elm, head, type, field) \
((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \
__containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next))

#define TAILQ_REMOVE(head, elm, field) do { \
QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \

+ 1
- 0
sys/sys/sleepqueue.h View File

@@ -84,6 +84,7 @@ struct thread;
#define SLEEPQ_SX 0x03 /* Used by an sx lock. */
#define SLEEPQ_LK 0x04 /* Used by a lockmgr. */
#define SLEEPQ_INTERRUPTIBLE 0x100 /* Sleep is interruptible. */
#define SLEEPQ_UNFAIR 0x200 /* Unfair wakeup order. */

void init_sleepqueues(void);
int sleepq_abort(struct thread *td, int intrval);

+ 1
- 0
sys/sys/systm.h View File

@@ -489,6 +489,7 @@ int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr,
_sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags))
void wakeup(void * chan);
void wakeup_one(void * chan);
void wakeup_any(void * chan);

/*
* Common `struct cdev *' stuff are declared here to avoid #include poisoning

+ 6
- 3
sys/ufs/ufs/ufs_bmap.c View File

@@ -200,12 +200,15 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb)
*bnp = blkptrtodb(ump, ip->i_din2->di_extb[-1 - bn]);
if (*bnp == 0)
*bnp = -1;
if (nbp == NULL)
panic("ufs_bmaparray: mapping ext data");
if (nbp == NULL) {
/* indirect block not found */
return (EINVAL);
}
nbp->b_xflags |= BX_ALTDATA;
return (0);
} else {
panic("ufs_bmaparray: blkno out of range");
/* blkno out of range */
return (EINVAL);
}
/*
* Since this is FFS independent code, we are out of

+ 42
- 5
sys/vm/vm_mmap.c View File

@@ -106,6 +106,9 @@ static int mincore_mapped = 1;
SYSCTL_INT(_vm, OID_AUTO, mincore_mapped,
CTLFLAG_RWTUN | CTLFLAG_SECURE, &mincore_mapped, 0,
"mincore reports mappings, not residency");
static int imply_prot_max = 0;
SYSCTL_INT(_vm, OID_AUTO, imply_prot_max, CTLFLAG_RWTUN, &imply_prot_max, 0,
"Imply maximum page permissions in mmap() when none are specified");

#ifdef MAP_32BIT
#define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31)
@@ -190,13 +193,29 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags,
vm_offset_t addr;
vm_size_t pageoff, size;
vm_prot_t cap_maxprot;
int align, error;
int align, error, max_prot;
cap_rights_t rights;
#ifdef PAX_ASLR
vm_offset_t orig_addr;
int pax_aslr_done;
#endif

if ((prot & ~(_PROT_ALL | PROT_MAX(_PROT_ALL))) != 0)
return (EINVAL);
max_prot = PROT_MAX_EXTRACT(prot);
prot = PROT_EXTRACT(prot);
if (max_prot != 0 && (max_prot & prot) != prot)
return (EINVAL);
/*
* Always honor PROT_MAX if set. If not, default to all
* permissions unless we're implying maximum permissions.
*
* XXX: should be tunable per process and ABI.
*/
if (max_prot == 0)
max_prot = (imply_prot_max && prot != PROT_NONE) ?
prot : _PROT_ALL;

vms = td->td_proc->p_vmspace;
fp = NULL;
AUDIT_ARG_FD(fd);
@@ -370,8 +389,12 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags,
cap_maxprot, flags, NULL, pos, FALSE, td);
#else
error = vm_mmap_object(&vms->vm_map, &addr, size, prot,
<<<<<<< HEAD
VM_PROT_ALL, flags, NULL, pos, FALSE, td);
#endif
=======
max_prot, flags, NULL, pos, FALSE, td);
>>>>>>> origin/freebsd/current/master
} else {
/*
* Mapping file, get fp for validation and don't let the
@@ -407,7 +430,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags,
#endif
/* This relies on VM_PROT_* matching PROT_*. */
error = fo_mmap(fp, &vms->vm_map, &addr, size, prot,
cap_maxprot, flags, pos, td);
max_prot & cap_maxprot, flags, pos, td);
}

if (error == 0)
@@ -633,9 +656,13 @@ kern_mprotect(struct thread *td, uintptr_t addr0, size_t size, int prot)
{
vm_offset_t addr;
vm_size_t pageoff;
int vm_error, max_prot;

addr = addr0;
prot = (prot & VM_PROT_ALL);
if ((prot & ~(_PROT_ALL | PROT_MAX(_PROT_ALL))) != 0)
return (EINVAL);
max_prot = PROT_MAX_EXTRACT(prot);
prot = PROT_EXTRACT(prot);
pageoff = (addr & PAGE_MASK);
addr -= pageoff;
size += pageoff;
@@ -649,8 +676,18 @@ kern_mprotect(struct thread *td, uintptr_t addr0, size_t size, int prot)
if (addr + size < addr)
return (EINVAL);

switch (vm_map_protect(&td->td_proc->p_vmspace->vm_map, addr,
addr + size, prot, FALSE)) {
vm_error = KERN_SUCCESS;
if (max_prot != 0) {
if ((max_prot & prot) != prot)
return (EINVAL);
vm_error = vm_map_protect(&td->td_proc->p_vmspace->vm_map,
addr, addr + size, max_prot, TRUE);
}
if (vm_error == KERN_SUCCESS)
vm_error = vm_map_protect(&td->td_proc->p_vmspace->vm_map,
addr, addr + size, prot, FALSE);

switch (vm_error) {
case KERN_SUCCESS:
return (0);
case KERN_PROTECTION_FAILURE:

+ 29
- 29
sys/vm/vm_page.c View File

@@ -3400,35 +3400,6 @@ vm_page_requeue(vm_page_t m)
vm_pqbatch_submit_page(m, atomic_load_8(&m->queue));
}

/*
* vm_page_activate:
*
* Put the specified page on the active list (if appropriate).
* Ensure that act_count is at least ACT_INIT but do not otherwise
* mess with it.
*
* The page must be locked.
*/
void
vm_page_activate(vm_page_t m)
{

vm_page_assert_locked(m);

if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
return;
if (vm_page_queue(m) == PQ_ACTIVE) {
if (m->act_count < ACT_INIT)
m->act_count = ACT_INIT;
return;
}

vm_page_dequeue(m);
if (m->act_count < ACT_INIT)
m->act_count = ACT_INIT;
vm_page_enqueue(m, PQ_ACTIVE);
}

/*
* vm_page_free_prep:
*
@@ -3679,6 +3650,35 @@ vm_page_unwire_noq(vm_page_t m)
return (false);
}

/*
* vm_page_activate:
*
* Put the specified page on the active list (if appropriate).
* Ensure that act_count is at least ACT_INIT but do not otherwise
* mess with it.
*
* The page must be locked.
*/
void
vm_page_activate(vm_page_t m)
{

vm_page_assert_locked(m);

if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
return;
if (vm_page_queue(m) == PQ_ACTIVE) {
if (m->act_count < ACT_INIT)
m->act_count = ACT_INIT;
return;
}

vm_page_dequeue(m);
if (m->act_count < ACT_INIT)
m->act_count = ACT_INIT;
vm_page_enqueue(m, PQ_ACTIVE);
}

/*
* Move the specified page to the tail of the inactive queue, or requeue
* the page if it is already in the inactive queue.

+ 6
- 0
usr.bin/top/display.c View File

@@ -675,6 +675,9 @@ i_swap(int *stats)
{
swap_buffer = setup_buffer(swap_buffer, 0);

if (swap_names == NULL)
return;

fputs("\nSwap: ", stdout);
lastline++;

@@ -690,6 +693,9 @@ u_swap(int *stats)

new = setup_buffer(new, 0);

if (swap_names == NULL)
return;

/* format the new line */
summary_format(new, stats, swap_names);
line_update(swap_buffer, new, x_swap, y_swap);

+ 17
- 8
usr.bin/top/machine.c View File

@@ -150,6 +150,7 @@ static const char *swapnames[] = {
};
static int swap_stats[nitems(swapnames)];

static int has_swap;

/* these are for keeping track of the proc array */

@@ -248,12 +249,12 @@ update_layout(void)
y_mem = 3;
y_arc = 4;
y_carc = 5;
y_swap = 4 + arc_enabled + carc_enabled;
y_idlecursor = 5 + arc_enabled + carc_enabled;
y_message = 5 + arc_enabled + carc_enabled;
y_header = 6 + arc_enabled + carc_enabled;
y_procs = 7 + arc_enabled + carc_enabled;
Header_lines = 7 + arc_enabled + carc_enabled;
y_swap = 3 + arc_enabled + carc_enabled + has_swap;
y_idlecursor = 4 + arc_enabled + carc_enabled + has_swap;
y_message = 4 + arc_enabled + carc_enabled + has_swap;
y_header = 5 + arc_enabled + carc_enabled + has_swap;
y_procs = 6 + arc_enabled + carc_enabled + has_swap;
Header_lines = 6 + arc_enabled + carc_enabled + has_swap;

if (pcpu_stats) {
y_mem += ncpus - 1;
@@ -273,7 +274,7 @@ machine_init(struct statics *statics)
{
int i, j, empty, pagesize;
uint64_t arc_size;
int carc_en;
int carc_en, nswapdev;
size_t size;

size = sizeof(smpmode);
@@ -298,6 +299,11 @@ machine_init(struct statics *statics)
if (kd == NULL)
return (-1);

size = sizeof(nswapdev);
if (sysctlbyname("vm.nswapdev", &nswapdev, &size, NULL,
0) == 0 && nswapdev != 0)
has_swap = 1;

GETSYSCTL("kern.ccpu", ccpu);

/* this is used in calculating WCPU -- calculate it ahead of time */
@@ -332,7 +338,10 @@ machine_init(struct statics *statics)
statics->carc_names = carcnames;
else
statics->carc_names = NULL;
statics->swap_names = swapnames;
if (has_swap)
statics->swap_names = swapnames;
else
statics->swap_names = NULL;
statics->order_names = ordernames;

/* Allocate state for per-CPU stats. */

Loading…
Cancel
Save