Merge ^/head r338298 through r338391.

This commit is contained in:
Dimitry Andric 2018-08-29 20:54:56 +00:00
commit da2d1e9d25
184 changed files with 1267 additions and 1144 deletions

View File

@ -1334,7 +1334,7 @@ distributeworld installworld stageworld: _installcheck_world .PHONY
METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys
${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys
.endif
${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
${IMAKEENV} rm -rf ${INSTALLTMP}

View File

@ -174,6 +174,8 @@ OLD_FILES+=usr/lib/clang/6.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_
OLD_DIRS+=usr/lib/clang/6.0.1/lib/freebsd
OLD_DIRS+=usr/lib/clang/6.0.1/lib
OLD_DIRS+=usr/lib/clang/6.0.1
# 20180824: libbe(3) SHLIBDIR fixed to reflect correct location
OLD_LIBS+=usr/lib/libbe.so.1
# 20180819: Remove deprecated arc4random(3) stir/addrandom interfaces
OLD_FILES+=usr/share/man/man3/arc4random_addrandom.3.gz
OLD_FILES+=usr/share/man/man3/arc4random_stir.3.gz

View File

@ -31,8 +31,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20170822:
devctl freeze/that have gone into the tree, the rc scripts have been
20180826:
The Yarrow CSPRNG has been removed from the kernel as it has not been
supported by its designers since at least 2003. Fortuna has been the
default since FreeBSD-11.
20180822:
devctl freeze/thaw have gone into the tree, the rc scripts have been
updated to use them and devmatch has been changed. You should update
kernel, userland and rc scripts all at the same time.

View File

@ -8,8 +8,12 @@
.include <src.opts.mk>
CONFGROUPS= ETC
CONFGROUPS= ETC ROOT
ETC= csh.cshrc csh.login csh.logout
ROOT= dot.cshrc dot.login
ROOTDIR= /root
ROOTNAME_dot.cshrc= .cshrc
ROOTNAME_dot.login= .login
PACKAGE=runtime
TCSHDIR= ${SRCTOP}/contrib/tcsh
.PATH: ${TCSHDIR}
@ -150,4 +154,10 @@ tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h ${BUILD
sort >> ${.TARGET}
@echo '#endif /* _h_tc_const */' >> ${.TARGET}
beforeinstallconfig:
rm -f ${DESTDIR}/.cshrc
afterinstallconfig:
${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
.include <bsd.prog.mk>

View File

@ -3,7 +3,9 @@
.include <src.opts.mk>
CONFS= profile
CONFS= dot.profile profile
CONFSDIR_dot.profile= /root
CONFSNAME_dot.profile= .profile
PACKAGE=runtime
PROG= sh
INSTALLFLAGS= -S
@ -61,4 +63,10 @@ token.h: mktokens
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
beforeinstallconfig:
rm -f ${DESTDIR}/.profile
afterinstallconfig:
${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
.include <bsd.prog.mk>

View File

@ -2,9 +2,8 @@
.ad l
.nh
.SH NAME
Heimdal Kerberos 5 library \-
.SS "Functions"
krb5 \- Heimdal Kerberos 5 library
.SH SYNOPSIS
.in +1c
.ti -1c
.RI "KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL \fBkrb5_add_et_list\fP (krb5_context context, void(*func)(struct et_list **))"

View File

@ -155,18 +155,6 @@ distribution:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
dot.k5login ${DESTDIR}/root/.k5login;
.endif
cd ${.CURDIR}/root; \
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
dot.profile ${DESTDIR}/root/.profile; \
rm -f ${DESTDIR}/.profile; \
${INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
.if ${MK_TCSH} != "no"
cd ${.CURDIR}/root; \
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
dot.cshrc ${DESTDIR}/root/.cshrc; \
rm -f ${DESTDIR}/.cshrc; \
${INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
.endif
.if ${MK_MAIL} != "no"
cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \

View File

@ -254,12 +254,6 @@ void arc4random_buf(void *, size_t);
__uint32_t
arc4random_uniform(__uint32_t);
#if !defined(BURN_BRIDGES)
/* Deprecated arc4random() functions */
#define arc4random_stir()
#define arc4random_addrandom(a,b)
#endif
#ifdef __BLOCKS__
int atexit_b(void (^ _Nonnull)(void));
void *bsearch_b(const void *, const void *, size_t,

View File

@ -2,6 +2,7 @@
PACKAGE= lib${LIB}
LIB= be
SHLIBDIR?= /lib
SHLIB_MAJOR= 1
SHLIB_MINOR= 0

View File

@ -623,10 +623,6 @@ be_rename(libbe_handle_t *lbh, const char *old, const char *new)
if ((err = be_root_concat(lbh, new, full_new)) != 0)
return (set_error(lbh, err));
/* Check if old is active BE */
if (strcmp(full_old, be_active_path(lbh)) == 0)
return (set_error(lbh, BE_ERR_MOUNTED));
if (!zfs_dataset_exists(lbh->lzh, full_old, ZFS_TYPE_DATASET))
return (set_error(lbh, BE_ERR_NOENT));
@ -637,14 +633,10 @@ be_rename(libbe_handle_t *lbh, const char *old, const char *new)
ZFS_TYPE_FILESYSTEM)) == NULL)
return (set_error(lbh, BE_ERR_ZFSOPEN));
/* XXX TODO: Allow a force flag */
if (zfs_is_mounted(zfs_hdl, NULL)) {
zfs_close(zfs_hdl);
return (set_error(lbh, BE_ERR_MOUNTED));
}
/* recurse, nounmount, forceunmount */
struct renameflags flags = { 0, 0, 0 };
struct renameflags flags = {
.nounmount = 1,
};
err = zfs_rename(zfs_hdl, NULL, full_new, flags);

View File

@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 16, 2018
.Dd August 24, 2018
.Dt LIBBE 3
.Os
.Sh NAME
@ -222,7 +222,12 @@ snapshot.
.Pp
The
.Fn be_rename
function renames a boot environment.
function renames a boot environment without unmounting it, as if renamed with
the
.Fl u
argument were passed to
.Nm zfs
.Cm rename
.Pp
The
.Fn be_activate

View File

@ -1,11 +1,12 @@
# $FreeBSD$
SHLIBDIR?= /lib
.include <src.opts.mk>
PACKAGE=lib${LIB}
LIB= md
SHLIB_MAJOR= 6
SHLIBDIR?= /lib
SRCS= md4c.c md5c.c md4hl.c md5hl.c \
rmd160c.c rmd160hl.c \
sha0c.c sha0hl.c sha1c.c sha1hl.c \

View File

@ -324,9 +324,7 @@ reloc_nonplt_object(Obj_Entry *obj, const Elf_Rel *rel, SymCache *cache,
if (!defobj->tls_done && allocate_tls_offset(obj))
return -1;
/* XXX: FIXME */
tmp = (Elf_Addr)def->st_value + defobj->tlsoffset +
TLS_TCB_SIZE;
tmp = (Elf_Addr)def->st_value + defobj->tlsoffset;
if (__predict_true(RELOC_ALIGNED_P(where)))
*where = tmp;
else

View File

@ -68,6 +68,13 @@ vm_extra_pre_umount() {
echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf
echo 'beastie_disable="YES"' >> ${DESTDIR}/boot/loader.conf
# The emulated keyboard attached to EC2 instances is inaccessible to
# users, and there is no mouse attached at all; disable to keyboard
# and the keyboard controller (to which the mouse would attach, if
# one existed) in order to save time in device probing.
echo 'hint.atkbd.0.disabled=1' >> ${DESTDIR}/boot/loader.conf
echo 'hint.atkbdc.0.disabled=1' >> ${DESTDIR}/boot/loader.conf
# EC2 has two consoles: An emulated serial port ("system log"),
# which has been present since 2006; and a VGA console ("instance
# screenshot") which was introduced in 2016.

View File

@ -18,7 +18,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 22, 2018
.Dd August 24, 2018
.Dt BECTL 8
.Os
.Sh NAME
@ -132,7 +132,8 @@ Destroys the given
.Ar beName
boot environment or
.Ar beName@snapshot
snapshot.
snapshot without confirmation, unlike in
.Nm beadm .
Specifying
.Fl F
will automatically unmount without confirmation.
@ -239,10 +240,11 @@ Mount at the specified
.Ar mountpoint
if provided.
.It Cm rename Ar origBeName newBeName
Renames the given nonactive
Renames the given
.Ar origBeName
to the given
.Ar newBeName .
The boot environment will not be unmounted in order for this rename to occur.
.It Cm unjail Brq Ar jailID | jailName | beName
Destroys the jail created from the given boot environment.
.It Xo

View File

@ -491,10 +491,8 @@ main(int argc, char *argv[])
const char *command;
int command_index, rc;
if (argc < 2) {
fprintf(stderr, "missing command\n");
if (argc < 2)
return (usage(false));
}
command = argv[1];

View File

@ -386,7 +386,7 @@ search_hints(const char *bus, const char *dev, const char *pnpinfo)
if (all_flag)
printf("%s: %s", *dev ? dev : "unattached", lastmod);
else
printf("%s", lastmod);
printf("%s\n", lastmod);
if (verbose_flag)
printf("Matches --- %s ---\n", lastmod);
}

View File

@ -23,7 +23,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 17, 2015
.Dd August 26, 2018
.Dt RANDOM 4
.Os
.Sh NAME
@ -153,26 +153,15 @@ the
device is not created
until an "algorithm module"
is loaded.
Two of these modules
are built by default,
.Em random_fortuna
and
.Em random_yarrow .
The only module built by default is
.Em random_fortuna .
The
.Em random_yarrow
module is deprecated,
and will be removed in
.Fx 12.
Use of the Yarrow algorithm
is not encouraged,
but while still present
in the kernel source,
it can be selected with the
.Cd "options RANDOM_YARROW"
kernel option.
Note that these loadable modules
are slightly less efficient
than their compiled-in equivalents.
module was removed in
.Fx 12 .
Note that this loadable module
is slightly less efficient
than its compiled-in equivalent.
This is because some functions
must be locked against
load and unload events,
@ -351,4 +340,4 @@ introduced in
The Yarrow algorithm
is no longer supported
by its authors,
and is therefore deprecated.
and is therefore no longer available.

View File

@ -1,6 +1,6 @@
.\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
.\" $FreeBSD$
.Dd August 16, 2018
.Dd August 28, 2018
.Dt SRC.CONF 5
.Os
.Sh NAME
@ -1184,8 +1184,14 @@ Enable firewire support in /boot/loader 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.
.Pp
This is a default setting on
sparc64/sparc64.
.It Va WITH_LOADER_LUA
Set to build LUA bindings for the boot loader.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armv6, arm/armv7, arm64/aarch64, 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 and riscv/riscv64sf.
.It Va WITHOUT_LOADER_OFW
Disable building of openfirmware bootloader components.
.Pp
@ -1342,6 +1348,11 @@ Set to build
.Pp
This is a default setting on
amd64/amd64, arm64/aarch64, i386/i386, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITHOUT_MODULE_DRM
Disable creation of old drm video modules.
.It Va WITHOUT_MODULE_DRM2
Disable creation of old drm2 video modules.
.It Va WITH_NAND
Set to build the NAND Flash components.
.It Va WITHOUT_NDIS

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 13, 2015
.Dd August 26, 2018
.Dt RANDOM_HARVEST 9
.Os
.Sh NAME
@ -38,21 +38,18 @@
.Fo random_harvest_direct
.Fa "void *entropy"
.Fa "u_int size"
.Fa "u_int bits"
.Fa "enum esource source"
.Fc
.Ft void
.Fo random_harvest_fast
.Fa "void *entropy"
.Fa "u_int size"
.Fa "u_int bits"
.Fa "enum esource source"
.Fc
.Ft void
.Fo random_harvest_queue
.Fa "void *entropy"
.Fa "u_int size"
.Fa "u_int bits"
.Fa "enum esource source"
.Fc
.Sh DESCRIPTION
@ -108,18 +105,6 @@ choice for most entropy sources
such as interrupts
or console events.
.Pp
The
.Fa bits
argument is only used
by the deprecated Yarrow algorithm.
For compatibility,
the caller should
.Em "very conservatively"
estimate the number of random bits
in the sample,
and pass this in
.Fa bits .
.Pp
Interrupt harvesting has been
in part simplified
for the kernel programmer.

View File

@ -29,8 +29,11 @@ all: buildconfig
. if !target(afterinstallconfig)
afterinstallconfig:
. endif
installconfig: realinstallconfig afterinstallconfig
.ORDER: realinstallconfig afterinstallconfig
. if !target(beforeinstallconfig)
beforeinstallconfig:
. endif
installconfig: beforeinstallconfig realinstallconfig afterinstallconfig
.ORDER: beforeinstallconfig realinstallconfig afterinstallconfig
${group}OWN?= ${SHAREOWN}
${group}GRP?= ${SHAREGRP}

View File

@ -23,7 +23,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.Dd March 23, 2018
.Dd August 28, 2018
.Dt LOADER.CONF 5
.Os
.Sh NAME
@ -289,6 +289,29 @@ See the entropy entries in
.Pq Dq /boot/entropy
The name of the very early
boot-time entropy cache file.
.It Va cpu_microcode_load
.Pq Dq NO
If set to
.Dq YES ,
the microcode update file specified by
.Va cpu_microcode_name
will be loaded and applied very early during boot.
This provides functionality similar to
.Xr cpucontrol 8
but ensures that CPU features enabled by microcode updates can be
used by the kernel.
The update will be re-applied automatically when resuming from an
ACPI sleep state.
If the update file contains updates for multiple processor models,
the kernel will search for and extract a matching update.
Currently this setting is supported only on Intel
.Dv i386
and
.Dv amd64
processors.
It has no effect on other processor types.
.It Va cpu_microcode_name
A path to a microcode update file.
.El
.Sh OTHER SETTINGS
Other settings that may be used in
@ -319,6 +342,7 @@ machine-specific settings for sites with a common loader.conf.
.Sh SEE ALSO
.Xr rc.conf 5 ,
.Xr boot 8 ,
.Xr cpucontrol 8 ,
.Xr loader 8 ,
.Xr loader.4th 8
.Sh HISTORY

View File

@ -6,6 +6,7 @@ PROG= boot1.sym
INTERNALPROG=
WARNS?= 6
CFLAGS+= -DEFI_BOOT1
# We implement a slightly non-standard %S in that it always takes a
# CHAR16 that's common in UEFI-land instead of a wchar_t. This only
# seems to matter on arm64 where wchar_t defaults to an int instead

View File

@ -160,6 +160,23 @@ _start:
ldp x0, x1, [sp], #16
#ifndef EFI_BOOT1
/*
* Load the stack to use. The default stack may be too small for
* the lua loader.
*/
adr x2, initstack_end
mov sp, x2
#endif
bl efi_main
1: b 1b
#ifndef EFI_BOOT1
.bss
.align 4
initstack:
.space (64 * 1024)
initstack_end:
#endif

View File

@ -479,6 +479,21 @@ function config.loadKernel(other_kernel)
return nil
end
local function getModulePath()
local module_path = loader.getenv("module_path")
local kernel_path = loader.getenv("kernel_path")
if kernel_path == nil then
return module_path
end
-- Strip the loaded kernel path from module_path. This currently assumes
-- that the kernel path will be prepended to the module_path when it's
-- found.
kernel_path = escapeName(kernel_path .. ';')
return module_path:gsub(kernel_path, '')
end
local function loadBootfile()
local bootfile = loader.getenv("bootfile")
@ -507,7 +522,7 @@ function config.loadKernel(other_kernel)
else
-- Use our cached module_path, so we don't end up with multiple
-- automatically added kernel paths to our final module_path
local module_path = config.module_path
local module_path = getModulePath()
local res
if other_kernel ~= nil then
@ -527,6 +542,7 @@ function config.loadKernel(other_kernel)
if module_path ~= nil then
loader.setenv("module_path", v .. ";" ..
module_path)
loader.setenv("kernel_path", v)
end
return true
end
@ -563,8 +579,6 @@ function config.load(file, reloading)
checkNextboot()
-- Cache the provided module_path at load time for later use
config.module_path = loader.getenv("module_path")
local verbose = loader.getenv("verbose_loading") or "no"
config.verbose = verbose:lower() == "yes"
if not reloading then

View File

@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_kern.h>
#include <vm/vm_map.h>
#include <vm/vm_extern.h>
#include <x86/apicreg.h>
@ -87,6 +86,8 @@ __FBSDID("$FreeBSD$");
#define GiB(v) (v ## ULL << 30)
#define AP_BOOTPT_SZ (PAGE_SIZE * 3)
extern struct pcpu __pcpu[];
/* Temporary variables for init_secondary() */
@ -101,45 +102,79 @@ char *dbg_stack;
static int start_ap(int apic_id);
static bool
is_kernel_paddr(vm_paddr_t pa)
{
return (pa >= trunc_2mpage(btext - KERNBASE) &&
pa < round_page(_end - KERNBASE));
}
static bool
is_mpboot_good(vm_paddr_t start, vm_paddr_t end)
{
return (start + AP_BOOTPT_SZ <= GiB(4) && atop(end) < Maxmem);
}
/*
* Calculate usable address in base memory for AP trampoline code.
*/
void
mp_bootaddress(vm_paddr_t *physmap, unsigned int *physmap_idx)
{
vm_paddr_t start, end;
unsigned int i;
bool allocated;
alloc_ap_trampoline(physmap, physmap_idx);
/*
* Find a memory region big enough below the 4GB boundary to
* store the initial page tables. Region must be mapped by
* the direct map.
*
* Note that it needs to be aligned to a page boundary.
*/
allocated = false;
for (i = *physmap_idx; i <= *physmap_idx; i -= 2) {
/*
* Find a memory region big enough below the 4GB
* boundary to store the initial page tables. Region
* must be mapped by the direct map.
*
* Note that it needs to be aligned to a page
* boundary.
* First, try to chomp at the start of the physmap region.
* Kernel binary might claim it already.
*/
if (physmap[i] >= GiB(4) || physmap[i + 1] -
round_page(physmap[i]) < PAGE_SIZE * 3 ||
atop(physmap[i + 1]) > Maxmem)
continue;
start = round_page(physmap[i]);
end = start + AP_BOOTPT_SZ;
if (start < end && end <= physmap[i + 1] &&
is_mpboot_good(start, end) &&
!is_kernel_paddr(start) && !is_kernel_paddr(end - 1)) {
allocated = true;
physmap[i] = end;
break;
}
allocated = true;
mptramp_pagetables = round_page(physmap[i]);
physmap[i] = round_page(physmap[i]) + (PAGE_SIZE * 3);
/*
* Second, try to chomp at the end. Again, check
* against kernel.
*/
end = trunc_page(physmap[i + 1]);
start = end - AP_BOOTPT_SZ;
if (start < end && start >= physmap[i] &&
is_mpboot_good(start, end) &&
!is_kernel_paddr(start) && !is_kernel_paddr(end - 1)) {
allocated = true;
physmap[i + 1] = start;
break;
}
}
if (allocated) {
mptramp_pagetables = start;
if (physmap[i] == physmap[i + 1] && *physmap_idx != 0) {
memmove(&physmap[i], &physmap[i + 2],
sizeof(*physmap) * (*physmap_idx - i + 2));
*physmap_idx -= 2;
}
break;
}
if (!allocated) {
mptramp_pagetables = trunc_page(boot_address) - (PAGE_SIZE * 3);
} else {
mptramp_pagetables = trunc_page(boot_address) - AP_BOOTPT_SZ;
if (bootverbose)
printf(
"Cannot find enough space for the initial AP page tables, placing them at %#x",
@ -343,7 +378,6 @@ init_secondary(void)
while (atomic_load_acq_int(&aps_ready) == 0)
ia32_pause();
pmap_activate_boot(vmspace_pmap(proc0.p_vmspace));
init_secondary_tail();
}

View File

@ -3094,8 +3094,8 @@ pmap_growkernel(vm_offset_t addr)
return;
addr = roundup2(addr, NBPDR);
if (addr - 1 >= kernel_map->max_offset)
addr = kernel_map->max_offset;
if (addr - 1 >= vm_map_max(kernel_map))
addr = vm_map_max(kernel_map);
while (kernel_vm_end < addr) {
pdpe = pmap_pdpe(kernel_pmap, kernel_vm_end);
if ((*pdpe & X86_PG_V) == 0) {
@ -3115,8 +3115,8 @@ pmap_growkernel(vm_offset_t addr)
pde = pmap_pdpe_to_pde(pdpe, kernel_vm_end);
if ((*pde & X86_PG_V) != 0) {
kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK;
if (kernel_vm_end - 1 >= kernel_map->max_offset) {
kernel_vm_end = kernel_map->max_offset;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
kernel_vm_end = vm_map_max(kernel_map);
break;
}
continue;
@ -3134,8 +3134,8 @@ pmap_growkernel(vm_offset_t addr)
pde_store(pde, newpdir);
kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK;
if (kernel_vm_end - 1 >= kernel_map->max_offset) {
kernel_vm_end = kernel_map->max_offset;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
kernel_vm_end = vm_map_max(kernel_map);
break;
}
}

View File

@ -479,7 +479,7 @@ user_ldt_alloc(struct proc *p, int force)
pldt = mdp->md_ldt;
if (pldt != NULL && !force) {
pmap_pti_remove_kva(sva, sva + sz);
kmem_free(kernel_arena, sva, sz);
kmem_free(sva, sz);
free(new_ldt, M_SUBPROC);
return (pldt);
}
@ -533,7 +533,7 @@ user_ldt_derefl(struct proc_ldt *pldt)
sva = (vm_offset_t)pldt->ldt_base;
sz = max_ldt_segment * sizeof(struct user_segment_descriptor);
pmap_pti_remove_kva(sva, sva + sz);
kmem_free(kernel_arena, sva, sz);
kmem_free(sva, sz);
free(pldt, M_SUBPROC);
}
}

View File

@ -331,8 +331,7 @@ cpu_thread_clean(struct thread *td)
if (pcb->pcb_tssp != NULL) {
pmap_pti_remove_kva((vm_offset_t)pcb->pcb_tssp,
(vm_offset_t)pcb->pcb_tssp + ctob(IOPAGES + 1));
kmem_free(kernel_arena, (vm_offset_t)pcb->pcb_tssp,
ctob(IOPAGES + 1));
kmem_free((vm_offset_t)pcb->pcb_tssp, ctob(IOPAGES + 1));
pcb->pcb_tssp = NULL;
}
}

View File

@ -192,7 +192,7 @@ a10fb_allocfb(struct a10fb_softc *sc)
static void
a10fb_freefb(struct a10fb_softc *sc)
{
kmem_free(kernel_arena, sc->vaddr, sc->fbsize);
kmem_free(sc->vaddr, sc->fbsize);
}
static int

View File

@ -75,8 +75,7 @@ aml8726_rng_harvest(void *arg)
rn[0] = CSR_READ_4(sc, AML_RNG_0_REG);
rn[1] = CSR_READ_4(sc, AML_RNG_1_REG);
random_harvest(rn, sizeof(rn), sizeof(rn) * NBBY / 2,
RANDOM_PURE_AML8726);
random_harvest(rn, sizeof(rn), RANDOM_PURE_AML8726);
callout_reset(&sc->co, sc->ticks, aml8726_rng_harvest, sc);
}

View File

@ -792,7 +792,7 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
!_bus_dma_can_bounce(dmat->lowaddr, dmat->highaddr))
uma_zfree(bufzone->umazone, vaddr);
else
kmem_free(kernel_arena, (vm_offset_t)vaddr, dmat->maxsize);
kmem_free((vm_offset_t)vaddr, dmat->maxsize);
dmat->map_count--;
if (map->flags & DMAMAP_COHERENT)

View File

@ -858,7 +858,7 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
!exclusion_bounce(dmat))
uma_zfree(bufzone->umazone, vaddr);
else
kmem_free(kernel_arena, (vm_offset_t)vaddr, dmat->maxsize);
kmem_free((vm_offset_t)vaddr, dmat->maxsize);
dmat->map_count--;
if (map->flags & DMAMAP_COHERENT)

View File

@ -2043,21 +2043,21 @@ pmap_growkernel(vm_offset_t addr)
* not called, it could be first unused KVA (which is not
* rounded up to PTE1_SIZE),
*
* (2) when all KVA space is mapped and kernel_map->max_offset
* (2) when all KVA space is mapped and vm_map_max(kernel_map)
* address is not rounded up to PTE1_SIZE. (For example,
* it could be 0xFFFFFFFF.)
*/
kernel_vm_end = pte1_roundup(kernel_vm_end);
mtx_assert(&kernel_map->system_mtx, MA_OWNED);
addr = roundup2(addr, PTE1_SIZE);
if (addr - 1 >= kernel_map->max_offset)
addr = kernel_map->max_offset;
if (addr - 1 >= vm_map_max(kernel_map))
addr = vm_map_max(kernel_map);
while (kernel_vm_end < addr) {
pte1 = pte1_load(kern_pte1(kernel_vm_end));
if (pte1_is_valid(pte1)) {
kernel_vm_end += PTE1_SIZE;
if (kernel_vm_end - 1 >= kernel_map->max_offset) {
kernel_vm_end = kernel_map->max_offset;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
kernel_vm_end = vm_map_max(kernel_map);
break;
}
continue;
@ -2099,8 +2099,8 @@ pmap_growkernel(vm_offset_t addr)
pmap_kenter_pte1(kernel_vm_end, PTE1_LINK(pt2_pa));
kernel_vm_end = kernel_vm_end_new;
if (kernel_vm_end - 1 >= kernel_map->max_offset) {
kernel_vm_end = kernel_map->max_offset;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
kernel_vm_end = vm_map_max(kernel_map);
break;
}
}
@ -2242,8 +2242,7 @@ pmap_pinit(pmap_t pmap)
* UMA_ZONE_NOFREE flag, it's important to leave
* no allocation in pmap if initialization failed.
*/
kmem_free(kernel_arena, (vm_offset_t)pmap->pm_pt1,
NB_IN_PT1);
kmem_free((vm_offset_t)pmap->pm_pt1, NB_IN_PT1);
pmap->pm_pt1 = NULL;
return (0);
}

View File

@ -293,7 +293,7 @@ vfp_store(struct vfp_state *vfpsave, boolean_t disable_vfp)
" .fpu vfpv3\n"
" vstmia %0!, {d0-d15}\n" /* d0-d15 */
" cmp %1, #0\n" /* -D16 or -D32? */
" vstmiane r0!, {d16-d31}\n" /* d16-d31 */
" vstmiane %0!, {d16-d31}\n" /* d16-d31 */
" addeq %0, %0, #128\n" /* skip missing regs */
: "+&r" (vfpsave) : "r" (is_d32) : "cc"
);

View File

@ -289,8 +289,7 @@ bcm2835_rng_harvest(void *arg)
cnt = nread * sizeof(uint32_t);
if (cnt > 0)
random_harvest_queue(sc->sc_buf, cnt, cnt * NBBY / 2,
RANDOM_PURE_BROADCOM);
random_harvest_queue(sc->sc_buf, cnt, RANDOM_PURE_BROADCOM);
callout_reset(&sc->sc_rngto, RNG_CALLOUT_TICKS, bcm2835_rng_harvest, sc);
}

View File

@ -196,8 +196,7 @@ sdma_free(int chn)
channel = &sc->channel[chn];
channel->in_use = 0;
kmem_free(kernel_arena, (vm_offset_t)channel->bd,
PAGE_SIZE);
kmem_free((vm_offset_t)channel->bd, PAGE_SIZE);
return (0);
}

View File

@ -465,7 +465,7 @@ static DEFINE_CLASS_0(sdhci, tegra_sdhci_driver, tegra_sdhci_methods,
sizeof(struct tegra_sdhci_softc));
DRIVER_MODULE(sdhci_tegra, simplebus, tegra_sdhci_driver, tegra_sdhci_devclass,
NULL, NULL);
#ifndef MMCCAM
MODULE_DEPEND(sdhci_tegra, sdhci, 1, 1, 1);
#ifndef MMCCAM
MMC_DECLARE_BRIDGE(sdhci);
#endif

View File

@ -984,7 +984,7 @@ tegra_xhci_detach(device_t dev)
if (sc->irq_hdl_mbox != NULL)
bus_teardown_intr(dev, sc->irq_res_mbox, sc->irq_hdl_mbox);
if (sc->fw_vaddr != 0)
kmem_free(kernel_arena, sc->fw_vaddr, sc->fw_size);
kmem_free(sc->fw_vaddr, sc->fw_size);
LOCK_DESTROY(sc);
return (0);
}

