Merge ^/head r327624 through r327885.
This commit is contained in:
commit
c79126f2e4
@ -144,7 +144,7 @@ TEST_SYSTEM_COMPILER_VARS= \
|
||||
WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
|
||||
CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
|
||||
COMPILER_FREEBSD_VERSION \
|
||||
LINKER_TYPE LINKER_VERSION
|
||||
LINKER_TYPE LINKER_FEATURES LINKER_VERSION
|
||||
test-system-compiler: .PHONY
|
||||
.for v in ${TEST_SYSTEM_COMPILER_VARS}
|
||||
${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
|
||||
@ -178,6 +178,7 @@ _COMPILER_METADATA_VARS= COMPILER_VERSION \
|
||||
COMPILER_FEATURES \
|
||||
COMPILER_FREEBSD_VERSION \
|
||||
LINKER_VERSION \
|
||||
LINKER_FEATURES \
|
||||
LINKER_TYPE
|
||||
compiler-metadata.mk: .PHONY .META
|
||||
@: > ${.TARGET}
|
||||
|
@ -35,11 +35,20 @@ LIB32WMAKEFLAGS= \
|
||||
OBJCOPY="${XOBJCOPY}"
|
||||
|
||||
.elif ${TARGET_ARCH:Mmips64*} != ""
|
||||
.if ${WANT_COMPILER_TYPE} == clang || \
|
||||
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
|
||||
.if ${TARGET_ARCH:Mmips64el*} != ""
|
||||
LIB32CPUFLAGS= -target mipsel-unknown-freebsd12.0
|
||||
.else
|
||||
LIB32CPUFLAGS= -target mips-unknown-freebsd12.0
|
||||
.endif
|
||||
.else
|
||||
.if empty(TARGET_CPUTYPE)
|
||||
LIB32CPUFLAGS= -march=mips3
|
||||
.else
|
||||
LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
|
||||
.endif
|
||||
.endif
|
||||
LIB32CPUFLAGS+= -mabi=32
|
||||
LIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips
|
||||
.if ${TARGET_ARCH:Mmips64el*} != ""
|
||||
|
@ -155,6 +155,27 @@ OLD_FILES+=usr/lib/clang/5.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_
|
||||
OLD_DIRS+=usr/lib/clang/5.0.1/lib/freebsd
|
||||
OLD_DIRS+=usr/lib/clang/5.0.1/lib
|
||||
OLD_DIRS+=usr/lib/clang/5.0.1
|
||||
# 20180109: Remove vestiges of digi(4) driver
|
||||
OLD_FILES+=usr/include/sys/digiio.h
|
||||
OLD_FILES+=usr/sbin/digictl
|
||||
OLD_FILES+=usr/share/man/man8/digictl.8.gz
|
||||
# 20180107: Convert remaining geli(8) tests to ATF
|
||||
OLD_FILES+=tests/sys/geom/class/eli/nokey_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/readonly_test.sh
|
||||
# 20180106: Convert most geli(8) tests to ATF
|
||||
OLD_FILES+=tests/sys/geom/class/eli/attach_d_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/configure_b_B_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/detach_l_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/init_B_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/init_J_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/init_a_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/init_alias_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/init_i_P_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/integrity_copy_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/integrity_data_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/integrity_hmac_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/onetime_a_test.sh
|
||||
OLD_FILES+=tests/sys/geom/class/eli/onetime_d_test.sh
|
||||
# 20171230: Remove /etc/skel from mtree
|
||||
OLD_DIRS+=/etc/skel
|
||||
# 20171208: Remove basename_r(3)
|
||||
|
20
UPDATING
20
UPDATING
@ -51,6 +51,20 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
|
||||
|
||||
****************************** SPECIAL WARNING: ******************************
|
||||
|
||||
20180110:
|
||||
LLVM's lld linker is now used as the FreeBSD/amd64 bootstrap linker.
|
||||
This means it is used to link the kernel and userland libraries and
|
||||
executables, but is not yet installed as /usr/bin/ld by default.
|
||||
|
||||
To revert to ld.bfd as the bootstrap linker, in /etc/src.conf set
|
||||
WITHOUT_LLD_BOOTSTRAP=yes
|
||||
|
||||
20180110:
|
||||
On i386, pmtimer has been removed. Its functionality has been folded
|
||||
into apm. It was a no-op on ACPI in current for a while now (but was still
|
||||
needed on i386 in FreeBSD 11 and earlier). Users may need to remove it
|
||||
from kernel config files.
|
||||
|
||||
20180104:
|
||||
The use of RSS hash from the network card aka flowid has been
|
||||
disabled by default for lagg(4) as it's currently incompatible with
|
||||
@ -195,7 +209,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
|
||||
will create the recovery information. If you have a filesystem
|
||||
created prior to this change and wish to have a recovery block
|
||||
created for your filesystem, you can do so by running fsck in
|
||||
forground mode (i.e., do not use the -p or -y options). As it
|
||||
foreground mode (i.e., do not use the -p or -y options). As it
|
||||
starts, fsck will ask ``SAVE DATA TO FIND ALTERNATE SUPERBLOCKS''
|
||||
to which you should answer yes.
|
||||
|
||||
@ -1855,7 +1869,7 @@ COMMON ITEMS:
|
||||
do an upgrade to the new branch. This is the best-tested upgrade path,
|
||||
and has the highest probability of being successful. Please try this
|
||||
approach if you encounter problems with a major version upgrade. Since
|
||||
the stable 4.x branch point, one has generally been able to upgade from
|
||||
the stable 4.x branch point, one has generally been able to upgrade from
|
||||
anywhere in the most recent stable branch to head / current (or even the
|
||||
last couple of stable branches). See the top of this file when there's
|
||||
an exception.
|
||||
@ -1993,7 +2007,7 @@ COMMON ITEMS:
|
||||
for potential gotchas. The -U option is also useful to consider.
|
||||
See mergemaster(8) for more information.
|
||||
|
||||
[5] Usually this step is a noop. However, from time to time
|
||||
[5] Usually this step is a no-op. However, from time to time
|
||||
you may need to do this if you get unknown user in the following
|
||||
step. It never hurts to do it all the time. You may need to
|
||||
install a new mergemaster (cd src/usr.sbin/mergemaster && make
|
||||
|
@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <locale.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
34
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/env/tst.setenv3.ksh
vendored
Normal file
34
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/env/tst.setenv3.ksh
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# Reset an environment variable we already know to be set.
|
||||
# Regression test for FreeBSD r327794.
|
||||
#
|
||||
|
||||
if [ $# != 1 ]; then
|
||||
echo expected one argument: '<'dtrace-path'>'
|
||||
exit 2
|
||||
fi
|
||||
|
||||
dtrace=$1
|
||||
|
||||
$dtrace -q -Z -n doogle -xsetenv=PATH=/foo -c '/usr/bin/printenv PATH'
|
||||
|
||||
exit $?
|
2
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/env/tst.setenv3.ksh.out
vendored
Normal file
2
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/env/tst.setenv3.ksh.out
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/foo
|
||||
|
@ -415,7 +415,7 @@ dt_opt_setenv(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
|
||||
{
|
||||
char **p;
|
||||
char *var;
|
||||
int i;
|
||||
int nvars;
|
||||
|
||||
/*
|
||||
* We can't effectively set environment variables from #pragma lines
|
||||
@ -430,7 +430,7 @@ dt_opt_setenv(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
|
||||
if (!option && strchr(arg, '=') != NULL)
|
||||
return (dt_set_errno(dtp, EDT_BADOPTVAL));
|
||||
|
||||
for (i = 1, p = dtp->dt_proc_env; *p != NULL; i++, p++)
|
||||
for (nvars = 0, p = dtp->dt_proc_env; *p != NULL; nvars++, p++)
|
||||
continue;
|
||||
|
||||
for (p = dtp->dt_proc_env; *p != NULL; p++) {
|
||||
@ -439,9 +439,9 @@ dt_opt_setenv(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
|
||||
var = *p + strlen(*p);
|
||||
if (strncmp(*p, arg, var - *p) == 0) {
|
||||
dt_free(dtp, *p);
|
||||
*p = dtp->dt_proc_env[i - 1];
|
||||
dtp->dt_proc_env[i - 1] = NULL;
|
||||
i--;
|
||||
*p = dtp->dt_proc_env[nvars - 1];
|
||||
dtp->dt_proc_env[nvars - 1] = NULL;
|
||||
nvars--;
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,17 +449,18 @@ dt_opt_setenv(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
|
||||
if ((var = strdup(arg)) == NULL)
|
||||
return (dt_set_errno(dtp, EDT_NOMEM));
|
||||
|
||||
if ((p = dt_alloc(dtp, sizeof (char *) * (i + 1))) == NULL) {
|
||||
nvars++;
|
||||
if ((p = dt_alloc(dtp, sizeof(char *) * (nvars + 1))) == NULL) {
|
||||
dt_free(dtp, var);
|
||||
return (dt_set_errno(dtp, EDT_NOMEM));
|
||||
}
|
||||
|
||||
bcopy(dtp->dt_proc_env, p, sizeof (char *) * i);
|
||||
bcopy(dtp->dt_proc_env, p, sizeof(char *) * nvars);
|
||||
dt_free(dtp, dtp->dt_proc_env);
|
||||
dtp->dt_proc_env = p;
|
||||
|
||||
dtp->dt_proc_env[i - 1] = var;
|
||||
dtp->dt_proc_env[i] = NULL;
|
||||
dtp->dt_proc_env[nvars - 1] = var;
|
||||
dtp->dt_proc_env[nvars] = NULL;
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
@ -15,6 +15,8 @@ ${PACKAGE}FILES= \
|
||||
tst.setenv1.ksh.out \
|
||||
tst.setenv2.ksh \
|
||||
tst.setenv2.ksh.out \
|
||||
tst.setenv3.ksh \
|
||||
tst.setenv3.ksh.out \
|
||||
tst.unsetenv1.ksh \
|
||||
tst.unsetenv1.ksh.out \
|
||||
tst.unsetenv2.ksh \
|
||||
|
@ -352,6 +352,7 @@ static const char *prefixes[] = {
|
||||
"Relnotes:",
|
||||
"Security:",
|
||||
"Sponsored by:",
|
||||
"Pull Request:",
|
||||
"Differential Revision:",
|
||||
};
|
||||
|
||||
@ -443,6 +444,7 @@ svn_cl__get_log_message(const char **log_msg,
|
||||
if (sponsored_by != NULL)
|
||||
svn_stringbuf_appendcstr(default_msg, sponsored_by);
|
||||
svn_stringbuf_appendcstr(default_msg, APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, "Pull Request:\t" APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, "Differential Revision:\t" APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, EDITOR_EOF_PREFIX);
|
||||
svn_stringbuf_appendcstr(default_msg, APR_EOL_STR);
|
||||
@ -458,6 +460,7 @@ svn_cl__get_log_message(const char **log_msg,
|
||||
svn_stringbuf_appendcstr(default_msg, "> Relnotes: Set to 'yes' for mention in release notes." APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, "> Security: Vulnerability reference (one per line) or description." APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, "> Sponsored by: If the change was sponsored by an organization." APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, "> Pull Request: https://github.com/freebsd/freebsd/pull/### (*full* GitHub URL needed)." APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, "> Differential Revision: https://reviews.freebsd.org/D### (*full* phabric URL needed)." APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, "> Empty fields above will be automatically removed." APR_EOL_STR);
|
||||
svn_stringbuf_appendcstr(default_msg, APR_EOL_STR);
|
||||
|
@ -536,6 +536,8 @@
|
||||
usr.bin
|
||||
apply
|
||||
..
|
||||
awk
|
||||
..
|
||||
basename
|
||||
..
|
||||
bmake
|
||||
@ -734,6 +736,8 @@
|
||||
..
|
||||
uniq
|
||||
..
|
||||
vmstat
|
||||
..
|
||||
xargs
|
||||
..
|
||||
xinstall
|
||||
|
@ -144,9 +144,9 @@ ntpd_fetch_leapfile() {
|
||||
done
|
||||
ntp_ver_no_tmp=$(get_ntp_leapfile_ver $ntp_tmp_leapfile)
|
||||
ntp_expiry_tmp=$(get_ntp_leapfile_expiry $ntp_tmp_leapfile)
|
||||
if [ "$ntp_ver_no_tmp" -gt "$ntp_ver_no_db" -o \
|
||||
"$ntp_ver_no_tmp" -eq "$ntp_ver_no_db" -a \
|
||||
"$ntp_expiry_tmp" -gt "$ntp_expiry_db" ]; then
|
||||
if [ "$ntp_expiry_tmp" -gt "$ntp_expiry_db" -o \
|
||||
"$ntp_expiry_tmp" -eq "$ntp_expiry_db" -a \
|
||||
"$ntp_ver_no_tmp" -gt "$ntp_ver_no_db" ]; then
|
||||
$verbose using $url as $ntp_db_leapfile
|
||||
mv $ntp_tmp_leapfile $ntp_db_leapfile
|
||||
else
|
||||
|
@ -304,7 +304,7 @@ int radixsort(const unsigned char **, int, const unsigned char *,
|
||||
unsigned);
|
||||
void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
|
||||
__alloc_size(3);
|
||||
void *reallocf(void *, size_t) __alloc_size(2);
|
||||
void *reallocf(void *, size_t) __result_use_check __alloc_size(2);
|
||||
int rpmatch(const char *);
|
||||
void setprogname(const char *);
|
||||
int sradixsort(const unsigned char **, int, const unsigned char *,
|
||||
|
@ -24,4 +24,14 @@ CFLAGS+=-I${.CURDIR}
|
||||
HAS_TESTS=
|
||||
SUBDIR.${MK_TESTS}+= tests
|
||||
|
||||
MAN+= cap_dns.3
|
||||
|
||||
MLINKS+=cap_dns.3 libcap_dns.3
|
||||
MLINKS+=cap_dns.3 cap_gethostbyname.3
|
||||
MLINKS+=cap_dns.3 cap_gethostbyname2.3
|
||||
MLINKS+=cap_dns.3 cap_gethostbyaddr.3
|
||||
MLINKS+=cap_dns.3 cap_getnameinfo.3
|
||||
MLINKS+=cap_dns.3 cap_dns_type_limit.3
|
||||
MLINKS+=cap_dns.3 cap_dns_family_limit.3
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
205
lib/libcasper/services/cap_dns/cap_dns.3
Normal file
205
lib/libcasper/services/cap_dns/cap_dns.3
Normal file
@ -0,0 +1,205 @@
|
||||
.\" Copyright (c) 2018 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" 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 AUTHORS 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 AUTHORS 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 January 10, 2018
|
||||
.Dt CAP_DNS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm cap_gethostbyname ,
|
||||
.Nm cap_gethostbyname2 ,
|
||||
.Nm cap_gethostbyaddr ,
|
||||
.Nm cap_getnameinfo ,
|
||||
.Nm cap_dns_type_limit ,
|
||||
.Nm cap_dns_family_limit
|
||||
.Nd "library for getting network host entry in capability mode"
|
||||
.Sh LIBRARY
|
||||
.Lb libcap_dns
|
||||
.Sh SYNOPSIS
|
||||
.In sys/nv.h
|
||||
.In libcasper.h
|
||||
.In casper/cap_dns.h
|
||||
.Ft "struct hostent *"
|
||||
.Fn cap_gethostbyname "const cap_channel_t *chan" "const char *name"
|
||||
.Ft "struct hostent *"
|
||||
.Fn cap_gethostbyname2 "const cap_channel_t *chan" "const char *name" "int af"
|
||||
.Ft "struct hostent *"
|
||||
.Fn cap_gethostbyaddr "const cap_channel_t *chan" "const void *addr" "socklen_t len" "int af"
|
||||
.Ft "int"
|
||||
.Fn cap_getnameinfo "const cap_channel_t *chan" "const void *name" "int namelen"
|
||||
.Ft "int"
|
||||
.Fn cap_dns_type_limit "cap_channel_t *chan" "const char * const *types" "size_t ntypes"
|
||||
.Ft "int"
|
||||
.Fn cap_dns_family_limit "const cap_channel_t *chan" "const int *families" "size_t nfamilies"
|
||||
.Sh DESCRIPTION
|
||||
The functions
|
||||
.Fn cap_gethostbyname ,
|
||||
.Fn cap_gethostbyname2 ,
|
||||
.Fn cep_gethostbyaddr
|
||||
and
|
||||
.Fn cap_getnameinfo
|
||||
are respectively equivalent to
|
||||
.Xr gethostbyname 2 ,
|
||||
.Xr gethostbyname2 2 ,
|
||||
.Xr gethostbyaddr 2
|
||||
and
|
||||
.Xr getnameinfo 2
|
||||
except that the connection to the
|
||||
.Nm system.dns
|
||||
service needs to be provided.
|
||||
.Pp
|
||||
The
|
||||
.Fn cap_dns_type_limit
|
||||
function limits the functions allowed in the service.
|
||||
The
|
||||
.Fa types
|
||||
variable can be set to
|
||||
.Dv ADDR
|
||||
or
|
||||
.Dv NAME .
|
||||
See the
|
||||
.Sx LIMITS
|
||||
section for more details.
|
||||
The
|
||||
.Fa ntpyes
|
||||
variable contains the number of
|
||||
.Fa types
|
||||
provided.
|
||||
.Pp
|
||||
The
|
||||
.Fn cap_dns_family_limit
|
||||
functions allows to limit address families.
|
||||
For details see
|
||||
.Sx LIMITS .
|
||||
The
|
||||
.Fa nfamilies
|
||||
variable contains the number of
|
||||
.Fa families
|
||||
provided.
|
||||
.Sh LIMITS
|
||||
The preferred way of setting limits is to use the
|
||||
.Fn cap_dns_type_limit
|
||||
and
|
||||
.Fn cap_dns_family_limit
|
||||
functions, but the limits of service can be set also using
|
||||
.Xr cap_limit_set 3 .
|
||||
The nvlist for that function can contain the following values and types:
|
||||
.Bl -ohang -offset indent
|
||||
.It type ( NV_TYPE_STRING )
|
||||
The
|
||||
.Va type
|
||||
can have two values:
|
||||
.Dv ADDR
|
||||
or
|
||||
.Dv NAME .
|
||||
The
|
||||
.Dv ADDR
|
||||
means that functions
|
||||
.Fn cap_gethostbyname ,
|
||||
.Fn cap_gethostbyname2
|
||||
and
|
||||
.Fn cap_gethostbyaddr
|
||||
are allowed.
|
||||
In case when
|
||||
.Va type
|
||||
is set to
|
||||
.Dv NAME
|
||||
the
|
||||
.Fn cap_getnameinfo
|
||||
function is allowed.
|
||||
.It family ( NV_TYPE_NUMBER )
|
||||
The
|
||||
.Va family
|
||||
limits service to one of the address families (e.g.
|
||||
.Dv AF_INET , AF_INET6 ,
|
||||
etc.).
|
||||
.Sh EXAMPLES
|
||||
The following example first opens a capability to casper and then uses this
|
||||
capability to create the
|
||||
.Nm system.dns
|
||||
casper service and uses it to resolve an IP address.
|
||||
.Bd -literal
|
||||
cap_channel_t *capcas, *capdns;
|
||||
const char *typelimit = "ADDR";
|
||||
int familylimit;
|
||||
const char *ipstr = "127.0.0.1";
|
||||
struct in_addr ip;
|
||||
struct hostent *hp;
|
||||
|
||||
/* Open capability to Casper. */
|
||||
capcas = cap_init();
|
||||
if (capcas == NULL)
|
||||
err(1, "Unable to contact Casper");
|
||||
|
||||
/* Enter capability mode sandbox. */
|
||||
if (cap_enter() < 0 && errno != ENOSYS)
|
||||
err(1, "Unable to enter capability mode");
|
||||
|
||||
/* Use Casper capability to create capability to the system.dns service. */
|
||||
capdns = cap_service_open(capcas, "system.dns");
|
||||
if (capdns == NULL)
|
||||
err(1, "Unable to open system.dns service");
|
||||
|
||||
/* Close Casper capability, we don't need it anymore. */
|
||||
cap_close(capcas);
|
||||
|
||||
/* Limit system.dns to reverse DNS lookups. */
|
||||
if (cap_dns_type_limit(capdns, &typelimit, 1) < 0)
|
||||
err(1, "Unable to limit access to the system.dns service");
|
||||
|
||||
/* Limit system.dns to reserve IPv4 addresses */
|
||||
familylimit = AF_INET;
|
||||
if (cap_dns_family_limit(capdns, &familylimit, 1) < 0)
|
||||
err(1, "Unable to limit access to the system.dns service");
|
||||
|
||||
/* Convert IP address in C-string to in_addr. */
|
||||
if (!inet_aton(ipstr, &ip))
|
||||
errx(1, "Unable to parse IP address %s.", ipstr);
|
||||
|
||||
/* Find hostname for the given IP address. */
|
||||
hp = cap_gethostbyaddr(capdns, (const void *)&ip, sizeof(ip), AF_INET);
|
||||
if (hp == NULL)
|
||||
errx(1, "No name associated with %s.", ipstr);
|
||||
|
||||
printf("Name associated with %s is %s.\\n", ipstr, hp->h_name);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr cap_enter 2 ,
|
||||
.Xr err 3 ,
|
||||
.Xr gethostbyaddr 3 ,
|
||||
.Xr gethostbyname 3 ,
|
||||
.Xr gethostbyname2 3 ,
|
||||
.Xr getnameinfo 3,
|
||||
.Xr nv 3 ,
|
||||
.Xr capsicum 4
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm cap_dns
|
||||
service was implemented by
|
||||
.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net
|
||||
under sponsorship from the FreeBSD Foundation.
|
||||
.Pp
|
||||
This manual page was written by
|
||||
.An Mariusz Zaborski Aq Mt oshogbo@FreeBSD.org .
|
@ -275,6 +275,12 @@ camcontrol_optret getoption(struct camcontrol_opts *table, char *arg,
|
||||
static int getdevlist(struct cam_device *device);
|
||||
#endif /* MINIMALISTIC */
|
||||
static int getdevtree(int argc, char **argv, char *combinedopt);
|
||||
static int print_dev_scsi(struct device_match_result *dev_result, char *tmpstr);
|
||||
static int print_dev_ata(struct device_match_result *dev_result, char *tmpstr);
|
||||
static int print_dev_semb(struct device_match_result *dev_result, char *tmpstr);
|
||||
static int print_dev_mmcsd(struct device_match_result *dev_result,
|
||||
char *tmpstr);
|
||||
static int print_dev_nvme(struct device_match_result *dev_result, char *tmpstr);
|
||||
#ifndef MINIMALISTIC
|
||||
static int testunitready(struct cam_device *device, int task_attr,
|
||||
int retry_count, int timeout, int quiet);
|
||||
@ -554,8 +560,7 @@ getdevtree(int argc, char **argv, char *combinedopt)
|
||||
}
|
||||
case DEV_MATCH_DEVICE: {
|
||||
struct device_match_result *dev_result;
|
||||
char vendor[16], product[48], revision[16];
|
||||
char fw[5], tmpstr[256];
|
||||
char tmpstr[256];
|
||||
|
||||
if (busonly == 1)
|
||||
break;
|
||||
@ -572,57 +577,36 @@ getdevtree(int argc, char **argv, char *combinedopt)
|
||||
skip_device = 0;
|
||||
|
||||
if (dev_result->protocol == PROTO_SCSI) {
|
||||
cam_strvis(vendor, dev_result->inq_data.vendor,
|
||||
sizeof(dev_result->inq_data.vendor),
|
||||
sizeof(vendor));
|
||||
cam_strvis(product,
|
||||
dev_result->inq_data.product,
|
||||
sizeof(dev_result->inq_data.product),
|
||||
sizeof(product));
|
||||
cam_strvis(revision,
|
||||
dev_result->inq_data.revision,
|
||||
sizeof(dev_result->inq_data.revision),
|
||||
sizeof(revision));
|
||||
sprintf(tmpstr, "<%s %s %s>", vendor, product,
|
||||
revision);
|
||||
if (print_dev_scsi(dev_result,
|
||||
&tmpstr[0]) != 0) {
|
||||
skip_device = 1;
|
||||
break;
|
||||
}
|
||||
} else if (dev_result->protocol == PROTO_ATA ||
|
||||
dev_result->protocol == PROTO_SATAPM) {
|
||||
cam_strvis(product,
|
||||
dev_result->ident_data.model,
|
||||
sizeof(dev_result->ident_data.model),
|
||||
sizeof(product));
|
||||
cam_strvis(revision,
|
||||
dev_result->ident_data.revision,
|
||||
sizeof(dev_result->ident_data.revision),
|
||||
sizeof(revision));
|
||||
sprintf(tmpstr, "<%s %s>", product,
|
||||
revision);
|
||||
} else if (dev_result->protocol == PROTO_MMCSD) {
|
||||
if (strlen(dev_result->mmc_ident_data.model) > 0) {
|
||||
sprintf(tmpstr, "<%s>", dev_result->mmc_ident_data.model);
|
||||
} else {
|
||||
sprintf(tmpstr, "<%s card>",
|
||||
dev_result->mmc_ident_data.card_features & CARD_FEATURE_SDIO ? "SDIO" : "unknown");
|
||||
if (print_dev_ata(dev_result,
|
||||
&tmpstr[0]) != 0) {
|
||||
skip_device = 1;
|
||||
break;
|
||||
}
|
||||
} else if (dev_result->protocol == PROTO_MMCSD){
|
||||
if (print_dev_mmcsd(dev_result,
|
||||
&tmpstr[0]) != 0) {
|
||||
skip_device = 1;
|
||||
break;
|
||||
}
|
||||
} else if (dev_result->protocol == PROTO_SEMB) {
|
||||
struct sep_identify_data *sid;
|
||||
|
||||
sid = (struct sep_identify_data *)
|
||||
&dev_result->ident_data;
|
||||
cam_strvis(vendor, sid->vendor_id,
|
||||
sizeof(sid->vendor_id),
|
||||
sizeof(vendor));
|
||||
cam_strvis(product, sid->product_id,
|
||||
sizeof(sid->product_id),
|
||||
sizeof(product));
|
||||
cam_strvis(revision, sid->product_rev,
|
||||
sizeof(sid->product_rev),
|
||||
sizeof(revision));
|
||||
cam_strvis(fw, sid->firmware_rev,
|
||||
sizeof(sid->firmware_rev),
|
||||
sizeof(fw));
|
||||
sprintf(tmpstr, "<%s %s %s %s>",
|
||||
vendor, product, revision, fw);
|
||||
if (print_dev_semb(dev_result,
|
||||
&tmpstr[0]) != 0) {
|
||||
skip_device = 1;
|
||||
break;
|
||||
}
|
||||
} else if (dev_result->protocol == PROTO_NVME) {
|
||||
if (print_dev_nvme(dev_result,
|
||||
&tmpstr[0]) != 0) {
|
||||
skip_device = 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sprintf(tmpstr, "<>");
|
||||
}
|
||||
@ -678,6 +662,122 @@ getdevtree(int argc, char **argv, char *combinedopt)
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
print_dev_scsi(struct device_match_result *dev_result, char *tmpstr)
|
||||
{
|
||||
char vendor[16], product[48], revision[16];
|
||||
|
||||
cam_strvis(vendor, dev_result->inq_data.vendor,
|
||||
sizeof(dev_result->inq_data.vendor), sizeof(vendor));
|
||||
cam_strvis(product, dev_result->inq_data.product,
|
||||
sizeof(dev_result->inq_data.product), sizeof(product));
|
||||
cam_strvis(revision, dev_result->inq_data.revision,
|
||||
sizeof(dev_result->inq_data.revision), sizeof(revision));
|
||||
sprintf(tmpstr, "<%s %s %s>", vendor, product, revision);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
print_dev_ata(struct device_match_result *dev_result, char *tmpstr)
|
||||
{
|
||||
char product[48], revision[16];
|
||||
|
||||
cam_strvis(product, dev_result->ident_data.model,
|
||||
sizeof(dev_result->ident_data.model), sizeof(product));
|
||||
cam_strvis(revision, dev_result->ident_data.revision,
|
||||
sizeof(dev_result->ident_data.revision), sizeof(revision));
|
||||
sprintf(tmpstr, "<%s %s>", product, revision);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
print_dev_semb(struct device_match_result *dev_result, char *tmpstr)
|
||||
{
|
||||
struct sep_identify_data *sid;
|
||||
char vendor[16], product[48], revision[16], fw[5];
|
||||
|
||||
sid = (struct sep_identify_data *)&dev_result->ident_data;
|
||||
cam_strvis(vendor, sid->vendor_id,
|
||||
sizeof(sid->vendor_id), sizeof(vendor));
|
||||
cam_strvis(product, sid->product_id,
|
||||
sizeof(sid->product_id), sizeof(product));
|
||||
cam_strvis(revision, sid->product_rev,
|
||||
sizeof(sid->product_rev), sizeof(revision));
|
||||
cam_strvis(fw, sid->firmware_rev,
|
||||
sizeof(sid->firmware_rev), sizeof(fw));
|
||||
sprintf(tmpstr, "<%s %s %s %s>", vendor, product, revision, fw);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
print_dev_mmcsd(struct device_match_result *dev_result, char *tmpstr)
|
||||
{
|
||||
|
||||
if (strlen(dev_result->mmc_ident_data.model) > 0) {
|
||||
sprintf(tmpstr, "<%s>", dev_result->mmc_ident_data.model);
|
||||
} else {
|
||||
sprintf(tmpstr, "<%s card>",
|
||||
dev_result->mmc_ident_data.card_features &
|
||||
CARD_FEATURE_SDIO ? "SDIO" : "unknown");
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
print_dev_nvme(struct device_match_result *dev_result, char *tmpstr)
|
||||
{
|
||||
union ccb *ccb;
|
||||
struct ccb_dev_advinfo *advi;
|
||||
struct cam_device *dev;
|
||||
struct nvme_controller_data cdata;
|
||||
char vendor[64], product[64];
|
||||
|
||||
dev = cam_open_btl(dev_result->path_id, dev_result->target_id,
|
||||
dev_result->target_lun, O_RDWR, NULL);
|
||||
if (dev == NULL) {
|
||||
warnx("%s", cam_errbuf);
|
||||
return (1);
|
||||
}
|
||||
|
||||
ccb = cam_getccb(dev);
|
||||
if (ccb == NULL) {
|
||||
warnx("couldn't allocate CCB");
|
||||
cam_close_device(dev);
|
||||
return (1);
|
||||
}
|
||||
|
||||
advi = &ccb->cdai;
|
||||
advi->ccb_h.flags = CAM_DIR_IN;
|
||||
advi->ccb_h.func_code = XPT_DEV_ADVINFO;
|
||||
advi->flags = CDAI_FLAG_NONE;
|
||||
advi->buftype = CDAI_TYPE_NVME_CNTRL;
|
||||
advi->bufsiz = sizeof(struct nvme_controller_data);
|
||||
advi->buf = (uint8_t *)&cdata;
|
||||
|
||||
if (cam_send_ccb(dev, ccb) < 0) {
|
||||
warn("error sending CAMIOCOMMAND ioctl");
|
||||
cam_freeccb(ccb);
|
||||
cam_close_device(dev);
|
||||
return(1);
|
||||
}
|
||||
if (advi->ccb_h.status != CAM_REQ_CMP) {
|
||||
warnx("got CAM error %#x", advi->ccb_h.status);
|
||||
cam_freeccb(ccb);
|
||||
cam_close_device(dev);
|
||||
return(1);
|
||||
}
|
||||
cam_strvis(vendor, cdata.mn, sizeof(cdata.mn), sizeof(vendor));
|
||||
cam_strvis(product, cdata.fr, sizeof(cdata.fr), sizeof(product));
|
||||
sprintf(tmpstr, "<%s %s>", vendor, product);
|
||||
|
||||
cam_freeccb(ccb);
|
||||
cam_close_device(dev);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef MINIMALISTIC
|
||||
static int
|
||||
testunitready(struct cam_device *device, int task_attr, int retry_count,
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dhcpd.h"
|
||||
#include "dhctoken.h"
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 19, 2013
|
||||
.Dd January 6, 2018
|
||||
.Dt LDCONFIG 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -58,7 +58,9 @@ the overhead that would otherwise result from the directory search
|
||||
operations the dynamic linker would have to perform to load the
|
||||
required shared libraries.
|
||||
.Pp
|
||||
Files named on the command line are expected to contain directories
|
||||
Alternatively,
|
||||
.Ar files
|
||||
may be specified; these are expected to contain directories
|
||||
to scan for shared libraries.
|
||||
Each directory's pathname must start on a new
|
||||
line.
|
||||
@ -157,9 +159,10 @@ file.
|
||||
In particular, the
|
||||
.Ev LD_LIBRARY_PATH
|
||||
is not used to search for libraries.
|
||||
Thus, the role of ldconfig is dual.
|
||||
In
|
||||
addition to building a set of hints for quick lookup, it also serves to
|
||||
Thus, the role of
|
||||
.Nm
|
||||
is dual.
|
||||
In addition to building a set of hints for quick lookup, it also serves to
|
||||
specify the trusted collection of directories from which shared objects can
|
||||
be safely loaded.
|
||||
.Sh FILES
|
||||
|
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 2, 2018
|
||||
.Dd January 6, 2018
|
||||
.Dt AW_SID 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -52,6 +52,8 @@ allwinner,sun7i-a20-sid
|
||||
allwinner,sun50i-a64-sid
|
||||
.It
|
||||
allwinner,sun8i-a83t-sid
|
||||
.It
|
||||
allwinner,sun8i-h3-sid
|
||||
.El
|
||||
.Sh SYSCTL VARIABLES
|
||||
The following read-only variables are available via
|
||||
|
@ -23,7 +23,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 7, 2008
|
||||
.Dd January 6, 2018
|
||||
.Dt SMP 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -57,6 +57,11 @@ The
|
||||
.Xr mptable 1
|
||||
command may be used to view the status of multi-processor support.
|
||||
.Pp
|
||||
.Nm
|
||||
support can be disabled by setting the loader tunable
|
||||
.Va kern.smp.disabled
|
||||
to 1.
|
||||
.Pp
|
||||
The number of CPUs detected by the system is available in
|
||||
the read-only sysctl variable
|
||||
.Va hw.ncpu .
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" @(#)core.5 8.3 (Berkeley) 12/11/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 5, 2015
|
||||
.Dd January 8, 2018
|
||||
.Dt CORE 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -67,8 +67,8 @@ generating it).
|
||||
.Pp
|
||||
The following format specifiers may be used in the
|
||||
.Va kern.corefile
|
||||
sysctl to insert additional information into the resulting core file
|
||||
name:
|
||||
sysctl to insert additional information into the resulting core
|
||||
filename:
|
||||
.Bl -tag -width "1234567890" -compact -offset "12345"
|
||||
.It Em \&%H
|
||||
Machine hostname.
|
||||
@ -108,17 +108,17 @@ is included in the kernel configuration file:
|
||||
GZIO
|
||||
.El
|
||||
.Pp
|
||||
When the GZIO option is included, the following sysctls control whether core
|
||||
files will be compressed:
|
||||
.Bl -tag -width "kern.compress_user_cores_gzlevel" -compact -offset "12345"
|
||||
.It Em kern.compress_user_cores_gzlevel
|
||||
Gzip compression level.
|
||||
Defaults to 6.
|
||||
The following sysctl control core file compression:
|
||||
.Bl -tag -width "kern.compress_user_cores_level" -compact -offset "12345"
|
||||
.It Em kern.compress_user_cores
|
||||
Actually compress user cores.
|
||||
Compressed core files will have a suffix of
|
||||
Enable compression of user cores.
|
||||
A value of 1 configures gzip compression.
|
||||
gzip-compressed core files will have a suffix of
|
||||
.Ql .gz
|
||||
appended to them.
|
||||
appended to their filenames.
|
||||
.It Em kern.compress_user_cores_level
|
||||
Compression level.
|
||||
Defaults to 6.
|
||||
.El
|
||||
.Sh NOTES
|
||||
Corefiles are written with open file descriptor information as an ELF note.
|
||||
@ -153,6 +153,7 @@ command can be used:
|
||||
.Dl sysctl kern.corefile=/var/coredumps/\&%U/\&%N.core
|
||||
.Sh SEE ALSO
|
||||
.Xr gdb 1 ,
|
||||
.Xr gzip 1 ,
|
||||
.Xr kgdb 1 ,
|
||||
.Xr setrlimit 2 ,
|
||||
.Xr sigaction 2 ,
|
||||
|
@ -1,6 +1,6 @@
|
||||
.\" DO NOT EDIT-- this file is generated by tools/build/options/makeman.
|
||||
.\" $FreeBSD$
|
||||
.Dd November 2, 2017
|
||||
.Dd January 11, 2018
|
||||
.Dt SRC.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -970,12 +970,12 @@ To be able to build the system, either Binutils or LLD bootstrap must be
|
||||
enabled unless an alternate linker is provided via XLD.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm/armv7, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, powerpc/powerpcspe, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
arm/arm, arm/armeb, arm/armv6, arm/armv7, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, powerpc/powerpcspe, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
.It Va WITH_LLD_BOOTSTRAP
|
||||
Set to build the LLD linker during the bootstrap phase of the build.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
arm64/aarch64.
|
||||
amd64/amd64, arm64/aarch64 and i386/i386.
|
||||
.It Va WITHOUT_LLD_IS_LD
|
||||
Set to use GNU binutils ld as the system linker, instead of LLVM's LLD.
|
||||
.Pp
|
||||
@ -996,6 +996,11 @@ Set to use LLVM's libunwind stack unwinder (instead of GCC's unwinder).
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm64/aarch64, i386/i386, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_LOADER_FIREWIRE
|
||||
Enable firewire support in /boot/loader and /boot/zfsloader on x86.
|
||||
This option is a nop on all other platforms.
|
||||
.It Va WITHOUT_LOADER_GELI
|
||||
Disable inclusion of GELI crypto support in the boot chain binaries.
|
||||
.It Va WITHOUT_LOCALES
|
||||
Set to not build localization files; see
|
||||
.Xr locale 1 .
|
||||
|
@ -1262,6 +1262,7 @@ MLINKS+=make_dev.9 destroy_dev.9 \
|
||||
make_dev.9 make_dev_p.9 \
|
||||
make_dev.9 make_dev_s.9
|
||||
MLINKS+=malloc.9 free.9 \
|
||||
malloc.9 mallocarray.9 \
|
||||
malloc.9 MALLOC_DECLARE.9 \
|
||||
malloc.9 MALLOC_DEFINE.9 \
|
||||
malloc.9 realloc.9 \
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd November 19, 2015
|
||||
.Dd January 10, 2018
|
||||
.Dt MALLOC 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -45,6 +45,8 @@
|
||||
.In sys/malloc.h
|
||||
.Ft void *
|
||||
.Fn malloc "unsigned long size" "struct malloc_type *type" "int flags"
|
||||
.Ft void *
|
||||
.Fn mallocarray "size_t nmemb" "size_t size" "struct malloc_type *type" "int flags"
|
||||
.Ft void
|
||||
.Fn free "void *addr" "struct malloc_type *type"
|
||||
.Ft void *
|
||||
@ -64,6 +66,14 @@ object whose size is specified by
|
||||
.Fa size .
|
||||
.Pp
|
||||
The
|
||||
.Fn mallocarray
|
||||
function allocates uninitialized memory in kernel address space for an
|
||||
array of
|
||||
.Fa nmemb
|
||||
entries whose size is specified by
|
||||
.Fa size .
|
||||
.Pp
|
||||
The
|
||||
.Fn free
|
||||
function releases memory at address
|
||||
.Fa addr
|
||||
@ -144,6 +154,7 @@ If the request cannot be immediately fulfilled, the current process is put
|
||||
to sleep to wait for resources to be released by other processes.
|
||||
The
|
||||
.Fn malloc ,
|
||||
.Fn mallocarray ,
|
||||
.Fn realloc ,
|
||||
and
|
||||
.Fn reallocf
|
||||
@ -152,6 +163,13 @@ functions cannot return
|
||||
if
|
||||
.Dv M_WAITOK
|
||||
is specified.
|
||||
If the multiplication of
|
||||
.Fa nmemb
|
||||
and
|
||||
.Fa size
|
||||
would cause an integer overflow, the
|
||||
.Fn mallocarray
|
||||
function induces a panic.
|
||||
.It Dv M_USE_RESERVE
|
||||
Indicates that the system can use its reserve of memory to satisfy the
|
||||
request.
|
||||
|
@ -253,6 +253,9 @@ __DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
|
||||
.endif
|
||||
.if ${__T} == "aarch64"
|
||||
__DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
|
||||
.elif ${__T} == "amd64" || ${__T} == "i386"
|
||||
__DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP
|
||||
__DEFAULT_NO_OPTIONS+=LLD_IS_LD
|
||||
.else
|
||||
__DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
|
||||
.endif
|
||||
|
@ -132,7 +132,8 @@ __objdir:= ${MAKEOBJDIR}
|
||||
.if ${.MAKE.LEVEL} == 0 && \
|
||||
${MK_AUTO_OBJ} == "no" && empty(.MAKEOVERRIDES:MMK_AUTO_OBJ) && \
|
||||
!defined(WITHOUT_AUTO_OBJ) && !make(showconfig) && !make(print-dir) && \
|
||||
!defined(NO_OBJ)
|
||||
!defined(NO_OBJ) && \
|
||||
empty(RELDIR:Msys/*/compile/*)
|
||||
# Find the last existing directory component and check if we can write to it.
|
||||
# If the last component is a symlink then recurse on the new path.
|
||||
CheckAutoObj= \
|
||||
|
@ -115,6 +115,7 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata,
|
||||
/* XXX, definitions not available on i386. */
|
||||
#define R_X86_64_64 1
|
||||
#define R_X86_64_RELATIVE 8
|
||||
#define R_X86_64_IRELATIVE 37
|
||||
|
||||
switch (rtype) {
|
||||
case R_X86_64_64: /* S + A */
|
||||
@ -129,6 +130,9 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata,
|
||||
val = addr;
|
||||
*where = val;
|
||||
break;
|
||||
case R_X86_64_IRELATIVE:
|
||||
/* leave it to kernel */
|
||||
break;
|
||||
default:
|
||||
printf("\nunhandled relocation type %u\n", (u_int)rtype);
|
||||
return (EFTYPE);
|
||||
@ -173,6 +177,7 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata,
|
||||
#define R_386_32 1 /* Add symbol value. */
|
||||
#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */
|
||||
#define R_386_RELATIVE 8 /* Add load address of shared object. */
|
||||
#define R_386_IRELATIVE 42
|
||||
|
||||
switch (rtype) {
|
||||
case R_386_RELATIVE:
|
||||
@ -186,6 +191,9 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata,
|
||||
val = addr + addend;
|
||||
*where = val;
|
||||
break;
|
||||
case R_386_IRELATIVE:
|
||||
/* leave it to kernel */
|
||||
break;
|
||||
default:
|
||||
printf("\nunhandled relocation type %u\n", (u_int)rtype);
|
||||
return (EFTYPE);
|
||||
|
@ -110,7 +110,7 @@ boot1.efi: ${PROG}
|
||||
# The following inserts our objects into a template FAT file system
|
||||
# created by generate-fat.sh
|
||||
|
||||
.include "${.CURDIR}/Makefile.fat"
|
||||
.include "Makefile.fat"
|
||||
|
||||
boot1.efifat: boot1.efi
|
||||
@set -- `ls -l ${.ALLSRC}`; \
|
||||
@ -120,7 +120,7 @@ boot1.efifat: boot1.efi
|
||||
exit 1; \
|
||||
fi
|
||||
echo ${.OBJDIR}
|
||||
xz -d -c ${.CURDIR}/fat-${MACHINE}.tmpl.xz > ${.TARGET}
|
||||
xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET}
|
||||
${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
|
||||
|
||||
CLEANFILES+= boot1.efi boot1.efifat
|
||||
|
@ -55,6 +55,7 @@ static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL;
|
||||
static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL;
|
||||
static EFI_GUID ConsoleControlGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
|
||||
static EFI_GUID FreeBSDBootVarGUID = FREEBSD_BOOT_VAR_GUID;
|
||||
static EFI_GUID GlobalBootVarGUID = UEFI_BOOT_VAR_GUID;
|
||||
|
||||
/*
|
||||
* Provide Malloc / Free backed by EFIs AllocatePool / FreePool which ensures
|
||||
@ -79,6 +80,25 @@ Free(void *buf, const char *file __unused, int line __unused)
|
||||
(void)BS->FreePool(buf);
|
||||
}
|
||||
|
||||
static EFI_STATUS
|
||||
efi_getenv(EFI_GUID *g, const char *v, void *data, size_t *len)
|
||||
{
|
||||
size_t ul;
|
||||
CHAR16 *uv;
|
||||
UINT32 attr;
|
||||
UINTN dl;
|
||||
EFI_STATUS rv;
|
||||
|
||||
utf8_to_ucs2(v, &uv, &ul);
|
||||
if (uv == NULL)
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
dl = *len;
|
||||
rv = RS->GetVariable(uv, g, &attr, &dl, data);
|
||||
if (rv == EFI_SUCCESS)
|
||||
*len = dl;
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static EFI_STATUS
|
||||
efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr)
|
||||
{
|
||||
@ -411,6 +431,9 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
|
||||
SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL;
|
||||
UINTN i, max_dim, best_mode, cols, rows, hsize, nhandles;
|
||||
CHAR16 *text;
|
||||
UINT16 boot_current;
|
||||
size_t sz;
|
||||
UINT16 boot_order[100];
|
||||
|
||||
/* Basic initialization*/
|
||||
ST = Xsystab;
|
||||
@ -480,12 +503,32 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
|
||||
}
|
||||
}
|
||||
|
||||
boot_current = 0;
|
||||
sz = sizeof(boot_current);
|
||||
efi_getenv(&GlobalBootVarGUID, "BootCurrent", &boot_current, &sz);
|
||||
printf(" BootCurrent: %04x\n", boot_current);
|
||||
|
||||
sz = sizeof(boot_order);
|
||||
efi_getenv(&GlobalBootVarGUID, "BootOrder", &boot_order, &sz);
|
||||
printf(" BootOrder:");
|
||||
for (i = 0; i < sz / sizeof(boot_order[0]); i++)
|
||||
printf(" %04x", boot_order[i]);
|
||||
printf("\n");
|
||||
|
||||
#ifdef TEST_FAILURE
|
||||
/*
|
||||
* For testing failover scenarios, it's nice to be able to fail fast.
|
||||
* Define TEST_FAILURE to create a boot1.efi that always fails after
|
||||
* reporting the boot manager protocol details.
|
||||
*/
|
||||
BS->Exit(IH, EFI_OUT_OF_RESOURCES, 0, NULL);
|
||||
#endif
|
||||
|
||||
/* Get all the device handles */
|
||||
hsize = (UINTN)NUM_HANDLES_INIT * sizeof(EFI_HANDLE);
|
||||
handles = malloc(hsize);
|
||||
if (handles == NULL) {
|
||||
if (handles == NULL)
|
||||
printf("Failed to allocate %d handles\n", NUM_HANDLES_INIT);
|
||||
}
|
||||
|
||||
status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL,
|
||||
&hsize, handles);
|
||||
|
@ -59,5 +59,7 @@ Revision History
|
||||
*/
|
||||
#define FREEBSD_BOOT_VAR_GUID \
|
||||
{ 0xCFEE69AD, 0xA0DE, 0x47A9, {0x93, 0xA8, 0xF6, 0x31, 0x06, 0xF8, 0xAE, 0x99} }
|
||||
#define UEFI_BOOT_VAR_GUID \
|
||||
{ 0x8be4df61, 0x93ca, 0x11d2, {0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c} }
|
||||
|
||||
#endif
|
||||
|
@ -128,6 +128,4 @@ char *inet_ntoa(struct in_addr);
|
||||
char *intoa(n_long); /* similar to inet_ntoa */
|
||||
n_long inet_addr(char *);
|
||||
|
||||
/* Machine-dependent functions: */
|
||||
time_t getsecs(void);
|
||||
#endif /* ! _STAND_NET_H */
|
||||
|
@ -394,6 +394,7 @@ extern void putchar(int);
|
||||
extern int devopen(struct open_file *, const char *, const char **);
|
||||
extern int devclose(struct open_file *f);
|
||||
extern void panic(const char *, ...) __dead2 __printflike(1, 2);
|
||||
extern time_t getsecs(void);
|
||||
extern struct fs_ops *file_system[];
|
||||
extern struct fs_ops *exclusive_file_system;
|
||||
extern struct devsw *devsw[];
|
||||
|
@ -118,8 +118,6 @@ static const unsigned char flags[NOPT] = {
|
||||
static const char *const dev_nm[] = {"dram", "cfi", "sdcard"};
|
||||
static const u_int dev_nm_count = nitems(dev_nm);
|
||||
|
||||
static struct dmadat __dmadat;
|
||||
|
||||
static struct dsk {
|
||||
unsigned type; /* BOOTINFO_DEV_TYPE_x object type. */
|
||||
uintptr_t unitptr; /* Unit number or pointer to object. */
|
||||
@ -149,10 +147,11 @@ static int dskread(void *, unsigned, unsigned);
|
||||
static int xputc(int);
|
||||
static int xgetc(int);
|
||||
|
||||
|
||||
#define UFS_SMALL_CGBASE
|
||||
#include "ufsread.c"
|
||||
|
||||
static struct dmadat __dmadat;
|
||||
|
||||
static inline int
|
||||
xfsread(ufs_ino_t inode, void *buf, size_t nbyte)
|
||||
{
|
||||
|
@ -33,8 +33,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stand.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -80,14 +80,14 @@ beri_elf64_exec(struct preloaded_file *fp)
|
||||
|
||||
md = file_findmetadata(fp, MODINFOMD_ELFHDR);
|
||||
if (md == NULL) {
|
||||
printf("%s: file_findmetadata failed\n");
|
||||
printf("%s: file_findmetadata failed\n", fp->f_name);
|
||||
return (EFTYPE);
|
||||
}
|
||||
ehdr = (Elf_Ehdr *)md->md_data;
|
||||
|
||||
error = md_load64(fp->f_args, &mdp);
|
||||
if (error) {
|
||||
printf("%s: md_load64 failed\n");
|
||||
printf("%s: md_load64 failed\n", fp->f_name);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ done_tss:
|
||||
movq %r8,PCPU(RSP0)
|
||||
movq %r8,PCPU(CURPCB)
|
||||
/* Update the TSS_RSP0 pointer for the next interrupt */
|
||||
movq %r8,COMMON_TSS_RSP0(%rdx)
|
||||
movq %r8,TSS_RSP0(%rdx)
|
||||
movq %r12,PCPU(CURTHREAD) /* into next thread */
|
||||
|
||||
/* Test if debug registers should be restored. */
|
||||
|
@ -410,7 +410,6 @@ IDTVEC(fast_syscall)
|
||||
movq %r14,TF_R14(%rsp) /* C preserved */
|
||||
movq %r15,TF_R15(%rsp) /* C preserved */
|
||||
movl $TF_HASSEGS,TF_FLAGS(%rsp)
|
||||
cld
|
||||
FAKE_MCOUNT(TF_RIP(%rsp))
|
||||
movq PCPU(CURTHREAD),%rdi
|
||||
movq %rsp,TD_FRAME(%rdi)
|
||||
|
@ -153,7 +153,7 @@ ASSYM(PCB_FULL_IRET, PCB_FULL_IRET);
|
||||
ASSYM(PCB_DBREGS, PCB_DBREGS);
|
||||
ASSYM(PCB_32BIT, PCB_32BIT);
|
||||
|
||||
ASSYM(COMMON_TSS_RSP0, offsetof(struct amd64tss, tss_rsp0));
|
||||
ASSYM(TSS_RSP0, offsetof(struct amd64tss, tss_rsp0));
|
||||
|
||||
ASSYM(TF_R15, offsetof(struct trapframe, tf_r15));
|
||||
ASSYM(TF_R14, offsetof(struct trapframe, tf_r14));
|
||||
|
@ -1512,6 +1512,22 @@ amd64_kdb_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set up the fast syscall stuff */
|
||||
void
|
||||
amd64_conf_fast_syscall(void)
|
||||
{
|
||||
uint64_t msr;
|
||||
|
||||
msr = rdmsr(MSR_EFER) | EFER_SCE;
|
||||
wrmsr(MSR_EFER, msr);
|
||||
wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall));
|
||||
wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32));
|
||||
msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) |
|
||||
((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48);
|
||||
wrmsr(MSR_STAR, msr);
|
||||
wrmsr(MSR_SF_MASK, PSL_NT | PSL_T | PSL_I | PSL_C | PSL_D);
|
||||
}
|
||||
|
||||
u_int64_t
|
||||
hammer_time(u_int64_t modulep, u_int64_t physfree)
|
||||
{
|
||||
@ -1520,7 +1536,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
|
||||
struct pcpu *pc;
|
||||
struct nmi_pcpu *np;
|
||||
struct xstate_hdr *xhdr;
|
||||
u_int64_t msr;
|
||||
char *env;
|
||||
size_t kstack0_sz;
|
||||
int late_console;
|
||||
@ -1663,15 +1678,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
|
||||
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
|
||||
ltr(gsel_tss);
|
||||
|
||||
/* Set up the fast syscall stuff */
|
||||
msr = rdmsr(MSR_EFER) | EFER_SCE;
|
||||
wrmsr(MSR_EFER, msr);
|
||||
wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall));
|
||||
wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32));
|
||||
msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) |
|
||||
((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48);
|
||||
wrmsr(MSR_STAR, msr);
|
||||
wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
|
||||
amd64_conf_fast_syscall();
|
||||
|
||||
/*
|
||||
* Temporary forge some valid pointer to PCB, for exception
|
||||
|
@ -89,8 +89,6 @@ extern struct pcpu __pcpu[];
|
||||
char *doublefault_stack;
|
||||
char *nmi_stack;
|
||||
|
||||
extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
|
||||
|
||||
/*
|
||||
* Local data and functions.
|
||||
*/
|
||||
@ -190,7 +188,7 @@ init_secondary(void)
|
||||
{
|
||||
struct pcpu *pc;
|
||||
struct nmi_pcpu *np;
|
||||
u_int64_t msr, cr0;
|
||||
u_int64_t cr0;
|
||||
int cpu, gsel_tss, x;
|
||||
struct region_descriptor ap_gdt;
|
||||
|
||||
@ -265,15 +263,7 @@ init_secondary(void)
|
||||
cr0 &= ~(CR0_CD | CR0_NW | CR0_EM);
|
||||
load_cr0(cr0);
|
||||
|
||||
/* Set up the fast syscall stuff */
|
||||
msr = rdmsr(MSR_EFER) | EFER_SCE;
|
||||
wrmsr(MSR_EFER, msr);
|
||||
wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall));
|
||||
wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32));
|
||||
msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) |
|
||||
((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48);
|
||||
wrmsr(MSR_STAR, msr);
|
||||
wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
|
||||
amd64_conf_fast_syscall();
|
||||
|
||||
/* signal our startup to the BSP. */
|
||||
mp_naps++;
|
||||
|
@ -50,7 +50,6 @@ ENTRY(bzero)
|
||||
movq %rsi,%rcx
|
||||
xorl %eax,%eax
|
||||
shrq $3,%rcx
|
||||
cld
|
||||
rep
|
||||
stosq
|
||||
movq %rsi,%rcx
|
||||
@ -100,7 +99,6 @@ ENTRY(bcmp)
|
||||
PUSH_FRAME_POINTER
|
||||
movq %rdx,%rcx
|
||||
shrq $3,%rcx
|
||||
cld /* compare forwards */
|
||||
repe
|
||||
cmpsq
|
||||
jne 1f
|
||||
@ -132,7 +130,6 @@ ENTRY(bcopy)
|
||||
jb 1f
|
||||
|
||||
shrq $3,%rcx /* copy by 64-bit words */
|
||||
cld /* nope, copy forwards */
|
||||
rep
|
||||
movsq
|
||||
movq %rdx,%rcx
|
||||
@ -171,7 +168,6 @@ ENTRY(memcpy)
|
||||
movq %rdi,%rax
|
||||
movq %rdx,%rcx
|
||||
shrq $3,%rcx /* copy by 64-bit words */
|
||||
cld /* copy forwards */
|
||||
rep
|
||||
movsq
|
||||
movq %rdx,%rcx
|
||||
@ -218,7 +214,6 @@ ENTRY(fillw)
|
||||
movq %rdi,%rax
|
||||
movq %rsi,%rdi
|
||||
movq %rdx,%rcx
|
||||
cld
|
||||
rep
|
||||
stosw
|
||||
POP_FRAME_POINTER
|
||||
@ -249,12 +244,11 @@ ENTRY(copyout)
|
||||
jz done_copyout
|
||||
|
||||
/*
|
||||
* Check explicitly for non-user addresses. If 486 write protection
|
||||
* is being used, this check is essential because we are in kernel
|
||||
* mode so the h/w does not provide any protection against writing
|
||||
* kernel addresses.
|
||||
* Check explicitly for non-user addresses. This check is essential
|
||||
* because it prevents usermode from writing into the kernel. We do
|
||||
* not verify anywhere else that the user did not specify a rogue
|
||||
* address.
|
||||
*/
|
||||
|
||||
/*
|
||||
* First, prevent address wrapping.
|
||||
*/
|
||||
@ -276,7 +270,6 @@ ENTRY(copyout)
|
||||
movq %rdx,%rcx
|
||||
|
||||
shrq $3,%rcx
|
||||
cld
|
||||
rep
|
||||
movsq
|
||||
movb %dl,%cl
|
||||
@ -325,7 +318,6 @@ ENTRY(copyin)
|
||||
movq %rdx,%rcx
|
||||
movb %cl,%al
|
||||
shrq $3,%rcx /* copy longword-wise */
|
||||
cld
|
||||
rep
|
||||
movsq
|
||||
movb %al,%cl
|
||||
@ -622,7 +614,6 @@ ENTRY(copyinstr)
|
||||
movq %rax,%r8
|
||||
1:
|
||||
incq %rdx
|
||||
cld
|
||||
|
||||
2:
|
||||
decq %rdx
|
||||
@ -673,7 +664,6 @@ ENTRY(copystr)
|
||||
|
||||
xchgq %rdi,%rsi
|
||||
incq %rdx
|
||||
cld
|
||||
1:
|
||||
decq %rdx
|
||||
jz 4f
|
||||
@ -763,7 +753,8 @@ ENTRY(longjmp)
|
||||
END(longjmp)
|
||||
|
||||
/*
|
||||
* Support for reading MSRs in the safe manner.
|
||||
* Support for reading MSRs in the safe manner. (Instead of panic on #gp,
|
||||
* return an error.)
|
||||
*/
|
||||
ENTRY(rdmsr_safe)
|
||||
/* int rdmsr_safe(u_int msr, uint64_t *data) */
|
||||
@ -783,7 +774,8 @@ ENTRY(rdmsr_safe)
|
||||
ret
|
||||
|
||||
/*
|
||||
* Support for writing MSRs in the safe manner.
|
||||
* Support for writing MSRs in the safe manner. (Instead of panic on #gp,
|
||||
* return an error.)
|
||||
*/
|
||||
ENTRY(wrmsr_safe)
|
||||
/* int wrmsr_safe(u_int msr, uint64_t data) */
|
||||
|
@ -42,6 +42,7 @@ extern int hw_lower_amd64_sharedpage;
|
||||
struct savefpu;
|
||||
struct sysentvec;
|
||||
|
||||
void amd64_conf_fast_syscall(void);
|
||||
void amd64_db_resume_dbreg(void);
|
||||
void amd64_lower_shared_page(struct sysentvec *);
|
||||
void amd64_syscall(struct thread *td, int traced);
|
||||
|
@ -517,15 +517,26 @@ svm_vminit(struct vm *vm, pmap_t pmap)
|
||||
vm_paddr_t msrpm_pa, iopm_pa, pml4_pa;
|
||||
int i;
|
||||
|
||||
svm_sc = contigmalloc(sizeof (*svm_sc), M_SVM, M_WAITOK | M_ZERO,
|
||||
0, ~(vm_paddr_t)0, PAGE_SIZE, 0);
|
||||
svm_sc = malloc(sizeof (*svm_sc), M_SVM, M_WAITOK | M_ZERO);
|
||||
if (((uintptr_t)svm_sc & PAGE_MASK) != 0)
|
||||
panic("malloc of svm_softc not aligned on page boundary");
|
||||
|
||||
svm_sc->msr_bitmap = contigmalloc(SVM_MSR_BITMAP_SIZE, M_SVM,
|
||||
M_WAITOK, 0, ~(vm_paddr_t)0, PAGE_SIZE, 0);
|
||||
if (svm_sc->msr_bitmap == NULL)
|
||||
panic("contigmalloc of SVM MSR bitmap failed");
|
||||
svm_sc->iopm_bitmap = contigmalloc(SVM_IO_BITMAP_SIZE, M_SVM,
|
||||
M_WAITOK, 0, ~(vm_paddr_t)0, PAGE_SIZE, 0);
|
||||
if (svm_sc->iopm_bitmap == NULL)
|
||||
panic("contigmalloc of SVM IO bitmap failed");
|
||||
|
||||
svm_sc->vm = vm;
|
||||
svm_sc->nptp = (vm_offset_t)vtophys(pmap->pm_pml4);
|
||||
|
||||
/*
|
||||
* Intercept read and write accesses to all MSRs.
|
||||
*/
|
||||
memset(svm_sc->msr_bitmap, 0xFF, sizeof(svm_sc->msr_bitmap));
|
||||
memset(svm_sc->msr_bitmap, 0xFF, SVM_MSR_BITMAP_SIZE);
|
||||
|
||||
/*
|
||||
* Access to the following MSRs is redirected to the VMCB when the
|
||||
@ -553,7 +564,7 @@ svm_vminit(struct vm *vm, pmap_t pmap)
|
||||
svm_msr_rd_ok(svm_sc->msr_bitmap, MSR_EFER);
|
||||
|
||||
/* Intercept access to all I/O ports. */
|
||||
memset(svm_sc->iopm_bitmap, 0xFF, sizeof(svm_sc->iopm_bitmap));
|
||||
memset(svm_sc->iopm_bitmap, 0xFF, SVM_IO_BITMAP_SIZE);
|
||||
|
||||
iopm_pa = vtophys(svm_sc->iopm_bitmap);
|
||||
msrpm_pa = vtophys(svm_sc->msr_bitmap);
|
||||
@ -2043,7 +2054,9 @@ svm_vmcleanup(void *arg)
|
||||
{
|
||||
struct svm_softc *sc = arg;
|
||||
|
||||
contigfree(sc, sizeof (*sc), M_SVM);
|
||||
contigfree(sc->iopm_bitmap, SVM_IO_BITMAP_SIZE, M_SVM);
|
||||
contigfree(sc->msr_bitmap, SVM_MSR_BITMAP_SIZE, M_SVM);
|
||||
free(sc, M_SVM);
|
||||
}
|
||||
|
||||
static register_t *
|
||||
|
@ -56,13 +56,13 @@ struct svm_vcpu {
|
||||
* SVM softc, one per virtual machine.
|
||||
*/
|
||||
struct svm_softc {
|
||||
uint8_t iopm_bitmap[SVM_IO_BITMAP_SIZE]; /* shared by all vcpus */
|
||||
uint8_t msr_bitmap[SVM_MSR_BITMAP_SIZE]; /* shared by all vcpus */
|
||||
uint8_t apic_page[VM_MAXCPU][PAGE_SIZE];
|
||||
struct svm_vcpu vcpu[VM_MAXCPU];
|
||||
vm_offset_t nptp; /* nested page table */
|
||||
uint8_t *iopm_bitmap; /* shared by all vcpus */
|
||||
uint8_t *msr_bitmap; /* shared by all vcpus */
|
||||
struct vm *vm;
|
||||
} __aligned(PAGE_SIZE);
|
||||
};
|
||||
|
||||
CTASSERT((offsetof(struct svm_softc, nptp) & PAGE_MASK) == 0);
|
||||
|
||||
|
@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <machine/bus.h>
|
||||
@ -48,6 +50,16 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <arm/allwinner/aw_sid.h>
|
||||
|
||||
/* efuse registers */
|
||||
#define SID_PRCTL 0x40
|
||||
#define SID_PRCTL_OFFSET_MASK 0xff
|
||||
#define SID_PRCTL_OFFSET(n) (((n) & SID_PRCTL_OFFSET_MASK) << 16)
|
||||
#define SID_PRCTL_LOCK (0xac << 8)
|
||||
#define SID_PRCTL_READ (0x01 << 1)
|
||||
#define SID_PRCTL_WRITE (0x01 << 0)
|
||||
#define SID_PRKEY 0x50
|
||||
#define SID_RDKEY 0x60
|
||||
|
||||
#define SID_SRAM 0x200
|
||||
#define SID_THERMAL_CALIB0 (SID_SRAM + 0x34)
|
||||
#define SID_THERMAL_CALIB1 (SID_SRAM + 0x38)
|
||||
@ -55,39 +67,58 @@ __FBSDID("$FreeBSD$");
|
||||
#define ROOT_KEY_SIZE 4
|
||||
|
||||
struct aw_sid_conf {
|
||||
bus_size_t efuse_size;
|
||||
bus_size_t rootkey_offset;
|
||||
bool has_prctl;
|
||||
bool has_thermal;
|
||||
bool requires_prctl_read;
|
||||
};
|
||||
|
||||
static const struct aw_sid_conf a10_conf = {
|
||||
.efuse_size = 0x10,
|
||||
.rootkey_offset = 0,
|
||||
};
|
||||
|
||||
static const struct aw_sid_conf a20_conf = {
|
||||
.efuse_size = 0x10,
|
||||
.rootkey_offset = 0,
|
||||
};
|
||||
|
||||
static const struct aw_sid_conf a64_conf = {
|
||||
.efuse_size = 0x100,
|
||||
.rootkey_offset = SID_SRAM,
|
||||
.has_prctl = true,
|
||||
.has_thermal = true,
|
||||
};
|
||||
|
||||
static const struct aw_sid_conf a83t_conf = {
|
||||
.efuse_size = 0x100,
|
||||
.rootkey_offset = SID_SRAM,
|
||||
.has_prctl = true,
|
||||
.has_thermal = true,
|
||||
};
|
||||
|
||||
static const struct aw_sid_conf h3_conf = {
|
||||
.efuse_size = 0x100,
|
||||
.rootkey_offset = SID_SRAM,
|
||||
.has_prctl = true,
|
||||
.has_thermal = true,
|
||||
.requires_prctl_read = true,
|
||||
};
|
||||
|
||||
static struct ofw_compat_data compat_data[] = {
|
||||
{ "allwinner,sun4i-a10-sid", (uintptr_t)&a10_conf},
|
||||
{ "allwinner,sun7i-a20-sid", (uintptr_t)&a20_conf},
|
||||
{ "allwinner,sun50i-a64-sid", (uintptr_t)&a64_conf},
|
||||
{ "allwinner,sun8i-a83t-sid", (uintptr_t)&a83t_conf},
|
||||
{ "allwinner,sun8i-h3-sid", (uintptr_t)&h3_conf},
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
struct aw_sid_softc {
|
||||
struct resource *res;
|
||||
struct aw_sid_conf *sid_conf;
|
||||
struct mtx prctl_mtx;
|
||||
};
|
||||
|
||||
static struct aw_sid_softc *aw_sid_sc;
|
||||
@ -105,6 +136,35 @@ enum sid_keys {
|
||||
#define WR4(sc, reg, val) bus_write_4((sc)->res, (reg), (val))
|
||||
|
||||
static int aw_sid_sysctl(SYSCTL_HANDLER_ARGS);
|
||||
static int aw_sid_prctl_read(device_t dev, bus_size_t offset, uint32_t *val);
|
||||
|
||||
|
||||
/*
|
||||
* offset here is offset into efuse space, rather than offset into sid register
|
||||
* space. This form of read is only an option for newer SoC: A83t, H3, A64
|
||||
*/
|
||||
static int
|
||||
aw_sid_prctl_read(device_t dev, bus_size_t offset, uint32_t *val)
|
||||
{
|
||||
struct aw_sid_softc *sc;
|
||||
uint32_t readval;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (!sc->sid_conf->has_prctl)
|
||||
return (1);
|
||||
|
||||
mtx_lock(&sc->prctl_mtx);
|
||||
readval = SID_PRCTL_OFFSET(offset) | SID_PRCTL_LOCK | SID_PRCTL_READ;
|
||||
WR4(sc, SID_PRCTL, readval);
|
||||
/* Read bit will be cleared once read has concluded */
|
||||
while (RD4(sc, SID_PRCTL) & SID_PRCTL_READ)
|
||||
continue;
|
||||
readval = RD4(sc, SID_RDKEY);
|
||||
mtx_unlock(&sc->prctl_mtx);
|
||||
*val = readval;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
aw_sid_probe(device_t dev)
|
||||
@ -123,6 +183,8 @@ static int
|
||||
aw_sid_attach(device_t dev)
|
||||
{
|
||||
struct aw_sid_softc *sc;
|
||||
bus_size_t i;
|
||||
uint32_t val;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
@ -131,8 +193,22 @@ aw_sid_attach(device_t dev)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
aw_sid_sc = sc;
|
||||
mtx_init(&sc->prctl_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
|
||||
sc->sid_conf = (struct aw_sid_conf *)ofw_bus_search_compatible(dev, compat_data)->ocd_data;
|
||||
aw_sid_sc = sc;
|
||||
|
||||
/*
|
||||
* This set of reads is solely for working around a silicon bug on some
|
||||
* SoC that require a prctl read in order for direct register access to
|
||||
* return a non-garbled value. Hence, the values we read are simply
|
||||
* ignored.
|
||||
*/
|
||||
if (sc->sid_conf->requires_prctl_read)
|
||||
for (i = 0; i < sc->sid_conf->efuse_size; i += 4)
|
||||
if (aw_sid_prctl_read(dev, i, &val) != 0) {
|
||||
device_printf(dev, "failed prctl read\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
||||
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
|
||||
|
@ -223,6 +223,8 @@ static void awg_txeof(struct awg_softc *sc);
|
||||
|
||||
static uint32_t syscon_read_emac_clk_reg(device_t dev);
|
||||
static void syscon_write_emac_clk_reg(device_t dev, uint32_t val);
|
||||
static phandle_t awg_get_phy_node(device_t dev);
|
||||
static bool awg_has_internal_phy(device_t dev);
|
||||
|
||||
static int
|
||||
awg_miibus_readreg(device_t dev, int phy, int reg)
|
||||
@ -1186,6 +1188,35 @@ syscon_write_emac_clk_reg(device_t dev, uint32_t val)
|
||||
bus_write_4(sc->res[_RES_SYSCON], 0, val);
|
||||
}
|
||||
|
||||
static phandle_t
|
||||
awg_get_phy_node(device_t dev)
|
||||
{
|
||||
phandle_t node;
|
||||
pcell_t phy_handle;
|
||||
|
||||
node = ofw_bus_get_node(dev);
|
||||
if (OF_getencprop(node, "phy-handle", (void *)&phy_handle,
|
||||
sizeof(phy_handle)) <= 0)
|
||||
return (0);
|
||||
|
||||
return (OF_node_from_xref(phy_handle));
|
||||
}
|
||||
|
||||
static bool
|
||||
awg_has_internal_phy(device_t dev)
|
||||
{
|
||||
phandle_t node, phy_node;
|
||||
|
||||
node = ofw_bus_get_node(dev);
|
||||
/* Legacy binding */
|
||||
if (OF_hasprop(node, "allwinner,use-internal-phy"))
|
||||
return (true);
|
||||
|
||||
phy_node = awg_get_phy_node(dev);
|
||||
return (phy_node != 0 && ofw_bus_node_is_compatible(OF_parent(phy_node),
|
||||
"allwinner,sun8i-h3-mdio-internal") != 0);
|
||||
}
|
||||
|
||||
static int
|
||||
awg_setup_phy(device_t dev)
|
||||
{
|
||||
@ -1241,7 +1272,7 @@ awg_setup_phy(device_t dev)
|
||||
}
|
||||
|
||||
if (sc->type == EMAC_H3) {
|
||||
if (OF_hasprop(node, "allwinner,use-internal-phy")) {
|
||||
if (awg_has_internal_phy(dev)) {
|
||||
reg |= EMAC_CLK_EPHY_SELECT;
|
||||
reg &= ~EMAC_CLK_EPHY_SHUTDOWN;
|
||||
if (OF_hasprop(node,
|
||||
@ -1308,7 +1339,7 @@ static int
|
||||
awg_setup_extres(device_t dev)
|
||||
{
|
||||
struct awg_softc *sc;
|
||||
phandle_t node;
|
||||
phandle_t node, phy_node;
|
||||
hwreset_t rst_ahb, rst_ephy;
|
||||
clk_t clk_ahb, clk_ephy;
|
||||
regulator_t reg;
|
||||
@ -1320,22 +1351,37 @@ awg_setup_extres(device_t dev)
|
||||
clk_ahb = clk_ephy = NULL;
|
||||
reg = NULL;
|
||||
node = ofw_bus_get_node(dev);
|
||||
phy_node = awg_get_phy_node(dev);
|
||||
|
||||
if (phy_node == 0 && OF_hasprop(node, "phy-handle")) {
|
||||
error = ENXIO;
|
||||
device_printf(dev, "cannot get phy handle\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Get AHB clock and reset resources */
|
||||
error = hwreset_get_by_ofw_name(dev, 0, "ahb", &rst_ahb);
|
||||
error = hwreset_get_by_ofw_name(dev, 0, "stmmaceth", &rst_ahb);
|
||||
if (error != 0)
|
||||
error = hwreset_get_by_ofw_name(dev, 0, "ahb", &rst_ahb);
|
||||
if (error != 0) {
|
||||
device_printf(dev, "cannot get ahb reset\n");
|
||||
goto fail;
|
||||
}
|
||||
if (hwreset_get_by_ofw_name(dev, 0, "ephy", &rst_ephy) != 0)
|
||||
rst_ephy = NULL;
|
||||
error = clk_get_by_ofw_name(dev, 0, "ahb", &clk_ahb);
|
||||
if (phy_node == 0 || hwreset_get_by_ofw_idx(dev, phy_node, 0,
|
||||
&rst_ephy) != 0)
|
||||
rst_ephy = NULL;
|
||||
error = clk_get_by_ofw_name(dev, 0, "stmmaceth", &clk_ahb);
|
||||
if (error != 0)
|
||||
error = clk_get_by_ofw_name(dev, 0, "ahb", &clk_ahb);
|
||||
if (error != 0) {
|
||||
device_printf(dev, "cannot get ahb clock\n");
|
||||
goto fail;
|
||||
}
|
||||
if (clk_get_by_ofw_name(dev, 0, "ephy", &clk_ephy) != 0)
|
||||
clk_ephy = NULL;
|
||||
if (phy_node == 0 || clk_get_by_ofw_index(dev, phy_node, 0,
|
||||
&clk_ephy) != 0)
|
||||
clk_ephy = NULL;
|
||||
|
||||
if (OF_hasprop(node, "syscon") && syscon_get_by_ofw_property(dev, node,
|
||||
"syscon", &sc->syscon) != 0) {
|
||||
|
@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
|
||||
#ifdef DEV_ACPI
|
||||
#include <contrib/dev/acpica/include/acpi.h>
|
||||
#include <dev/acpica/acpivar.h>
|
||||
#include "acpi_bus_if.h"
|
||||
#endif
|
||||
|
||||
#define GT_CTRL_ENABLE (1 << 0)
|
||||
@ -312,6 +313,15 @@ arm_tmr_fdt_probe(device_t dev)
|
||||
#endif
|
||||
|
||||
#ifdef DEV_ACPI
|
||||
static void
|
||||
arm_tmr_acpi_add_irq(device_t parent, device_t dev, int rid, u_int irq)
|
||||
{
|
||||
|
||||
irq = ACPI_BUS_MAP_INTR(parent, dev, irq,
|
||||
INTR_TRIGGER_LEVEL, INTR_POLARITY_HIGH);
|
||||
BUS_SET_RESOURCE(parent, dev, SYS_RES_IRQ, rid, irq, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
arm_tmr_acpi_identify(driver_t *driver, device_t parent)
|
||||
{
|
||||
@ -336,12 +346,9 @@ arm_tmr_acpi_identify(driver_t *driver, device_t parent)
|
||||
goto out;
|
||||
}
|
||||
|
||||
BUS_SET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
|
||||
gtdt->SecureEl1Interrupt, 1);
|
||||
BUS_SET_RESOURCE(parent, dev, SYS_RES_IRQ, 1,
|
||||
gtdt->NonSecureEl1Interrupt, 1);
|
||||
BUS_SET_RESOURCE(parent, dev, SYS_RES_IRQ, 2,
|
||||
gtdt->VirtualTimerInterrupt, 1);
|
||||
arm_tmr_acpi_add_irq(parent, dev, 0, gtdt->SecureEl1Interrupt);
|
||||
arm_tmr_acpi_add_irq(parent, dev, 1, gtdt->NonSecureEl1Interrupt);
|
||||
arm_tmr_acpi_add_irq(parent, dev, 2, gtdt->VirtualTimerInterrupt);
|
||||
|
||||
out:
|
||||
acpi_unmap_table(gtdt);
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -68,6 +69,11 @@ __FBSDID("$FreeBSD$");
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEV_ACPI
|
||||
#include <contrib/dev/acpica/include/acpi.h>
|
||||
#include <dev/acpica/acpivar.h>
|
||||
#endif
|
||||
|
||||
#include <arm/arm/gic.h>
|
||||
#include <arm/arm/gic_common.h>
|
||||
|
||||
@ -888,6 +894,9 @@ gic_map_intr(device_t dev, struct intr_map_data *data, u_int *irqp,
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt *daf;
|
||||
#endif
|
||||
#ifdef DEV_ACPI
|
||||
struct intr_map_data_acpi *daa;
|
||||
#endif
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
switch (data->type) {
|
||||
@ -902,6 +911,14 @@ gic_map_intr(device_t dev, struct intr_map_data *data, u_int *irqp,
|
||||
("%s: Attempting to map a MSI interrupt from FDT",
|
||||
__func__));
|
||||
break;
|
||||
#endif
|
||||
#ifdef DEV_ACPI
|
||||
case INTR_MAP_DATA_ACPI:
|
||||
daa = (struct intr_map_data_acpi *)data;
|
||||
irq = daa->irq;
|
||||
pol = daa->pol;
|
||||
trig = daa->trig;
|
||||
break;
|
||||
#endif
|
||||
case INTR_MAP_DATA_MSI:
|
||||
/* Non-GICv2m MSI */
|
||||
|
346
sys/arm/arm/gic_acpi.c
Normal file
346
sys/arm/arm/gic_acpi.c
Normal file
@ -0,0 +1,346 @@
|
||||
/*-
|
||||
* Copyright (c) 2011,2016 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Andrew Turner under
|
||||
* sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* Developed by Damjan Marion <damjan.marion@gmail.com>
|
||||
*
|
||||
* Based on OMAP4 GIC code by Ben Gray
|
||||
*
|
||||
* 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.
|
||||
* 3. The name of the company nor the name of the author may be used to
|
||||
* endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <contrib/dev/acpica/include/acpi.h>
|
||||
#include <dev/acpica/acpivar.h>
|
||||
|
||||
#include <arm/arm/gic.h>
|
||||
#include <arm/arm/gic_common.h>
|
||||
|
||||
struct gic_acpi_devinfo {
|
||||
struct resource_list rl;
|
||||
};
|
||||
|
||||
static device_identify_t gic_acpi_identify;
|
||||
static device_probe_t gic_acpi_probe;
|
||||
static device_attach_t gic_acpi_attach;
|
||||
static bus_get_resource_list_t gic_acpi_get_resource_list;
|
||||
static bool arm_gic_add_children(device_t);
|
||||
|
||||
static device_method_t gic_acpi_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_identify, gic_acpi_identify),
|
||||
DEVMETHOD(device_probe, gic_acpi_probe),
|
||||
DEVMETHOD(device_attach, gic_acpi_attach),
|
||||
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_get_resource_list, gic_acpi_get_resource_list),
|
||||
|
||||
DEVMETHOD_END,
|
||||
};
|
||||
|
||||
DEFINE_CLASS_1(gic, gic_acpi_driver, gic_acpi_methods,
|
||||
sizeof(struct arm_gic_softc), arm_gic_driver);
|
||||
|
||||
static devclass_t gic_acpi_devclass;
|
||||
|
||||
EARLY_DRIVER_MODULE(gic, acpi, gic_acpi_driver, gic_acpi_devclass, 0, 0,
|
||||
BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
|
||||
struct madt_table_data {
|
||||
device_t parent;
|
||||
ACPI_MADT_GENERIC_DISTRIBUTOR *dist;
|
||||
ACPI_MADT_GENERIC_INTERRUPT *intr[MAXCPU];
|
||||
};
|
||||
|
||||
static void
|
||||
madt_handler(ACPI_SUBTABLE_HEADER *entry, void *arg)
|
||||
{
|
||||
struct madt_table_data *madt_data;
|
||||
ACPI_MADT_GENERIC_INTERRUPT *intr;
|
||||
|
||||
madt_data = (struct madt_table_data *)arg;
|
||||
|
||||
switch(entry->Type) {
|
||||
case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
|
||||
if (madt_data->dist != NULL) {
|
||||
if (bootverbose)
|
||||
device_printf(madt_data->parent,
|
||||
"gic: Already have a distributor table");
|
||||
} else
|
||||
madt_data->dist =
|
||||
(ACPI_MADT_GENERIC_DISTRIBUTOR *)entry;
|
||||
break;
|
||||
case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
|
||||
intr = (ACPI_MADT_GENERIC_INTERRUPT *)entry;
|
||||
if (intr->CpuInterfaceNumber < MAXCPU)
|
||||
madt_data->intr[intr->CpuInterfaceNumber] = intr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gic_acpi_identify(driver_t *driver, device_t parent)
|
||||
{
|
||||
struct madt_table_data madt_data;
|
||||
ACPI_MADT_GENERIC_INTERRUPT *intr;
|
||||
ACPI_TABLE_MADT *madt;
|
||||
vm_paddr_t physaddr;
|
||||
device_t dev;
|
||||
int i;
|
||||
|
||||
physaddr = acpi_find_table(ACPI_SIG_MADT);
|
||||
if (physaddr == 0)
|
||||
return;
|
||||
|
||||
madt = acpi_map_table(physaddr, ACPI_SIG_MADT);
|
||||
if (madt == NULL) {
|
||||
device_printf(parent, "gic: Unable to map the MADT\n");
|
||||
return;
|
||||
}
|
||||
|
||||
bzero(&madt_data, sizeof(madt_data));
|
||||
madt_data.parent = parent;
|
||||
madt_data.dist = NULL;
|
||||
|
||||
acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
|
||||
madt_handler, &madt_data);
|
||||
|
||||
/* Check the version of the GIC we have */
|
||||
switch (madt_data.dist->Version) {
|
||||
case ACPI_MADT_GIC_VERSION_NONE:
|
||||
case ACPI_MADT_GIC_VERSION_V1:
|
||||
case ACPI_MADT_GIC_VERSION_V2:
|
||||
break;
|
||||
default:
|
||||
goto out;
|
||||
}
|
||||
|
||||
intr = NULL;
|
||||
for (i = 0; i < MAXCPU; i++) {
|
||||
if (madt_data.intr[i] != NULL) {
|
||||
if (intr == NULL) {
|
||||
intr = madt_data.intr[i];
|
||||
} else if (intr->BaseAddress !=
|
||||
madt_data.intr[i]->BaseAddress) {
|
||||
device_printf(parent,
|
||||
"gic: Not all CPU interfaces at the same address, this may fail\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (intr == NULL) {
|
||||
device_printf(parent, "gic: No CPU interfaces found\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
dev = BUS_ADD_CHILD(parent, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE,
|
||||
"gic", -1);
|
||||
if (dev == NULL) {
|
||||
device_printf(parent, "add gic child failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
BUS_SET_RESOURCE(parent, dev, SYS_RES_MEMORY, 0,
|
||||
madt_data.dist->BaseAddress, 4 * 1024);
|
||||
BUS_SET_RESOURCE(parent, dev, SYS_RES_MEMORY, 1,
|
||||
intr->BaseAddress, 4 * 1024);
|
||||
|
||||
acpi_set_private(dev, (void *)(uintptr_t)madt_data.dist->Version);
|
||||
out:
|
||||
acpi_unmap_table(madt);
|
||||
}
|
||||
|
||||
static int
|
||||
gic_acpi_probe(device_t dev)
|
||||
{
|
||||
|
||||
switch((uintptr_t)acpi_get_private(dev)) {
|
||||
case ACPI_MADT_GIC_VERSION_NONE:
|
||||
case ACPI_MADT_GIC_VERSION_V1:
|
||||
case ACPI_MADT_GIC_VERSION_V2:
|
||||
break;
|
||||
default:
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
device_set_desc(dev, "ARM Generic Interrupt Controller");
|
||||
return (BUS_PROBE_NOWILDCARD);
|
||||
}
|
||||
|
||||
static int
|
||||
gic_acpi_attach(device_t dev)
|
||||
{
|
||||
struct arm_gic_softc *sc = device_get_softc(dev);
|
||||
intptr_t xref;
|
||||
int err;
|
||||
|
||||
sc->gic_bus = GIC_BUS_ACPI;
|
||||
|
||||
err = arm_gic_attach(dev);
|
||||
if (err != 0)
|
||||
return (err);
|
||||
|
||||
xref = 0;
|
||||
|
||||
/*
|
||||
* Now, when everything is initialized, it's right time to
|
||||
* register interrupt controller to interrupt framefork.
|
||||
*/
|
||||
if (intr_pic_register(dev, xref) == NULL) {
|
||||
device_printf(dev, "could not register PIC\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Controller is root:
|
||||
*/
|
||||
if (intr_pic_claim_root(dev, xref, arm_gic_intr, sc,
|
||||
GIC_LAST_SGI - GIC_FIRST_SGI + 1) != 0) {
|
||||
device_printf(dev, "could not set PIC as a root\n");
|
||||
intr_pic_deregister(dev, xref);
|
||||
goto cleanup;
|
||||
}
|
||||
/* If we have children probe and attach them */
|
||||
if (arm_gic_add_children(dev)) {
|
||||
bus_generic_probe(dev);
|
||||
return (bus_generic_attach(dev));
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
cleanup:
|
||||
arm_gic_detach(dev);
|
||||
return(ENXIO);
|
||||
}
|
||||
|
||||
static struct resource_list *
|
||||
gic_acpi_get_resource_list(device_t bus, device_t child)
|
||||
{
|
||||
struct gic_acpi_devinfo *di;
|
||||
|
||||
di = device_get_ivars(child);
|
||||
KASSERT(di != NULL, ("gic_acpi_get_resource_list: No devinfo"));
|
||||
|
||||
return (&di->rl);
|
||||
}
|
||||
|
||||
static void
|
||||
madt_gicv2m_handler(ACPI_SUBTABLE_HEADER *entry, void *arg)
|
||||
{
|
||||
struct arm_gic_softc *sc;
|
||||
ACPI_MADT_GENERIC_MSI_FRAME *msi;
|
||||
struct gic_acpi_devinfo *dinfo;
|
||||
device_t dev, cdev;
|
||||
|
||||
if (entry->Type == ACPI_MADT_TYPE_GENERIC_MSI_FRAME) {
|
||||
sc = arg;
|
||||
dev = sc->gic_dev;
|
||||
msi = (ACPI_MADT_GENERIC_MSI_FRAME *)entry;
|
||||
|
||||
device_printf(dev, "frame: %x %lx %x %u %u\n", msi->MsiFrameId,
|
||||
msi->BaseAddress, msi->Flags, msi->SpiCount, msi->SpiBase);
|
||||
|
||||
cdev = device_add_child(dev, NULL, -1);
|
||||
if (cdev == NULL)
|
||||
return;
|
||||
|
||||
dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
resource_list_init(&dinfo->rl);
|
||||
resource_list_add(&dinfo->rl, SYS_RES_MEMORY, 0,
|
||||
msi->BaseAddress, msi->BaseAddress + PAGE_SIZE - 1,
|
||||
PAGE_SIZE);
|
||||
device_set_ivars(cdev, dinfo);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
arm_gic_add_children(device_t dev)
|
||||
{
|
||||
struct arm_gic_softc *sc = device_get_softc(dev);
|
||||
ACPI_TABLE_MADT *madt;
|
||||
vm_paddr_t physaddr;
|
||||
|
||||
/* This should return a valid address as it did in gic_acpi_identify */
|
||||
physaddr = acpi_find_table(ACPI_SIG_MADT);
|
||||
if (physaddr == 0)
|
||||
return (false);
|
||||
|
||||
madt = acpi_map_table(physaddr, ACPI_SIG_MADT);
|
||||
if (madt == NULL) {
|
||||
device_printf(dev, "gic: Unable to map the MADT\n");
|
||||
return (false);
|
||||
}
|
||||
|
||||
acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
|
||||
madt_gicv2m_handler, sc);
|
||||
|
||||
acpi_unmap_table(madt);
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
static int
|
||||
arm_gicv2m_acpi_probe(device_t dev)
|
||||
{
|
||||
|
||||
if (gic_get_bus(dev) != GIC_BUS_ACPI)
|
||||
return (EINVAL);
|
||||
|
||||
if (gic_get_hw_rev(dev) > 2)
|
||||
return (EINVAL);
|
||||
|
||||
device_set_desc(dev, "ARM Generic Interrupt Controller MSI/MSIX");
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
static device_method_t arm_gicv2m_acpi_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, arm_gicv2m_acpi_probe),
|
||||
|
||||
/* End */
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_1(gicv2m, arm_gicv2m_acpi_driver, arm_gicv2m_acpi_methods,
|
||||
sizeof(struct arm_gicv2m_softc), arm_gicv2m_driver);
|
||||
|
||||
static devclass_t arm_gicv2m_acpi_devclass;
|
||||
|
||||
EARLY_DRIVER_MODULE(gicv2m, gic, arm_gicv2m_acpi_driver,
|
||||
arm_gicv2m_acpi_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
103
sys/arm64/arm64/cpu_errata.c
Normal file
103
sys/arm64/arm64/cpu_errata.c
Normal file
@ -0,0 +1,103 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018 Andrew Turner
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by SRI International and the University of
|
||||
* Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
|
||||
* ("CTSRD"), as part of the DARPA CRASH research programme.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/pcpu.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#ifdef DEV_PSCI
|
||||
#include <dev/psci/psci.h>
|
||||
#endif
|
||||
|
||||
typedef void (cpu_quirk_install)(void);
|
||||
struct cpu_quirks {
|
||||
cpu_quirk_install *quirk_install;
|
||||
u_int midr_mask;
|
||||
u_int midr_value;
|
||||
};
|
||||
|
||||
static cpu_quirk_install install_psci_bp_hardening;
|
||||
|
||||
static struct cpu_quirks cpu_quirks[] = {
|
||||
{
|
||||
.midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
|
||||
.midr_value = CPU_ID_RAW(CPU_IMPL_ARM, CPU_PART_CORTEX_A57,0,0),
|
||||
.quirk_install = install_psci_bp_hardening,
|
||||
},
|
||||
{
|
||||
.midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
|
||||
.midr_value = CPU_ID_RAW(CPU_IMPL_ARM, CPU_PART_CORTEX_A72,0,0),
|
||||
.quirk_install = install_psci_bp_hardening,
|
||||
},
|
||||
{
|
||||
.midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
|
||||
.midr_value = CPU_ID_RAW(CPU_IMPL_ARM, CPU_PART_CORTEX_A73,0,0),
|
||||
.quirk_install = install_psci_bp_hardening,
|
||||
},
|
||||
{
|
||||
.midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
|
||||
.midr_value = CPU_ID_RAW(CPU_IMPL_ARM, CPU_PART_CORTEX_A75,0,0),
|
||||
.quirk_install = install_psci_bp_hardening,
|
||||
},
|
||||
};
|
||||
|
||||
static void
|
||||
install_psci_bp_hardening(void)
|
||||
{
|
||||
|
||||
#ifdef DEV_PSCI
|
||||
PCPU_SET(bp_harden, psci_get_version);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
install_cpu_errata(void)
|
||||
{
|
||||
u_int midr;
|
||||
size_t i;
|
||||
|
||||
midr = get_midr();
|
||||
|
||||
for (i = 0; i < nitems(cpu_quirks); i++) {
|
||||
if ((midr & cpu_quirks[i].midr_mask) ==
|
||||
cpu_quirks[i].midr_value) {
|
||||
cpu_quirks[i].quirk_install();
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
@ -63,6 +64,11 @@ __FBSDID("$FreeBSD$");
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEV_ACPI
|
||||
#include <contrib/dev/acpica/include/acpi.h>
|
||||
#include <dev/acpica/acpivar.h>
|
||||
#endif
|
||||
|
||||
#include "pic_if.h"
|
||||
|
||||
#include <arm/arm/gic_common.h>
|
||||
@ -569,6 +575,9 @@ do_gic_v3_map_intr(device_t dev, struct intr_map_data *data, u_int *irqp,
|
||||
struct intr_map_data_msi *dam;
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt *daf;
|
||||
#endif
|
||||
#ifdef DEV_ACPI
|
||||
struct intr_map_data_acpi *daa;
|
||||
#endif
|
||||
u_int irq;
|
||||
|
||||
@ -582,6 +591,14 @@ do_gic_v3_map_intr(device_t dev, struct intr_map_data *data, u_int *irqp,
|
||||
&trig) != 0)
|
||||
return (EINVAL);
|
||||
break;
|
||||
#endif
|
||||
#ifdef DEV_ACPI
|
||||
case INTR_MAP_DATA_ACPI:
|
||||
daa = (struct intr_map_data_acpi *)data;
|
||||
irq = daa->irq;
|
||||
pol = daa->pol;
|
||||
trig = daa->trig;
|
||||
break;
|
||||
#endif
|
||||
case INTR_MAP_DATA_MSI:
|
||||
/* SPI-mapped MSI */
|
||||
|
335
sys/arm64/arm64/gic_v3_acpi.c
Normal file
335
sys/arm64/arm64/gic_v3_acpi.c
Normal file
@ -0,0 +1,335 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Andrew Turner under
|
||||
* the sponsorship of 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
#include <machine/resource.h>
|
||||
|
||||
#include <contrib/dev/acpica/include/acpi.h>
|
||||
#include <dev/acpica/acpivar.h>
|
||||
|
||||
#include "gic_v3_reg.h"
|
||||
#include "gic_v3_var.h"
|
||||
|
||||
struct gic_v3_acpi_devinfo {
|
||||
struct resource_list di_rl;
|
||||
};
|
||||
|
||||
static device_identify_t gic_v3_acpi_identify;
|
||||
static device_probe_t gic_v3_acpi_probe;
|
||||
static device_attach_t gic_v3_acpi_attach;
|
||||
static bus_alloc_resource_t gic_v3_acpi_bus_alloc_res;
|
||||
|
||||
static void gic_v3_acpi_bus_attach(device_t);
|
||||
|
||||
static device_method_t gic_v3_acpi_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_identify, gic_v3_acpi_identify),
|
||||
DEVMETHOD(device_probe, gic_v3_acpi_probe),
|
||||
DEVMETHOD(device_attach, gic_v3_acpi_attach),
|
||||
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_alloc_resource, gic_v3_acpi_bus_alloc_res),
|
||||
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
|
||||
|
||||
/* End */
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_1(gic, gic_v3_acpi_driver, gic_v3_acpi_methods,
|
||||
sizeof(struct gic_v3_softc), gic_v3_driver);
|
||||
|
||||
static devclass_t gic_v3_acpi_devclass;
|
||||
|
||||
EARLY_DRIVER_MODULE(gic_v3, acpi, gic_v3_acpi_driver, gic_v3_acpi_devclass,
|
||||
0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
|
||||
|
||||
struct madt_table_data {
|
||||
device_t parent;
|
||||
device_t dev;
|
||||
ACPI_MADT_GENERIC_DISTRIBUTOR *dist;
|
||||
int count;
|
||||
};
|
||||
|
||||
static void
|
||||
madt_handler(ACPI_SUBTABLE_HEADER *entry, void *arg)
|
||||
{
|
||||
struct madt_table_data *madt_data;
|
||||
|
||||
madt_data = (struct madt_table_data *)arg;
|
||||
|
||||
switch(entry->Type) {
|
||||
case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
|
||||
if (madt_data->dist != NULL) {
|
||||
if (bootverbose)
|
||||
device_printf(madt_data->parent,
|
||||
"gic: Already have a distributor table");
|
||||
break;
|
||||
}
|
||||
madt_data->dist = (ACPI_MADT_GENERIC_DISTRIBUTOR *)entry;
|
||||
break;
|
||||
|
||||
case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rdist_map(ACPI_SUBTABLE_HEADER *entry, void *arg)
|
||||
{
|
||||
ACPI_MADT_GENERIC_REDISTRIBUTOR *redist;
|
||||
struct madt_table_data *madt_data;
|
||||
|
||||
madt_data = (struct madt_table_data *)arg;
|
||||
|
||||
switch(entry->Type) {
|
||||
case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR:
|
||||
redist = (ACPI_MADT_GENERIC_REDISTRIBUTOR *)entry;
|
||||
|
||||
madt_data->count++;
|
||||
BUS_SET_RESOURCE(madt_data->parent, madt_data->dev,
|
||||
SYS_RES_MEMORY, madt_data->count, redist->BaseAddress,
|
||||
redist->Length);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gic_v3_acpi_identify(driver_t *driver, device_t parent)
|
||||
{
|
||||
struct madt_table_data madt_data;
|
||||
ACPI_TABLE_MADT *madt;
|
||||
vm_paddr_t physaddr;
|
||||
device_t dev;
|
||||
|
||||
physaddr = acpi_find_table(ACPI_SIG_MADT);
|
||||
if (physaddr == 0)
|
||||
return;
|
||||
|
||||
madt = acpi_map_table(physaddr, ACPI_SIG_MADT);
|
||||
if (madt == NULL) {
|
||||
device_printf(parent, "gic: Unable to map the MADT\n");
|
||||
return;
|
||||
}
|
||||
|
||||
madt_data.parent = parent;
|
||||
madt_data.dist = NULL;
|
||||
madt_data.count = 0;
|
||||
|
||||
acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
|
||||
madt_handler, &madt_data);
|
||||
if (madt_data.dist == NULL) {
|
||||
device_printf(parent,
|
||||
"No gic interrupt or distributor table\n");
|
||||
goto out;
|
||||
}
|
||||
/* This is for the wrong GIC version */
|
||||
if (madt_data.dist->Version != ACPI_MADT_GIC_VERSION_V3)
|
||||
goto out;
|
||||
|
||||
dev = BUS_ADD_CHILD(parent, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE,
|
||||
"gic", -1);
|
||||
if (dev == NULL) {
|
||||
device_printf(parent, "add gic child failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Add the MADT data */
|
||||
BUS_SET_RESOURCE(parent, dev, SYS_RES_MEMORY, 0,
|
||||
madt_data.dist->BaseAddress, 128 * 1024);
|
||||
|
||||
madt_data.dev = dev;
|
||||
acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
|
||||
rdist_map, &madt_data);
|
||||
|
||||
acpi_set_private(dev, (void *)(uintptr_t)madt_data.dist->Version);
|
||||
|
||||
out:
|
||||
acpi_unmap_table(madt);
|
||||
}
|
||||
|
||||
static int
|
||||
gic_v3_acpi_probe(device_t dev)
|
||||
{
|
||||
|
||||
switch((uintptr_t)acpi_get_private(dev)) {
|
||||
case ACPI_MADT_GIC_VERSION_V3:
|
||||
break;
|
||||
default:
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
device_set_desc(dev, GIC_V3_DEVSTR);
|
||||
return (BUS_PROBE_NOWILDCARD);
|
||||
}
|
||||
|
||||
static int
|
||||
gic_v3_acpi_attach(device_t dev)
|
||||
{
|
||||
struct gic_v3_softc *sc;
|
||||
int err;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->dev = dev;
|
||||
sc->gic_bus = GIC_BUS_ACPI;
|
||||
|
||||
/* TODO: Count these correctly */
|
||||
sc->gic_redists.nregions = 1;
|
||||
|
||||
err = gic_v3_attach(dev);
|
||||
if (err != 0)
|
||||
goto error;
|
||||
|
||||
sc->gic_pic = intr_pic_register(dev, 0);
|
||||
if (sc->gic_pic == NULL) {
|
||||
device_printf(dev, "could not register PIC\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (intr_pic_claim_root(dev, 0, arm_gic_v3_intr, sc,
|
||||
GIC_LAST_SGI - GIC_FIRST_SGI + 1) != 0) {
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to register the ITS driver to this GIC. The GIC will act as
|
||||
* a bus in that case. Failure here will not affect the main GIC
|
||||
* functionality.
|
||||
*/
|
||||
gic_v3_acpi_bus_attach(dev);
|
||||
|
||||
return (0);
|
||||
|
||||
error:
|
||||
if (bootverbose) {
|
||||
device_printf(dev,
|
||||
"Failed to attach. Error %d\n", err);
|
||||
}
|
||||
/* Failure so free resources */
|
||||
gic_v3_detach(dev);
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
static void
|
||||
gic_v3_add_children(ACPI_SUBTABLE_HEADER *entry, void *arg)
|
||||
{
|
||||
ACPI_MADT_GENERIC_TRANSLATOR *gict;
|
||||
struct gic_v3_acpi_devinfo *di;
|
||||
device_t child, dev;
|
||||
|
||||
if (entry->Type == ACPI_MADT_TYPE_GENERIC_TRANSLATOR) {
|
||||
/* We have an ITS, add it as a child */
|
||||
gict = (ACPI_MADT_GENERIC_TRANSLATOR *)entry;
|
||||
dev = arg;
|
||||
|
||||
child = device_add_child(dev, "its", -1);
|
||||
if (child == NULL)
|
||||
return;
|
||||
|
||||
di = malloc(sizeof(*di), M_GIC_V3, M_WAITOK | M_ZERO);
|
||||
resource_list_init(&di->di_rl);
|
||||
resource_list_add(&di->di_rl, SYS_RES_MEMORY, 0,
|
||||
gict->BaseAddress, gict->BaseAddress + 128 * 1024 - 1,
|
||||
128 * 1024);
|
||||
device_set_ivars(child, di);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gic_v3_acpi_bus_attach(device_t dev)
|
||||
{
|
||||
ACPI_TABLE_MADT *madt;
|
||||
vm_paddr_t physaddr;
|
||||
|
||||
physaddr = acpi_find_table(ACPI_SIG_MADT);
|
||||
if (physaddr == 0)
|
||||
return;
|
||||
|
||||
madt = acpi_map_table(physaddr, ACPI_SIG_MADT);
|
||||
if (madt == NULL) {
|
||||
device_printf(dev, "Unable to map the MADT to add children\n");
|
||||
return;
|
||||
}
|
||||
|
||||
acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
|
||||
gic_v3_add_children, dev);
|
||||
|
||||
acpi_unmap_table(madt);
|
||||
|
||||
bus_generic_attach(dev);
|
||||
}
|
||||
|
||||
static struct resource *
|
||||
gic_v3_acpi_bus_alloc_res(device_t bus, device_t child, int type, int *rid,
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct gic_v3_acpi_devinfo *di;
|
||||
struct resource_list_entry *rle;
|
||||
|
||||
/* We only allocate memory */
|
||||
if (type != SYS_RES_MEMORY)
|
||||
return (NULL);
|
||||
|
||||
if (RMAN_IS_DEFAULT_RANGE(start, end)) {
|
||||
if ((di = device_get_ivars(child)) == NULL)
|
||||
return (NULL);
|
||||
|
||||
/* Find defaults for this rid */
|
||||
rle = resource_list_find(&di->di_rl, type, *rid);
|
||||
if (rle == NULL)
|
||||
return (NULL);
|
||||
|
||||
start = rle->start;
|
||||
end = rle->end;
|
||||
count = rle->count;
|
||||
}
|
||||
|
||||
return (bus_generic_alloc_resource(bus, child, type, rid, start, end,
|
||||
count, flags));
|
||||
}
|
@ -32,6 +32,8 @@
|
||||
#ifndef _GIC_V3_VAR_H_
|
||||
#define _GIC_V3_VAR_H_
|
||||
|
||||
#include <arm/arm/gic_common.h>
|
||||
|
||||
#define GIC_V3_DEVSTR "ARM Generic Interrupt Controller v3.0"
|
||||
|
||||
DECLARE_CLASS(gic_v3_driver);
|
||||
@ -92,10 +94,8 @@ struct gic_v3_devinfo {
|
||||
MALLOC_DECLARE(M_GIC_V3);
|
||||
|
||||
/* ivars */
|
||||
enum {
|
||||
GICV3_IVAR_NIRQS,
|
||||
GICV3_IVAR_REDIST_VADDR,
|
||||
};
|
||||
#define GICV3_IVAR_NIRQS 1000
|
||||
#define GICV3_IVAR_REDIST_VADDR 1001
|
||||
|
||||
__BUS_ACCESSOR(gicv3, nirqs, GICV3, NIRQS, u_int);
|
||||
__BUS_ACCESSOR(gicv3, redist_vaddr, GICV3, REDIST_VADDR, void *);
|
||||
|
@ -30,6 +30,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
@ -1640,7 +1641,7 @@ DEFINE_CLASS_1(its, gicv3_its_fdt_driver, gicv3_its_fdt_methods,
|
||||
#undef its_baseclasses
|
||||
static devclass_t gicv3_its_fdt_devclass;
|
||||
|
||||
EARLY_DRIVER_MODULE(its, gic, gicv3_its_fdt_driver,
|
||||
EARLY_DRIVER_MODULE(its_fdt, gic, gicv3_its_fdt_driver,
|
||||
gicv3_its_fdt_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
|
||||
static int
|
||||
@ -1686,3 +1687,62 @@ gicv3_its_fdt_attach(device_t dev)
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEV_ACPI
|
||||
static device_probe_t gicv3_its_acpi_probe;
|
||||
static device_attach_t gicv3_its_acpi_attach;
|
||||
|
||||
static device_method_t gicv3_its_acpi_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, gicv3_its_acpi_probe),
|
||||
DEVMETHOD(device_attach, gicv3_its_acpi_attach),
|
||||
|
||||
/* End */
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
#define its_baseclasses its_acpi_baseclasses
|
||||
DEFINE_CLASS_1(its, gicv3_its_acpi_driver, gicv3_its_acpi_methods,
|
||||
sizeof(struct gicv3_its_softc), gicv3_its_driver);
|
||||
#undef its_baseclasses
|
||||
static devclass_t gicv3_its_acpi_devclass;
|
||||
|
||||
EARLY_DRIVER_MODULE(its_acpi, gic, gicv3_its_acpi_driver,
|
||||
gicv3_its_acpi_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
|
||||
static int
|
||||
gicv3_its_acpi_probe(device_t dev)
|
||||
{
|
||||
|
||||
if (gic_get_bus(dev) != GIC_BUS_ACPI)
|
||||
return (EINVAL);
|
||||
|
||||
if (gic_get_hw_rev(dev) < 3)
|
||||
return (EINVAL);
|
||||
|
||||
device_set_desc(dev, "ARM GIC Interrupt Translation Service");
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
static int
|
||||
gicv3_its_acpi_attach(device_t dev)
|
||||
{
|
||||
struct gicv3_its_softc *sc;
|
||||
int err;
|
||||
|
||||
err = gicv3_its_attach(dev);
|
||||
if (err != 0)
|
||||
return (err);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
sc->sc_pic = intr_pic_register(dev, 1);
|
||||
intr_pic_add_handler(device_get_parent(dev), sc->sc_pic,
|
||||
gicv3_its_intr, sc, GIC_FIRST_LPI, LPI_NIRQS);
|
||||
|
||||
/* Register this device to handle MSI interrupts */
|
||||
intr_msi_register(dev, 1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
@ -167,7 +167,7 @@ ENTRY(mpentry)
|
||||
bl drop_to_el1
|
||||
|
||||
/* Set the context id */
|
||||
msr contextidr_el1, x1
|
||||
msr contextidr_el1, xzr
|
||||
|
||||
/* Load the kernel page table */
|
||||
adr x24, pagetable_l0_ttbr1
|
||||
|
@ -172,6 +172,7 @@ cpu_startup(void *dummy)
|
||||
|
||||
undef_init();
|
||||
identify_cpu();
|
||||
install_cpu_errata();
|
||||
|
||||
vm_ksubmap_init(&kmi);
|
||||
bufinit();
|
||||
|
@ -282,6 +282,7 @@ init_secondary(uint64_t cpu)
|
||||
* runtime chip identification.
|
||||
*/
|
||||
identify_cpu();
|
||||
install_cpu_errata();
|
||||
|
||||
intr_pic_init_secondary();
|
||||
|
||||
|
@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
|
||||
#ifdef DEV_ACPI
|
||||
#include <contrib/dev/acpica/include/acpi.h>
|
||||
#include <dev/acpica/acpivar.h>
|
||||
#include "acpi_bus_if.h"
|
||||
#endif
|
||||
|
||||
extern struct bus_space memmap_bus;
|
||||
@ -460,11 +461,16 @@ nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells,
|
||||
#endif
|
||||
|
||||
#ifdef DEV_ACPI
|
||||
static int nexus_acpi_map_intr(device_t dev, device_t child, u_int irq, int trig, int pol);
|
||||
|
||||
static device_method_t nexus_acpi_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, nexus_acpi_probe),
|
||||
DEVMETHOD(device_attach, nexus_acpi_attach),
|
||||
|
||||
/* ACPI interface */
|
||||
DEVMETHOD(acpi_bus_map_intr, nexus_acpi_map_intr),
|
||||
|
||||
DEVMETHOD_END,
|
||||
};
|
||||
|
||||
@ -495,4 +501,30 @@ nexus_acpi_attach(device_t dev)
|
||||
nexus_add_child(dev, 10, "acpi", 0);
|
||||
return (nexus_attach(dev));
|
||||
}
|
||||
|
||||
static int
|
||||
nexus_acpi_map_intr(device_t dev, device_t child, u_int irq, int trig, int pol)
|
||||
{
|
||||
struct intr_map_data_acpi *acpi_data;
|
||||
size_t len;
|
||||
|
||||
len = sizeof(*acpi_data);
|
||||
acpi_data = (struct intr_map_data_acpi *)intr_alloc_map_data(
|
||||
INTR_MAP_DATA_ACPI, len, M_WAITOK | M_ZERO);
|
||||
acpi_data->irq = irq;
|
||||
acpi_data->pol = pol;
|
||||
acpi_data->trig = trig;
|
||||
|
||||
/*
|
||||
* TODO: This will only handle a single interrupt controller.
|
||||
* ACPI will map multiple controllers into a single virtual IRQ
|
||||
* space. Each controller has a System Vector Base to hold the
|
||||
* first irq it handles in this space. As such the correct way
|
||||
* to handle interrupts with ACPI is to search through the
|
||||
* controllers for the largest base value that is no larger than
|
||||
* the IRQ value.
|
||||
*/
|
||||
irq = intr_map_irq(NULL, 0, (struct intr_map_data *)acpi_data);
|
||||
return (irq);
|
||||
}
|
||||
#endif
|
||||
|
@ -4660,6 +4660,51 @@ pmap_activate(struct thread *td)
|
||||
critical_exit();
|
||||
}
|
||||
|
||||
struct pcb *
|
||||
pmap_switch(struct thread *old, struct thread *new)
|
||||
{
|
||||
pcpu_bp_harden bp_harden;
|
||||
struct pcb *pcb;
|
||||
|
||||
/* Store the new curthread */
|
||||
PCPU_SET(curthread, new);
|
||||
|
||||
/* And the new pcb */
|
||||
pcb = new->td_pcb;
|
||||
PCPU_SET(curpcb, pcb);
|
||||
|
||||
/*
|
||||
* TODO: We may need to flush the cache here if switching
|
||||
* to a user process.
|
||||
*/
|
||||
|
||||
if (old == NULL ||
|
||||
old->td_proc->p_md.md_l0addr != new->td_proc->p_md.md_l0addr) {
|
||||
__asm __volatile(
|
||||
/* Switch to the new pmap */
|
||||
"msr ttbr0_el1, %0 \n"
|
||||
"isb \n"
|
||||
|
||||
/* Invalidate the TLB */
|
||||
"dsb ishst \n"
|
||||
"tlbi vmalle1is \n"
|
||||
"dsb ish \n"
|
||||
"isb \n"
|
||||
: : "r"(new->td_proc->p_md.md_l0addr));
|
||||
|
||||
/*
|
||||
* Stop userspace from training the branch predictor against
|
||||
* other processes. This will call into a CPU specific
|
||||
* function that clears the branch predictor state.
|
||||
*/
|
||||
bp_harden = PCPU_GET(bp_harden);
|
||||
if (bp_harden != NULL)
|
||||
bp_harden();
|
||||
}
|
||||
|
||||
return (pcb);
|
||||
}
|
||||
|
||||
void
|
||||
pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_t sz)
|
||||
{
|
||||
|
@ -70,32 +70,15 @@ ENTRY(cpu_throw)
|
||||
|
||||
#ifdef VFP
|
||||
/* Backup the new thread pointer around a call to C code */
|
||||
mov x19, x1
|
||||
mov x19, x0
|
||||
mov x20, x1
|
||||
bl vfp_discard
|
||||
mov x1, x19
|
||||
mov x1, x20
|
||||
mov x0, x19
|
||||
#endif
|
||||
|
||||
/* Store the new curthread */
|
||||
str x1, [x18, #PC_CURTHREAD]
|
||||
/* And the new pcb */
|
||||
ldr x4, [x1, #TD_PCB]
|
||||
str x4, [x18, #PC_CURPCB]
|
||||
|
||||
/*
|
||||
* TODO: We may need to flush the cache here.
|
||||
*/
|
||||
|
||||
/* Switch to the new pmap */
|
||||
ldr x28, [x1, #TD_PROC]
|
||||
ldr x5, [x28, #(P_MD + MD_L0ADDR)]
|
||||
msr ttbr0_el1, x5
|
||||
isb
|
||||
|
||||
/* Invalidate the TLB */
|
||||
dsb ishst
|
||||
tlbi vmalle1
|
||||
dsb ish
|
||||
isb
|
||||
bl pmap_switch
|
||||
mov x4, x0
|
||||
|
||||
/* If we are single stepping, enable it */
|
||||
ldr w5, [x4, #PCB_FLAGS]
|
||||
@ -161,45 +144,25 @@ ENTRY(cpu_switch)
|
||||
ldr w5, [x4, #PCB_FLAGS]
|
||||
clear_step_flag w5, x6
|
||||
|
||||
#ifdef VFP
|
||||
mov x19, x0
|
||||
mov x20, x1
|
||||
mov x21, x2
|
||||
|
||||
#ifdef VFP
|
||||
/* Load the pcb address */
|
||||
mov x1, x4
|
||||
bl vfp_save_state
|
||||
mov x2, x21
|
||||
mov x1, x20
|
||||
mov x0, x19
|
||||
#endif
|
||||
|
||||
/* Store the new curthread */
|
||||
str x1, [x18, #PC_CURTHREAD]
|
||||
bl pmap_switch
|
||||
/* Move the new pcb out of the way */
|
||||
mov x4, x0
|
||||
|
||||
/*
|
||||
* Restore the saved context and set it as curpcb.
|
||||
*/
|
||||
ldr x4, [x1, #TD_PCB]
|
||||
str x4, [x18, #PC_CURPCB]
|
||||
|
||||
/*
|
||||
* TODO: We may need to flush the cache here if switching
|
||||
* to a user process.
|
||||
*/
|
||||
|
||||
/* Load the new proc address */
|
||||
ldr x28, [x1, #TD_PROC]
|
||||
|
||||
/* Switch to the new pmap */
|
||||
ldr x5, [x28, #(P_MD + MD_L0ADDR)]
|
||||
msr ttbr0_el1, x5
|
||||
isb
|
||||
|
||||
/* Invalidate the TLB */
|
||||
dsb ishst
|
||||
tlbi vmalle1
|
||||
dsb ish
|
||||
isb
|
||||
mov x2, x21
|
||||
mov x1, x20
|
||||
mov x0, x19
|
||||
|
||||
/*
|
||||
* Release the old thread. This doesn't need to be a store-release
|
||||
|
@ -352,6 +352,7 @@ do_el1h_sync(struct thread *td, struct trapframe *frame)
|
||||
void
|
||||
do_el0_sync(struct thread *td, struct trapframe *frame)
|
||||
{
|
||||
pcpu_bp_harden bp_harden;
|
||||
uint32_t exception;
|
||||
uint64_t esr, far;
|
||||
|
||||
@ -363,11 +364,25 @@ do_el0_sync(struct thread *td, struct trapframe *frame)
|
||||
esr = frame->tf_esr;
|
||||
exception = ESR_ELx_EXCEPTION(esr);
|
||||
switch (exception) {
|
||||
case EXCP_UNKNOWN:
|
||||
case EXCP_INSN_ABORT_L:
|
||||
far = READ_SPECIALREG(far_el1);
|
||||
|
||||
/*
|
||||
* Userspace may be trying to train the branch predictor to
|
||||
* attack the kernel. If we are on a CPU affected by this
|
||||
* call the handler to clear the branch predictor state.
|
||||
*/
|
||||
if (far > VM_MAXUSER_ADDRESS) {
|
||||
bp_harden = PCPU_GET(bp_harden);
|
||||
if (bp_harden != NULL)
|
||||
bp_harden();
|
||||
}
|
||||
break;
|
||||
case EXCP_UNKNOWN:
|
||||
case EXCP_DATA_ABORT_L:
|
||||
case EXCP_DATA_ABORT:
|
||||
far = READ_SPECIALREG(far_el1);
|
||||
break;
|
||||
}
|
||||
intr_enable();
|
||||
|
||||
|
@ -150,6 +150,7 @@ void cpu_halt(void) __dead2;
|
||||
void cpu_reset(void) __dead2;
|
||||
void fork_trampoline(void);
|
||||
void identify_cpu(void);
|
||||
void install_cpu_errata(void);
|
||||
void print_cpu_features(u_int);
|
||||
void swi_vm(void *v);
|
||||
|
||||
|
@ -35,11 +35,14 @@
|
||||
|
||||
#define ALT_STACK_SIZE 128
|
||||
|
||||
typedef int (*pcpu_bp_harden)(void);
|
||||
|
||||
#define PCPU_MD_FIELDS \
|
||||
u_int pc_acpi_id; /* ACPI CPU id */ \
|
||||
u_int pc_midr; /* stored MIDR value */ \
|
||||
uint64_t pc_clock; \
|
||||
char __pad[241]
|
||||
pcpu_bp_harden pc_bp_harden; \
|
||||
char __pad[233]
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
|
@ -106,6 +106,8 @@ struct pv_chunk {
|
||||
|
||||
typedef struct pmap *pmap_t;
|
||||
|
||||
struct thread;
|
||||
|
||||
#ifdef _KERNEL
|
||||
extern struct pmap kernel_pmap_store;
|
||||
#define kernel_pmap (&kernel_pmap_store)
|
||||
@ -156,6 +158,8 @@ bool pmap_get_tables(pmap_t, vm_offset_t, pd_entry_t **, pd_entry_t **,
|
||||
|
||||
int pmap_fault(pmap_t, uint64_t, uint64_t);
|
||||
|
||||
struct pcb *pmap_switch(struct thread *, struct thread *);
|
||||
|
||||
#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list))
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
@ -1062,15 +1062,12 @@ adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
|
||||
dp = arg;
|
||||
periph = dp->d_drv1;
|
||||
softc = (struct ada_softc *)periph->softc;
|
||||
cam_periph_lock(periph);
|
||||
secsize = softc->params.secsize;
|
||||
lba = offset / secsize;
|
||||
count = length / secsize;
|
||||
|
||||
if ((periph->flags & CAM_PERIPH_INVALID) != 0) {
|
||||
cam_periph_unlock(periph);
|
||||
if ((periph->flags & CAM_PERIPH_INVALID) != 0)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
memset(&ataio, 0, sizeof(ataio));
|
||||
if (length > 0) {
|
||||
@ -1098,7 +1095,6 @@ adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
|
||||
if (error != 0)
|
||||
printf("Aborting dump due to I/O error.\n");
|
||||
|
||||
cam_periph_unlock(periph);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1129,7 +1125,6 @@ adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
|
||||
if (error != 0)
|
||||
xpt_print(periph->path, "Synchronize cache failed\n");
|
||||
}
|
||||
cam_periph_unlock(periph);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -1160,8 +1160,6 @@ cam_periph_runccb(union ccb *ccb,
|
||||
struct bintime ltime;
|
||||
int error;
|
||||
bool must_poll;
|
||||
struct mtx *periph_mtx;
|
||||
struct cam_periph *periph;
|
||||
uint32_t timeout = 1;
|
||||
|
||||
starttime = NULL;
|
||||
@ -1188,20 +1186,26 @@ cam_periph_runccb(union ccb *ccb,
|
||||
* stopped for dumping, except when we call doadump from ddb. While the
|
||||
* scheduler is running in this case, we still need to poll the I/O to
|
||||
* avoid sleeping waiting for the ccb to complete.
|
||||
*
|
||||
* A panic triggered dump stops the scheduler, any callback from the
|
||||
* shutdown_post_sync event will run with the scheduler stopped, but
|
||||
* before we're officially dumping. To avoid hanging in adashutdown
|
||||
* initiated commands (or other similar situations), we have to test for
|
||||
* either SCHEDULER_STOPPED() here as well.
|
||||
*
|
||||
* To avoid locking problems, dumping/polling callers must call
|
||||
* without a periph lock held.
|
||||
*/
|
||||
must_poll = dumping;
|
||||
must_poll = dumping || SCHEDULER_STOPPED();
|
||||
ccb->ccb_h.cbfcnp = cam_periph_done;
|
||||
periph = xpt_path_periph(ccb->ccb_h.path);
|
||||
periph_mtx = cam_periph_mtx(periph);
|
||||
|
||||
/*
|
||||
* If we're polling, then we need to ensure that we have ample resources
|
||||
* in the periph. We also need to drop the periph lock while we're polling.
|
||||
* in the periph.
|
||||
* cam_periph_error can reschedule the ccb by calling xpt_action and returning
|
||||
* ERESTART, so we have to effect the polling in the do loop below.
|
||||
*/
|
||||
if (must_poll) {
|
||||
mtx_unlock(periph_mtx);
|
||||
timeout = xpt_poll_setup(ccb);
|
||||
}
|
||||
|
||||
@ -1227,9 +1231,6 @@ cam_periph_runccb(union ccb *ccb,
|
||||
} while (error == ERESTART);
|
||||
}
|
||||
|
||||
if (must_poll)
|
||||
mtx_lock(periph_mtx);
|
||||
|
||||
if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) {
|
||||
cam_release_devq(ccb->ccb_h.path,
|
||||
/* relsim_flags */0,
|
||||
|
@ -202,7 +202,10 @@ int cam_periph_error(union ccb *ccb, cam_flags camflags,
|
||||
static __inline struct mtx *
|
||||
cam_periph_mtx(struct cam_periph *periph)
|
||||
{
|
||||
return (xpt_path_mtx(periph->path));
|
||||
if (periph != NULL)
|
||||
return (xpt_path_mtx(periph->path));
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#define cam_periph_owned(periph) \
|
||||
|
@ -3383,6 +3383,7 @@ xpt_run_allocq(struct cam_periph *periph, int sleep)
|
||||
cam_periph_assert(periph, MA_OWNED);
|
||||
if (periph->periph_allocating)
|
||||
return;
|
||||
cam_periph_doacquire(periph);
|
||||
periph->periph_allocating = 1;
|
||||
CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_run_allocq(%p)\n", periph));
|
||||
device = periph->path->device;
|
||||
@ -3426,6 +3427,7 @@ xpt_run_allocq(struct cam_periph *periph, int sleep)
|
||||
if (ccb != NULL)
|
||||
xpt_release_ccb(ccb);
|
||||
periph->periph_allocating = 0;
|
||||
cam_periph_release_locked(periph);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -388,15 +388,12 @@ ndadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
|
||||
dp = arg;
|
||||
periph = dp->d_drv1;
|
||||
softc = (struct nda_softc *)periph->softc;
|
||||
cam_periph_lock(periph);
|
||||
secsize = softc->disk->d_sectorsize;
|
||||
lba = offset / secsize;
|
||||
count = length / secsize;
|
||||
|
||||
if ((periph->flags & CAM_PERIPH_INVALID) != 0) {
|
||||
cam_periph_unlock(periph);
|
||||
if ((periph->flags & CAM_PERIPH_INVALID) != 0)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/* xpt_get_ccb returns a zero'd allocation for the ccb, mimic that here */
|
||||
memset(&nvmeio, 0, sizeof(nvmeio));
|
||||
@ -408,7 +405,6 @@ ndadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
|
||||
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
|
||||
if (error != 0)
|
||||
printf("Aborting dump due to I/O error %d.\n", error);
|
||||
cam_periph_unlock(periph);
|
||||
|
||||
return (error);
|
||||
}
|
||||
@ -422,7 +418,6 @@ ndadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
|
||||
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
|
||||
if (error != 0)
|
||||
xpt_print(periph->path, "flush cmd failed\n");
|
||||
cam_periph_unlock(periph);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -318,8 +318,7 @@ nvme_probe_start(struct cam_periph *periph, union ccb *start_ccb)
|
||||
xpt_done(start_ccb);
|
||||
}
|
||||
cam_periph_invalidate(periph);
|
||||
/* Can't release periph since we hit a (possibly bogus) assertion */
|
||||
// cam_periph_release_locked(periph);
|
||||
cam_periph_release_locked(periph);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1647,13 +1647,10 @@ dadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t leng
|
||||
dp = arg;
|
||||
periph = dp->d_drv1;
|
||||
softc = (struct da_softc *)periph->softc;
|
||||
cam_periph_lock(periph);
|
||||
secsize = softc->params.secsize;
|
||||
|
||||
if ((softc->flags & DA_FLAG_PACK_INVALID) != 0) {
|
||||
cam_periph_unlock(periph);
|
||||
if ((softc->flags & DA_FLAG_PACK_INVALID) != 0)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
memset(&csio, 0, sizeof(csio));
|
||||
if (length > 0) {
|
||||
@ -1676,7 +1673,6 @@ dadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t leng
|
||||
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
|
||||
if (error != 0)
|
||||
printf("Aborting dump due to I/O error.\n");
|
||||
cam_periph_unlock(periph);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1700,7 +1696,6 @@ dadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t leng
|
||||
if (error != 0)
|
||||
xpt_print(periph->path, "Synchronize cache failed\n");
|
||||
}
|
||||
cam_periph_unlock(periph);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,65 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/cons.h>
|
||||
|
||||
/**************************************************************
|
||||
* CCB Macros
|
||||
**************************************************************/
|
||||
|
||||
/* (II) static allocated memory */
|
||||
#define GENERIC_CCB_STATIC_ALLOC(DEV, CCBTYPE) \
|
||||
static struct CCBTYPE##que CCBTYPE##que;
|
||||
|
||||
/* (III) functions */
|
||||
#define GENERIC_CCB(DEV, CCBTYPE, CHAIN) \
|
||||
\
|
||||
void \
|
||||
DEV##_init_ccbque(int count) \
|
||||
{ \
|
||||
if (CCBTYPE##que.maxccb == 0) \
|
||||
TAILQ_INIT(&CCBTYPE##que.CCBTYPE##tab); \
|
||||
CCBTYPE##que.maxccb += count; \
|
||||
} \
|
||||
\
|
||||
struct CCBTYPE * \
|
||||
DEV##_get_ccb(void) \
|
||||
{ \
|
||||
struct CCBTYPE *cb; \
|
||||
\
|
||||
if (CCBTYPE##que.count < CCBTYPE##que.maxccb) \
|
||||
{ \
|
||||
CCBTYPE##que.count ++; \
|
||||
cb = TAILQ_FIRST(&(CCBTYPE##que.CCBTYPE##tab)); \
|
||||
if (cb != NULL) { \
|
||||
TAILQ_REMOVE(&CCBTYPE##que.CCBTYPE##tab, cb, CHAIN);\
|
||||
goto out; \
|
||||
} else { \
|
||||
cb = malloc(sizeof(*cb), M_DEVBUF, M_NOWAIT | M_ZERO); \
|
||||
if (cb != NULL) \
|
||||
goto out; \
|
||||
} \
|
||||
CCBTYPE##que.count --; \
|
||||
} \
|
||||
\
|
||||
cb = NULL; \
|
||||
\
|
||||
out: \
|
||||
return cb; \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
DEV##_free_ccb(struct CCBTYPE *cb) \
|
||||
{ \
|
||||
\
|
||||
TAILQ_INSERT_TAIL(&CCBTYPE##que.CCBTYPE##tab, cb, CHAIN); \
|
||||
CCBTYPE##que.count --; \
|
||||
\
|
||||
if (CCBTYPE##que.flags & CCB_MWANTED) \
|
||||
{ \
|
||||
CCBTYPE##que.flags &= ~CCB_MWANTED; \
|
||||
wakeup ((caddr_t) &CCBTYPE##que.count); \
|
||||
} \
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
* Constants
|
||||
**************************************************************/
|
||||
|
@ -57,7 +57,61 @@
|
||||
#include <cam/cam_debug.h>
|
||||
|
||||
#include <cam/scsi/scsi_dvcfg.h>
|
||||
#include <i386/isa/ccbque.h>
|
||||
/************ ccbque.h ***************************/
|
||||
|
||||
/* $NetBSD$ */
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* [NetBSD for NEC PC98 series]
|
||||
* Copyright (c) 1994, 1995, 1996 NetBSD/pc98 porting staff.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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$
|
||||
*/
|
||||
/*
|
||||
* Common command control queue funcs.
|
||||
* Written by N. Honda.
|
||||
*/
|
||||
|
||||
#define CCB_MWANTED 0x01
|
||||
|
||||
/* (I) structure and prototype */
|
||||
#define GENERIC_CCB_ASSERT(DEV, CCBTYPE) \
|
||||
TAILQ_HEAD(CCBTYPE##tab, CCBTYPE); \
|
||||
struct CCBTYPE##que { \
|
||||
struct CCBTYPE##tab CCBTYPE##tab; \
|
||||
int count; \
|
||||
int maxccb; \
|
||||
u_int flags; \
|
||||
}; \
|
||||
\
|
||||
void DEV##_init_ccbque(int); \
|
||||
struct CCBTYPE *DEV##_get_ccb(void); \
|
||||
void DEV##_free_ccb(struct CCBTYPE *);
|
||||
|
||||
/******** functions macro ************************/
|
||||
|
||||
|
@ -1629,13 +1629,21 @@ zfs_mount(vfs_t *vfsp)
|
||||
* can be interrogated.
|
||||
*/
|
||||
if ((uap->flags & MS_DATA) && uap->datalen > 0)
|
||||
return (SET_ERROR(EINVAL));
|
||||
|
||||
/*
|
||||
* Get the objset name (the "special" mount argument).
|
||||
*/
|
||||
if (error = pn_get(uap->spec, fromspace, &spn))
|
||||
return (error);
|
||||
|
||||
osname = spn.pn_path;
|
||||
#else /* !illumos */
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_MOUNT_ZFS))
|
||||
return (SET_ERROR(EPERM));
|
||||
|
||||
if (vfs_getopt(vfsp->mnt_optnew, "from", (void **)&osname, NULL))
|
||||
return (SET_ERROR(EINVAL));
|
||||
#endif /* illumos */
|
||||
|
||||
/*
|
||||
* If full-owner-access is enabled and delegated administration is
|
||||
@ -1645,6 +1653,7 @@ zfs_mount(vfs_t *vfsp)
|
||||
dsl_deleg_access(osname, ZFS_DELEG_PERM_MOUNT, cr) != ECANCELED) {
|
||||
secpolicy_fs_mount_clearopts(cr, vfsp);
|
||||
}
|
||||
#endif /* illumos */
|
||||
|
||||
/*
|
||||
* Check for mount privilege?
|
||||
|
@ -60,7 +60,7 @@ cloudabi32_sys_sock_recv(struct thread *td,
|
||||
/* Convert iovecs to native format. */
|
||||
if (ri.ri_data_len > UIO_MAXIOV)
|
||||
return (EINVAL);
|
||||
iov = malloc(ri.ri_data_len * sizeof(struct iovec),
|
||||
iov = mallocarray(ri.ri_data_len, sizeof(struct iovec),
|
||||
M_SOCKET, M_WAITOK);
|
||||
user_iov = TO_PTR(ri.ri_data);
|
||||
for (i = 0; i < ri.ri_data_len; i++) {
|
||||
@ -104,7 +104,7 @@ cloudabi32_sys_sock_send(struct thread *td,
|
||||
/* Convert iovecs to native format. */
|
||||
if (si.si_data_len > UIO_MAXIOV)
|
||||
return (EINVAL);
|
||||
iov = malloc(si.si_data_len * sizeof(struct iovec),
|
||||
iov = mallocarray(si.si_data_len, sizeof(struct iovec),
|
||||
M_SOCKET, M_WAITOK);
|
||||
user_iov = TO_PTR(si.si_data);
|
||||
for (i = 0; i < si.si_data_len; i++) {
|
||||
|
@ -60,7 +60,7 @@ cloudabi64_sys_sock_recv(struct thread *td,
|
||||
/* Convert iovecs to native format. */
|
||||
if (ri.ri_data_len > UIO_MAXIOV)
|
||||
return (EINVAL);
|
||||
iov = malloc(ri.ri_data_len * sizeof(struct iovec),
|
||||
iov = mallocarray(ri.ri_data_len, sizeof(struct iovec),
|
||||
M_SOCKET, M_WAITOK);
|
||||
user_iov = TO_PTR(ri.ri_data);
|
||||
for (i = 0; i < ri.ri_data_len; i++) {
|
||||
@ -104,7 +104,7 @@ cloudabi64_sys_sock_send(struct thread *td,
|
||||
/* Convert iovecs to native format. */
|
||||
if (si.si_data_len > UIO_MAXIOV)
|
||||
return (EINVAL);
|
||||
iov = malloc(si.si_data_len * sizeof(struct iovec),
|
||||
iov = mallocarray(si.si_data_len, sizeof(struct iovec),
|
||||
M_SOCKET, M_WAITOK);
|
||||
user_iov = TO_PTR(si.si_data);
|
||||
for (i = 0; i < si.si_data_len; i++) {
|
||||
|
@ -46,7 +46,6 @@ MALLOC_DECLARE(M_KMALLOC);
|
||||
#define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO)
|
||||
#define kzalloc_node(size, flags, node) kmalloc(size, (flags) | __GFP_ZERO)
|
||||
#define kfree_const(ptr) kfree(ptr)
|
||||
#define kcalloc(n, size, flags) kmalloc((n) * (size), (flags) | __GFP_ZERO)
|
||||
#define vzalloc(size) __vmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 0)
|
||||
#define vfree(arg) kfree(arg)
|
||||
#define kvfree(arg) kfree(arg)
|
||||
@ -100,6 +99,13 @@ kmalloc(size_t size, gfp_t flags)
|
||||
return (malloc(size, M_KMALLOC, linux_check_m_flags(flags)));
|
||||
}
|
||||
|
||||
static inline void *
|
||||
kcalloc(size_t n, size_t size, gfp_t flags)
|
||||
{
|
||||
flags |= __GFP_ZERO;
|
||||
return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags)));
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__vmalloc(size_t size, gfp_t flags, int other)
|
||||
{
|
||||
@ -115,9 +121,7 @@ vmalloc_32(size_t size)
|
||||
static inline void *
|
||||
kmalloc_array(size_t n, size_t size, gfp_t flags)
|
||||
{
|
||||
if (size != 0 && n > (SIZE_MAX / size))
|
||||
return (NULL);
|
||||
return (malloc(n * size, M_KMALLOC, linux_check_m_flags(flags)));
|
||||
return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags)));
|
||||
}
|
||||
|
||||
static inline void *
|
||||
|
@ -626,6 +626,23 @@ contrib/ngatm/netnatm/sig/sig_unimsgcpy.c optional ngatm_uni \
|
||||
compile-with "${NORMAL_C} -I$S/contrib/ngatm"
|
||||
contrib/ngatm/netnatm/sig/sig_verify.c optional ngatm_uni \
|
||||
compile-with "${NORMAL_C} -I$S/contrib/ngatm"
|
||||
# Zstd
|
||||
contrib/zstd/lib/freebsd/zstd_kmalloc.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/common/zstd_common.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/common/fse_decompress.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/common/entropy_common.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/common/error_private.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/common/xxhash.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/compress/zstd_compress.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/compress/fse_compress.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/compress/huf_compress.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/compress/zstd_double_fast.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/compress/zstd_fast.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/compress/zstd_lazy.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/compress/zstd_ldm.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/compress/zstd_opt.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/decompress/zstd_decompress.c standard compile-with ${ZSTD_C}
|
||||
contrib/zstd/lib/decompress/huf_decompress.c standard compile-with ${ZSTD_C}
|
||||
crypto/blowfish/bf_ecb.c optional ipsec | ipsec_support
|
||||
crypto/blowfish/bf_skey.c optional crypto | ipsec | ipsec_support
|
||||
crypto/camellia/camellia.c optional crypto | ipsec | ipsec_support
|
||||
@ -3750,7 +3767,6 @@ kern/kern_exit.c standard
|
||||
kern/kern_fail.c standard
|
||||
kern/kern_ffclock.c standard
|
||||
kern/kern_fork.c standard
|
||||
kern/kern_gzio.c optional gzio
|
||||
kern/kern_hhook.c standard
|
||||
kern/kern_idle.c standard
|
||||
kern/kern_intr.c standard
|
||||
@ -3826,6 +3842,7 @@ kern/subr_bus_dma.c standard
|
||||
kern/subr_bufring.c standard
|
||||
kern/subr_capability.c standard
|
||||
kern/subr_clock.c standard
|
||||
kern/subr_compressor.c standard
|
||||
kern/subr_counter.c standard
|
||||
kern/subr_devstat.c standard
|
||||
kern/subr_disk.c standard
|
||||
|
@ -23,17 +23,13 @@ cloudabi64_vdso_blob.o optional compat_cloudabi64 \
|
||||
no-implicit-rule \
|
||||
clean "cloudabi64_vdso_blob.o"
|
||||
#
|
||||
|
||||
# Allwinner common files
|
||||
arm/allwinner/a10_ehci.c optional ehci aw_ehci fdt
|
||||
arm/allwinner/aw_gpio.c optional gpio aw_gpio fdt
|
||||
arm/allwinner/aw_mmc.c optional mmc aw_mmc fdt
|
||||
arm/allwinner/a64/a64_padconf.c optional soc_allwinner_a64 fdt
|
||||
arm/allwinner/a64/a64_r_padconf.c optional soc_allwinner_a64 fdt
|
||||
arm/allwinner/h3/h3_padconf.c optional soc_allwinner_h5 fdt
|
||||
arm/allwinner/h3/h3_r_padconf.c optional soc_allwinner_h5 fdt
|
||||
arm/allwinner/aw_ccu.c optional aw_ccu fdt
|
||||
arm/allwinner/aw_nmi.c optional aw_nmi fdt \
|
||||
compile-with "${NORMAL_C} -I$S/gnu/dts/include"
|
||||
arm/allwinner/aw_reset.c optional aw_ccu fdt
|
||||
arm/allwinner/aw_rsb.c optional aw_rsb fdt
|
||||
arm/allwinner/aw_rtc.c optional aw_rtc fdt
|
||||
arm/allwinner/aw_sid.c optional aw_sid fdt
|
||||
@ -41,25 +37,23 @@ arm/allwinner/aw_thermal.c optional aw_thermal fdt
|
||||
arm/allwinner/aw_usbphy.c optional ehci aw_usbphy fdt
|
||||
arm/allwinner/aw_wdog.c optional aw_wdog fdt
|
||||
arm/allwinner/axp81x.c optional axp81x fdt
|
||||
arm/allwinner/clk/aw_ahbclk.c optional aw_ccu fdt
|
||||
arm/allwinner/clk/aw_apbclk.c optional aw_ccu fdt
|
||||
arm/allwinner/clk/aw_axiclk.c optional aw_ccu fdt
|
||||
arm/allwinner/clk/aw_cpuclk.c optional aw_ccu fdt
|
||||
arm/allwinner/clk/aw_gate.c optional aw_ccu fdt
|
||||
arm/allwinner/clk/aw_modclk.c optional aw_ccu fdt
|
||||
arm/allwinner/clk/aw_pll.c optional aw_ccu fdt \
|
||||
compile-with "${NORMAL_C} -I$S/gnu/dts/include"
|
||||
arm/allwinner/clk/aw_thsclk.c optional aw_ccu fdt
|
||||
arm/allwinner/clk/aw_usbclk.c optional aw_ccu fdt
|
||||
arm/allwinner/clkng/aw_ccung.c optional aw_ccu fdt
|
||||
arm/allwinner/if_awg.c optional awg ext_resources syscon fdt
|
||||
|
||||
# Allwinner clock driver
|
||||
arm/allwinner/clkng/aw_ccung.c optional aw_ccu fdt
|
||||
arm/allwinner/clkng/aw_clk_nkmp.c optional aw_ccu fdt
|
||||
arm/allwinner/clkng/aw_clk_nm.c optional aw_ccu fdt
|
||||
arm/allwinner/clkng/aw_clk_nm.c optional aw_ccu fdt
|
||||
arm/allwinner/clkng/aw_clk_prediv_mux.c optional aw_ccu fdt
|
||||
arm/allwinner/clkng/ccu_a64.c optional aw_ccu fdt
|
||||
arm/allwinner/clkng/ccu_h3.c optional aw_ccu fdt
|
||||
arm/allwinner/clkng/ccu_a64.c optional soc_allwinner_a64 aw_ccu fdt
|
||||
arm/allwinner/clkng/ccu_h3.c optional soc_allwinner_h5 aw_ccu fdt
|
||||
arm/allwinner/clkng/ccu_sun8i_r.c optional aw_ccu fdt
|
||||
|
||||
arm/allwinner/if_awg.c optional awg ext_resources syscon fdt
|
||||
# Allwinner padconf files
|
||||
arm/allwinner/a64/a64_padconf.c optional soc_allwinner_a64 fdt
|
||||
arm/allwinner/a64/a64_r_padconf.c optional soc_allwinner_a64 fdt
|
||||
arm/allwinner/h3/h3_padconf.c optional soc_allwinner_h5 fdt
|
||||
arm/allwinner/h3/h3_r_padconf.c optional soc_allwinner_h5 fdt
|
||||
|
||||
arm/annapurna/alpine/alpine_ccu.c optional al_ccu fdt
|
||||
arm/annapurna/alpine/alpine_nb_service.c optional al_nb_service fdt
|
||||
arm/annapurna/alpine/alpine_pci.c optional al_pci fdt
|
||||
@ -69,6 +63,7 @@ arm/annapurna/alpine/alpine_serdes.c optional al_serdes fdt \
|
||||
compile-with "${CC} -c -o ${.TARGET} ${CFLAGS} -I$S/contrib/alpine-hal -I$S/contrib/alpine-hal/eth ${PROF} ${.IMPSRC}"
|
||||
arm/arm/generic_timer.c standard
|
||||
arm/arm/gic.c standard
|
||||
arm/arm/gic_acpi.c optional acpi
|
||||
arm/arm/gic_fdt.c optional fdt
|
||||
arm/arm/pmu.c standard
|
||||
arm/broadcom/bcm2835/bcm2835_audio.c optional sound vchiq fdt \
|
||||
@ -102,6 +97,7 @@ arm64/arm64/bzero.S standard
|
||||
arm64/arm64/clock.c standard
|
||||
arm64/arm64/copyinout.S standard
|
||||
arm64/arm64/copystr.c standard
|
||||
arm64/arm64/cpu_errata.c standard
|
||||
arm64/arm64/cpufunc_asm.S standard
|
||||
arm64/arm64/db_disasm.c optional ddb
|
||||
arm64/arm64/db_interface.c optional ddb
|
||||
@ -116,6 +112,7 @@ arm64/arm64/exception.S standard
|
||||
arm64/arm64/freebsd32_machdep.c optional compat_freebsd32
|
||||
arm64/arm64/gicv3_its.c optional intrng fdt
|
||||
arm64/arm64/gic_v3.c standard
|
||||
arm64/arm64/gic_v3_acpi.c optional acpi
|
||||
arm64/arm64/gic_v3_fdt.c optional fdt
|
||||
arm64/arm64/identcpu.c standard
|
||||
arm64/arm64/in_cksum.c optional inet | inet6
|
||||
@ -172,6 +169,7 @@ armv8_crypto_wrap.o optional armv8crypto \
|
||||
clean "armv8_crypto_wrap.o"
|
||||
crypto/blowfish/bf_enc.c optional crypto | ipsec | ipsec_support
|
||||
crypto/des/des_enc.c optional crypto | ipsec | ipsec_support | netsmb
|
||||
dev/acpica/acpi_bus_if.m optional acpi
|
||||
dev/acpica/acpi_if.m optional acpi
|
||||
dev/ahci/ahci_generic.c optional ahci
|
||||
dev/axgbe/if_axgbe.c optional axgbe
|
||||
|
@ -493,6 +493,7 @@ i386/i386/mpboot.s optional smp
|
||||
i386/i386/npx.c standard
|
||||
i386/i386/perfmon.c optional perfmon
|
||||
i386/i386/pmap.c standard
|
||||
i386/i386/prof_machdep.c optional profiling-routine
|
||||
i386/i386/ptrace_machdep.c standard
|
||||
i386/i386/support.s standard
|
||||
i386/i386/swtch.s standard
|
||||
@ -520,8 +521,6 @@ i386/ibcs2/ibcs2_util.c optional ibcs2
|
||||
i386/ibcs2/ibcs2_xenix.c optional ibcs2
|
||||
i386/ibcs2/ibcs2_xenix_sysent.c optional ibcs2
|
||||
i386/ibcs2/imgact_coff.c optional ibcs2
|
||||
i386/isa/pmtimer.c optional pmtimer
|
||||
i386/isa/prof_machdep.c optional profiling-routine
|
||||
i386/linux/imgact_linux.c optional compat_linux
|
||||
i386/linux/linux_dummy.c optional compat_linux
|
||||
i386/linux/linux_machdep.c optional compat_linux
|
||||
|
@ -112,3 +112,6 @@ cddl/compat/opensolaris/kern/opensolaris_atomic.c optional zfs | dtrace compile-
|
||||
cddl/dev/dtrace/mips/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}"
|
||||
cddl/dev/dtrace/mips/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}"
|
||||
cddl/dev/fbt/mips/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}"
|
||||
|
||||
# Zstd
|
||||
contrib/zstd/lib/freebsd/zstd_kfreebsd.c standard compile-with ${ZSTD_C}
|
||||
|
@ -183,6 +183,12 @@ powerpc/powermac/smusat.c optional powermac smu
|
||||
powerpc/powermac/uninorth.c optional powermac
|
||||
powerpc/powermac/uninorthpci.c optional powermac pci
|
||||
powerpc/powermac/vcoregpio.c optional powermac
|
||||
powerpc/powernv/opal.c optional powernv
|
||||
powerpc/powernv/opal_console.c optional powernv
|
||||
powerpc/powernv/opal_dev.c optional powernv
|
||||
powerpc/powernv/opal_pci.c optional powernv pci
|
||||
powerpc/powernv/opalcall.S optional powernv
|
||||
powerpc/powernv/platform_powernv.c optional powernv
|
||||
powerpc/powerpc/altivec.c optional powerpc | powerpc64
|
||||
powerpc/powerpc/autoconf.c standard
|
||||
powerpc/powerpc/bcopy.c standard
|
||||
|
@ -14,6 +14,7 @@ kern/subr_dummy_vdso_tc.c standard
|
||||
libkern/bcmp.c standard
|
||||
libkern/ffs.c standard
|
||||
libkern/ffsl.c standard
|
||||
libkern/ffsll.c standard
|
||||
libkern/fls.c standard
|
||||
libkern/flsl.c standard
|
||||
libkern/flsll.c standard
|
||||
@ -56,3 +57,6 @@ riscv/riscv/uio_machdep.c standard
|
||||
riscv/riscv/uma_machdep.c standard
|
||||
riscv/riscv/unwind.c optional ddb | kdtrace_hooks | stack
|
||||
riscv/riscv/vm_machdep.c standard
|
||||
|
||||
# Zstd
|
||||
contrib/zstd/lib/freebsd/zstd_kfreebsd.c standard compile-with ${ZSTD_C}
|
||||
|
@ -132,6 +132,9 @@ NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
|
||||
NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \
|
||||
-m ${LD_EMULATION} -o ${.TARGET} ${.ALLSRC:M*.fw}
|
||||
|
||||
# for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS)
|
||||
ZSTD_C= ${CC} -c -DZSTD_HEAPMODE=1 -I$S/contrib/zstd/lib/freebsd ${CFLAGS} -I$S/contrib/zstd/lib -I$S/contrib/zstd/lib/common ${WERROR} -Wno-inline -Wno-missing-prototypes ${PROF} -U__BMI__ ${.IMPSRC}
|
||||
|
||||
# Common for dtrace / zfs
|
||||
CDDL_CFLAGS= -DFREEBSD_NAMECACHE -nostdinc -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common -I$S -I$S/cddl/contrib/opensolaris/common ${CFLAGS} -Wno-unknown-pragmas -Wno-missing-prototypes -Wno-undef -Wno-strict-prototypes -Wno-cast-qual -Wno-parentheses -Wno-redundant-decls -Wno-missing-braces -Wno-uninitialized -Wno-unused -Wno-inline -Wno-switch -Wno-pointer-arith -Wno-unknown-pragmas
|
||||
CDDL_CFLAGS+= -include $S/cddl/compat/opensolaris/sys/debug_compat.h
|
||||
|
@ -23,6 +23,7 @@ MPC85XX opt_platform.h
|
||||
POWERMAC opt_platform.h
|
||||
PS3 opt_platform.h
|
||||
MAMBO
|
||||
POWERNV
|
||||
PSERIES
|
||||
PSIM
|
||||
|
||||
|
@ -301,6 +301,32 @@ ipf_state_soft_destroy(softc, arg)
|
||||
KFREE(softs);
|
||||
}
|
||||
|
||||
static void *
|
||||
ipf_state_seed_alloc(u_int state_size, u_int state_max)
|
||||
{
|
||||
u_int i;
|
||||
u_long *state_seed;
|
||||
KMALLOCS(state_seed, u_long *, state_size * sizeof(*state_seed));
|
||||
if (state_seed == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < state_size; i++) {
|
||||
/*
|
||||
* XXX - ipf_state_seed[X] should be a random number of sorts.
|
||||
*/
|
||||
#if FREEBSD_GE_REV(400000)
|
||||
state_seed[i] = arc4random();
|
||||
#else
|
||||
state_seed[i] = ((u_long)state_seed + i) * state_size;
|
||||
state_seed[i] ^= 0xa5a55a5a;
|
||||
state_seed[i] *= (u_long)state_seed;
|
||||
state_seed[i] ^= 0x5a5aa5a5;
|
||||
state_seed[i] *= state_max;
|
||||
#endif
|
||||
}
|
||||
return state_seed;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* Function: ipf_state_soft_init */
|
||||
@ -333,27 +359,11 @@ ipf_state_soft_init(softc, arg)
|
||||
bzero((char *)softs->ipf_state_table,
|
||||
softs->ipf_state_size * sizeof(ipstate_t *));
|
||||
|
||||
KMALLOCS(softs->ipf_state_seed, u_long *,
|
||||
softs->ipf_state_size * sizeof(*softs->ipf_state_seed));
|
||||
softs->ipf_state_seed = ipf_state_seed_alloc(softs->ipf_state_size,
|
||||
softs->ipf_state_max);
|
||||
if (softs->ipf_state_seed == NULL)
|
||||
return -2;
|
||||
|
||||
for (i = 0; i < softs->ipf_state_size; i++) {
|
||||
/*
|
||||
* XXX - ipf_state_seed[X] should be a random number of sorts.
|
||||
*/
|
||||
#if FREEBSD_GE_REV(400000)
|
||||
softs->ipf_state_seed[i] = arc4random();
|
||||
#else
|
||||
softs->ipf_state_seed[i] = ((u_long)softs->ipf_state_seed + i) *
|
||||
softs->ipf_state_size;
|
||||
softs->ipf_state_seed[i] ^= 0xa5a55a5a;
|
||||
softs->ipf_state_seed[i] *= (u_long)softs->ipf_state_seed;
|
||||
softs->ipf_state_seed[i] ^= 0x5a5aa5a5;
|
||||
softs->ipf_state_seed[i] *= softs->ipf_state_max;
|
||||
#endif
|
||||
}
|
||||
|
||||
KMALLOCS(softs->ipf_state_stats.iss_bucketlen, u_int *,
|
||||
softs->ipf_state_size * sizeof(u_int));
|
||||
if (softs->ipf_state_stats.iss_bucketlen == NULL)
|
||||
@ -5259,6 +5269,7 @@ ipf_state_rehash(softc, t, p)
|
||||
{
|
||||
ipf_state_softc_t *softs = softc->ipf_state_soft;
|
||||
ipstate_t **newtab, *is;
|
||||
u_long *newseed;
|
||||
u_int *bucketlens;
|
||||
u_int maxbucket;
|
||||
u_int newsize;
|
||||
@ -5285,6 +5296,14 @@ ipf_state_rehash(softc, t, p)
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
newseed = ipf_state_seed_alloc(newsize, softs->ipf_state_max);
|
||||
if (newseed == NULL) {
|
||||
KFREES(bucketlens, newsize * sizeof(*bucketlens));
|
||||
KFREES(newtab, newsize * sizeof(*newtab));
|
||||
IPFERROR(100037);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
for (maxbucket = 0, i = newsize; i > 0; i >>= 1)
|
||||
maxbucket++;
|
||||
maxbucket *= 2;
|
||||
@ -5300,6 +5319,12 @@ ipf_state_rehash(softc, t, p)
|
||||
}
|
||||
softs->ipf_state_table = newtab;
|
||||
|
||||
if (softs->ipf_state_seed != NULL) {
|
||||
KFREES(softs->ipf_state_seed,
|
||||
softs->ipf_state_size * sizeof(*softs->ipf_state_seed));
|
||||
}
|
||||
softs->ipf_state_seed = newseed;
|
||||
|
||||
if (softs->ipf_state_stats.iss_bucketlen != NULL) {
|
||||
KFREES(softs->ipf_state_stats.iss_bucketlen,
|
||||
softs->ipf_state_size * sizeof(u_int));
|
||||
|
@ -329,7 +329,8 @@ device_rlprintf(int pps, device_t dev, const char *fmt, ...)
|
||||
MALLOC_DECLARE(M_VCHI);
|
||||
|
||||
#define kmalloc(size, flags) malloc((size), M_VCHI, M_NOWAIT | M_ZERO)
|
||||
#define kcalloc(n, size, flags) malloc((n) * (size), M_VCHI, M_NOWAIT | M_ZERO)
|
||||
#define kcalloc(n, size, flags) mallocarray((n), (size), M_VCHI, \
|
||||
M_NOWAIT | M_ZERO)
|
||||
#define kzalloc(a, b) kcalloc(1, (a), (b))
|
||||
#define kfree(p) free(p, M_VCHI)
|
||||
|
||||
|
3
sys/contrib/zstd/lib/freebsd/stddef.h
Normal file
3
sys/contrib/zstd/lib/freebsd/stddef.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* This file is in the public domain */
|
||||
/* $FreeBSD$ */
|
||||
#include "zstd_kfreebsd.h"
|
3
sys/contrib/zstd/lib/freebsd/stdint.h
Normal file
3
sys/contrib/zstd/lib/freebsd/stdint.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* This file is in the public domain */
|
||||
/* $FreeBSD$ */
|
||||
#include "zstd_kfreebsd.h"
|
3
sys/contrib/zstd/lib/freebsd/stdio.h
Normal file
3
sys/contrib/zstd/lib/freebsd/stdio.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* This file is in the public domain */
|
||||
/* $FreeBSD$ */
|
||||
#include "zstd_kfreebsd.h"
|
3
sys/contrib/zstd/lib/freebsd/stdlib.h
Normal file
3
sys/contrib/zstd/lib/freebsd/stdlib.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* This file is in the public domain */
|
||||
/* $FreeBSD$ */
|
||||
#include "zstd_kfreebsd.h"
|
3
sys/contrib/zstd/lib/freebsd/string.h
Normal file
3
sys/contrib/zstd/lib/freebsd/string.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* This file is in the public domain */
|
||||
/* $FreeBSD$ */
|
||||
#include "zstd_kfreebsd.h"
|
89
sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.c
Normal file
89
sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.c
Normal file
@ -0,0 +1,89 @@
|
||||
/*-
|
||||
* Copyright (c) 2018 Conrad Meyer <cem@freebsd.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
#include "zstd_kfreebsd.h"
|
||||
#include <sys/endian.h>
|
||||
|
||||
/*
|
||||
* The kernel as a standalone target does not link against libgcc or
|
||||
* libcompiler-rt. On platforms (e.g., MIPS and RISCV) that do not have a
|
||||
* direct assembly implementation of the relevant builtin functions that zstd
|
||||
* references, the compiler converts them into calls to the runtime library
|
||||
* intrinsics. Since the kernel does not link against the runtime libraries,
|
||||
* this results in a failure to link the kernel.
|
||||
*
|
||||
* The goal of the following definitions is to use supported kernel constructs
|
||||
* to implement the same functionality, without adding diff to the Zstd contrib
|
||||
* code.
|
||||
*
|
||||
* A subsequent enhancement might create a mini compiler-rt library for kernel
|
||||
* use and move these over there instead.
|
||||
*/
|
||||
|
||||
/* Swap endianness */
|
||||
int
|
||||
__bswapsi2(int x)
|
||||
{
|
||||
return (bswap32(x));
|
||||
}
|
||||
|
||||
long long
|
||||
__bswapdi2(long long x)
|
||||
{
|
||||
return (bswap64(x));
|
||||
}
|
||||
|
||||
/* Count trailing zeros */
|
||||
int
|
||||
__ctzsi2(int x)
|
||||
{
|
||||
if (x == 0)
|
||||
return (sizeof(x) * NBBY);
|
||||
return (ffs(x) - 1);
|
||||
}
|
||||
|
||||
long long
|
||||
__ctzdi2(long long x)
|
||||
{
|
||||
if (x == 0)
|
||||
return (sizeof(x) * NBBY);
|
||||
return (ffsll(x) - 1);
|
||||
}
|
||||
|
||||
/* Count leading zeros */
|
||||
int
|
||||
__clzsi2(int x)
|
||||
{
|
||||
return (sizeof(x) * NBBY - fls(x));
|
||||
}
|
||||
|
||||
long long
|
||||
__clzdi2(long long x)
|
||||
{
|
||||
return (sizeof(x) * NBBY - flsll(x));
|
||||
}
|
@ -1,10 +1,5 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
|
||||
* based on work by Slawa Olhovchenkov
|
||||
* John Prince <johnp@knight-trosoft.com>
|
||||
* Eric Hernes
|
||||
* Copyright (c) 2014-2015 Allan Jude <allanjude@freebsd.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -31,38 +26,31 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* A very small subset of cards.
|
||||
*/
|
||||
enum digi_model {
|
||||
PCXE,
|
||||
PCXEVE,
|
||||
PCXI,
|
||||
PCXEM,
|
||||
PCCX,
|
||||
PCIEPCX,
|
||||
PCIXR
|
||||
};
|
||||
#ifndef ZSTD_KFREEBSD_H
|
||||
#define ZSTD_KFREEBSD_H
|
||||
|
||||
enum {
|
||||
DIGIDB_INIT = (1<<0),
|
||||
DIGIDB_OPEN = (1<<1),
|
||||
DIGIDB_CLOSE = (1<<2),
|
||||
DIGIDB_SET = (1<<3),
|
||||
DIGIDB_INT = (1<<4),
|
||||
DIGIDB_READ = (1<<5),
|
||||
DIGIDB_WRITE = (1<<6),
|
||||
DIGIDB_RX = (1<<7),
|
||||
DIGIDB_TX = (1<<8),
|
||||
DIGIDB_IRQ = (1<<9),
|
||||
DIGIDB_MODEM = (1<<10),
|
||||
DIGIDB_RI = (1<<11),
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DIGIIO_REINIT _IO('e', 'A')
|
||||
#define DIGIIO_DEBUG _IOW('e', 'B', int)
|
||||
#define DIGIIO_RING _IOWINT('e', 'C')
|
||||
#define DIGIIO_MODEL _IOR('e', 'D', enum digi_model)
|
||||
#define DIGIIO_IDENT _IOW('e', 'E', char *)
|
||||
#define DIGIIO_SETALTPIN _IOW('e', 'F', int)
|
||||
#define DIGIIO_GETALTPIN _IOR('e', 'G', int)
|
||||
#ifdef _KERNEL
|
||||
#include <sys/param.h> /* size_t */
|
||||
#include <sys/systm.h> /* memcpy, memset */
|
||||
#ifndef BUILDING_ZFS
|
||||
#include <sys/stddef.h> /* ptrdiff_t */
|
||||
#endif
|
||||
#include <sys/malloc.h>
|
||||
|
||||
MALLOC_DECLARE(M_ZSTD);
|
||||
|
||||
#define malloc(x) (malloc)((x), M_ZSTD, M_WAITOK)
|
||||
#define free(x) (free)((x), M_ZSTD)
|
||||
/* in zstd's use of calloc, a is always 1 */
|
||||
#define calloc(a,b) (malloc)((a)*(b), M_ZSTD, M_WAITOK | M_ZERO)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZSTD_KFREEBSD_H */
|
33
sys/contrib/zstd/lib/freebsd/zstd_kmalloc.c
Normal file
33
sys/contrib/zstd/lib/freebsd/zstd_kmalloc.c
Normal file
@ -0,0 +1,33 @@
|
||||
/*-
|
||||
* Copyright (c) 2016-2017 Allan Jude <allanjude@freebsd.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
|
||||
MALLOC_DEFINE(M_ZSTD, "zstd", "ZSTD Compressor");
|
@ -724,6 +724,8 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd,
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
ctx = NULL;
|
||||
ctxidx = 0;
|
||||
error = 0;
|
||||
kt = is_fpu_kern_thread(0);
|
||||
if (!kt) {
|
||||
@ -776,6 +778,9 @@ aesni_cipher_crypt(struct aesni_session *ses, struct cryptodesc *enccrd,
|
||||
KASSERT(ses->algo != CRYPTO_AES_NIST_GCM_16 || authcrd != NULL,
|
||||
("AES_NIST_GCM_16 must include MAC descriptor"));
|
||||
|
||||
ivlen = 0;
|
||||
authbuf = NULL;
|
||||
|
||||
buf = aesni_cipher_alloc(enccrd, crp, &allocated);
|
||||
if (buf == NULL)
|
||||
return (ENOMEM);
|
||||
|
@ -454,8 +454,8 @@ textdump_dumpsys(struct dumperinfo *di)
|
||||
/*
|
||||
* Disable EKCD because we don't provide encrypted textdumps.
|
||||
*/
|
||||
kdc = di->kdc;
|
||||
di->kdc = NULL;
|
||||
kdc = di->kdcrypto;
|
||||
di->kdcrypto = NULL;
|
||||
|
||||
/*
|
||||
* Position the start of the dump so that we'll write the kernel dump
|
||||
@ -512,7 +512,7 @@ textdump_dumpsys(struct dumperinfo *di)
|
||||
/*
|
||||
* Restore EKCD status.
|
||||
*/
|
||||
di->kdc = kdc;
|
||||
di->kdcrypto = kdc;
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -95,6 +95,9 @@ struct acpi_interface {
|
||||
int num;
|
||||
};
|
||||
|
||||
static char *sysres_ids[] = { "PNP0C01", "PNP0C02", NULL };
|
||||
static char *pcilink_ids[] = { "PNP0C0F", NULL };
|
||||
|
||||
/* Global mutex for locking access to the ACPI subsystem. */
|
||||
struct mtx acpi_mutex;
|
||||
struct callout acpi_sleep_timer;
|
||||
@ -1168,7 +1171,6 @@ acpi_sysres_alloc(device_t dev)
|
||||
struct resource_list *rl;
|
||||
struct resource_list_entry *rle;
|
||||
struct rman *rm;
|
||||
char *sysres_ids[] = { "PNP0C01", "PNP0C02", NULL };
|
||||
device_t *children;
|
||||
int child_count, i;
|
||||
|
||||
@ -1216,9 +1218,6 @@ acpi_sysres_alloc(device_t dev)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static char *pcilink_ids[] = { "PNP0C0F", NULL };
|
||||
static char *sysres_ids[] = { "PNP0C01", "PNP0C02", NULL };
|
||||
|
||||
/*
|
||||
* Reserve declared resources for devices found during attach once system
|
||||
* resources have been allocated.
|
||||
@ -1359,7 +1358,9 @@ static struct resource *
|
||||
acpi_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
#ifndef INTRNG
|
||||
ACPI_RESOURCE ares;
|
||||
#endif
|
||||
struct acpi_device *ad;
|
||||
struct resource_list_entry *rle;
|
||||
struct resource_list *rl;
|
||||
@ -1386,6 +1387,7 @@ acpi_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
resource_list_add(rl, type, *rid, start, end, count);
|
||||
res = resource_list_alloc(rl, bus, child, type, rid, start, end, count,
|
||||
flags);
|
||||
#ifndef INTRNG
|
||||
if (res != NULL && type == SYS_RES_IRQ) {
|
||||
/*
|
||||
* Since bus_config_intr() takes immediate effect, we cannot
|
||||
@ -1398,6 +1400,7 @@ acpi_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
if (ACPI_SUCCESS(acpi_lookup_irq_resource(child, *rid, res, &ares)))
|
||||
acpi_config_intr(child, &ares);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If this is an allocation of the "default" range for a given
|
||||
|
67
sys/dev/acpica/acpi_bus_if.m
Normal file
67
sys/dev/acpica/acpi_bus_if.m
Normal file
@ -0,0 +1,67 @@
|
||||
#-
|
||||
# Copyright (c) 2016 The FreeBSD Foundation
|
||||
# All rights reserved.
|
||||
#
|
||||
# This software was developed by Andrew Turner 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$
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
INTERFACE acpi_bus;
|
||||
|
||||
CODE {
|
||||
static acpi_bus_map_intr_t acpi_bus_default_map_intr;
|
||||
|
||||
int
|
||||
acpi_bus_default_map_intr(device_t bus, device_t dev, u_int irq,
|
||||
int trig, int pol)
|
||||
{
|
||||
device_t parent;
|
||||
|
||||
/* Pass up the hierarchy */
|
||||
parent = device_get_parent(bus);
|
||||
if (parent != NULL)
|
||||
return (ACPI_BUS_MAP_INTR(parent, dev, irq, trig, pol));
|
||||
|
||||
panic("Unable to map interrupt %u", irq);
|
||||
}
|
||||
};
|
||||
|
||||
# Map an interrupt from ACPI space to the FreeBSD IRQ space. Note that
|
||||
# both of these may be different than the pysical interrupt space as this
|
||||
# may be local to each interrupt controller.
|
||||
#
|
||||
# This method also associates interrupt metadata with the interrupt,
|
||||
# removing the need for a post hoc configure step.
|
||||
METHOD int map_intr {
|
||||
device_t bus;
|
||||
device_t dev;
|
||||
u_int irq;
|
||||
int trig;
|
||||
int pol;
|
||||
} DEFAULT acpi_bus_default_map_intr;
|
@ -45,6 +45,10 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <dev/acpica/acpivar.h>
|
||||
|
||||
#ifdef INTRNG
|
||||
#include "acpi_bus_if.h"
|
||||
#endif
|
||||
|
||||
/* Hooks for the ACPI CA debugging infrastructure */
|
||||
#define _COMPONENT ACPI_BUS
|
||||
ACPI_MODULE_NAME("RESOURCE")
|
||||
@ -556,6 +560,7 @@ acpi_res_set_irq(device_t dev, void *context, uint8_t *irq, int count,
|
||||
int trig, int pol)
|
||||
{
|
||||
struct acpi_res_context *cp = (struct acpi_res_context *)context;
|
||||
rman_res_t intr;
|
||||
|
||||
if (cp == NULL || irq == NULL)
|
||||
return;
|
||||
@ -564,7 +569,14 @@ acpi_res_set_irq(device_t dev, void *context, uint8_t *irq, int count,
|
||||
if (count != 1)
|
||||
return;
|
||||
|
||||
bus_set_resource(dev, SYS_RES_IRQ, cp->ar_nirq++, *irq, 1);
|
||||
#ifdef INTRNG
|
||||
intr = ACPI_BUS_MAP_INTR(device_get_parent(dev), dev, *irq,
|
||||
(trig == ACPI_EDGE_SENSITIVE) ? INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL,
|
||||
(pol == ACPI_ACTIVE_HIGH) ? INTR_POLARITY_HIGH : INTR_POLARITY_LOW);
|
||||
#else
|
||||
intr = *irq;
|
||||
#endif
|
||||
bus_set_resource(dev, SYS_RES_IRQ, cp->ar_nirq++, intr, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -572,6 +584,7 @@ acpi_res_set_ext_irq(device_t dev, void *context, uint32_t *irq, int count,
|
||||
int trig, int pol)
|
||||
{
|
||||
struct acpi_res_context *cp = (struct acpi_res_context *)context;
|
||||
rman_res_t intr;
|
||||
|
||||
if (cp == NULL || irq == NULL)
|
||||
return;
|
||||
@ -580,7 +593,14 @@ acpi_res_set_ext_irq(device_t dev, void *context, uint32_t *irq, int count,
|
||||
if (count != 1)
|
||||
return;
|
||||
|
||||
bus_set_resource(dev, SYS_RES_IRQ, cp->ar_nirq++, *irq, 1);
|
||||
#ifdef INTRNG
|
||||
intr = ACPI_BUS_MAP_INTR(device_get_parent(dev), dev, *irq,
|
||||
(trig == ACPI_EDGE_SENSITIVE) ? INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL,
|
||||
(pol == ACPI_ACTIVE_HIGH) ? INTR_POLARITY_HIGH : INTR_POLARITY_LOW);
|
||||
#else
|
||||
intr = *irq;
|
||||
#endif
|
||||
bus_set_resource(dev, SYS_RES_IRQ, cp->ar_nirq++, intr, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user