View File

@ -532,8 +532,7 @@ bounce_bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
if ((dmat->bounce_flags & BF_KMEM_ALLOC) == 0)
free(vaddr, M_DEVBUF);
else
kmem_free(kernel_arena, (vm_offset_t)vaddr,
dmat->common.maxsize);
kmem_free((vm_offset_t)vaddr, dmat->common.maxsize);
free(map, M_DEVBUF);
dmat->map_count--;
CTR3(KTR_BUSDMA, "%s: tag %p flags 0x%x", __func__, dmat,

View File

@ -502,8 +502,7 @@ start_cpu(u_int id, uint64_t target_cpu)
("Failed to start CPU %u (%lx)\n", id, target_cpu));
pcpu_destroy(pcpup);
kmem_free(kernel_arena, (vm_offset_t)dpcpu[cpuid - 1],
DPCPU_SIZE);
kmem_free((vm_offset_t)dpcpu[cpuid - 1], DPCPU_SIZE);
dpcpu[cpuid - 1] = NULL;
mp_ncpus--;

View File

@ -1744,8 +1744,8 @@ pmap_growkernel(vm_offset_t addr)
mtx_assert(&kernel_map->system_mtx, MA_OWNED);
addr = roundup2(addr, L2_SIZE);
if (addr - 1 >= kernel_map->max_offset)
addr = kernel_map->max_offset;
if (addr - 1 >= vm_map_max(kernel_map))
addr = vm_map_max(kernel_map);
while (kernel_vm_end < addr) {
l0 = pmap_l0(kernel_pmap, kernel_vm_end);
KASSERT(pmap_load(l0) != 0,
@ -1768,8 +1768,8 @@ pmap_growkernel(vm_offset_t addr)
l2 = pmap_l1_to_l2(l1, kernel_vm_end);
if ((pmap_load(l2) & ATTR_AF) != 0) {
kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET;
if (kernel_vm_end - 1 >= kernel_map->max_offset) {
kernel_vm_end = kernel_map->max_offset;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
kernel_vm_end = vm_map_max(kernel_map);
break;
}
continue;
@ -1787,8 +1787,8 @@ pmap_growkernel(vm_offset_t addr)
pmap_invalidate_page(kernel_pmap, kernel_vm_end);
kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET;
if (kernel_vm_end - 1 >= kernel_map->max_offset) {
kernel_vm_end = kernel_map->max_offset;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
kernel_vm_end = vm_map_max(kernel_map);
break;
}
}

View File

@ -153,6 +153,8 @@ size_t zfs_abd_chunk_size = 4096;
#if defined(__FreeBSD__) && defined(_KERNEL)
SYSCTL_DECL(_vfs_zfs);
SYSCTL_INT(_vfs_zfs, OID_AUTO, abd_scatter_enabled, CTLFLAG_RWTUN,
&zfs_abd_scatter_enabled, 0, "Enable scattered ARC data buffers");
SYSCTL_ULONG(_vfs_zfs, OID_AUTO, abd_chunk_size, CTLFLAG_RDTUN,
&zfs_abd_chunk_size, 0, "The size of the chunks ABD allocates");
#endif

View File

@ -104,13 +104,6 @@ extern "C" {
#include <vm/vm_object.h>
#include <vm/vm_kern.h>
#include <vm/vm_map.h>
/* There is clash. vm_map.h defines the two below and vdev_cache.c use them. */
#ifdef min_offset
#undef min_offset
#endif
#ifdef max_offset
#undef max_offset
#endif
#include <vm/vm_extern.h>
#include <vm/vnode_pager.h>

View File

@ -152,7 +152,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
name, FBT_RETURN, 3, fbt);
} else {
retfbt->fbtp_next = fbt;
retfbt->fbtp_probenext = fbt;
fbt->fbtp_id = retfbt->fbtp_id;
}
retfbt = fbt;

View File

@ -165,7 +165,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
name, FBT_RETURN, 2, fbt);
} else {
retfbt->fbtp_next = fbt;
retfbt->fbtp_probenext = fbt;
fbt->fbtp_id = retfbt->fbtp_id;
}
retfbt = fbt;

View File

@ -156,7 +156,7 @@ fbt_doubletrap(void)
for (i = 0; i < fbt_probetab_size; i++) {
fbt = fbt_probetab[i];
for (; fbt != NULL; fbt = fbt->fbtp_next)
for (; fbt != NULL; fbt = fbt->fbtp_probenext)
fbt_patch_tracepoint(fbt, fbt->fbtp_savedval);
}
}
@ -204,40 +204,53 @@ fbt_provide_module(void *arg, modctl_t *lf)
(void) linker_file_function_listall(lf, fbt_provide_module_function, modname);
}
static void
fbt_destroy_one(fbt_probe_t *fbt)
{
fbt_probe_t *hash, *hashprev, *next;
int ndx;
ndx = FBT_ADDR2NDX(fbt->fbtp_patchpoint);
for (hash = fbt_probetab[ndx], hashprev = NULL; hash != NULL;
hash = hash->fbtp_hashnext, hashprev = hash) {
if (hash == fbt) {
if ((next = fbt->fbtp_tracenext) != NULL)
next->fbtp_hashnext = hash->fbtp_hashnext;
else
next = hash->fbtp_hashnext;
if (hashprev != NULL)
hashprev->fbtp_hashnext = next;
else
fbt_probetab[ndx] = next;
goto free;
} else if (hash->fbtp_patchpoint == fbt->fbtp_patchpoint) {
for (next = hash; next->fbtp_tracenext != NULL;
next = next->fbtp_tracenext) {
if (fbt == next->fbtp_tracenext) {
next->fbtp_tracenext =
fbt->fbtp_tracenext;
goto free;
}
}
}
}
panic("probe %p not found in hash table", fbt);
free:
free(fbt, M_FBT);
}
static void
fbt_destroy(void *arg, dtrace_id_t id, void *parg)
{
fbt_probe_t *fbt = parg, *next, *hash, *last;
fbt_probe_t *fbt = parg, *next;
modctl_t *ctl;
int ndx;
do {
ctl = fbt->fbtp_ctl;
ctl->fbt_nentries--;
/*
* Now we need to remove this probe from the fbt_probetab.
*/
ndx = FBT_ADDR2NDX(fbt->fbtp_patchpoint);
last = NULL;
hash = fbt_probetab[ndx];
while (hash != fbt) {
ASSERT(hash != NULL);
last = hash;
hash = hash->fbtp_hashnext;
}
if (last != NULL) {
last->fbtp_hashnext = fbt->fbtp_hashnext;
} else {
fbt_probetab[ndx] = fbt->fbtp_hashnext;
}
next = fbt->fbtp_next;
free(fbt, M_FBT);
next = fbt->fbtp_probenext;
fbt_destroy_one(fbt);
fbt = next;
} while (fbt != NULL);
}
@ -265,14 +278,16 @@ fbt_enable(void *arg, dtrace_id_t id, void *parg)
return;
}
for (; fbt != NULL; fbt = fbt->fbtp_next)
for (; fbt != NULL; fbt = fbt->fbtp_probenext) {
fbt_patch_tracepoint(fbt, fbt->fbtp_patchval);
fbt->fbtp_enabled++;
}
}
static void
fbt_disable(void *arg, dtrace_id_t id, void *parg)
{
fbt_probe_t *fbt = parg;
fbt_probe_t *fbt = parg, *hash;
modctl_t *ctl = fbt->fbtp_ctl;
ASSERT(ctl->nenabled > 0);
@ -281,8 +296,21 @@ fbt_disable(void *arg, dtrace_id_t id, void *parg)
if ((ctl->loadcnt != fbt->fbtp_loadcnt))
return;
for (; fbt != NULL; fbt = fbt->fbtp_next)
fbt_patch_tracepoint(fbt, fbt->fbtp_savedval);
for (; fbt != NULL; fbt = fbt->fbtp_probenext) {
fbt->fbtp_enabled--;
for (hash = fbt_probetab[FBT_ADDR2NDX(fbt->fbtp_patchpoint)];
hash != NULL; hash = hash->fbtp_hashnext) {
if (hash->fbtp_patchpoint == fbt->fbtp_patchpoint) {
for (; hash != NULL; hash = hash->fbtp_tracenext)
if (hash->fbtp_enabled > 0)
break;
break;
}
}
if (hash == NULL)
fbt_patch_tracepoint(fbt, fbt->fbtp_savedval);
}
}
static void
@ -296,7 +324,7 @@ fbt_suspend(void *arg, dtrace_id_t id, void *parg)
if ((ctl->loadcnt != fbt->fbtp_loadcnt))
return;
for (; fbt != NULL; fbt = fbt->fbtp_next)
for (; fbt != NULL; fbt = fbt->fbtp_probenext)
fbt_patch_tracepoint(fbt, fbt->fbtp_savedval);
}
@ -311,7 +339,7 @@ fbt_resume(void *arg, dtrace_id_t id, void *parg)
if ((ctl->loadcnt != fbt->fbtp_loadcnt))
return;
for (; fbt != NULL; fbt = fbt->fbtp_next)
for (; fbt != NULL; fbt = fbt->fbtp_probenext)
fbt_patch_tracepoint(fbt, fbt->fbtp_patchval);
}

View File

@ -34,9 +34,18 @@
#include "fbt_isa.h"
/*
* fbt_probe is a bit of a misnomer. One of these structures is created for
* each trace point of an FBT probe. A probe might have multiple trace points
* (e.g., a function with multiple return instructions), and different probes
* might have a trace point at the same address (e.g., GNU ifuncs).
*/
typedef struct fbt_probe {
struct fbt_probe *fbtp_hashnext;
fbt_patchval_t *fbtp_patchpoint;
struct fbt_probe *fbtp_hashnext; /* global hash table linkage */
struct fbt_probe *fbtp_tracenext; /* next probe for tracepoint */
struct fbt_probe *fbtp_probenext; /* next tracepoint for probe */
int fbtp_enabled;
fbt_patchval_t *fbtp_patchpoint;
int8_t fbtp_rval;
fbt_patchval_t fbtp_patchval;
fbt_patchval_t fbtp_savedval;
@ -46,7 +55,6 @@ typedef struct fbt_probe {
modctl_t *fbtp_ctl;
int fbtp_loadcnt;
int fbtp_symindx;
struct fbt_probe *fbtp_next;
} fbt_probe_t;
struct linker_file;

View File

@ -142,7 +142,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
name, FBT_RETURN, 3, fbt);
} else {
retfbt->fbtp_next = fbt;
retfbt->fbtp_probenext = fbt;
fbt->fbtp_id = retfbt->fbtp_id;
}
retfbt = fbt;

View File

@ -208,7 +208,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
name, FBT_RETURN, FBT_AFRAMES, fbt);
} else {
retfbt->fbtp_next = fbt;
retfbt->fbtp_probenext = fbt;
fbt->fbtp_id = retfbt->fbtp_id;
}

View File

@ -141,7 +141,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
name, FBT_RETURN, 3, fbt);
} else {
retfbt->fbtp_next = fbt;
retfbt->fbtp_probenext = fbt;
fbt->fbtp_id = retfbt->fbtp_id;
}
retfbt = fbt;

View File

@ -67,6 +67,7 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uintptr_t rval)
uintptr_t *stack;
uintptr_t arg0, arg1, arg2, arg3, arg4;
fbt_probe_t *fbt;
int8_t fbtrval;
#ifdef __amd64__
stack = (uintptr_t *)frame->tf_rsp;
@ -78,7 +79,11 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uintptr_t rval)
cpu = &solaris_cpu[curcpu];
fbt = fbt_probetab[FBT_ADDR2NDX(addr)];
for (; fbt != NULL; fbt = fbt->fbtp_hashnext) {
if ((uintptr_t)fbt->fbtp_patchpoint == addr) {
if ((uintptr_t)fbt->fbtp_patchpoint != addr)
continue;
fbtrval = fbt->fbtp_rval;
for (; fbt != NULL; fbt = fbt->fbtp_tracenext) {
ASSERT(fbt->fbtp_rval == fbtrval);
if (fbt->fbtp_roffset == 0) {
#ifdef __amd64__
/* fbt->fbtp_rval == DTRACE_INVOP_PUSHQ_RBP */
@ -135,9 +140,8 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uintptr_t rval)
rval, 0, 0, 0);
cpu->cpu_dtrace_caller = 0;
}
return (fbt->fbtp_rval);
}
return (fbtrval);
}
return (0);
@ -162,7 +166,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
{
char *modname = opaque;
const char *name = symval->name;
fbt_probe_t *fbt, *retfbt;
fbt_probe_t *fbt, *hash, *retfbt;
int j;
int size;
uint8_t *instr, *limit;
@ -224,8 +228,18 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
fbt->fbtp_patchval = FBT_PATCHVAL;
fbt->fbtp_symindx = symindx;
fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];
fbt_probetab[FBT_ADDR2NDX(instr)] = fbt;
for (hash = fbt_probetab[FBT_ADDR2NDX(instr)]; hash != NULL;
hash = hash->fbtp_hashnext) {
if (hash->fbtp_patchpoint == fbt->fbtp_patchpoint) {
fbt->fbtp_tracenext = hash->fbtp_tracenext;
hash->fbtp_tracenext = fbt;
break;
}
}
if (hash == NULL) {
fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];
fbt_probetab[FBT_ADDR2NDX(instr)] = fbt;
}
lf->fbt_nentries++;
@ -301,7 +315,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
name, FBT_RETURN, 3, fbt);
} else {
retfbt->fbtp_next = fbt;
retfbt->fbtp_probenext = fbt;
fbt->fbtp_id = retfbt->fbtp_id;
}

View File

@ -108,6 +108,7 @@ freebsd32_fstat
fstatfs
fsync
ftruncate
freebsd32_ftruncate
freebsd32_futimens
freebsd32_futimes
getaudit

View File

@ -257,7 +257,7 @@ struct sysent freebsd32_sysent[] = {
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 198 = __syscall */
{ compat6(AS(freebsd6_freebsd32_lseek_args),freebsd32_lseek), AUE_LSEEK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 199 = freebsd6 freebsd32_lseek */
{ compat6(AS(freebsd6_freebsd32_truncate_args),freebsd32_truncate), AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 200 = freebsd6 freebsd32_truncate */
{ compat6(AS(freebsd6_freebsd32_ftruncate_args),freebsd32_ftruncate), AUE_FTRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 201 = freebsd6 freebsd32_ftruncate */
{ compat6(AS(freebsd6_freebsd32_ftruncate_args),freebsd32_ftruncate), AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 201 = freebsd6 freebsd32_ftruncate */
{ AS(freebsd32_sysctl_args), (sy_call_t *)freebsd32_sysctl, AUE_SYSCTL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 202 = freebsd32_sysctl */
{ AS(mlock_args), (sy_call_t *)sys_mlock, AUE_MLOCK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 203 = mlock */
{ AS(munlock_args), (sy_call_t *)sys_munlock, AUE_MUNLOCK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 204 = munlock */
@ -537,14 +537,14 @@ struct sysent freebsd32_sysent[] = {
{ AS(freebsd32_mmap_args), (sy_call_t *)freebsd32_mmap, AUE_MMAP, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 477 = freebsd32_mmap */
{ AS(freebsd32_lseek_args), (sy_call_t *)freebsd32_lseek, AUE_LSEEK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 478 = freebsd32_lseek */
{ AS(freebsd32_truncate_args), (sy_call_t *)freebsd32_truncate, AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 479 = freebsd32_truncate */
{ AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */
{ AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */
#else
{ AS(freebsd32_pread_args), (sy_call_t *)freebsd32_pread, AUE_PREAD, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 475 = freebsd32_pread */
{ AS(freebsd32_pwrite_args), (sy_call_t *)freebsd32_pwrite, AUE_PWRITE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 476 = freebsd32_pwrite */
{ AS(freebsd32_mmap_args), (sy_call_t *)freebsd32_mmap, AUE_MMAP, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 477 = freebsd32_mmap */
{ AS(freebsd32_lseek_args), (sy_call_t *)freebsd32_lseek, AUE_LSEEK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 478 = freebsd32_lseek */
{ AS(freebsd32_truncate_args), (sy_call_t *)freebsd32_truncate, AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 479 = freebsd32_truncate */
{ AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */
{ AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */
#endif
{ AS(thr_kill2_args), (sy_call_t *)sys_thr_kill2, AUE_THR_KILL2, NULL, 0, 0, 0, SY_THR_STATIC }, /* 481 = thr_kill2 */
{ AS(shm_open_args), (sy_call_t *)sys_shm_open, AUE_SHMOPEN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 482 = shm_open */

View File

@ -156,7 +156,7 @@ dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
dma_addr_t dma_handle)
{
kmem_free(kmem_arena, (vm_offset_t)cpu_addr, size);
kmem_free((vm_offset_t)cpu_addr, size);
}
/* XXX This only works with no iommu. */

View File

@ -178,7 +178,7 @@ linux_free_kmem(vm_offset_t addr, unsigned int order)
{
size_t size = ((size_t)PAGE_SIZE) << order;
kmem_free(kmem_arena, addr, size);
kmem_free(addr, size);
}
static int

View File

@ -3008,11 +3008,8 @@ options BROOKTREE_ALLOC_PAGES=(217*4+1)
options MAXFILES=999
# Random number generator
# Only ONE of the below two may be used; they are mutually exclusive.
# If neither is present, then the Fortuna algorithm is selected.
#options RANDOM_YARROW # Yarrow CSPRNG (old default)
#options RANDOM_LOADABLE # Allow the algorithm to be loaded as
# a module.
# Allow the CSPRNG algorithm to be loaded as a module.
#options RANDOM_LOADABLE
# Select this to allow high-rate but potentially expensive
# harvesting of Slab-Allocator entropy. In very high-rate
# situations the value of doing this is dubious at best.

View File

@ -2822,12 +2822,9 @@ rt2860.fw optional rt2860fw | ralfw \
clean "rt2860.fw"
dev/random/random_infra.c optional random
dev/random/random_harvestq.c optional random
dev/random/randomdev.c optional random random_yarrow | \
random !random_yarrow !random_loadable
dev/random/yarrow.c optional random random_yarrow
dev/random/fortuna.c optional random !random_yarrow !random_loadable
dev/random/hash.c optional random random_yarrow | \
random !random_yarrow !random_loadable
dev/random/randomdev.c optional random
dev/random/fortuna.c optional random !random_loadable
dev/random/hash.c optional random
dev/rc/rc.c optional rc
dev/rccgpio/rccgpio.c optional rccgpio gpio
dev/re/if_re.c optional re

View File

@ -38,6 +38,8 @@ __DEFAULT_YES_OPTIONS = \
IPSEC_SUPPORT \
ISCSI \
KERNEL_SYMBOLS \
MODULE_DRM \
MODULE_DRM2 \
NETGRAPH \
PF \
SOURCELESS_HOST \

View File

@ -983,9 +983,6 @@ RACCT_DEFAULT_TO_DISABLED opt_global.h
RCTL opt_global.h
# Random number generator(s)
# Which CSPRNG hash we get.
# If Yarrow is not chosen, Fortuna is selected.
RANDOM_YARROW opt_global.h
# With this, no entropy processor is loaded, but the entropy
# harvesting infrastructure is present. This means an entropy
# processor may be loaded as a module.

View File

@ -171,8 +171,8 @@ agp_alloc_gatt(device_t dev)
void
agp_free_gatt(struct agp_gatt *gatt)
{
kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
gatt->ag_entries * sizeof(u_int32_t));
kmem_free((vm_offset_t)gatt->ag_virtual, gatt->ag_entries *
sizeof(u_int32_t));
free(gatt, M_AGP);
}

View File

@ -119,8 +119,8 @@ agp_amd_alloc_gatt(device_t dev)
if (bootverbose)
device_printf(dev,
"failed to allocate page directory\n");
kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
entries * sizeof(u_int32_t));
kmem_free((vm_offset_t)gatt->ag_virtual, entries *
sizeof(u_int32_t));
free(gatt, M_AGP);
return 0;
}
@ -168,9 +168,9 @@ agp_amd_alloc_gatt(device_t dev)
static void
agp_amd_free_gatt(struct agp_amd_gatt *gatt)
{
kmem_free(kernel_arena, (vm_offset_t)gatt->ag_vdir, AGP_PAGE_SIZE);
kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
gatt->ag_entries * sizeof(u_int32_t));
kmem_free((vm_offset_t)gatt->ag_vdir, AGP_PAGE_SIZE);
kmem_free((vm_offset_t)gatt->ag_virtual, gatt->ag_entries *
sizeof(u_int32_t));
free(gatt, M_AGP);
}

View File

@ -147,8 +147,8 @@ agp_ati_alloc_gatt(device_t dev)
if (sc->ag_vdir == NULL) {
if (bootverbose)
device_printf(dev, "pagedir allocation failed\n");
kmem_free(kernel_arena, (vm_offset_t)sc->ag_virtual,
entries * sizeof(u_int32_t));
kmem_free((vm_offset_t)sc->ag_virtual, entries *
sizeof(u_int32_t));
return ENOMEM;
}
sc->ag_pdir = vtophys((vm_offset_t)sc->ag_vdir);
@ -265,9 +265,9 @@ agp_ati_detach(device_t dev)
temp = pci_read_config(dev, apsize_reg, 4);
pci_write_config(dev, apsize_reg, temp & ~1, 4);
kmem_free(kernel_arena, (vm_offset_t)sc->ag_vdir, AGP_PAGE_SIZE);
kmem_free(kernel_arena, (vm_offset_t)sc->ag_virtual,
sc->ag_entries * sizeof(u_int32_t));
kmem_free((vm_offset_t)sc->ag_vdir, AGP_PAGE_SIZE);
kmem_free((vm_offset_t)sc->ag_virtual, sc->ag_entries *
sizeof(u_int32_t));
bus_release_resource(dev, SYS_RES_MEMORY, ATI_GART_MMADDR, sc->regs);
agp_free_res(dev);

View File

@ -1329,7 +1329,7 @@ agp_i810_deinstall_gatt(device_t dev)
sc = device_get_softc(dev);
bus_write_4(sc->sc_res[0], AGP_I810_PGTBL_CTL, 0);
kmem_free(kernel_arena, (vm_offset_t)sc->gatt->ag_virtual, 64 * 1024);
kmem_free((vm_offset_t)sc->gatt->ag_virtual, 64 * 1024);
}
static void

View File

@ -1202,8 +1202,12 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
uint32_t mss = m->m_pkthdr.tso_segsz;
struct ether_vlan_header *eh;
uint16_t etype;
#ifdef INET
struct ip *ip;
#endif
#ifdef INET6
struct ip6_hdr *ip6;
#endif
struct tcphdr *th = NULL;
int ehdrlen, ip_hlen = 0;
uint8_t ipproto = 0;
@ -1243,6 +1247,7 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
}
switch (etype) {
#ifdef INET
case ETHERTYPE_IP:
ip = (struct ip *)(m->m_data + ehdrlen);
ip_hlen = ip->ip_hl << 2;
@ -1256,6 +1261,8 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
else
hal_pkt->l4_proto_idx = AL_ETH_PROTO_ID_UDP;
break;
#endif /* INET */
#ifdef INET6
case ETHERTYPE_IPV6:
ip6 = (struct ip6_hdr *)(m->m_data + ehdrlen);
hal_pkt->l3_proto_idx = AL_ETH_PROTO_ID_IPv6;
@ -1267,6 +1274,7 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
else
hal_pkt->l4_proto_idx = AL_ETH_PROTO_ID_UDP;
break;
#endif /* INET6 */
default:
break;
}

View File

@ -195,7 +195,7 @@ ecc_ei_inject(int count)
pause_sbt("ecc_ei_inject", delay_ms * SBT_1MS, 0, 0);
}
kmem_free(kernel_arena, memory, PAGE_SIZE);
kmem_free(memory, PAGE_SIZE);
}
static int

View File

@ -76,6 +76,7 @@ struct cpl_set_tcb_rpl;
#include <linux/inetdevice.h>
#include <linux/if_vlan.h>
#include <net/netevent.h>
#include <rdma/rdma_cm.h>
static spinlock_t req_lock;
static TAILQ_HEAD(c4iw_ep_list, c4iw_ep_common) req_list;
@ -2523,6 +2524,8 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
struct c4iw_dev *dev = to_c4iw_dev(cm_id->device);
struct c4iw_ep *ep = NULL;
struct ifnet *nh_ifp; /* Logical egress interface */
struct rdma_cm_id *rdma_id = (struct rdma_cm_id*)cm_id->context;
struct vnet *vnet = rdma_id->route.addr.dev_addr.net;
CTR2(KTR_IW_CXGBE, "%s:ccB %p", __func__, cm_id);
@ -2568,7 +2571,10 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
ref_qp(ep);
ep->com.thread = curthread;
CURVNET_SET(vnet);
err = get_ifnet_from_raddr(&cm_id->remote_addr, &nh_ifp);
CURVNET_RESTORE();
if (err) {
CTR2(KTR_IW_CXGBE, "%s:cc7 %p", __func__, ep);
@ -2811,7 +2817,10 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
if (!ep->parent_ep)
ep->com.state = MORIBUND;
CURVNET_SET(ep->com.so->so_vnet);
sodisconnect(ep->com.so);
CURVNET_RESTORE();
}
}

View File

@ -1970,6 +1970,8 @@ t4_ddp_mod_unload(void)
taskqueue_drain(taskqueue_thread, &ddp_orphan_task);
MPASS(TAILQ_EMPTY(&ddp_orphan_pagesets));
mtx_destroy(&ddp_orphan_pagesets_lock);
t4_register_shared_cpl_handler(CPL_SET_TCB_RPL, NULL, CPL_COOKIE_DDP0);
t4_register_shared_cpl_handler(CPL_SET_TCB_RPL, NULL, CPL_COOKIE_DDP1);
t4_register_cpl_handler(CPL_RX_DATA_DDP, NULL);
t4_register_cpl_handler(CPL_RX_DDP_COMPLETE, NULL);
}

View File

@ -1145,4 +1145,15 @@ typedef struct drm_mm_init_arg drm_mm_init_arg_t;
typedef enum drm_bo_type drm_bo_type_t;
#endif
#define DRM_PORT "graphics/drm-legacy-kmod"
#define DRM_OBSOLETE(dev) \
do { \
device_printf(dev, "=======================================================\n"); \
device_printf(dev, "This code is obsolete abandonware. Install the " DRM_PORT " pkg\n"); \
device_printf(dev, "=======================================================\n"); \
gone_in_dev(dev, 13, "drm drivers"); \
} while (0)
#endif

View File

@ -174,7 +174,8 @@ int drm_probe(device_t kdev, drm_pci_id_list_t *idlist)
DRM_DEBUG("desc : %s\n", device_get_desc(kdev));
device_set_desc(kdev, id_entry->name);
}
return 0;
DRM_OBSOLETE(kdev);
return BUS_PROBE_GENERIC;
}
return ENXIO;

View File

@ -99,7 +99,7 @@ drm_sg_cleanup(struct drm_sg_mem *entry)
return;
if (entry->vaddr != 0)
kmem_free(kernel_arena, entry->vaddr, IDX_TO_OFF(entry->pages));
kmem_free(entry->vaddr, IDX_TO_OFF(entry->pages));
free(entry->busaddr, DRM_MEM_SGLISTS);
free(entry, DRM_MEM_DRIVER);

View File

@ -126,7 +126,8 @@ drm_probe_helper(device_t kdev, const drm_pci_id_list_t *idlist)
device_get_nameunit(kdev), id_entry->name);
device_set_desc(kdev, id_entry->name);
}
return (0);
DRM_OBSOLETE(kdev);
return (-BUS_PROBE_GENERIC);
}
return (-ENXIO);

View File

@ -154,6 +154,20 @@ typedef void irqreturn_t;
*(volatile u_int64_t *)(((vm_offset_t)(map)->handle) + \
(vm_offset_t)(offset)) = htole64(val)
#ifdef __LP64__
#define DRM_PORT "graphics/drm-stable-kmod"
#else
#define DRM_PORT "graphics/drm-legacy-kmod"
#endif
#define DRM_OBSOLETE(dev) \
do { \
device_printf(dev, "=======================================================\n"); \
device_printf(dev, "This code is obsolete abandonware. Install the " DRM_PORT " pkg\n"); \
device_printf(dev, "=======================================================\n"); \
gone_in_dev(dev, 13, "drm2 drivers"); \
} while (0)
/* DRM_READMEMORYBARRIER() prevents reordering of reads.
* DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
* DRM_MEMORYBARRIER() prevents reordering of reads and writes.

View File

@ -47,7 +47,7 @@ void drm_sg_cleanup(struct drm_sg_mem * entry)
return;
if (entry->vaddr != 0)
kmem_free(kernel_arena, entry->vaddr, IDX_TO_OFF(entry->pages));
kmem_free(entry->vaddr, IDX_TO_OFF(entry->pages));
free(entry->busaddr, DRM_MEM_SGLISTS);
free(entry, DRM_MEM_DRIVER);

View File

@ -457,7 +457,7 @@ glxsb_rnd(void *v)
value = bus_read_4(sc->sc_sr, SB_RANDOM_NUM);
/* feed with one uint32 */
/* MarkM: FIX!! Check that this does not swamp the harvester! */
random_harvest_queue(&value, sizeof(value), 32/2, RANDOM_PURE_GLXSB);
random_harvest_queue(&value, sizeof(value), RANDOM_PURE_GLXSB);
}
callout_reset(&sc->sc_rngco, sc->sc_rnghz, glxsb_rnd, sc);

View File

@ -259,7 +259,7 @@ static void
default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
{
/* MarkM: FIX!! Check that this does not swamp the harvester! */
random_harvest_queue(buf, count, count*NBBY/2, RANDOM_PURE_HIFN);
random_harvest_queue(buf, count, RANDOM_PURE_HIFN);
}
static u_int

View File

@ -264,8 +264,7 @@ SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init,
static void
hypercall_memfree(void)
{
kmem_free(kernel_arena, (vm_offset_t)hypercall_context.hc_addr,
PAGE_SIZE);
kmem_free((vm_offset_t)hypercall_context.hc_addr, PAGE_SIZE);
hypercall_context.hc_addr = NULL;
}

View File

@ -212,7 +212,7 @@ static inline void
lio_dma_free(size_t size, void *cpu_addr)
{
kmem_free(kmem_arena, (vm_offset_t)cpu_addr, size);
kmem_free((vm_offset_t)cpu_addr, size);
}
static inline uint64_t

View File

@ -97,7 +97,6 @@ MMCBR_ACCESSOR(host_ocr, HOST_OCR, int)
MMCBR_ACCESSOR(mode, MODE, int)
MMCBR_ACCESSOR(ocr, OCR, int)
MMCBR_ACCESSOR(power_mode, POWER_MODE, int)
MMCBR_ACCESSOR(retune_req, RETUNE_REQ, int)
MMCBR_ACCESSOR(vdd, VDD, int)
MMCBR_ACCESSOR(vccq, VCCQ, int)
MMCBR_ACCESSOR(caps, CAPS, int)
@ -105,6 +104,20 @@ MMCBR_ACCESSOR(timing, TIMING, int)
MMCBR_ACCESSOR(max_data, MAX_DATA, int)
MMCBR_ACCESSOR(max_busy_timeout, MAX_BUSY_TIMEOUT, u_int)
static int __inline
mmcbr_get_retune_req(device_t dev)
{
uintptr_t v;
if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev,
MMCBR_IVAR_RETUNE_REQ, &v) != 0))
return (retune_req_none);
return ((int)v);
}
/*
* Convenience wrappers for the mmcbr interface
*/
static int __inline
mmcbr_update_ios(device_t dev)
{

View File

@ -28,23 +28,23 @@
#
# Basic script to build crude unit tests.
#
# Diff-reduction checking between Yarrow and fortuna is done like so:
# Diff-reduction checking between fortuna and the other algorithm is done like so:
#
# $ diff -u -B <(sed -e 's/yarrow/wombat/g' \
# -e 's/YARROW/WOMBAT/g' yarrow.c) \
# <(sed -e 's/fortuna/wombat/g' \
# -e 's/FORTUNA/WOMBAT/g' fortuna.c) | less
# $ diff -u -B <(sed -e 's/random_other/random_wombat/g' \
# -e 's/RANDOM_OTHER/RANDOM_WOMBAT/g' other_algorithm.c) \
# <(sed -e 's/random_fortuna/random_wombat/g' \
# -e 's/RANDOM_FORTUNA/RANDOM_WOMBAT/g' fortuna.c) | less
#
cc -g -O0 -pthread \
-I../.. -lstdthreads -Wall \
unit_test.c \
yarrow.c \
other_algorithm.c \
hash.c \
../../crypto/rijndael/rijndael-api-fst.c \
../../crypto/rijndael/rijndael-alg-fst.c \
../../crypto/sha2/sha256c.c \
-lz \
-o yunit_test
-o other_unit_test
cc -g -O0 -pthread \
-I../.. -lstdthreads -Wall \
unit_test.c \
@ -54,4 +54,4 @@ cc -g -O0 -pthread \
../../crypto/rijndael/rijndael-alg-fst.c \
../../crypto/sha2/sha256c.c \
-lz \
-o funit_test
-o fortuna_unit_test

View File

@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <dev/random/uint128.h>
#include <dev/random/fortuna.h>
#else /* !_KERNEL */
#include <sys/param.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
@ -97,9 +98,11 @@ CTASSERT(RANDOM_BLOCKSIZE == sizeof(uint128_t));
CTASSERT(RANDOM_KEYSIZE == 2*RANDOM_BLOCKSIZE);
/* Probes for dtrace(1) */
#ifdef _KERNEL
SDT_PROVIDER_DECLARE(random);
SDT_PROVIDER_DEFINE(random);
SDT_PROBE_DEFINE2(random, fortuna, event_processor, debug, "u_int", "struct fs_pool *");
#endif /* _KERNEL */
/*
* This is the beastie that needs protecting. It contains all of the
@ -398,7 +401,9 @@ random_fortuna_pre_read(void)
} else
break;
}
#ifdef _KERNEL
SDT_PROBE2(random, fortuna, event_processor, debug, fortuna_state.fs_reseedcount, fortuna_state.fs_pool);
#endif
/* FS&K */
random_fortuna_reseed_internal(s, i < RANDOM_FORTUNA_NPOOLS ? i + 1 : RANDOM_FORTUNA_NPOOLS);
/* Clean up and secure */

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2015 Mark R V Murray
* Copyright (c) 2015-2018 Mark R V Murray
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -30,19 +30,21 @@
* containing an alternative entropy-processing algorithm for random(4).
*
* The functions below should be completed with the appropriate code,
* and the nearby yarrow.c and fortuna.c may be consulted for examples
* of working code.
* and the nearby fortuna.c may be consulted for examples of working code.
*
* The author is willing to provide reasonable help to those wishing to
* write such a module for themselves. Please use the markm@ FreeBSD
* email address, and ensure that you are developing this on a suitably
* supported branch (This is currently 11-CURRENT, and will be no
* older than 11-STABLE in the future).
* supported branch (This is currently 12-CURRENT, and may be no
* older than 12-STABLE in the future).
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/limits.h>
#ifdef _KERNEL
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
@ -62,6 +64,24 @@ __FBSDID("$FreeBSD$");
#include <dev/random/random_harvestq.h>
#include <dev/random/uint128.h>
#include <dev/random/other_algorithm.h>
#else /* !_KERNEL */
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <threads.h>
#include "unit_test.h"
#include <crypto/rijndael/rijndael-api-fst.h>
#include <crypto/sha2/sha256.h>
#include <dev/random/hash.h>
#include <dev/random/randomdev.h>
#include <dev/random/uint128.h>
#include <dev/random/other_algorithm.h>
#endif /* _KERNEL */
static void random_other_pre_read(void);
static void random_other_read(uint8_t *, u_int);
@ -73,9 +93,7 @@ static void random_other_deinit_alg(void *);
/*
* RANDOM_OTHER_NPOOLS is used when reading hardware random
* number sources to ensure that each pool gets one read sample
* per loop iteration. Yarrow has 2 such pools (FAST and SLOW),
* and fortuna has 32 (0-31). The RNG used prior to Yarrow and
* ported from Linux had just 1 pool.
* per loop iteration. Fortuna has 32 (0-31).
*/
#define RANDOM_OTHER_NPOOLS 1

View File

@ -31,14 +31,13 @@
* containing an alternative entropy-processing algorithm for random(4).
*
* The functions below should be completed with the appropriate code,
* and the nearby yarrow.c and fortuna.c may be consulted for examples
* of working code.
* and the nearby fortuna.c may be consulted for examples of working code.
*
* The author is willing to provide reasonable help to those wishing to
* write such a module for themselves. Please use the markm@ FreeBSD
* email address, and ensure that you are developing this on a suitably
* supported branch (This is currently 11-CURRENT, and will be no
* older than 11-STABLE in the future).
* supported branch (This is currently 12-CURRENT, and may be no
* older than 12-STABLE in the future).
*/
#ifndef SYS_DEV_RANDOM_OTHER_H_INCLUDED

View File

@ -140,7 +140,7 @@ static struct kproc_desc random_proc_kp = {
&harvest_context.hc_kthread_proc,
};
/* Pass the given event straight through to Fortuna/Yarrow/Whatever. */
/* Pass the given event straight through to Fortuna/Whatever. */
static __inline void
random_harvestq_fast_process_event(struct harvest_event *event)
{
@ -178,7 +178,7 @@ random_kthread(void)
/* XXX: FIX!! Increase the high-performance data rate? Need some measurements first. */
for (i = 0; i < RANDOM_ACCUM_MAX; i++) {
if (harvest_context.hc_entropy_fast_accumulator.buf[i]) {
random_harvest_direct(harvest_context.hc_entropy_fast_accumulator.buf + i, sizeof(harvest_context.hc_entropy_fast_accumulator.buf[0]), 4, RANDOM_UMA);
random_harvest_direct(harvest_context.hc_entropy_fast_accumulator.buf + i, sizeof(harvest_context.hc_entropy_fast_accumulator.buf[0]), RANDOM_UMA);
harvest_context.hc_entropy_fast_accumulator.buf[i] = 0;
}
}
@ -197,8 +197,7 @@ SYSINIT(random_device_h_proc, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, kproc_start,
/*
* Run through all fast sources reading entropy for the given
* number of rounds, which should be a multiple of the number
* of entropy accumulation pools in use; 2 for Yarrow and 32
* for Fortuna.
* of entropy accumulation pools in use; it is 32 for Fortuna.
*/
static void
random_sources_feed(void)
@ -234,7 +233,7 @@ random_sources_feed(void)
printf("%s: rs_read for hardware device '%s' returned no entropy.\n", __func__, rrs->rrs_source->rs_ident);
continue;
}
random_harvest_direct(entropy, n, (n*8)/2, rrs->rrs_source->rs_source);
random_harvest_direct(entropy, n, rrs->rrs_source->rs_source);
}
}
explicit_bzero(entropy, sizeof(entropy));
@ -380,7 +379,7 @@ SYSINIT(random_device_h_init, SI_SUB_RANDOM, SI_ORDER_SECOND, random_harvestq_in
/*
* This is used to prime the RNG by grabbing any early random stuff
* known to the kernel, and inserting it directly into the hashing
* module, e.g. Fortuna or Yarrow.
* module, currently Fortuna.
*/
/* ARGSUSED */
static void
@ -414,7 +413,6 @@ random_harvestq_prime(void *unused __unused)
count = sizeof(event.he_entropy);
event.he_somecounter = (uint32_t)get_cyclecount();
event.he_size = count;
event.he_bits = count/4; /* Underestimate the size for Yarrow */
event.he_source = RANDOM_CACHED;
event.he_destination = harvest_context.hc_destination[0]++;
memcpy(event.he_entropy, data + i, sizeof(event.he_entropy));
@ -459,8 +457,7 @@ SYSUNINIT(random_device_h_init, SI_SUB_RANDOM, SI_ORDER_SECOND, random_harvestq_
* read which can be quite expensive.
*/
void
random_harvest_queue_(const void *entropy, u_int size, u_int bits,
enum random_entropy_source origin)
random_harvest_queue_(const void *entropy, u_int size, enum random_entropy_source origin)
{
struct harvest_event *event;
u_int ring_in;
@ -474,7 +471,6 @@ random_harvest_queue_(const void *entropy, u_int size, u_int bits,
event->he_somecounter = (uint32_t)get_cyclecount();
event->he_source = origin;
event->he_destination = harvest_context.hc_destination[origin]++;
event->he_bits = bits;
if (size <= sizeof(event->he_entropy)) {
event->he_size = size;
memcpy(event->he_entropy, entropy, size);
@ -496,7 +492,7 @@ random_harvest_queue_(const void *entropy, u_int size, u_int bits,
* This is the right place for high-rate harvested data.
*/
void
random_harvest_fast_(const void *entropy, u_int size, u_int bits)
random_harvest_fast_(const void *entropy, u_int size)
{
u_int pos;
@ -512,7 +508,7 @@ random_harvest_fast_(const void *entropy, u_int size, u_int bits)
* (e.g.) booting when initial entropy is being gathered.
*/
void
random_harvest_direct_(const void *entropy, u_int size, u_int bits, enum random_entropy_source origin)
random_harvest_direct_(const void *entropy, u_int size, enum random_entropy_source origin)
{
struct harvest_event event;
@ -520,7 +516,6 @@ random_harvest_direct_(const void *entropy, u_int size, u_int bits, enum random_
size = MIN(size, sizeof(event.he_entropy));
event.he_somecounter = (uint32_t)get_cyclecount();
event.he_size = size;
event.he_bits = bits;
event.he_source = origin;
event.he_destination = harvest_context.hc_destination[origin]++;
memcpy(event.he_entropy, entropy, size);

View File

@ -38,10 +38,9 @@ struct harvest_event {
uint32_t he_somecounter; /* fast counter for clock jitter */
uint32_t he_entropy[HARVESTSIZE];/* some harvested entropy */
uint8_t he_size; /* harvested entropy byte count */
uint8_t he_bits; /* stats about the entropy */
uint8_t he_destination; /* destination pool of this entropy */
uint8_t he_source; /* origin of the entropy */
} __packed;
};
void read_rate_increment(u_int);

View File

@ -166,7 +166,7 @@ READ_RANDOM_UIO(struct uio *uio, bool nonblock)
* Belt-and-braces.
* Round up the read length to a crypto block size multiple,
* which is what the underlying generator is expecting.
* See the random_buf size requirements in the Yarrow/Fortuna code.
* See the random_buf size requirements in the Fortuna code.
*/
read_len = roundup(read_len, RANDOM_BLOCKSIZE);
/* Work in chunks page-sized or less */
@ -250,7 +250,6 @@ randomdev_accumulate(uint8_t *buf, u_int count)
for (i = 0; i < RANDOM_KEYSIZE_WORDS; i += sizeof(event.he_entropy)/sizeof(event.he_entropy[0])) {
event.he_somecounter = (uint32_t)get_cyclecount();
event.he_size = sizeof(event.he_entropy);
event.he_bits = event.he_size/8;
event.he_source = RANDOM_CACHED;
event.he_destination = destination++; /* Harmless cheating */
memcpy(event.he_entropy, entropy_data + i, sizeof(event.he_entropy));

View File

@ -31,7 +31,6 @@
cc -g -O0 -pthread -DRANDOM_<alg> -I../.. -lstdthreads -Wall \
unit_test.c \
yarrow.c \
fortuna.c \
hash.c \
../../crypto/rijndael/rijndael-api-fst.c \
@ -41,7 +40,9 @@ cc -g -O0 -pthread -DRANDOM_<alg> -I../.. -lstdthreads -Wall \
-o unit_test
./unit_test
Where <alg> is YARROW or FORTUNA.
Where <alg> is FORTUNA. The parameterisation is a leftover from
when Yarrow was an option, and remains to enable the testing of
possible future algorithms.
*/
#include <sys/types.h>
@ -157,7 +158,6 @@ RunHarvester(void *arg __unused)
e.he_somecounter = i;
*((uint64_t *)e.he_entropy) = random();
e.he_size = 8;
e.he_bits = random()%4;
e.he_destination = i;
e.he_source = (i + 3)%7;
e.he_next = NULL;

View File

@ -74,9 +74,8 @@ enum random_entropy_source {
struct harvest_event {
uintmax_t he_somecounter; /* fast counter for clock jitter */
uint32_t he_entropy[HARVESTSIZE];/* some harvested entropy */
u_int he_size; /* harvested entropy byte count */
u_int he_bits; /* stats about the entropy */
u_int he_destination; /* destination pool of this entropy */
uint8_t he_size; /* harvested entropy byte count */
uint8_t he_destination; /* destination pool of this entropy */
enum random_entropy_source he_source; /* origin of the entropy */
void * he_next; /* next item on the list */
};

View File

@ -1,395 +0,0 @@
/*-
* Copyright (c) 2000-2015 Mark R V Murray
* 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
* in this position and unchanged.
* 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 ``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.
*
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef _KERNEL
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/random.h>
#include <sys/sdt.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <machine/cpu.h>
#include <crypto/rijndael/rijndael-api-fst.h>
#include <crypto/sha2/sha256.h>
#include <dev/random/hash.h>
#include <dev/random/randomdev.h>
#include <dev/random/random_harvestq.h>
#include <dev/random/uint128.h>
#include <dev/random/yarrow.h>
#else /* !_KERNEL */
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <threads.h>
#include "unit_test.h"
#include <crypto/rijndael/rijndael-api-fst.h>
#include <crypto/sha2/sha256.h>
#include <dev/random/hash.h>
#include <dev/random/randomdev.h>
#include <dev/random/uint128.h>
#include <dev/random/yarrow.h>
#endif /* _KERNEL */
#define RANDOM_YARROW_TIMEBIN 16 /* max value for Pt/t */
#define RANDOM_YARROW_FAST 0
#define RANDOM_YARROW_SLOW 1
#define RANDOM_YARROW_NPOOLS 2
/* This algorithm (and code) presumes that RANDOM_KEYSIZE is twice as large as RANDOM_BLOCKSIZE */
CTASSERT(RANDOM_BLOCKSIZE == sizeof(uint128_t));
CTASSERT(RANDOM_KEYSIZE == 2*RANDOM_BLOCKSIZE);
/* Probes for dtrace(1) */
SDT_PROVIDER_DECLARE(random);
SDT_PROVIDER_DEFINE(random);
SDT_PROBE_DEFINE3(random, yarrow, event_processor, debug, "boolean", "u_int", "struct ys_pool *");
/*
* This is the beastie that needs protecting. It contains all of the
* state that we are excited about. Exactly one is instantiated.
*/
static struct yarrow_state {
uint128_t ys_counter; /* C */
struct randomdev_key ys_key; /* K */
u_int ys_gengateinterval; /* Pg */
u_int ys_bins; /* Pt/t */
u_int ys_outputblocks; /* count output blocks for gates */
u_int ys_slowoverthresh; /* slow pool overthreshhold reseed count */
struct ys_pool {
u_int ysp_source_bits[ENTROPYSOURCE]; /* estimated bits of entropy per source */
u_int ysp_thresh; /* pool reseed threshold */
struct randomdev_hash ysp_hash; /* accumulated entropy */
} ys_pool[RANDOM_YARROW_NPOOLS];/* pool[0] is fast, pool[1] is slow */
bool ys_seeded;
/* Reseed lock */
mtx_t ys_mtx;
} yarrow_state;
#ifdef _KERNEL
static struct sysctl_ctx_list random_clist;
RANDOM_CHECK_UINT(gengateinterval, 4, 64);
RANDOM_CHECK_UINT(bins, RANDOM_YARROW_NPOOLS, 16);
RANDOM_CHECK_UINT(fastthresh, (RANDOM_BLOCKSIZE*8)/4, (RANDOM_BLOCKSIZE*8)); /* Bit counts */
RANDOM_CHECK_UINT(slowthresh, (RANDOM_BLOCKSIZE*8)/4, (RANDOM_BLOCKSIZE*8)); /* Bit counts */
RANDOM_CHECK_UINT(slowoverthresh, 1, 5);
#endif /* _KERNEL */
static void random_yarrow_pre_read(void);
static void random_yarrow_read(uint8_t *, u_int);
static bool random_yarrow_seeded(void);
static void random_yarrow_process_event(struct harvest_event *);
static void random_yarrow_init_alg(void *);
static void random_yarrow_deinit_alg(void *);
static void random_yarrow_reseed_internal(u_int);
struct random_algorithm random_alg_context = {
.ra_ident = "Yarrow",
.ra_init_alg = random_yarrow_init_alg,
.ra_deinit_alg = random_yarrow_deinit_alg,
.ra_pre_read = random_yarrow_pre_read,
.ra_read = random_yarrow_read,
.ra_seeded = random_yarrow_seeded,
.ra_event_processor = random_yarrow_process_event,
.ra_poolcount = RANDOM_YARROW_NPOOLS,
};
/* ARGSUSED */
static void
random_yarrow_init_alg(void *unused __unused)
{
int i, j;
#ifdef _KERNEL
struct sysctl_oid *random_yarrow_o;
#endif
RANDOM_RESEED_INIT_LOCK();
/* Start unseeded, therefore blocked. */
yarrow_state.ys_seeded = false;
#ifdef _KERNEL
/*
* Yarrow parameters. Do not adjust these unless you have
* have a very good clue about what they do!
*/
random_yarrow_o = SYSCTL_ADD_NODE(&random_clist,
SYSCTL_STATIC_CHILDREN(_kern_random),
OID_AUTO, "yarrow", CTLFLAG_RW, 0,
"Yarrow Parameters");
SYSCTL_ADD_PROC(&random_clist,
SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
"gengateinterval", CTLTYPE_UINT | CTLFLAG_RWTUN,
&yarrow_state.ys_gengateinterval, 0,
random_check_uint_gengateinterval, "UI",
"Generation gate interval");
SYSCTL_ADD_PROC(&random_clist,
SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
"bins", CTLTYPE_UINT | CTLFLAG_RWTUN,
&yarrow_state.ys_bins, 0,
random_check_uint_bins, "UI",
"Execution time tuner");
SYSCTL_ADD_PROC(&random_clist,
SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
"fastthresh", CTLTYPE_UINT | CTLFLAG_RWTUN,
&yarrow_state.ys_pool[0].ysp_thresh, 0,
random_check_uint_fastthresh, "UI",
"Fast reseed threshold");
SYSCTL_ADD_PROC(&random_clist,
SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
"slowthresh", CTLTYPE_UINT | CTLFLAG_RWTUN,
&yarrow_state.ys_pool[1].ysp_thresh, 0,
random_check_uint_slowthresh, "UI",
"Slow reseed threshold");
SYSCTL_ADD_PROC(&random_clist,
SYSCTL_CHILDREN(random_yarrow_o), OID_AUTO,
"slowoverthresh", CTLTYPE_UINT | CTLFLAG_RWTUN,
&yarrow_state.ys_slowoverthresh, 0,
random_check_uint_slowoverthresh, "UI",
"Slow over-threshold reseed");
#endif /* _KERNEL */
yarrow_state.ys_gengateinterval = 10;
yarrow_state.ys_bins = 10;
yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_thresh = (3*(RANDOM_BLOCKSIZE*8))/4;
yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_thresh = (RANDOM_BLOCKSIZE*8);
yarrow_state.ys_slowoverthresh = 2;
/* Ensure that the first time we read, we are gated. */
yarrow_state.ys_outputblocks = yarrow_state.ys_gengateinterval;
/* Initialise the fast and slow entropy pools */
for (i = RANDOM_YARROW_FAST; i <= RANDOM_YARROW_SLOW; i++) {
randomdev_hash_init(&yarrow_state.ys_pool[i].ysp_hash);
for (j = RANDOM_START; j < ENTROPYSOURCE; j++)
yarrow_state.ys_pool[i].ysp_source_bits[j] = 0;
}
/* Clear the counter */
yarrow_state.ys_counter = UINT128_ZERO;
}
/* ARGSUSED */
static void
random_yarrow_deinit_alg(void *unused __unused)
{
RANDOM_RESEED_DEINIT_LOCK();
explicit_bzero(&yarrow_state, sizeof(yarrow_state));
#ifdef _KERNEL
sysctl_ctx_free(&random_clist);
#endif
}
/* Process a single stochastic event off the harvest queue */
static void
random_yarrow_process_event(struct harvest_event *event)
{
u_int pl, overthreshhold[RANDOM_YARROW_NPOOLS];
enum random_entropy_source src;
RANDOM_RESEED_LOCK();
/*
* Accumulate the event into the appropriate pool
* where each event carries the destination information.
* We lock against pool state modification which can happen
* during accumulation/reseeding and reading/regating
*/
pl = event->he_destination % RANDOM_YARROW_NPOOLS;
randomdev_hash_iterate(&yarrow_state.ys_pool[pl].ysp_hash, event, sizeof(*event));
yarrow_state.ys_pool[pl].ysp_source_bits[event->he_source] += event->he_bits;
/* Count the over-threshold sources in each pool */
for (pl = RANDOM_YARROW_FAST; pl <= RANDOM_YARROW_SLOW; pl++) {
overthreshhold[pl] = 0;
for (src = RANDOM_START; src < ENTROPYSOURCE; src++) {
if (yarrow_state.ys_pool[pl].ysp_source_bits[src] > yarrow_state.ys_pool[pl].ysp_thresh)
overthreshhold[pl]++;
}
}
/*
* If enough slow sources are over threshold, then slow reseed
* else if any fast source over threshold, then fast reseed.
*/
if (overthreshhold[RANDOM_YARROW_SLOW] >= yarrow_state.ys_slowoverthresh)
random_yarrow_reseed_internal(RANDOM_YARROW_SLOW);
else if (overthreshhold[RANDOM_YARROW_FAST] > 0 && yarrow_state.ys_seeded)
random_yarrow_reseed_internal(RANDOM_YARROW_FAST);
explicit_bzero(event, sizeof(*event));
RANDOM_RESEED_UNLOCK();
}
static void
random_yarrow_reseed_internal(u_int fastslow)
{
/*
* Interrupt-context stack is a limited resource; make large
* structures static.
*/
static uint8_t v[RANDOM_YARROW_TIMEBIN][RANDOM_KEYSIZE]; /* v[i] */
static uint128_t temp;
static struct randomdev_hash context;
u_int i;
enum random_entropy_source j;
KASSERT(yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_thresh > 0, ("random: Yarrow fast threshold = 0"));
KASSERT(yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_thresh > 0, ("random: Yarrow slow threshold = 0"));
RANDOM_RESEED_ASSERT_LOCK_OWNED();
SDT_PROBE3(random, yarrow, event_processor, debug, yarrow_state.ys_seeded, yarrow_state.ys_slowoverthresh, yarrow_state.ys_pool);
/* 1. Hash the accumulated entropy into v[0] */
randomdev_hash_init(&context);
/* Feed the slow pool hash in if slow */
if (fastslow == RANDOM_YARROW_SLOW) {
randomdev_hash_finish(&yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_hash, &temp);
randomdev_hash_iterate(&context, &temp, sizeof(temp));
}
randomdev_hash_finish(&yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_hash, &temp);
randomdev_hash_iterate(&context, &temp, sizeof(temp));
randomdev_hash_finish(&context, v[0]);
/*-
* 2. Compute hash values for all v. _Supposed_ to be computationally
* intensive.
*/
if (yarrow_state.ys_bins > RANDOM_YARROW_TIMEBIN)
yarrow_state.ys_bins = RANDOM_YARROW_TIMEBIN;
for (i = 1; i < yarrow_state.ys_bins; i++) {
randomdev_hash_init(&context);
/* v[i] #= h(v[i - 1]) */
randomdev_hash_iterate(&context, v[i - 1], RANDOM_KEYSIZE);
/* v[i] #= h(v[0]) */
randomdev_hash_iterate(&context, v[0], RANDOM_KEYSIZE);
/* v[i] #= h(i) */
randomdev_hash_iterate(&context, &i, sizeof(i));
/* Return the hashval */
randomdev_hash_finish(&context, v[i]);
}
/*-
* 3. Compute a new key; h' is the identity function here;
* it is not being ignored!
*/
randomdev_hash_init(&context);
randomdev_hash_iterate(&context, &yarrow_state.ys_key, RANDOM_KEYSIZE);
for (i = 1; i < yarrow_state.ys_bins; i++)
randomdev_hash_iterate(&context, v[i], RANDOM_KEYSIZE);
randomdev_hash_finish(&context, &temp);
randomdev_encrypt_init(&yarrow_state.ys_key, &temp);
/* 4. Recompute the counter */
yarrow_state.ys_counter = UINT128_ZERO;
randomdev_encrypt(&yarrow_state.ys_key, &yarrow_state.ys_counter, &temp, RANDOM_BLOCKSIZE);
yarrow_state.ys_counter = temp;
/* 5. Reset entropy estimate accumulators to zero */
for (i = 0; i <= fastslow; i++)
for (j = RANDOM_START; j < ENTROPYSOURCE; j++)
yarrow_state.ys_pool[i].ysp_source_bits[j] = 0;
/* 6. Wipe memory of intermediate values */
explicit_bzero(v, sizeof(v));
explicit_bzero(&temp, sizeof(temp));
explicit_bzero(&context, sizeof(context));
/* Not defined so writes ain't gonna happen. Kept for documenting. */
#ifdef RANDOM_RWFILE_WRITE_IS_OK
/*-
* 7. Dump to seed file.
* This pseudo-code is documentation. Please leave it alone.
*/
seed_file = "<some file>";
error = randomdev_write_file(seed_file, <generated entropy>, PAGE_SIZE);
if (error == 0)
printf("random: entropy seed file '%s' successfully written\n", seed_file);
#endif
/* Unblock the device if it was blocked due to being unseeded */
if (!yarrow_state.ys_seeded) {
yarrow_state.ys_seeded = true;
randomdev_unblock();
}
}
static __inline void
random_yarrow_generator_gate(void)
{
u_int i;
uint8_t temp[RANDOM_KEYSIZE];
RANDOM_RESEED_ASSERT_LOCK_OWNED();
uint128_increment(&yarrow_state.ys_counter);
for (i = 0; i < RANDOM_KEYSIZE; i += RANDOM_BLOCKSIZE)
randomdev_encrypt(&yarrow_state.ys_key, &yarrow_state.ys_counter, temp + i, RANDOM_BLOCKSIZE);
randomdev_encrypt_init(&yarrow_state.ys_key, temp);
explicit_bzero(temp, sizeof(temp));
}
/*-
* Used to return processed entropy from the PRNG. There is a pre_read
* required to be present (but it can be a stub) in order to allow
* specific actions at the begin of the read.
* Yarrow does its reseeding in its own thread; _pre_read() is not used
* by Yarrow but must be kept for completeness.
*/
void
random_yarrow_pre_read(void)
{
}
/*-
* Main read from Yarrow.
* The supplied buf MUST be a multiple (>=0) of RANDOM_BLOCKSIZE in size.
* Lots of code presumes this for efficiency, both here and in other
* routines. You are NOT allowed to break this!
*/
void
random_yarrow_read(uint8_t *buf, u_int bytecount)
{
u_int blockcount, i;
KASSERT((bytecount % RANDOM_BLOCKSIZE) == 0, ("%s(): bytecount (= %d) must be a multiple of %d", __func__, bytecount, RANDOM_BLOCKSIZE ));
RANDOM_RESEED_LOCK();
blockcount = howmany(bytecount, RANDOM_BLOCKSIZE);
for (i = 0; i < blockcount; i++) {
if (yarrow_state.ys_outputblocks++ >= yarrow_state.ys_gengateinterval) {
random_yarrow_generator_gate();
yarrow_state.ys_outputblocks = 0;
}
uint128_increment(&yarrow_state.ys_counter);
randomdev_encrypt(&yarrow_state.ys_key, &yarrow_state.ys_counter, buf, RANDOM_BLOCKSIZE);
buf += RANDOM_BLOCKSIZE;
}
RANDOM_RESEED_UNLOCK();
}
bool
random_yarrow_seeded(void)
{
return (yarrow_state.ys_seeded);
}

View File

@ -1,47 +0,0 @@
/*-
* Copyright (c) 2000-2015 Mark R V Murray
* 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
* in this position and unchanged.
* 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 ``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$
*/
#ifndef SYS_DEV_RANDOM_YARROW_H_INCLUDED
#define SYS_DEV_RANDOM_YARROW_H_INCLUDED
#ifdef _KERNEL
typedef struct mtx mtx_t;
#define RANDOM_RESEED_INIT_LOCK(x) mtx_init(&yarrow_state.ys_mtx, "reseed mutex", NULL, MTX_DEF)
#define RANDOM_RESEED_DEINIT_LOCK(x) mtx_destroy(&yarrow_state.ys_mtx)
#define RANDOM_RESEED_LOCK(x) mtx_lock(&yarrow_state.ys_mtx)
#define RANDOM_RESEED_UNLOCK(x) mtx_unlock(&yarrow_state.ys_mtx)
#define RANDOM_RESEED_ASSERT_LOCK_OWNED(x) mtx_assert(&yarrow_state.ys_mtx, MA_OWNED)
#else
#define RANDOM_RESEED_INIT_LOCK(x) mtx_init(&yarrow_state.ys_mtx, mtx_plain)
#define RANDOM_RESEED_DEINIT_LOCK(x) mtx_destroy(&yarrow_state.ys_mtx)
#define RANDOM_RESEED_LOCK(x) mtx_lock(&yarrow_state.ys_mtx)
#define RANDOM_RESEED_UNLOCK(x) mtx_unlock(&yarrow_state.ys_mtx)
#define RANDOM_RESEED_ASSERT_LOCK_OWNED(x)
#endif
#endif /* SYS_DEV_RANDOM_YARROW_H_INCLUDED */

View File

@ -149,7 +149,7 @@ rndtest_harvest(struct rndtest_state *rsp, void *buf, u_int len)
rndstats.rst_discard += len;
else
/* MarkM: FIX!! Check that this does not swamp the harvester! */
random_harvest_queue(buf, len, len*NBBY/2, RANDOM_PURE_RNDTEST);
random_harvest_queue(buf, len, RANDOM_PURE_RNDTEST);
}
static void

View File

@ -212,7 +212,7 @@ static void
default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
{
/* MarkM: FIX!! Check that this does not swamp the harvester! */
random_harvest_queue(buf, count, count*NBBY/2, RANDOM_PURE_SAFE);
random_harvest_queue(buf, count, RANDOM_PURE_SAFE);
}
#endif /* SAFE_NO_RNG */

View File

@ -353,7 +353,7 @@ static devclass_t sdhci_fdt_devclass;
DRIVER_MODULE(sdhci_fdt, simplebus, sdhci_fdt_driver, sdhci_fdt_devclass,
NULL, NULL);
#ifndef MMCCAM
MODULE_DEPEND(sdhci_fdt, sdhci, 1, 1, 1);
#ifndef MMCCAM
MMC_DECLARE_BRIDGE(sdhci_fdt);
#endif

View File

@ -61,6 +61,8 @@ __FBSDID("$FreeBSD$");
#include "mmcbr_if.h"
#include "sdhci_if.h"
#include "opt_mmccam.h"
#define MAX_SLOTS 6
static struct ofw_compat_data compat_data[] = {
@ -542,5 +544,8 @@ static devclass_t sdhci_xenon_devclass;
DRIVER_MODULE(sdhci_xenon, simplebus, sdhci_xenon_driver, sdhci_xenon_devclass,
NULL, NULL);
MODULE_DEPEND(sdhci_xenon, sdhci, 1, 1, 1);
#ifndef MMCCAM
MMC_DECLARE_BRIDGE(sdhci_xenon);
#endif

View File

@ -669,7 +669,7 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
mouse = (mouse_info_t*)data;
random_harvest_queue(mouse, sizeof(mouse_info_t), 2, RANDOM_MOUSE);
random_harvest_queue(mouse, sizeof(mouse_info_t), RANDOM_MOUSE);
if (cmd == OLD_CONS_MOUSECTL) {
static u_char swapb[] = { 0, 4, 2, 6, 1, 5, 3, 7 };

View File

@ -3734,7 +3734,7 @@ scgetc(sc_softc_t *sc, u_int flags, struct sc_cnstate *sp)
sc_touch_scrn_saver();
if (!(flags & SCGETC_CN))
random_harvest_queue(&c, sizeof(c), 1, RANDOM_KEYBOARD);
random_harvest_queue(&c, sizeof(c), RANDOM_KEYBOARD);
if (sc->kbd_open_level == 0 && scp->kbd_mode != K_XLATE)
return KEYCHAR(c);

View File

@ -260,7 +260,7 @@ static void
default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
{
/* MarkM: FIX!! Check that this does not swamp the harvester! */
random_harvest_queue(buf, count, count*NBBY/2, RANDOM_PURE_UBSEC);
random_harvest_queue(buf, count, RANDOM_PURE_UBSEC);
}
static int

View File

@ -217,8 +217,7 @@ vtrnd_harvest(struct vtrnd_softc *sc)
virtqueue_notify(vq);
virtqueue_poll(vq, NULL);
random_harvest_queue(&value, sizeof(value), sizeof(value) * NBBY / 2,
RANDOM_PURE_VIRTIO);
random_harvest_queue(&value, sizeof(value), RANDOM_PURE_VIRTIO);
}
static void

Some files were not shown because too many files have changed in this diff Show More