MFhead@r324837

While here, diff reduce some of the changes in sys/boot by moving
MK_COVERAGE=no to sys/boot/Makefile.inc .
This commit is contained in:
Enji Cooper 2017-10-21 23:40:52 +00:00
commit 0a8f81bc28
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/runtime-coverage/; revision=324839
1009 changed files with 24913 additions and 9980 deletions

View file

@ -38,7 +38,20 @@
# xargs -n1 | sort | uniq -d;
# done
# 20161010: Remove libstand
# 20171017: Removal of mbpool(9)
OLD_FILES+=usr/include/sys/mbpool.h
OLD_FILES+=usr/share/man/man9/mbpool.9.gz
OLD_FILES+=usr/share/man/man9/mbp_destroy.9.gz
OLD_FILES+=usr/share/man/man9/mbp_alloc.9.gz
OLD_FILES+=usr/share/man/man9/mbp_ext_free.9.gz
OLD_FILES+=usr/share/man/man9/mbp_count.9.gz
OLD_FILES+=usr/share/man/man9/mbp_card_free.9.gz
OLD_FILES+=usr/share/man/man9/mbp_get_keep.9.gz
OLD_FILES+=usr/share/man/man9/mbp_free.9.gz
OLD_FILES+=usr/share/man/man9/mbp_get.9.gz
OLD_FILES+=usr/share/man/man9/mbp_create.9.gz
OLD_FILES+=usr/share/man/man9/mbp_sync.9.gz
# 20171010: Remove libstand
OLD_FILES+=usr/lib/libstand.a
OLD_FILES+=usr/lib/libstand_p.a
OLD_FILES+=usr/include/stand.h

View file

@ -42,6 +42,7 @@
* using our derived config, and record the results.
*/
#include <aio.h>
#include <ctype.h>
#include <devid.h>
#include <dirent.h>
@ -919,13 +920,17 @@ zpool_read_label(int fd, nvlist_t **config)
* Given a file descriptor, read the label information and return an nvlist
* describing the configuration, if there is one.
* returns the number of valid labels found
* If a label is found, returns it via config. The caller is responsible for
* freeing it.
*/
int
zpool_read_all_labels(int fd, nvlist_t **config)
{
struct stat64 statbuf;
struct aiocb aiocbs[VDEV_LABELS];
struct aiocb *aiocbps[VDEV_LABELS];
int l;
vdev_label_t *label;
vdev_label_t *labels;
uint64_t state, txg, size;
int nlabels = 0;
@ -935,19 +940,39 @@ zpool_read_all_labels(int fd, nvlist_t **config)
return (0);
size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);
if ((label = malloc(sizeof (vdev_label_t))) == NULL)
if ((labels = calloc(VDEV_LABELS, sizeof (vdev_label_t))) == NULL)
return (0);
memset(aiocbs, 0, sizeof(aiocbs));
for (l = 0; l < VDEV_LABELS; l++) {
aiocbs[l].aio_fildes = fd;
aiocbs[l].aio_offset = label_offset(size, l);
aiocbs[l].aio_buf = &labels[l];
aiocbs[l].aio_nbytes = sizeof(vdev_label_t);
aiocbs[l].aio_lio_opcode = LIO_READ;
aiocbps[l] = &aiocbs[l];
}
if (lio_listio(LIO_WAIT, aiocbps, VDEV_LABELS, NULL) != 0) {
if (errno == EAGAIN || errno == EINTR || errno == EIO) {
for (l = 0; l < VDEV_LABELS; l++) {
errno = 0;
int r = aio_error(&aiocbs[l]);
if (r != EINVAL)
(void)aio_return(&aiocbs[l]);
}
}
return (0);
}
for (l = 0; l < VDEV_LABELS; l++) {
nvlist_t *temp = NULL;
/* TODO: use aio_read so we can read al 4 labels in parallel */
if (pread64(fd, label, sizeof (vdev_label_t),
label_offset(size, l)) != sizeof (vdev_label_t))
if (aio_return(&aiocbs[l]) != sizeof(vdev_label_t))
continue;
if (nvlist_unpack(label->vl_vdev_phys.vp_nvlist,
sizeof (label->vl_vdev_phys.vp_nvlist), &temp, 0) != 0)
if (nvlist_unpack(labels[l].vl_vdev_phys.vp_nvlist,
sizeof (labels[l].vl_vdev_phys.vp_nvlist), &temp, 0) != 0)
continue;
if (nvlist_lookup_uint64(temp, ZPOOL_CONFIG_POOL_STATE,
@ -970,7 +995,7 @@ zpool_read_all_labels(int fd, nvlist_t **config)
nlabels++;
}
free(label);
free(labels);
return (nlabels);
}

View file

@ -1344,7 +1344,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
val = read_value (abfd, buf, per_width,
get_DW_EH_PE_signed (per_encoding));
val += ent->offset - ent->new_offset;
val += (bfd_vma)ent->offset - ent->new_offset;
val -= extra_string + extra_data;
write_value (abfd, buf, val, per_width);
action &= ~4;
@ -1400,7 +1400,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
}
break;
case DW_EH_PE_pcrel:
value += ent->offset - ent->new_offset;
value += (bfd_vma)ent->offset - ent->new_offset;
address += sec->output_section->vma + ent->offset + 8;
break;
}
@ -1428,7 +1428,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
if (value)
{
if ((ent->lsda_encoding & 0xf0) == DW_EH_PE_pcrel)
value += ent->offset - ent->new_offset;
value += (bfd_vma)ent->offset - ent->new_offset;
else if (ent->cie_inf->need_lsda_relative)
value -= (sec->output_section->vma + ent->new_offset + 8
+ ent->lsda_offset);

View file

@ -940,6 +940,12 @@ bool AArch64InstrInfo::areMemAccessesTriviallyDisjoint(
bool AArch64InstrInfo::analyzeCompare(const MachineInstr &MI, unsigned &SrcReg,
unsigned &SrcReg2, int &CmpMask,
int &CmpValue) const {
// The first operand can be a frame index where we'd normally expect a
// register.
assert(MI.getNumOperands() >= 2 && "All AArch64 cmps should have 2 operands");
if (!MI.getOperand(1).isReg())
return false;
switch (MI.getOpcode()) {
default:
break;

View file

@ -167,6 +167,9 @@ AArch64RedundantCopyElimination::knownRegValInBlock(
// CMP is an alias for SUBS with a dead destination register.
case AArch64::SUBSWri:
case AArch64::SUBSXri: {
// Sometimes the first operand is a FrameIndex. Bail if tht happens.
if (!PredI.getOperand(1).isReg())
return None;
MCPhysReg SrcReg = PredI.getOperand(1).getReg();
// Must not be a symbolic immediate.

View file

@ -528,4 +528,5 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_riscv6jumptoEv)
#endif
.section .note.GNU-stack,"",@progbits
NO_EXEC_STACK_DIRECTIVE

View file

@ -470,4 +470,5 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
#endif
.section .note.GNU-stack,"",@progbits
NO_EXEC_STACK_DIRECTIVE

View file

@ -35,19 +35,34 @@
#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
#if defined(__APPLE__)
#define SYMBOL_IS_FUNC(name)
#define NO_EXEC_STACK_DIRECTIVE
#elif defined(__ELF__)
#if defined(__arm__)
#define SYMBOL_IS_FUNC(name) .type name,%function
#else
#define SYMBOL_IS_FUNC(name) .type name,@function
#endif
#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__)
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
#else
#define NO_EXEC_STACK_DIRECTIVE
#endif
#else
#define SYMBOL_IS_FUNC(name) \
.def name SEPARATOR \
.scl 2 SEPARATOR \
.type 32 SEPARATOR \
.endef
#define NO_EXEC_STACK_DIRECTIVE
#endif
#define DEFINE_LIBUNWIND_FUNCTION(name) \

View file

@ -1893,6 +1893,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2)
}
static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm)
{
if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
wpa_printf(MSG_ERROR,
"WPA: Failed to get random data for ANonce");
sm->Disconnect = TRUE;
return -1;
}
wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce,
WPA_NONCE_LEN);
sm->TimeoutCtr = 0;
return 0;
}
SM_STATE(WPA_PTK, INITPMK)
{
u8 msk[2 * PMK_LEN];
@ -2414,9 +2429,12 @@ SM_STEP(WPA_PTK)
SM_ENTER(WPA_PTK, AUTHENTICATION);
else if (sm->ReAuthenticationRequest)
SM_ENTER(WPA_PTK, AUTHENTICATION2);
else if (sm->PTKRequest)
SM_ENTER(WPA_PTK, PTKSTART);
else switch (sm->wpa_ptk_state) {
else if (sm->PTKRequest) {
if (wpa_auth_sm_ptk_update(sm) < 0)
SM_ENTER(WPA_PTK, DISCONNECTED);
else
SM_ENTER(WPA_PTK, PTKSTART);
} else switch (sm->wpa_ptk_state) {
case WPA_PTK_INITIALIZE:
break;
case WPA_PTK_DISCONNECT:
@ -3209,6 +3227,14 @@ int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm)
}
int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm)
{
if (!sm || !wpa_key_mgmt_ft(sm->wpa_key_mgmt))
return 0;
return sm->tk_already_set;
}
int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
struct rsn_pmksa_cache_entry *entry)
{

View file

@ -271,6 +271,7 @@ int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
int wpa_auth_get_pairwise(struct wpa_state_machine *sm);
int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm);
int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
struct rsn_pmksa_cache_entry *entry);
struct rsn_pmksa_cache_entry *

View file

@ -780,6 +780,14 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm)
return;
}
if (sm->tk_already_set) {
/* Must avoid TK reconfiguration to prevent clearing of TX/RX
* PN in the driver */
wpa_printf(MSG_DEBUG,
"FT: Do not re-install same PTK to the driver");
return;
}
/* FIX: add STA entry to kernel/driver here? The set_key will fail
* most likely without this.. At the moment, STA entry is added only
* after association has been completed. This function will be called
@ -792,6 +800,7 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm)
/* FIX: MLME-SetProtection.Request(TA, Tx_Rx) */
sm->pairwise_set = TRUE;
sm->tk_already_set = TRUE;
}
@ -898,6 +907,7 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm,
sm->pairwise = pairwise;
sm->PTK_valid = TRUE;
sm->tk_already_set = FALSE;
wpa_ft_install_ptk(sm);
buflen = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) +

View file

@ -64,6 +64,7 @@ struct wpa_state_machine {
struct wpa_ptk PTK;
Boolean PTK_valid;
Boolean pairwise_set;
Boolean tk_already_set;
int keycount;
Boolean Pair;
struct wpa_key_replay_counter {

View file

@ -213,8 +213,20 @@ struct wpa_ptk {
size_t kck_len;
size_t kek_len;
size_t tk_len;
int installed; /* 1 if key has already been installed to driver */
};
struct wpa_gtk {
u8 gtk[WPA_GTK_MAX_LEN];
size_t gtk_len;
};
#ifdef CONFIG_IEEE80211W
struct wpa_igtk {
u8 igtk[WPA_IGTK_MAX_LEN];
size_t igtk_len;
};
#endif /* CONFIG_IEEE80211W */
/* WPA IE version 1
* 00-50-f2:1 (OUI:OUI type)

View file

@ -112,6 +112,7 @@ struct wpa_tdls_peer {
u8 tk[16]; /* TPK-TK; assuming only CCMP will be used */
} tpk;
int tpk_set;
int tk_set; /* TPK-TK configured to the driver */
int tpk_success;
int tpk_in_progress;
@ -192,6 +193,20 @@ static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
u8 rsc[6];
enum wpa_alg alg;
if (peer->tk_set) {
/*
* This same TPK-TK has already been configured to the driver
* and this new configuration attempt (likely due to an
* unexpected retransmitted frame) would result in clearing
* the TX/RX sequence number which can break security, so must
* not allow that to happen.
*/
wpa_printf(MSG_INFO, "TDLS: TPK-TK for the peer " MACSTR
" has already been configured to the driver - do not reconfigure",
MAC2STR(peer->addr));
return -1;
}
os_memset(rsc, 0, 6);
switch (peer->cipher) {
@ -209,12 +224,15 @@ static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
return -1;
}
wpa_printf(MSG_DEBUG, "TDLS: Configure pairwise key for peer " MACSTR,
MAC2STR(peer->addr));
if (wpa_sm_set_key(sm, alg, peer->addr, -1, 1,
rsc, sizeof(rsc), peer->tpk.tk, key_len) < 0) {
wpa_printf(MSG_WARNING, "TDLS: Failed to set TPK to the "
"driver");
return -1;
}
peer->tk_set = 1;
return 0;
}
@ -690,7 +708,7 @@ static void wpa_tdls_peer_clear(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
peer->cipher = 0;
peer->qos_info = 0;
peer->wmm_capable = 0;
peer->tpk_set = peer->tpk_success = 0;
peer->tk_set = peer->tpk_set = peer->tpk_success = 0;
peer->chan_switch_enabled = 0;
os_memset(&peer->tpk, 0, sizeof(peer->tpk));
os_memset(peer->inonce, 0, WPA_NONCE_LEN);
@ -1153,6 +1171,7 @@ static int wpa_tdls_send_tpk_m1(struct wpa_sm *sm,
wpa_tdls_peer_free(sm, peer);
return -1;
}
peer->tk_set = 0; /* A new nonce results in a new TK */
wpa_hexdump(MSG_DEBUG, "TDLS: Initiator Nonce for TPK handshake",
peer->inonce, WPA_NONCE_LEN);
os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
@ -1745,6 +1764,19 @@ static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
}
static int tdls_nonce_set(const u8 *nonce)
{
int i;
for (i = 0; i < WPA_NONCE_LEN; i++) {
if (nonce[i])
return 1;
}
return 0;
}
static int wpa_tdls_process_tpk_m1(struct wpa_sm *sm, const u8 *src_addr,
const u8 *buf, size_t len)
{
@ -1998,7 +2030,8 @@ static int wpa_tdls_process_tpk_m1(struct wpa_sm *sm, const u8 *src_addr,
peer->rsnie_i_len = kde.rsn_ie_len;
peer->cipher = cipher;
if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0 ||
!tdls_nonce_set(peer->inonce)) {
/*
* There is no point in updating the RNonce for every obtained
* TPK M1 frame (e.g., retransmission due to timeout) with the
@ -2014,6 +2047,7 @@ static int wpa_tdls_process_tpk_m1(struct wpa_sm *sm, const u8 *src_addr,
"TDLS: Failed to get random data for responder nonce");
goto error;
}
peer->tk_set = 0; /* A new nonce results in a new TK */
}
#if 0
@ -2170,6 +2204,14 @@ static int wpa_tdls_process_tpk_m2(struct wpa_sm *sm, const u8 *src_addr,
"ignore TPK M2 from " MACSTR, MAC2STR(src_addr));
return -1;
}
if (peer->tpk_success) {
wpa_printf(MSG_INFO, "TDLS: Ignore incoming TPK M2 retry, from "
MACSTR " as TPK M3 was already sent",
MAC2STR(src_addr));
return 0;
}
wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST);
if (len < 3 + 2 + 1) {

View file

@ -605,6 +605,12 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
const u8 *key_rsc;
u8 null_rsc[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
if (sm->ptk.installed) {
wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
"WPA: Do not re-install same PTK to the driver");
return 0;
}
wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
"WPA: Installing PTK to the driver");
@ -643,6 +649,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
/* TK is not needed anymore in supplicant */
os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN);
sm->ptk.installed = 1;
if (sm->wpa_ptk_rekey) {
eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL);
@ -692,11 +699,23 @@ struct wpa_gtk_data {
static int wpa_supplicant_install_gtk(struct wpa_sm *sm,
const struct wpa_gtk_data *gd,
const u8 *key_rsc)
const u8 *key_rsc, int wnm_sleep)
{
const u8 *_gtk = gd->gtk;
u8 gtk_buf[32];
/* Detect possible key reinstallation */
if ((sm->gtk.gtk_len == (size_t) gd->gtk_len &&
os_memcmp(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len) == 0) ||
(sm->gtk_wnm_sleep.gtk_len == (size_t) gd->gtk_len &&
os_memcmp(sm->gtk_wnm_sleep.gtk, gd->gtk,
sm->gtk_wnm_sleep.gtk_len) == 0)) {
wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
"WPA: Not reinstalling already in-use GTK to the driver (keyidx=%d tx=%d len=%d)",
gd->keyidx, gd->tx, gd->gtk_len);
return 0;
}
wpa_hexdump_key(MSG_DEBUG, "WPA: Group Key", gd->gtk, gd->gtk_len);
wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
"WPA: Installing GTK to the driver (keyidx=%d tx=%d len=%d)",
@ -731,6 +750,15 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *sm,
}
os_memset(gtk_buf, 0, sizeof(gtk_buf));
if (wnm_sleep) {
sm->gtk_wnm_sleep.gtk_len = gd->gtk_len;
os_memcpy(sm->gtk_wnm_sleep.gtk, gd->gtk,
sm->gtk_wnm_sleep.gtk_len);
} else {
sm->gtk.gtk_len = gd->gtk_len;
os_memcpy(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len);
}
return 0;
}
@ -788,7 +816,7 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm,
(wpa_supplicant_check_group_cipher(sm, sm->group_cipher,
gtk_len, gtk_len,
&gd.key_rsc_len, &gd.alg) ||
wpa_supplicant_install_gtk(sm, &gd, key->key_rsc))) {
wpa_supplicant_install_gtk(sm, &gd, key->key_rsc, 0))) {
wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
"RSN: Failed to install GTK");
os_memset(&gd, 0, sizeof(gd));
@ -802,6 +830,58 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm,
}
#ifdef CONFIG_IEEE80211W
static int wpa_supplicant_install_igtk(struct wpa_sm *sm,
const struct wpa_igtk_kde *igtk,
int wnm_sleep)
{
size_t len = wpa_cipher_key_len(sm->mgmt_group_cipher);
u16 keyidx = WPA_GET_LE16(igtk->keyid);
/* Detect possible key reinstallation */
if ((sm->igtk.igtk_len == len &&
os_memcmp(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len) == 0) ||
(sm->igtk_wnm_sleep.igtk_len == len &&
os_memcmp(sm->igtk_wnm_sleep.igtk, igtk->igtk,
sm->igtk_wnm_sleep.igtk_len) == 0)) {
wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
"WPA: Not reinstalling already in-use IGTK to the driver (keyidx=%d)",
keyidx);
return 0;
}
wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
"WPA: IGTK keyid %d pn %02x%02x%02x%02x%02x%02x",
keyidx, MAC2STR(igtk->pn));
wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", igtk->igtk, len);
if (keyidx > 4095) {
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
"WPA: Invalid IGTK KeyID %d", keyidx);
return -1;
}
if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher),
broadcast_ether_addr,
keyidx, 0, igtk->pn, sizeof(igtk->pn),
igtk->igtk, len) < 0) {
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
"WPA: Failed to configure IGTK to the driver");
return -1;
}
if (wnm_sleep) {
sm->igtk_wnm_sleep.igtk_len = len;
os_memcpy(sm->igtk_wnm_sleep.igtk, igtk->igtk,
sm->igtk_wnm_sleep.igtk_len);
} else {
sm->igtk.igtk_len = len;
os_memcpy(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len);
}
return 0;
}
#endif /* CONFIG_IEEE80211W */
static int ieee80211w_set_keys(struct wpa_sm *sm,
struct wpa_eapol_ie_parse *ie)
{
@ -812,30 +892,14 @@ static int ieee80211w_set_keys(struct wpa_sm *sm,
if (ie->igtk) {
size_t len;
const struct wpa_igtk_kde *igtk;
u16 keyidx;
len = wpa_cipher_key_len(sm->mgmt_group_cipher);
if (ie->igtk_len != WPA_IGTK_KDE_PREFIX_LEN + len)
return -1;
igtk = (const struct wpa_igtk_kde *) ie->igtk;
keyidx = WPA_GET_LE16(igtk->keyid);
wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: IGTK keyid %d "
"pn %02x%02x%02x%02x%02x%02x",
keyidx, MAC2STR(igtk->pn));
wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK",
igtk->igtk, len);
if (keyidx > 4095) {
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
"WPA: Invalid IGTK KeyID %d", keyidx);
if (wpa_supplicant_install_igtk(sm, igtk, 0) < 0)
return -1;
}
if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher),
broadcast_ether_addr,
keyidx, 0, igtk->pn, sizeof(igtk->pn),
igtk->igtk, len) < 0) {
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
"WPA: Failed to configure IGTK to the driver");
return -1;
}
}
return 0;
@ -1483,7 +1547,7 @@ static void wpa_supplicant_process_1_of_2(struct wpa_sm *sm,
if (ret)
goto failed;
if (wpa_supplicant_install_gtk(sm, &gd, key->key_rsc) ||
if (wpa_supplicant_install_gtk(sm, &gd, key->key_rsc, 0) ||
wpa_supplicant_send_2_of_2(sm, key, ver, key_info))
goto failed;
os_memset(&gd, 0, sizeof(gd));
@ -2251,7 +2315,7 @@ void wpa_sm_deinit(struct wpa_sm *sm)
*/
void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
{
int clear_ptk = 1;
int clear_keys = 1;
if (sm == NULL)
return;
@ -2277,11 +2341,11 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
/* Prepare for the next transition */
wpa_ft_prepare_auth_request(sm, NULL);
clear_ptk = 0;
clear_keys = 0;
}
#endif /* CONFIG_IEEE80211R */
if (clear_ptk) {
if (clear_keys) {
/*
* IEEE 802.11, 8.4.10: Delete PTK SA on (re)association if
* this is not part of a Fast BSS Transition.
@ -2291,6 +2355,12 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
os_memset(&sm->ptk, 0, sizeof(sm->ptk));
sm->tptk_set = 0;
os_memset(&sm->tptk, 0, sizeof(sm->tptk));
os_memset(&sm->gtk, 0, sizeof(sm->gtk));
os_memset(&sm->gtk_wnm_sleep, 0, sizeof(sm->gtk_wnm_sleep));
#ifdef CONFIG_IEEE80211W
os_memset(&sm->igtk, 0, sizeof(sm->igtk));
os_memset(&sm->igtk_wnm_sleep, 0, sizeof(sm->igtk_wnm_sleep));
#endif /* CONFIG_IEEE80211W */
}
#ifdef CONFIG_TDLS
@ -2322,6 +2392,9 @@ void wpa_sm_notify_disassoc(struct wpa_sm *sm)
#ifdef CONFIG_TDLS
wpa_tdls_disassoc(sm);
#endif /* CONFIG_TDLS */
#ifdef CONFIG_IEEE80211R
sm->ft_reassoc_completed = 0;
#endif /* CONFIG_IEEE80211R */
/* Keys are not needed in the WPA state machine anymore */
wpa_sm_drop_sa(sm);
@ -2807,6 +2880,12 @@ void wpa_sm_drop_sa(struct wpa_sm *sm)
os_memset(sm->pmk, 0, sizeof(sm->pmk));
os_memset(&sm->ptk, 0, sizeof(sm->ptk));
os_memset(&sm->tptk, 0, sizeof(sm->tptk));
os_memset(&sm->gtk, 0, sizeof(sm->gtk));
os_memset(&sm->gtk_wnm_sleep, 0, sizeof(sm->gtk_wnm_sleep));
#ifdef CONFIG_IEEE80211W
os_memset(&sm->igtk, 0, sizeof(sm->igtk));
os_memset(&sm->igtk_wnm_sleep, 0, sizeof(sm->igtk_wnm_sleep));
#endif /* CONFIG_IEEE80211W */
#ifdef CONFIG_IEEE80211R
os_memset(sm->xxkey, 0, sizeof(sm->xxkey));
os_memset(sm->pmk_r0, 0, sizeof(sm->pmk_r0));
@ -2870,7 +2949,7 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf)
wpa_hexdump_key(MSG_DEBUG, "Install GTK (WNM SLEEP)",
gd.gtk, gd.gtk_len);
if (wpa_supplicant_install_gtk(sm, &gd, key_rsc)) {
if (wpa_supplicant_install_gtk(sm, &gd, key_rsc, 1)) {
os_memset(&gd, 0, sizeof(gd));
wpa_printf(MSG_DEBUG, "Failed to install the GTK in "
"WNM mode");
@ -2879,29 +2958,11 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf)
os_memset(&gd, 0, sizeof(gd));
#ifdef CONFIG_IEEE80211W
} else if (subelem_id == WNM_SLEEP_SUBELEM_IGTK) {
struct wpa_igtk_kde igd;
u16 keyidx;
const struct wpa_igtk_kde *igtk;
os_memset(&igd, 0, sizeof(igd));
keylen = wpa_cipher_key_len(sm->mgmt_group_cipher);
os_memcpy(igd.keyid, buf + 2, 2);
os_memcpy(igd.pn, buf + 4, 6);
keyidx = WPA_GET_LE16(igd.keyid);
os_memcpy(igd.igtk, buf + 10, keylen);
wpa_hexdump_key(MSG_DEBUG, "Install IGTK (WNM SLEEP)",
igd.igtk, keylen);
if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher),
broadcast_ether_addr,
keyidx, 0, igd.pn, sizeof(igd.pn),
igd.igtk, keylen) < 0) {
wpa_printf(MSG_DEBUG, "Failed to install the IGTK in "
"WNM mode");
os_memset(&igd, 0, sizeof(igd));
igtk = (const struct wpa_igtk_kde *) (buf + 2);
if (wpa_supplicant_install_igtk(sm, igtk, 1) < 0)
return -1;
}
os_memset(&igd, 0, sizeof(igd));
#endif /* CONFIG_IEEE80211W */
} else {
wpa_printf(MSG_DEBUG, "Unknown element id");

View file

@ -153,6 +153,7 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
u16 capab;
sm->ft_completed = 0;
sm->ft_reassoc_completed = 0;
buf_len = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) +
2 + sm->r0kh_id_len + ric_ies_len + 100;
@ -681,6 +682,11 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
return -1;
}
if (sm->ft_reassoc_completed) {
wpa_printf(MSG_DEBUG, "FT: Reassociation has already been completed for this FT protocol instance - ignore unexpected retransmission");
return 0;
}
if (wpa_ft_parse_ies(ies, ies_len, &parse) < 0) {
wpa_printf(MSG_DEBUG, "FT: Failed to parse IEs");
return -1;
@ -781,6 +787,8 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
return -1;
}
sm->ft_reassoc_completed = 1;
if (wpa_ft_process_gtk_subelem(sm, parse.gtk, parse.gtk_len) < 0)
return -1;

View file

@ -30,6 +30,12 @@ struct wpa_sm {
u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
int rx_replay_counter_set;
u8 request_counter[WPA_REPLAY_COUNTER_LEN];
struct wpa_gtk gtk;
struct wpa_gtk gtk_wnm_sleep;
#ifdef CONFIG_IEEE80211W
struct wpa_igtk igtk;
struct wpa_igtk igtk_wnm_sleep;
#endif /* CONFIG_IEEE80211W */
struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
@ -121,6 +127,7 @@ struct wpa_sm {
size_t r0kh_id_len;
u8 r1kh_id[FT_R1KH_ID_LEN];
int ft_completed;
int ft_reassoc_completed;
int over_the_ds_in_progress;
u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */
int set_ptk_after_assoc;

View file

@ -6891,6 +6891,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
}
eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
wpa_s->wnmsleep_used = 0;
}

View file

@ -303,6 +303,7 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
wpa_s->key_mgmt = 0;
wpas_rrm_reset(wpa_s);
wpa_s->wnmsleep_used = 0;
}

View file

@ -137,6 +137,8 @@ int ieee802_11_send_wnmsleep_req(struct wpa_supplicant *wpa_s,
if (res < 0)
wpa_printf(MSG_DEBUG, "Failed to send WNM-Sleep Request "
"(action=%d, intval=%d)", action, intval);
else
wpa_s->wnmsleep_used = 1;
os_free(wnmsleep_ie);
os_free(wnmtfs_ie);
@ -187,6 +189,12 @@ static void wnm_sleep_mode_exit_success(struct wpa_supplicant *wpa_s,
end = ptr + key_len_total;
wpa_hexdump_key(MSG_DEBUG, "WNM: Key Data", ptr, key_len_total);
if (key_len_total && !wpa_sm_pmf_enabled(wpa_s->wpa)) {
wpa_msg(wpa_s, MSG_INFO,
"WNM: Ignore Key Data in WNM-Sleep Mode Response - PMF not enabled");
return;
}
while (ptr + 1 < end) {
if (ptr + 2 + ptr[1] > end) {
wpa_printf(MSG_DEBUG, "WNM: Invalid Key Data element "
@ -247,6 +255,12 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s,
u8 *tfsresp_ie_end = NULL;
size_t left;
if (!wpa_s->wnmsleep_used) {
wpa_printf(MSG_DEBUG,
"WNM: Ignore WNM-Sleep Mode Response frame since WNM-Sleep Mode operation has not been requested");
return;
}
if (len < 3)
return;
key_len_total = WPA_GET_LE16(frm + 1);
@ -282,6 +296,8 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s,
return;
}
wpa_s->wnmsleep_used = 0;
if (wnmsleep_ie->status == WNM_STATUS_SLEEP_ACCEPT ||
wnmsleep_ie->status == WNM_STATUS_SLEEP_EXIT_ACCEPT_GTK_UPDATE) {
wpa_printf(MSG_DEBUG, "Successfully recv WNM-Sleep Response "

View file

@ -658,6 +658,7 @@ struct wpa_supplicant {
unsigned int reattach:1; /* reassociation to the same BSS requested */
unsigned int mac_addr_changed:1;
unsigned int added_vif:1;
unsigned int wnmsleep_used:1;
struct os_reltime last_mac_addr_change;
int last_mac_addr_style;

View file

@ -212,9 +212,6 @@ distribution:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
snmpd.config ${DESTDIR}/etc;
.endif
.if ${MK_AT} == "no"
sed -i "" -e 's;.*/usr/libexec/atrun;#&;' ${DESTDIR}/etc/crontab
.endif
.if ${MK_TCSH} == "no"
sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
.endif

View file

@ -4741,6 +4741,14 @@ nomatch 32 {
action "kldload -n if_axe";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x17ef";
match "product" "0x7205";
action "kldload -n if_ure";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -5097,7 +5105,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x2001";
match "product" "(0x7d02|0x7e12|0xa707|0xa805)";
match "product" "(0x7d02|0x7e12|0x7e35|0xa707|0xa805|0xab00)";
action "kldload -n u3g";
};
@ -5905,5 +5913,5 @@ nomatch 32 {
action "kldload -n umass";
};
# 2754 USB entries processed
# 2757 USB entries processed

View file

@ -13,9 +13,11 @@ fi
case "$daily_ntpd_leapfile_enable" in
[Yy][Ee][Ss])
anticongestion
service ntpd onefetch
;;
if service ntpd oneneedfetch; then
anticongestion
service ntpd onefetch
fi
;;
esac
exit $rc

View file

@ -15,8 +15,9 @@ desc="Network Time Protocol daemon"
rcvar="ntpd_enable"
command="/usr/sbin/${name}"
pidfile="/var/run/${name}.pid"
extra_commands="fetch"
extra_commands="fetch needfetch"
fetch_cmd="ntpd_fetch_leapfile"
needfetch_cmd="ntpd_needfetch_leapfile"
start_precmd="ntpd_precmd"
load_rc_config $name
@ -90,7 +91,7 @@ ntpd_init_leapfile() {
fi
}
ntpd_fetch_leapfile() {
ntpd_needfetch_leapfile() {
local ntp_tmp_leapfile rc verbose
if checkyesno ntp_leapfile_fetch_verbose; then
@ -122,6 +123,21 @@ ntpd_fetch_leapfile() {
ntp_leap_fetch_date=$((ntp_leap_expiry-ntp_leapfile_expiry_seconds))
if [ $(current_ntp_ts) -ge $ntp_leap_fetch_date ]; then
$verbose Within ntp leapfile expiry limit, initiating fetch
# Return code 0: ntp leapfile fetch needed
return 0
fi
# Return code 1: ntp leapfile fetch not needed
return 1
}
ntpd_fetch_leapfile() {
if checkyesno ntp_leapfile_fetch_verbose; then
verbose=echo
else
verbose=:
fi
if ntpd_needfetch_leapfile ; then
for url in $ntp_leapfile_sources ; do
$verbose fetching $url
fetch $ntp_leapfile_fetch_opts -o $ntp_tmp_leapfile $url && break

View file

@ -930,9 +930,7 @@ run_rc_command()
else
_pidcmd='rc_pid=$(check_process '"$_procname $command_interpreter"')'
fi
if [ -n "$_pidcmd" ]; then
_keywords="${_keywords} status poll"
fi
_keywords="${_keywords} status poll"
fi
if [ -z "$rc_arg" ]; then

View file

@ -70,7 +70,7 @@ typedef __max_align_t max_align_t;
#endif
#endif
#define offsetof(type, member) __offsetof(type, member)
#define offsetof(type, field) __offsetof(type, field)
#if __EXT1_VISIBLE
/* ISO/IEC 9899:2011 K.3.3.2 */

View file

@ -157,10 +157,8 @@ _libclang_rt= libclang_rt
.if ${MK_LIBCPLUSPLUS} != "no"
_libcxxrt= libcxxrt
_libcplusplus= libc++
.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
_libcplusplus+= libc++experimental
.endif
.endif
SUBDIR.${MK_EFI}+= libefivar
SUBDIR.${MK_LIBTHR}+= libthr

View file

@ -5,7 +5,7 @@ SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \
infinity.c ldexp.c makecontext.c \
__aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c \
arm_initfini.c \
trivial-getcontextx.c
getcontextx.c
.if ${MACHINE_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "")
SRCS+= fpgetmask_vfp.c fpgetround_vfp.c fpgetsticky_vfp.c fpsetmask_vfp.c \

View file

@ -0,0 +1,99 @@
/*
* Copyright (c) 2017 Michal Meloun <mmel@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 ``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$");
#include <sys/types.h>
#include <sys/ucontext.h>
#include <errno.h>
#include <stdlib.h>
#include <machine/sysarch.h>
struct ucontextx {
ucontext_t ucontext;
mcontext_vfp_t mcontext_vfp;
};
int
__getcontextx_size(void)
{
return (sizeof(struct ucontextx));
}
int
__fillcontextx2(char *ctx)
{
struct ucontextx *ucxp;
ucontext_t *ucp;
mcontext_vfp_t *mvp;
struct arm_get_vfpstate_args vfp_arg;
ucxp = (struct ucontextx *)ctx;
ucp = &ucxp->ucontext;
mvp = &ucxp->mcontext_vfp;
vfp_arg.mc_vfp_size = sizeof(mcontext_vfp_t);
vfp_arg.mc_vfp = mvp;
if (sysarch(ARM_GET_VFPSTATE, &vfp_arg) == -1)
return (-1);
ucp->uc_mcontext.mc_vfp_size = sizeof(mcontext_vfp_t);
ucp->uc_mcontext.mc_vfp_ptr = mvp;
return (0);
}
int
__fillcontextx(char *ctx)
{
struct ucontextx *ucxp;
ucxp = (struct ucontextx *)ctx;
if (getcontext(&ucxp->ucontext) == -1)
return (-1);
__fillcontextx2(ctx);
return (0);
}
__weak_reference(__getcontextx, getcontextx);
ucontext_t *
__getcontextx(void)
{
char *ctx;
int error;
ctx = malloc(__getcontextx_size());
if (ctx == NULL)
return (NULL);
if (__fillcontextx(ctx) == -1) {
error = errno;
free(ctx);
errno = error;
return (NULL);
}
return ((ucontext_t *)ctx);
}

View file

@ -398,6 +398,7 @@ FBSD_1.5 {
devname;
devname_r;
dirname;
elf_aux_info;
fts_children;
fts_close;
fts_get_clientptr;

View file

@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <link.h>
#include <pthread.h>
#include <string.h>
#include <sys/auxv.h>
#include "un-namespace.h"
#include "libc_private.h"
@ -65,8 +66,10 @@ __init_elf_aux_vector(void)
static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
static int pagesize, osreldate, canary_len, ncpus, pagesizes_len;
static int hwcap_present, hwcap2_present;
static char *canary, *pagesizes;
static void *timekeep;
static u_long hwcap, hwcap2;
static void
init_aux(void)
@ -83,6 +86,16 @@ init_aux(void)
canary_len = aux->a_un.a_val;
break;
case AT_HWCAP:
hwcap_present = 1;
hwcap = (u_long)(aux->a_un.a_val);
break;
case AT_HWCAP2:
hwcap2_present = 1;
hwcap2 = (u_long)(aux->a_un.a_val);
break;
case AT_PAGESIZES:
pagesizes = (char *)(aux->a_un.a_ptr);
break;
@ -110,6 +123,8 @@ init_aux(void)
}
}
__weak_reference(_elf_aux_info, elf_aux_info);
int
_elf_aux_info(int aux, void *buf, int buflen)
{
@ -130,6 +145,20 @@ _elf_aux_info(int aux, void *buf, int buflen)
} else
res = ENOENT;
break;
case AT_HWCAP:
if (hwcap_present && buflen == sizeof(u_long)) {
*(u_long *)buf = hwcap;
res = 0;
} else
res = ENOENT;
break;
case AT_HWCAP2:
if (hwcap2_present && buflen == sizeof(u_long)) {
*(u_long *)buf = hwcap2;
res = 0;
} else
res = ENOENT;
break;
case AT_PAGESIZES:
if (pagesizes != NULL && pagesizes_len >= buflen) {
memcpy(buf, pagesizes, buflen);
@ -137,7 +166,6 @@ _elf_aux_info(int aux, void *buf, int buflen)
} else
res = ENOENT;
break;
case AT_PAGESZ:
if (buflen == sizeof(int)) {
if (pagesize != 0) {

View file

@ -28,7 +28,7 @@
.\" @(#)open.2 8.2 (Berkeley) 11/16/93
.\" $FreeBSD$
.\"
.Dd January 23, 2014
.Dd October 12, 2017
.Dt POSIX_FALLOCATE 2
.Os
.Sh NAME
@ -118,6 +118,10 @@ argument does not refer to a regular file.
.It Bq Er ENOSPC
There is insufficient free space remaining on the file system storage
media.
.It Bq Er ENOTCAPABLE
The file descriptor
.Fa fd
has insufficient rights.
.It Bq Er ESPIPE
The
.Fa fd

View file

@ -28,7 +28,7 @@
.\" @(#)write.2 8.5 (Berkeley) 4/2/94
.\" $FreeBSD$
.\"
.Dd December 15, 2015
.Dd October 16, 2017
.Dt WRITE 2
.Os
.Sh NAME
@ -199,7 +199,12 @@ to enable writing on the disk label area.
The value
.Fa nbytes
is greater than
.Dv INT_MAX .
.Dv SSIZE_MAX
(or greater than
.Dv INT_MAX ,
if the sysctl
.Va debug.iosize_max_clamp
is non-zero).
.El
.Pp
In addition,

View file

@ -33,6 +33,10 @@ MLINKS+= \
libgeom.3 gctl_issue.3 \
libgeom.3 gctl_free.3 \
libgeom.3 gctl_dump.3 \
libgeom.3 geom_getxml.3 \
libgeom.3 geom_xml2tree.3 \
libgeom.3 geom_gettree.3 \
libgeom.3 geom_deletetree.3 \
libgeom.3 g_close.3 \
libgeom.3 g_delete.3 \
libgeom.3 g_device_path.3 \

View file

@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd April 22, 2017
.Dd October 16, 2017
.Dt LIBGEOM 3
.Os
.Sh NAME
@ -46,6 +46,10 @@
.Nm gctl_issue ,
.Nm gctl_free ,
.Nm gctl_dump ,
.Nm geom_getxml ,
.Nm geom_xml2tree ,
.Nm geom_gettree ,
.Nm geom_deletetree ,
.Nm g_open ,
.Nm g_close ,
.Nm g_mediasize ,
@ -99,6 +103,14 @@
.Ft void
.Fn gctl_dump "struct gctl_req *req" "FILE *f"
.Ss "Utility Functions"
.Ft "char *"
.Fn geom_getxml void
.Ft int
.Fn geom_xml2tree "struct gmesh *gmp" "char *p"
.Ft int
.Fn geom_gettree "struct gmesh *gmp"
.Ft void
.Fn geom_deletetree "struct gmesh *gmp"
.Ft int
.Fn g_open "const char *name" "int dowrite"
.Ft int
@ -279,6 +291,46 @@ on success, or an error message corresponding to the
first error which happened.
.Ss "Utility Functions"
The
.Fn geom_getxml
function is a wrapper around
.Xr sysctl 3
that fetches the
.Ar kern.geom.confxml
OID, and returns it's value.
The allocated memory should be released with
.Xr free 2
after use.
.Pp
The
.Fn geom_xml2tree
function parses the XML representation of a GEOM topology passed as
.Ar p ,
allocates the needed data structures to access this information and fills in
the passed
.Ar gmp
data structure.
Memory allocated during this transformation should be released
using
.Fn geom_deletetree
after use.
.Pp
The
.Fn geom_gettree
function is a wrapper around the
.Fn geom_getxml
and
.Fn geom_xml2tree
functions.
Memory allocated during this operation should be released using
.Fn geom_deletetree
after use.
.Pp
The
.Fn geom_deletetree
function releases memory allocated for storing the data-structures referenced by
.Ar gmp .
.Pp
The
.Fn g_*
functions are used to communicate with GEOM providers.
.Pp

View file

@ -61,9 +61,43 @@
* $FreeBSD$
*/
/*
* Copyright 1996 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
* granted, provided that both the above copyright notice and this
* permission notice appear in all copies, that both the above
* copyright notice and this permission notice appear in all
* supporting documentation, and that the name of M.I.T. not be used
* in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. M.I.T. makes
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
*
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
* SHALL M.I.T. 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/ioctl.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_mib.h>
#include <err.h>
#include <errno.h>
@ -247,6 +281,67 @@ ifconfig_set_name(ifconfig_handle_t *h, const char *name, const char *newname)
return (0);
}
int
ifconfig_get_orig_name(ifconfig_handle_t *h, const char *ifname,
char **orig_name)
{
struct ifmibdata ifmd;
size_t len;
int name[6];
int i, maxifno;
name[0] = CTL_NET;
name[1] = PF_LINK;
name[2] = NETLINK_GENERIC;
name[3] = IFMIB_SYSTEM;
name[4] = IFMIB_IFCOUNT;
len = sizeof maxifno;
if (sysctl(name, 5, &maxifno, &len, 0, 0) < 0) {
h->error.errtype = OTHER;
h->error.errcode = errno;
return (-1);
}
name[3] = IFMIB_IFDATA;
name[5] = IFDATA_GENERAL;
for (i = 1; i <= maxifno; i++) {
len = sizeof ifmd;
name[4] = i;
if (sysctl(name, 6, &ifmd, &len, 0, 0) < 0) {
if (errno == ENOENT)
continue;
goto fail;
}
if (strncmp(ifmd.ifmd_name, ifname, IFNAMSIZ) != 0)
continue;
len = 0;
name[5] = IFDATA_DRIVERNAME;
if (sysctl(name, 6, NULL, &len, 0, 0) < 0)
goto fail;
*orig_name = malloc(len);
if (*orig_name == NULL)
goto fail;
if (sysctl(name, 6, *orig_name, &len, 0, 0) < 0) {
free(*orig_name);
*orig_name = NULL;
goto fail;
}
return (0);
}
fail:
h->error.errtype = OTHER;
h->error.errcode = (i <= maxifno) ? errno : ENOENT;
return (-1);
}
int
ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu)
{

View file

@ -82,6 +82,8 @@ int ifconfig_set_description(ifconfig_handle_t *h, const char *name,
int ifconfig_unset_description(ifconfig_handle_t *h, const char *name);
int ifconfig_set_name(ifconfig_handle_t *h, const char *name,
const char *newname);
int ifconfig_get_orig_name(ifconfig_handle_t *h, const char *ifname,
char **orig_name);
int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu);
int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu);
int ifconfig_set_metric(ifconfig_handle_t *h, const char *name,

View file

@ -1,163 +0,0 @@
# $FreeBSD$
# Originally from $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
#
# Notes:
# - We don't use the libc strerror/sys_errlist because the string table is
# quite large.
#
PACKAGE=lib${LIB}
MK_PROFILE= no
MK_SSP= no
.include <src.opts.mk>
LIBSTAND_SRC?= ${.CURDIR}
LIBSTAND_CPUARCH?=${MACHINE_CPUARCH}
LIBC_SRC= ${LIBSTAND_SRC}/../libc
LIB= stand
NO_PIC=
INCS?= stand.h
MAN?= libstand.3
WARNS?= 0
CFLAGS+= -I${LIBSTAND_SRC}
# standalone components and stuff we have modified locally
SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
sbrk.c twiddle.c zalloc.c zalloc_malloc.c
# private (pruned) versions of libc string functions
SRCS+= strcasecmp.c
.PATH: ${LIBC_SRC}/net
SRCS+= ntoh.c
# string functions from libc
.PATH: ${LIBC_SRC}/string
SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \
memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \
strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
.if ${MACHINE_CPUARCH} == "arm"
.PATH: ${LIBC_SRC}/arm/gen
# Do not generate movt/movw, because the relocation fixup for them does not
# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
# Also, the fpu is not available in a standalone environment.
.if ${COMPILER_VERSION} < 30800
CFLAGS.clang+= -mllvm -arm-use-movt=0
.else
CFLAGS.clang+= -mno-movt
.endif
CFLAGS.clang+= -mfpu=none
# Compiler support functions
.PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/
# __clzsi2 and ctzsi2 for various builtin functions
SRCS+= clzsi2.c ctzsi2.c
# Divide and modulus functions called by the compiler
SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c
SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
.PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/arm/
SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
.endif
.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
.PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen
.endif
.if ${MACHINE_CPUARCH} == "powerpc"
.PATH: ${LIBC_SRC}/quad
SRCS+= ashldi3.c ashrdi3.c
SRCS+= syncicache.c
.endif
# uuid functions from libc
.PATH: ${LIBC_SRC}/uuid
SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
# _setjmp/_longjmp
.PATH: ${LIBSTAND_SRC}/${LIBSTAND_CPUARCH}
SRCS+= _setjmp.S
# decompression functionality from libbz2
# NOTE: to actually test this functionality after libbz2 upgrade compile
# loader(8) with LOADER_BZIP2_SUPPORT defined
.PATH: ${LIBSTAND_SRC}/../../contrib/bzip2
CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
SRCS+= libstand_bzlib_private.h
.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
SRCS+= _${file}
CLEANFILES+= _${file}
_${file}: ${file}
sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \
${.ALLSRC} > ${.TARGET}
.endfor
CLEANFILES+= libstand_bzlib_private.h
libstand_bzlib_private.h: bzlib_private.h
sed -e 's|<stdlib.h>|"stand.h"|' \
${.ALLSRC} > ${.TARGET}
# decompression functionality from zlib
.PATH: ${LIBSTAND_SRC}/../../contrib/zlib
CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../../contrib/zlib
SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
SRCS+= _${file}
CLEANFILES+= _${file}
_${file}: ${file}
sed -e "s|zutil\.h|libstand_zutil.h|" \
-e "s|gzguts\.h|libstand_gzguts.h|" \
${.ALLSRC} > ${.TARGET}
.endfor
# depend on stand.h being able to be included multiple times
.for file in zutil.h gzguts.h
CLEANFILES+= libstand_${file}
libstand_${file}: ${file}
sed -e 's|<fcntl.h>|"stand.h"|' \
-e 's|<stddef.h>|"stand.h"|' \
-e 's|<string.h>|"stand.h"|' \
-e 's|<stdio.h>|"stand.h"|' \
-e 's|<stdlib.h>|"stand.h"|' \
${.ALLSRC} > ${.TARGET}
.endfor
# io routines
SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \
fstat.c close.c lseek.c open.c read.c write.c readdir.c
# network routines
SRCS+= arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
# network info services:
SRCS+= bootp.c rarp.c bootparam.c
# boot filesystems
SRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
SRCS+= dosfs.c ext2fs.c
SRCS+= splitfs.c
SRCS+= pkgfs.c
.if ${MK_NAND} != "no"
SRCS+= nandfs.c
.endif
# explicit_bzero
.PATH: ${SRCTOP}/sys/libkern
SRCS+= explicit_bzero.c
.include <bsd.stand.mk>
.include <bsd.lib.mk>

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv7"
EMBEDDEDPORTS="sysutils/u-boot-bananapi"
KERNEL="GENERIC"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x42000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="32m -b 1m"
FAT_TYPE="16"

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv7"
EMBEDDEDPORTS="sysutils/u-boot-beaglebone"
KERNEL="GENERIC"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x88000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="2m"
FAT_TYPE="12"

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv7"
EMBEDDEDPORTS="sysutils/u-boot-cubieboard"
KERNEL="GENERIC"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x42000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="32m -b 1m"
FAT_TYPE="16"

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv7"
EMBEDDEDPORTS="sysutils/u-boot-cubieboard2"
KERNEL="GENERIC"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x42000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="32m -b 1m"
FAT_TYPE="16"

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv7"
EMBEDDEDPORTS="sysutils/u-boot-cubox-hummingboard"
KERNEL="IMX6"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x12000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="50m -b 16384"
FAT_TYPE="16"

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-duovero"
KERNEL="GUMSTIX"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x88000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="2m"
FAT_TYPE="12"

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv7"
EMBEDDEDPORTS="sysutils/u-boot-pandaboard"
KERNEL="GENERIC"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x88000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="2m"
FAT_TYPE="12"

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-rpi"
KERNEL="RPI-B"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x2000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="17m"
FAT_TYPE="16"

View file

@ -9,12 +9,13 @@ EMBEDDED_TARGET_ARCH="armv7"
EMBEDDEDPORTS="sysutils/u-boot-rpi2"
KERNEL="GENERIC"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x2000000"
IMAGE_SIZE="2560M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="50m"
FAT_TYPE="16"
MD_ARGS="-x 63 -y 255"
NODOC=1
export BOARDNAME="RPI2"
arm_install_uboot() {
UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi2"

View file

@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv7"
EMBEDDEDPORTS="sysutils/u-boot-wandboard"
KERNEL="IMX6"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x12000000"
IMAGE_SIZE="1536M"
IMAGE_SIZE="3072M"
PART_SCHEME="MBR"
FAT_SIZE="50m -b 16384"
FAT_TYPE="16"

View file

@ -148,7 +148,7 @@ env_check() {
WITH_COMPRESSED_IMAGES=
NODOC=yes
case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in
arm:armv6|arm64:aarch64)
arm:armv6|arm:armv7|arm64:aarch64)
chroot_build_release_cmd="chroot_arm_build_release"
;;
*)

View file

@ -20,7 +20,7 @@ CFLAGS+= -DFS_DEBUG
NO_WCAST_ALIGN= yes
.endif
LIBADD= util
LIBADD= ufs util
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests

View file

@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
#include <libutil.h>
#include <libufs.h>
#include "debug.h"
@ -121,6 +122,7 @@ static void updcsloc(time_t, int, int, unsigned int);
static void frag_adjust(ufs2_daddr_t, int);
static void updclst(int);
static void mount_reload(const struct statfs *stfs);
static void cgckhash(struct cg *);
/*
* Here we actually start growing the file system. We basically read the
@ -480,6 +482,7 @@ initcg(int cylno, time_t modtime, int fso, unsigned int Nflag)
sblock.fs_cstotal.cs_nifree += acg.cg_cs.cs_nifree;
*cs = acg.cg_cs;
cgckhash(&acg);
memcpy(iobuf, &acg, sblock.fs_cgsize);
memset(iobuf + sblock.fs_cgsize, '\0',
sblock.fs_bsize * 3 - sblock.fs_cgsize);
@ -771,6 +774,7 @@ updjcg(int cylno, time_t modtime, int fsi, int fso, unsigned int Nflag)
/*
* Write the updated "joining" cylinder group back to disk.
*/
cgckhash(&acg);
wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)), (size_t)sblock.fs_cgsize,
(void *)&acg, fso, Nflag);
DBG_PRINT0("jcg written\n");
@ -1739,3 +1743,16 @@ mount_reload(const struct statfs *stfs)
*errmsg != '\0' ? ": " : "", errmsg);
}
}
/*
* Calculate the check-hash of the cylinder group.
*/
static void
cgckhash(struct cg *cgp)
{
if ((sblock.fs_metackhash & CK_CYLGRP) == 0)
return;
cgp->cg_ckhash = 0;
cgp->cg_ckhash = calculate_crc32c(~0L, (void *)cgp, sblock.fs_cgsize);
}

View file

@ -885,6 +885,8 @@ table_do_modify_record(int cmd, ipfw_obj_header *oh,
sz += sizeof(*oh);
error = do_get3(cmd, &oh->opheader, &sz);
if (error != 0)
error = errno;
tent = (ipfw_obj_tentry *)(ctlv + 1);
/* Copy result back to provided buffer */
memcpy(tent_base, ctlv + 1, sizeof(*tent) * count);

View file

@ -35,7 +35,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 27, 2013
.Dd October 16, 2017
.Dt IF_BRIDGE 4
.Os
.Sh NAME
@ -129,8 +129,11 @@ in
The MTU of the first member interface to be added is used as the bridge MTU.
All additional members are required to have exactly the same value.
.Pp
The TXCSUM capability is disabled for any interface added to the bridge, and it
is restored when the interface is removed again.
The TOE, TSO, TXCSUM and TXCSUM6 capabilities on all interfaces added to the
bridge are disabled if any of the interfaces doesn't support/enable them.
The LRO capability is always disabled.
All the capabilities are restored when the interface is removed from bridge.
Changing capabilities in run time may cause NIC reinit and the link flap.
.Pp
The bridge supports
.Dq monitor mode ,

View file

@ -393,7 +393,8 @@ The following levels are available:
.Sh HISTORY
The
.Nm
driver first appeared in FreeBSD 9.3.
driver first appeared in
.Fx 9.3 .
.Sh AUTHORS
The
.Nm

View file

@ -369,7 +369,8 @@ The following levels are available:
.Sh HISTORY
The
.Nm
driver first appeared in FreeBSD 9.3.
driver first appeared in
.Fx 9.0 .
.Sh AUTHORS
The
.Nm

View file

@ -65,4 +65,5 @@ Upon attach the driver creates a RAM disk which can be read and written.
.Sh HISTORY
The
.Nm
driver appeared in FreeBSD 8.
driver appeared in
.Fx 8.0 .

View file

@ -64,6 +64,9 @@ is used to override settings in
.Pa /etc/rc.conf
for historical reasons.
.Pp
The sysrc(8) command provides a scripting interface to modify system
config files.
.Pp
In addition to
.Pa /etc/rc.conf.local
you can also place smaller configuration files for each
@ -4537,6 +4540,7 @@ configuration file.
.Xr swapon 8 ,
.Xr sysctl 8 ,
.Xr syslogd 8 ,
.Xr sysrc 8 ,
.Xr timed 8 ,
.Xr unbound 8 ,
.Xr usbconfig 8 ,

View file

@ -87,6 +87,9 @@ The
.Nm rc.d/
directories contain scripts which will be automatically
executed at boot time and shutdown time.
.Pp
The sysrc(8) command provides a scripting interface to modify system
config files.
.Ss Operation of Nm
.Bl -enum
.It
@ -548,7 +551,8 @@ is unnecessary, but is often included.
.Xr rc.subr 8 ,
.Xr rcorder 8 ,
.Xr reboot 8 ,
.Xr savecore 8
.Xr savecore 8 ,
.Xr sysrc 8
.Sh HISTORY
The
.Nm

View file

@ -184,7 +184,6 @@ MAN= accept_filter.9 \
make_dev.9 \
malloc.9 \
mbchain.9 \
mbpool.9 \
mbuf.9 \
mbuf_tags.9 \
MD5.9 \
@ -414,6 +413,7 @@ MAN= accept_filter.9 \
MLINKS= unr.9 alloc_unr.9 \
unr.9 alloc_unrl.9 \
unr.9 alloc_unr_specific.9 \
unr.9 clear_unrhdr.9 \
unr.9 delete_unrhdr.9 \
unr.9 free_unr.9 \
unr.9 new_unrhdr.9
@ -1161,16 +1161,6 @@ MLINKS+=mbchain.9 mb_detach.9 \
mbchain.9 mb_put_uint8.9 \
mbchain.9 mb_put_uio.9 \
mbchain.9 mb_reserve.9
MLINKS+=mbpool.9 mbp_alloc.9 \
mbpool.9 mbp_card_free.9 \
mbpool.9 mbp_count.9 \
mbpool.9 mbp_create.9 \
mbpool.9 mbp_destroy.9 \
mbpool.9 mbp_ext_free.9 \
mbpool.9 mbp_free.9 \
mbpool.9 mbp_get.9 \
mbpool.9 mbp_get_keep.9 \
mbpool.9 mbp_sync.9
MLINKS+=\
mbuf.9 m_adj.9 \
mbuf.9 m_align.9 \

View file

@ -1,262 +0,0 @@
.\" Copyright (c) 2003
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
.\" 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.
.\"
.\" Author: Hartmut Brandt <harti@FreeBSD.org>
.\"
.\" $FreeBSD$
.\"
.Dd September 27, 2017
.Dt MBPOOL 9
.Os
.Sh NAME
.Nm mbpool
.Nd "buffer pools for network interfaces"
.Sh SYNOPSIS
.In sys/types.h
.In machine/bus.h
.In sys/mbpool.h
.Vt struct mbpool ;
.Ft int
.Fo mbp_create
.Fa "struct mbpool **mbp" "const char *name" "bus_dma_tag_t dmat"
.Fa "u_int max_pages" "size_t page_size" "size_t chunk_size"
.Fc
.Ft void
.Fn mbp_destroy "struct mbpool *mbp"
.Ft "void *"
.Fn mbp_alloc "struct mbpool *mbp" "bus_addr_t *pa" "uint32_t *hp"
.Ft void
.Fn mbp_free "struct mbpool *mbp" "void *p"
.Ft void
.Fn mbp_ext_free "struct mbuf *"
.Ft void
.Fn mbp_card_free "struct mbpool *mbp"
.Ft void
.Fn mbp_count "struct mbpool *mbp" "u_int *used" "u_int *card" "u_int *free"
.Ft "void *"
.Fn mbp_get "struct mbpool *mbp" "uint32_t h"
.Ft "void *"
.Fn mbp_get_keep "struct mbpool *mbp" "uint32_t h"
.Ft void
.Fo mbp_sync
.Fa "struct mbpool *mbp" "uint32_t h" "bus_addr_t off" "bus_size_t len"
.Fa "u_int op"
.Fc
.Pp
.Fn MODULE_DEPEND "your_module" "libmbpool" 1 1 1
.Pp
.Cd "options LIBMBPOOL"
.Sh DESCRIPTION
Mbuf pools are intended to help drivers for interface cards that need huge
amounts of receive buffers, and additionally provides a mapping between these
buffers and 32-bit handles.
.Pp
An example of these cards are the Fore/Marconi ForeRunnerHE cards.
These
employ up to 8 receive groups, each with two buffer pools, each of which
can contain up to 8192.
This gives a total maximum number of more than
100000 buffers.
Even with a more moderate configuration the card eats several
thousand buffers.
Each of these buffers must be mapped for DMA.
While for
machines without an IOMMU and with lesser than 4GByte memory this is not
a problem, for other machines this may quickly eat up all available IOMMU
address space and/or bounce buffers.
On sparc64, the default I/O page size
is 16k, so mapping a simple mbuf wastes 31/32 of the address space.
.Pp
Another problem with most of these cards is that they support putting a 32-bit
handle into the buffer descriptor together with the physical address.
This handle is reflected back to the driver when the buffer is filled, and
assists the driver in finding the buffer in host memory.
For 32-bit machines,
the virtual address of the buffer is usually used as the handle.
This does not
work for 64-bit machines for obvious reasons, so a mapping is needed between
these handles and the buffers.
This mapping should be possible without
searching lists and the like.
.Pp
An mbuf pool overcomes both problems by allocating DMA-able memory page wise
with a per-pool configurable page size.
Each page is divided into a number of
equally-sized chunks, the last
.Dv MBPOOL_TRAILER_SIZE
of which are used by the pool code (4 bytes).
The rest of each chunk is
usable as a buffer.
There is a per-pool limit on pages that will be allocated.
.Pp
Additionally, the code manages two flags for each buffer:
.Dq on-card
and
.Dq used .
A buffer may be in one of three states:
.Bl -tag -width "on-card"
.It free
None of the flags is set.
.It on-card
Both flags are set.
The buffer is assumed to be handed over to the card and
waiting to be filled.
.It used
The buffer was returned by the card and is now travelling through the system.
.El
.Pp
A pool is created with
.Fn mbp_create .
This call specifies a DMA tag
.Fa dmat
to be used to create and map the memory pages via
.Xr bus_dmamem_alloc 9 .
The
.Fa chunk_size
includes the pool overhead.
It means that to get buffers for 5 ATM cells
(240 bytes), a chunk size of 256 should be specified.
This results in 12 unused
bytes between the buffer, and the pool overhead of four byte.
The total
maximum number of buffers in a pool is
.Fa max_pages
*
.Fa ( page_size
/
.Fa chunk_size ) .
The maximum value for
.Fa max_pages
is 2^14-1 (16383) and the maximum of
.Fa page_size
/
.Fa chunk_size
is 2^9 (512).
If the call is successful, a pointer to a newly allocated
.Vt "struct mbpool"
is set into the variable pointed to by
.Fa mpb .
.Pp
A pool is destroyed with
.Fn mbp_destroy .
This frees all pages and the pool structure itself.
If compiled with
.Dv DIAGNOSTICS ,
the code checks that all buffers are free.
If not, a warning message is issued
to the console.
.Pp
A buffer is allocated with
.Fn mbp_alloc .
This returns the virtual address of the buffer and stores the physical
address into the variable pointed to by
.Fa pa .
The handle is stored into the variable pointed to by
.Fa hp .
The two most significant bits and the 7 least significant bits of the handle
are unused by the pool code and may be used by the caller.
These are
automatically stripped when passing a handle to one of the other functions.
If a buffer cannot be allocated (either because the maximum number of pages
is reached, no memory is available or the memory cannot be mapped),
.Dv NULL
is returned.
If a buffer could be allocated, it is in the
.Dq on-card
state.
.Pp
When the buffer is returned by the card, the driver calls
.Fn mbp_get
with the handle.
This function returns the virtual address of the buffer
and clears the
.Dq on-card
bit.
The buffer is now in the
.Dq used
state.
The function
.Fn mbp_get_keep
differs from
.Fn mbp_get
in that it does not clear the
.Dq on-card
bit.
This can be used for buffers
that are returned
.Dq partially
by the card.
.Pp
A buffer is freed by calling
.Fn mbp_free
with the virtual address of the buffer.
This clears the
.Dq used
bit, and
puts the buffer on the free list of the pool.
Note that free buffers
are NOT returned to the system.
The function
.Fn mbp_ext_free
can be given to
.Fn m_extadd
as the free function.
.Pp
Before using the contents of a buffer returned by the card, the driver
must call
.Fn mbp_sync
with the appropriate parameters.
This results in a call to
.Xr bus_dmamap_sync 9
for the buffer.
.Pp
All buffers in the pool that are currently in the
.Dq on-card
state can be freed
with a call to
.Fn mbp_card_free .
This may be called by the driver when it stops the interface.
Buffers in the
.Dq used
state are not freed by this call.
.Pp
For debugging it is possible to call
.Fn mbp_count .
This returns the number of buffers in the
.Dq used
and
.Dq on-card
states and
the number of buffers on the free list.
.Sh SEE ALSO
.Xr mbuf 9
.Sh AUTHORS
.An Harti Brandt Aq Mt harti@FreeBSD.org
.Sh CAVEATS
The function
.Fn mbp_sync
is currently a no-op because
.Xr bus_dmamap_sync 9
is missing the offset and length parameters.

View file

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd December 13, 2016
.Dd October 10, 2017
.Dt SYSCTL 9
.Os
.Sh NAME
@ -668,6 +668,10 @@ Additionally, any of the following optional flags may also be specified:
.Bl -tag -width ".Dv CTLFLAG_ANYBODY"
.It Dv CTLFLAG_ANYBODY
Any user or process can write to this sysctl.
.It Dv CTLFLAG_CAPRD
A process in capability mode can read from this sysctl.
.It Dv CTLFLAG_CAPWR
A process in capability mode can write to this sysctl.
.It Dv CTLFLAG_SECURE
This sysctl can be written to only if the effective securelevel of the
process is \[<=] 0.

View file

@ -24,11 +24,12 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 5, 2010
.Dd October 4, 2017
.Dt UNR 9
.Os
.Sh NAME
.Nm new_unrhdr ,
.Nm clear_unrhdr ,
.Nm delete_unrhdr ,
.Nm alloc_unr ,
.Nm alloc_unr_specific ,
@ -39,6 +40,8 @@
.Ft "struct unrhdr *"
.Fn new_unrhdr "int low" "int high" "struct mtx *mutex"
.Ft void
.Fn clear_unrhdr "struct unrhdr *uh"
.Ft void
.Fn delete_unrhdr "struct unrhdr *uh"
.Ft int
.Fn alloc_unr "struct unrhdr *uh"
@ -70,8 +73,16 @@ is not
.Dv NULL ,
it is used for locking when allocating and freeing units.
Otherwise, internal mutex is used.
.It Fn clear_unrhdr uh
Clear all units from the specified unit number allocator entity.
This function resets the entity as if it were just initialized with
.Fn new_unrhdr .
.It Fn delete_unrhdr uh
Destroy specified unit number allocator entity.
Delete specified unit number allocator entity.
This function frees the memory associated with the entity, it does not free
any units.
To free all units use
.Fn clear_unrhdr .
.It Fn alloc_unr uh
Return a new unit number.
The lowest free number is always allocated.

View file

@ -356,7 +356,7 @@ FreeBSD 5.2 | | | |
| FreeBSD | | | | |
| 11.1 FreeBSD | | | |
| | 10.4 | | OpenBSD 6.2 |
| v | | | |
| v | | | DragonFly 5.0.0
| | | | |
FreeBSD 12 -current | NetBSD -current OpenBSD -current DragonFly -current
| | | | |
@ -720,6 +720,7 @@ FreeBSD 11.1 2017-07-26 [FBD]
macOS 10.13 2017-09-25 [APL]
FreeBSD 10.4 2017-10-03 [FBD]
OpenBSD 6.2 2017-10-09 [OBD]
DragonFly 5.0.0 2017-10-16 [DFB]
Bibliography
------------------------

View file

@ -194,7 +194,9 @@ LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/}
CLEANFILES+= ${OBJS} ${STATICOBJS}
BCOBJS+= ${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g}
LLOBJS+= ${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g}
CLEANFILES+= ${OBJS} ${BCOBJS} ${LLOBJS} ${STATICOBJS}
.endif
.if defined(LIB) && !empty(LIB)
@ -225,15 +227,13 @@ lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS}
.endif
.if defined(LLVM_LINK)
BCOBJS= ${OBJS:.o=.bco} ${STATICOBJS:.o=.bco}
LLOBJS= ${OBJS:.o=.llo} ${STATICOBJS:.o=.llo}
CLEANFILES+= ${BCOBJS} ${LLOBJS}
lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS}
${LLVM_LINK} -o ${.TARGET} ${BCOBJS}
lib${LIB_PRIVATE}${LIB}.ll: ${LLOBJS}
${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS}
CLEANFILES+= lib${LIB_PRIVATE}${LIB}.bc lib${LIB_PRIVATE}${LIB}.ll
.endif
.if defined(SHLIB_NAME) || \

View file

@ -102,6 +102,10 @@ PROGNAME?= ${PROG}
OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/g}
# LLVM bitcode / textual IR representations of the program
BCOBJS+=${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g}
LLOBJS+=${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g}
.if target(beforelinking)
beforelinking: ${OBJS}
${PROG_FULL}: beforelinking
@ -132,7 +136,10 @@ SRCS= ${PROG}.c
# - the name of the object gets put into the executable symbol table instead of
# the name of a variable temporary object.
# - it's useful to keep objects around for crunching.
OBJS+= ${PROG}.o
OBJS+= ${PROG}.o
BCOBJS+= ${PROG}.bc
LLOBJS+= ${PROG}.ll
CLEANFILES+= ${PROG}.o ${PROG}.bc ${PROG}.ll
.if target(beforelinking)
beforelinking: ${OBJS}
@ -163,16 +170,13 @@ ${PROGNAME}.debug: ${PROG_FULL}
.endif
.if defined(LLVM_LINK)
# LLVM bitcode / textual IR representations of the program
BCOBJS= ${OBJS:.o=.bco}
LLOBJS= ${OBJS:.o=.llo}
${PROG_FULL}.bc: ${BCOBJS}
${LLVM_LINK} -o ${.TARGET} ${BCOBJS}
${PROG_FULL}.ll: ${LLOBJS}
${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS}
CLEANFILES+= ${PROG_FULL}.bc ${PROG_FULL}.ll
.endif # defined(LLVM_LINK)
.if ${MK_MAN} != "no" && !defined(MAN) && \
@ -196,7 +200,7 @@ all: all-man
.if defined(PROG)
CLEANFILES+= ${PROG} ${PROG}.bc ${PROG}.ll
.if ${MK_DEBUG_FILES} != "no"
CLEANFILES+= ${PROG_FULL} ${PROG_FULL}.bc ${PROGNAME}.debug ${PROG_FULL}.ll
CLEANFILES+= ${PROG_FULL} ${PROGNAME}.debug
.endif
.endif

View file

@ -581,12 +581,9 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
struct trapframe *regs = td->td_frame;
struct pcb *pcb = td->td_pcb;
mtx_lock(&dt_lock);
if (td->td_proc->p_md.md_ldt != NULL)
user_ldt_free(td);
else
mtx_unlock(&dt_lock);
update_pcb_bases(pcb);
pcb->pcb_fsbase = 0;
pcb->pcb_gsbase = 0;

View file

@ -56,7 +56,6 @@ uint64_t *vm_page_dump;
int vm_page_dump_size;
static struct kerneldumpheader kdh;
static off_t dumplo;
/* Handle chunked writes. */
static size_t fragsz;
@ -93,8 +92,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0)
return (0);
error = dump_write(di, dump_va, 0, dumplo, fragsz);
dumplo += fragsz;
error = dump_append(di, dump_va, 0, fragsz);
fragsz = 0;
return (error);
}
@ -177,10 +175,9 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
wdog_kern_pat(WD_LASTVAL);
if (ptr) {
error = dump_write(di, ptr, 0, dumplo, len);
error = dump_append(di, ptr, 0, len);
if (error)
return (error);
dumplo += len;
ptr += len;
sz -= len;
} else {
@ -333,7 +330,7 @@ minidumpsys(struct dumperinfo *di)
printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20,
ptoa((uintmax_t)physmem) / 1048576);
error = dump_start(di, &kdh, &dumplo);
error = dump_start(di, &kdh);
if (error != 0)
goto fail;
@ -419,7 +416,7 @@ minidumpsys(struct dumperinfo *di)
if (error)
goto fail;
error = dump_finish(di, &kdh, dumplo);
error = dump_finish(di, &kdh);
if (error != 0)
goto fail;

View file

@ -380,8 +380,8 @@ static int pmap_initialized;
* elements, but reads are not.
*/
static TAILQ_HEAD(pch, pv_chunk) pv_chunks = TAILQ_HEAD_INITIALIZER(pv_chunks);
static struct mtx pv_chunks_mutex;
static struct rwlock pv_list_locks[NPV_LIST_LOCKS];
static struct mtx __exclusive_cache_line pv_chunks_mutex;
static struct rwlock __exclusive_cache_line pv_list_locks[NPV_LIST_LOCKS];
static u_long pv_invl_gen[NPV_LIST_LOCKS];
static struct md_page *pv_table;
static struct md_page pv_dummy;
@ -2888,11 +2888,11 @@ reclaim_pv_chunk_leave_pmap(pmap_t pmap, pmap_t locked_pmap, bool start_di)
static vm_page_t
reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **lockp)
{
struct pch new_tail;
struct pv_chunk *pc;
struct pv_chunk *pc, *pc_marker;
struct pv_chunk_header pc_marker_b;
struct md_page *pvh;
pd_entry_t *pde;
pmap_t pmap;
pmap_t next_pmap, pmap;
pt_entry_t *pte, tpte;
pt_entry_t PG_G, PG_A, PG_M, PG_RW;
pv_entry_t pv;
@ -2909,7 +2909,8 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **lockp)
m_pc = NULL;
PG_G = PG_A = PG_M = PG_RW = 0;
SLIST_INIT(&free);
TAILQ_INIT(&new_tail);
bzero(&pc_marker_b, sizeof(pc_marker_b));
pc_marker = (struct pv_chunk *)&pc_marker_b;
/*
* A delayed invalidation block should already be active if
@ -2919,30 +2920,52 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **lockp)
start_di = pmap_not_in_di();
mtx_lock(&pv_chunks_mutex);
while ((pc = TAILQ_FIRST(&pv_chunks)) != NULL && SLIST_EMPTY(&free)) {
TAILQ_REMOVE(&pv_chunks, pc, pc_lru);
TAILQ_INSERT_HEAD(&pv_chunks, pc_marker, pc_lru);
while ((pc = TAILQ_NEXT(pc_marker, pc_lru)) != NULL &&
SLIST_EMPTY(&free)) {
next_pmap = pc->pc_pmap;
if (next_pmap == NULL) /* marker */
goto next_chunk;
mtx_unlock(&pv_chunks_mutex);
if (pmap != pc->pc_pmap) {
/*
* A pv_chunk can only be removed from the pc_lru list
* when both pc_chunks_mutex is owned and the
* corresponding pmap is locked.
*/
if (pmap != next_pmap) {
reclaim_pv_chunk_leave_pmap(pmap, locked_pmap,
start_di);
pmap = pc->pc_pmap;
pmap = next_pmap;
/* Avoid deadlock and lock recursion. */
if (pmap > locked_pmap) {
RELEASE_PV_LIST_LOCK(lockp);
PMAP_LOCK(pmap);
} else if (pmap != locked_pmap &&
!PMAP_TRYLOCK(pmap)) {
pmap = NULL;
TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru);
if (start_di)
pmap_delayed_invl_started();
mtx_lock(&pv_chunks_mutex);
continue;
}
} else if (pmap != locked_pmap) {
if (PMAP_TRYLOCK(pmap)) {
if (start_di)
pmap_delayed_invl_started();
mtx_lock(&pv_chunks_mutex);
continue;
} else {
pmap = NULL; /* pmap is not locked */
mtx_lock(&pv_chunks_mutex);
pc = TAILQ_NEXT(pc_marker, pc_lru);
if (pc == NULL ||
pc->pc_pmap != next_pmap)
continue;
goto next_chunk;
}
} else if (start_di)
pmap_delayed_invl_started();
PG_G = pmap_global_bit(pmap);
PG_A = pmap_accessed_bit(pmap);
PG_M = pmap_modified_bit(pmap);
PG_RW = pmap_rw_bit(pmap);
if (start_di)
pmap_delayed_invl_started();
}
/*
@ -2987,9 +3010,8 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **lockp)
}
}
if (freed == 0) {
TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru);
mtx_lock(&pv_chunks_mutex);
continue;
goto next_chunk;
}
/* Every freed mapping is for a 4 KB page. */
pmap_resident_count_dec(pmap, freed);
@ -3006,16 +3028,19 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **lockp)
m_pc = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc));
dump_drop_page(m_pc->phys_addr);
mtx_lock(&pv_chunks_mutex);
TAILQ_REMOVE(&pv_chunks, pc, pc_lru);
break;
}
TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru);
mtx_lock(&pv_chunks_mutex);
/* One freed pv entry in locked_pmap is sufficient. */
if (pmap == locked_pmap)
break;
next_chunk:
TAILQ_REMOVE(&pv_chunks, pc_marker, pc_lru);
TAILQ_INSERT_AFTER(&pv_chunks, pc, pc_marker, pc_lru);
}
TAILQ_CONCAT(&pv_chunks, &new_tail, pc_lru);
TAILQ_REMOVE(&pv_chunks, pc_marker, pc_lru);
mtx_unlock(&pv_chunks_mutex);
reclaim_pv_chunk_leave_pmap(pmap, locked_pmap, start_di);
if (m_pc == NULL && !SLIST_EMPTY(&free)) {

View file

@ -500,7 +500,7 @@ user_ldt_free(struct thread *td)
struct mdproc *mdp = &p->p_md;
struct proc_ldt *pldt;
mtx_assert(&dt_lock, MA_OWNED);
mtx_lock(&dt_lock);
if ((pldt = mdp->md_ldt) == NULL) {
mtx_unlock(&dt_lock);
return;

View file

@ -244,6 +244,10 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
/* Copy the LDT, if necessary. */
mdp1 = &td1->td_proc->p_md;
mdp2 = &p2->p_md;
if (mdp1->md_ldt == NULL) {
mdp2->md_ldt = NULL;
return;
}
mtx_lock(&dt_lock);
if (mdp1->md_ldt != NULL) {
if (flags & RFMEM) {
@ -299,11 +303,8 @@ cpu_exit(struct thread *td)
/*
* If this process has a custom LDT, release it.
*/
mtx_lock(&dt_lock);
if (td->td_proc->p_md.md_ldt != 0)
if (td->td_proc->p_md.md_ldt != NULL)
user_ldt_free(td);
else
mtx_unlock(&dt_lock);
}
void

View file

@ -26,6 +26,7 @@ makeoptions WITH_CTF=1 # Run ctfconvert(1) for DTrace support
options SCHED_ULE # ULE scheduler
options PREEMPTION # Enable kernel thread preemption
options VIMAGE # Subsystem virtualization, e.g. VNET
options INET # InterNETworking
options INET6 # IPv6 communications protocols
options IPSEC # IP (v4/v6) security

View file

@ -937,12 +937,9 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack)
{
struct trapframe *regs = td->td_frame;
struct pcb *pcb = td->td_pcb;
mtx_lock(&dt_lock);
if (td->td_proc->p_md.md_ldt != NULL)
user_ldt_free(td);
else
mtx_unlock(&dt_lock);
#ifdef COMPAT_43
setup_lcall_gate();
#endif

View file

@ -366,11 +366,18 @@ typedef struct pv_entry {
*/
#define _NPCM 3
#define _NPCPV 168
struct pv_chunk {
pmap_t pc_pmap;
TAILQ_ENTRY(pv_chunk) pc_list;
uint64_t pc_map[_NPCM]; /* bitmap; 1 = free */
#define PV_CHUNK_HEADER \
pmap_t pc_pmap; \
TAILQ_ENTRY(pv_chunk) pc_list; \
uint64_t pc_map[_NPCM]; /* bitmap; 1 = free */ \
TAILQ_ENTRY(pv_chunk) pc_lru;
struct pv_chunk_header {
PV_CHUNK_HEADER
};
struct pv_chunk {
PV_CHUNK_HEADER
struct pv_entry pc_pventry[_NPCPV];
};

View file

@ -453,11 +453,8 @@ linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
struct trapframe *regs = td->td_frame;
struct pcb *pcb = td->td_pcb;
mtx_lock(&dt_lock);
if (td->td_proc->p_md.md_ldt != NULL)
user_ldt_free(td);
else
mtx_unlock(&dt_lock);
pcb->pcb_fsbase = 0;
pcb->pcb_gsbase = 0;

View file

@ -804,11 +804,8 @@ exec_linux_setregs(struct thread *td, struct image_params *imgp, u_long stack)
struct trapframe *regs = td->td_frame;
struct pcb *pcb = td->td_pcb;
mtx_lock(&dt_lock);
if (td->td_proc->p_md.md_ldt != NULL)
user_ldt_free(td);
else
mtx_unlock(&dt_lock);
critical_enter();
wrmsr(MSR_FSBASE, 0);

View file

@ -65,17 +65,10 @@ __FBSDID("$FreeBSD$");
#define EHCI_HC_DEVSTR "Allwinner Integrated USB 2.0 controller"
#define SW_USB_PMU_IRQ_ENABLE 0x800
#define SW_SDRAM_REG_HPCR_USB1 (0x250 + ((1 << 2) * 4))
#define SW_SDRAM_REG_HPCR_USB2 (0x250 + ((1 << 2) * 5))
#define SW_SDRAM_BP_HPCR_ACCESS (1 << 0)
#define SW_ULPI_BYPASS (1 << 0)
#define SW_AHB_INCRX_ALIGN (1 << 8)
#define SW_AHB_INCR4 (1 << 9)
#define SW_AHB_INCR8 (1 << 10)
#define USB_CONF(d) \
(void *)ofw_bus_search_compatible((d), compat_data)->ocd_data
@ -124,7 +117,7 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun7i-a20-ehci", (uintptr_t)&a10_ehci_conf },
{ "allwinner,sun8i-a83t-ehci", (uintptr_t)&a31_ehci_conf },
{ "allwinner,sun8i-h3-ehci", (uintptr_t)&a31_ehci_conf },
/* { "allwinner,sun50i-a64-ehci", (uintptr_t)&a31_ehci_conf }, */
{ "allwinner,sun50i-a64-ehci", (uintptr_t)&a31_ehci_conf },
{ NULL, (uintptr_t)NULL }
};
@ -254,14 +247,6 @@ a10_ehci_attach(device_t self)
}
}
/* Enable passby */
reg_value = A10_READ_4(sc, SW_USB_PMU_IRQ_ENABLE);
reg_value |= SW_AHB_INCR8; /* AHB INCR8 enable */
reg_value |= SW_AHB_INCR4; /* AHB burst type INCR4 enable */
reg_value |= SW_AHB_INCRX_ALIGN; /* AHB INCRX align enable */
reg_value |= SW_ULPI_BYPASS; /* ULPI bypass enable */
A10_WRITE_4(sc, SW_USB_PMU_IRQ_ENABLE, reg_value);
/* Configure port */
if (conf->sdram_init) {
reg_value = A10_READ_4(sc, SW_SDRAM_REG_HPCR_USB2);
@ -333,14 +318,6 @@ a10_ehci_detach(device_t self)
A10_WRITE_4(sc, SW_SDRAM_REG_HPCR_USB2, reg_value);
}
/* Disable passby */
reg_value = A10_READ_4(sc, SW_USB_PMU_IRQ_ENABLE);
reg_value &= ~SW_AHB_INCR8; /* AHB INCR8 disable */
reg_value &= ~SW_AHB_INCR4; /* AHB burst type INCR4 disable */
reg_value &= ~SW_AHB_INCRX_ALIGN; /* AHB INCRX align disable */
reg_value &= ~SW_ULPI_BYPASS; /* ULPI bypass disable */
A10_WRITE_4(sc, SW_USB_PMU_IRQ_ENABLE, reg_value);
/* Disable clock */
TAILQ_FOREACH_SAFE(clk, &aw_sc->clk_list, next, clk_tmp) {
err = clk_disable(clk->clk);

View file

@ -164,6 +164,30 @@ allwinner_cpu_reset(platform_t plat)
while (1);
}
/*
* To use early printf on Allwinner SoC, add to kernel config
* options SOCDEV_PA=0x01C00000
* options SOCDEV_VA=0x10000000
* options EARLY_PRINTF
* And remove the if 0
*/
#if 0
#ifdef EARLY_PRINTF
static void
allwinner_early_putc(int c)
{
volatile uint32_t * UART_STAT_REG = (uint32_t *)0x1002807C;
volatile uint32_t * UART_TX_REG = (uint32_t *)0x10028000;
const uint32_t UART_TXRDY = (1 << 2);
while ((*UART_STAT_REG & UART_TXRDY) == 0)
continue;
*UART_TX_REG = c;
}
early_putc_t *early_putc = allwinner_early_putc;
#endif /* EARLY_PRINTF */
#endif
#if defined(SOC_ALLWINNER_A10)
static platform_method_t a10_methods[] = {
PLATFORMMETHOD(platform_attach, a10_attach),

View file

@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
#include <machine/cpuinfo.h>
#include <machine/elf.h>
#include <machine/md_var.h>
#if __ARM_ARCH >= 6
void reinit_mmu(uint32_t ttb, uint32_t aux_clr, uint32_t aux_set);
@ -77,6 +79,9 @@ SYSCTL_INT(_hw_cpu_quirks, OID_AUTO, actlr_set,
void
cpuinfo_init(void)
{
#if __ARM_ARCH >= 6
uint32_t tmp;
#endif
/*
* Prematurely fetch CPU quirks. Standard fetch for tunable
@ -190,6 +195,47 @@ cpuinfo_init(void)
}
cpuinfo.dcache_line_mask = cpuinfo.dcache_line_size - 1;
cpuinfo.icache_line_mask = cpuinfo.icache_line_size - 1;
/* Fill AT_HWCAP bits. */
elf_hwcap |= HWCAP_HALF | HWCAP_FAST_MULT; /* Required for all CPUs */
elf_hwcap |= HWCAP_TLS | HWCAP_EDSP; /* Required for v6+ CPUs */
tmp = (cpuinfo.id_isar0 >> 24) & 0xF; /* Divide_instrs */
if (tmp >= 1)
elf_hwcap |= HWCAP_IDIVT;
if (tmp >= 2)
elf_hwcap |= HWCAP_IDIVA;
tmp = (cpuinfo.id_pfr0 >> 4) & 0xF; /* State1 */
if (tmp >= 1)
elf_hwcap |= HWCAP_THUMB;
tmp = (cpuinfo.id_pfr0 >> 12) & 0xF; /* State3 */
if (tmp >= 1)
elf_hwcap |= HWCAP_THUMBEE;
tmp = (cpuinfo.id_mmfr0 >> 0) & 0xF; /* VMSA */
if (tmp >= 5)
elf_hwcap |= HWCAP_LPAE;
/* Fill AT_HWCAP2 bits. */
tmp = (cpuinfo.id_isar5 >> 4) & 0xF; /* AES */
if (tmp >= 1)
elf_hwcap2 |= HWCAP2_AES;
if (tmp >= 2)
elf_hwcap2 |= HWCAP2_PMULL;
tmp = (cpuinfo.id_isar5 >> 8) & 0xF; /* SHA1 */
if (tmp >= 1)
elf_hwcap2 |= HWCAP2_SHA1;
tmp = (cpuinfo.id_isar5 >> 12) & 0xF; /* SHA2 */
if (tmp >= 1)
elf_hwcap2 |= HWCAP2_SHA2;
tmp = (cpuinfo.id_isar5 >> 16) & 0xF; /* CRC32 */
if (tmp >= 1)
elf_hwcap2 |= HWCAP2_CRC32;
#endif
}

View file

@ -131,6 +131,7 @@ static const struct arm32_insn arm32_i[] = {
{ 0x0c500000, 0x04400000, "strb", "daW" },
{ 0x0c500000, 0x04500000, "ldrb", "daW" },
#if __ARM_ARCH >= 6
{ 0x0fff0ff0, 0x06bf0fb0, "rev16", "dm" },
{ 0xffffffff, 0xf57ff01f, "clrex", "c" },
{ 0x0ff00ff0, 0x01800f90, "strex", "dmo" },
{ 0x0ff00fff, 0x01900f9f, "ldrex", "do" },

View file

@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
static boolean_t elf32_arm_abi_supported(struct image_params *);
u_long elf_hwcap;
u_long elf_hwcap2;
struct sysentvec elf32_freebsd_sysvec = {
.sv_size = SYS_MAXSYSCALL,
@ -92,6 +93,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_hwcap = &elf_hwcap,
.sv_hwcap2 = &elf_hwcap2,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);

View file

@ -443,6 +443,30 @@ set_vfpcontext(struct thread *td, mcontext_vfp_t *vfp)
}
#endif
int
arm_get_vfpstate(struct thread *td, void *args)
{
int rv;
struct arm_get_vfpstate_args ua;
mcontext_vfp_t mcontext_vfp;
rv = copyin(args, &ua, sizeof(ua));
if (rv != 0)
return (rv);
if (ua.mc_vfp_size != sizeof(mcontext_vfp_t))
return (EINVAL);
#ifdef VFP
get_vfpcontext(td, &mcontext_vfp);
#else
bzero(&mcontext_vfp, sizeof(mcontext_vfp));
#endif
rv = copyout(&mcontext_vfp, ua.mc_vfp, sizeof(mcontext_vfp));
if (rv != 0)
return (rv);
return (0);
}
/*
* Get machine context.
*/

View file

@ -58,8 +58,6 @@ int vm_page_dump_size;
static struct kerneldumpheader kdh;
static off_t dumplo;
/* Handle chunked writes. */
static size_t fragsz;
static void *dump_va;
@ -89,8 +87,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0)
return (0);
error = dump_write(di, dump_va, 0, dumplo, fragsz);
dumplo += fragsz;
error = dump_append(di, dump_va, 0, fragsz);
fragsz = 0;
return (error);
}
@ -141,10 +138,9 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
wdog_kern_pat(WD_LASTVAL);
#endif
if (ptr) {
error = dump_write(di, ptr, 0, dumplo, len);
error = dump_append(di, ptr, 0, len);
if (error)
return (error);
dumplo += len;
ptr += len;
sz -= len;
} else {
@ -251,7 +247,7 @@ minidumpsys(struct dumperinfo *di)
printf("Physical memory: %u MB\n", ptoa((uintmax_t)physmem) / 1048576);
printf("Dumping %llu MB:", (long long)dumpsize >> 20);
error = dump_start(di, &kdh, &dumplo);
error = dump_start(di, &kdh);
if (error != 0)
goto fail;
@ -329,7 +325,7 @@ minidumpsys(struct dumperinfo *di)
if (error)
goto fail;
error = dump_finish(di, &kdh, dumplo);
error = dump_finish(di, &kdh);
if (error != 0)
goto fail;

View file

@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
#include <machine/sysarch.h>
#include <machine/machdep.h>
#include <machine/vmparam.h>
#ifndef _SYS_SYSPROTO_H_
@ -204,6 +205,7 @@ sysarch(struct thread *td, struct sysarch_args *uap)
case ARM_DRAIN_WRITEBUF:
case ARM_SET_TP:
case ARM_GET_TP:
case ARM_GET_VFPSTATE:
break;
default:
@ -229,6 +231,9 @@ sysarch(struct thread *td, struct sysarch_args *uap)
case ARM_GET_TP:
error = arm32_get_tp(td, uap->parms);
break;
case ARM_GET_VFPSTATE:
error = arm_get_vfpstate(td, uap->parms);
break;
default:
error = EINVAL;
break;

View file

@ -149,6 +149,8 @@ vfp_init(void)
(tmp & VMVFR1_I_MASK) >> VMVFR1_I_OFF == 1 &&
(tmp & VMVFR1_SP_MASK) >> VMVFR1_SP_OFF == 1)
elf_hwcap |= HWCAP_NEON;
if ((tmp & VMVFR1_FMAC_MASK) >> VMVFR1_FMAC_OFF == 1)
elf_hwcap |= HWCAP_VFPv4;
}
/* initialize the coprocess 10 and 11 calls

View file

@ -99,6 +99,7 @@ device ahci # AHCI-compatible SATA controllers
# PCI
options NEW_PCIB
device pci
device pci_host_generic
# PCI NICs
device re # RealTek 8139C+/8169/8169S/8110S
@ -106,6 +107,7 @@ device re # RealTek 8139C+/8169/8169S/8110S
# VirtIO
device virtio
device virtio_mmio
device virtio_pci
device virtio_blk
device vtnet

View file

@ -5,6 +5,7 @@
options HZ=1000
options ARM_L2_PIPT # Only L2 PIPT is supported
options PREEMPTION # Enable kernel thread preemption
options VIMAGE # Subsystem virtualization, e.g. VNET
options INET # InterNETworking
options INET6 # IPv6 communications protocols
options TCP_HHOOK # hhook(9) framework for TCP

View file

@ -5,6 +5,7 @@
options HZ=1000
options ARM_L2_PIPT # Only L2 PIPT is supported
options PREEMPTION # Enable kernel thread preemption
options VIMAGE # Subsystem virtualization, e.g. VNET
options INET # InterNETworking
options INET6 # IPv6 communications protocols
options TCP_HHOOK # hhook(9) framework for TCP

View file

@ -86,8 +86,9 @@ __ElfType(Auxinfo);
#define AT_STACKPROT 23 /* Initial stack protection. */
#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */
#define AT_HWCAP 25 /* CPU feature flags. */
#define AT_HWCAP2 26 /* CPU feature flags 2. */
#define AT_COUNT 26 /* Count of defined aux entry types. */
#define AT_COUNT 27 /* Count of defined aux entry types. */
#define R_ARM_COUNT 33 /* Count of defined relocation types. */
@ -116,10 +117,36 @@ __ElfType(Auxinfo);
#define ET_DYN_LOAD_ADDR 0x12000
/* Flags passed in AT_HWCAP. */
#define HWCAP_SWP 0x00000001 /* Unsupported, never set. */
#define HWCAP_HALF 0x00000002 /* Always set. */
#define HWCAP_THUMB 0x00000004
#define HWCAP_26BIT 0x00000008 /* Unsupported, never set. */
#define HWCAP_FAST_MULT 0x00000010 /* Always set. */
#define HWCAP_FPA 0x00000020 /* Unsupported, never set. */
#define HWCAP_VFP 0x00000040
#define HWCAP_EDSP 0x00000080 /* Always set for ARMv6+. */
#define HWCAP_JAVA 0x00000100 /* Unsupported, never set. */
#define HWCAP_IWMMXT 0x00000200 /* Unsupported, never set. */
#define HWCAP_CRUNCH 0x00000400 /* Unsupported, never set. */
#define HWCAP_THUMBEE 0x00000800
#define HWCAP_NEON 0x00001000
#define HWCAP_VFPv3 0x00002000
#define HWCAP_VFPv3D16 0x00004000
#define HWCAP_TLS 0x00008000 /* Always set for ARMv6+. */
#define HWCAP_VFPv4 0x00010000
#define HWCAP_IDIVA 0x00020000
#define HWCAP_IDIVT 0x00040000
#define HWCAP_VFPD32 0x00080000
#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)
#define HWCAP_LPAE 0x00100000
#define HWCAP_EVTSTRM 0x00200000 /* Not implemented yet. */
/* Flags passed in AT_HWCAP2. */
#define HWCAP2_AES 0x00000001
#define HWCAP2_PMULL 0x00000002
#define HWCAP2_SHA1 0x00000004
#define HWCAP2_SHA2 0x00000008
#define HWCAP2_CRC32 0x00000010
#endif /* !_MACHINE_ELF_H_ */

View file

@ -40,6 +40,7 @@ void arm_parse_fdt_bootargs(void);
void arm_print_kenv(void);
void arm_generic_initclocks(void);
int arm_get_vfpstate(struct thread *td, void *args);
/* Board-specific attributes */
void board_set_serial(uint64_t);

View file

@ -39,6 +39,7 @@ extern int szsigcode;
extern uint32_t *vm_page_dump;
extern int vm_page_dump_size;
extern u_long elf_hwcap;
extern u_long elf_hwcap2;
extern int (*_arm_memcpy)(void *, void *, int, int);
extern int (*_arm_bzero)(void *, int, int);

View file

@ -78,12 +78,18 @@
#define ARM_DRAIN_WRITEBUF 1
#define ARM_SET_TP 2
#define ARM_GET_TP 3
#define ARM_GET_VFPSTATE 4
struct arm_sync_icache_args {
uintptr_t addr; /* Virtual start address */
size_t len; /* Region size */
};
struct arm_get_vfpstate_args {
size_t mc_vfp_size;
void *mc_vfp;
};
#ifndef _KERNEL
__BEGIN_DECLS
int arm_sync_icache (u_int addr, int len);

View file

@ -119,6 +119,12 @@
#define VMVFR0_RB_MASK (0x0000000f) /* VFP 64 bit media support */
/* VMVFR1 */
#define VMVFR1_FMAC_OFF 28
#define VMVFR1_FMAC_MASK (0xf0000000) /* Neon FMAC support */
#define VMVFR1_VFP_HP_OFF 24
#define VMVFR1_VFP_HP_MASK (0x0f000000) /* VFP half prec support */
#define VMVFR1_HP_OFF 20
#define VMVFR1_HP_MASK (0x00f00000) /* Neon half prec support */
#define VMVFR1_SP_OFF 16
#define VMVFR1_SP_MASK (0x000f0000) /* Neon single prec support */
#define VMVFR1_I_OFF 12

View file

@ -122,6 +122,7 @@ tegra124_cpu_reset(platform_t plat)
* option SOCDEV_VA=0x70000000
* option EARLY_PRINTF
*/
#if 0
#ifdef EARLY_PRINTF
static void
tegra124_early_putc(int c)
@ -136,6 +137,7 @@ tegra124_early_putc(int c)
}
early_putc_t *early_putc = tegra124_early_putc;
#endif
#endif
static platform_method_t tegra124_methods[] = {
PLATFORMMETHOD(platform_attach, tegra124_attach),

View file

@ -62,7 +62,6 @@ uint64_t *vm_page_dump;
int vm_page_dump_size;
static struct kerneldumpheader kdh;
static off_t dumplo;
/* Handle chunked writes. */
static size_t fragsz;
@ -96,8 +95,7 @@ blk_flush(struct dumperinfo *di)
if (fragsz == 0)
return (0);
error = dump_write(di, dump_va, 0, dumplo, fragsz);
dumplo += fragsz;
error = dump_append(di, dump_va, 0, fragsz);
fragsz = 0;
return (error);
}
@ -183,10 +181,9 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
wdog_kern_pat(WD_LASTVAL);
if (ptr) {
error = dump_write(di, ptr, 0, dumplo, len);
error = dump_append(di, ptr, 0, len);
if (error)
return (error);
dumplo += len;
ptr += len;
sz -= len;
} else {
@ -295,7 +292,7 @@ minidumpsys(struct dumperinfo *di)
printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20,
ptoa((uintmax_t)physmem) / 1048576);
error = dump_start(di, &kdh, &dumplo);
error = dump_start(di, &kdh);
if (error != 0)
goto fail;
@ -395,7 +392,7 @@ minidumpsys(struct dumperinfo *di)
if (error)
goto fail;
error = dump_finish(di, &kdh, dumplo);
error = dump_finish(di, &kdh);
if (error != 0)
goto fail;

View file

@ -26,6 +26,7 @@ makeoptions WITH_CTF=1 # Run ctfconvert(1) for DTrace support
options SCHED_ULE # ULE scheduler
options PREEMPTION # Enable kernel thread preemption
options VIMAGE # Subsystem virtualization, e.g. VNET
options INET # InterNETworking
options INET6 # IPv6 communications protocols
options IPSEC # IP (v4/v6) security

View file

@ -92,8 +92,9 @@ __ElfType(Auxinfo);
#define AT_STACKPROT 23 /* Initial stack protection. */
#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */
#define AT_HWCAP 25 /* CPU feature flags. */
#define AT_HWCAP2 26 /* CPU feature flags 2. */
#define AT_COUNT 26 /* Count of defined aux entry types. */
#define AT_COUNT 27 /* Count of defined aux entry types. */
/* Define "machine" characteristics */
#define ELF_TARG_CLASS ELFCLASS64

View file

@ -9,7 +9,7 @@ SUBDIR+= ficl
SUBDIR+= forth
.endif
SUBDIR+= common
SUBDIR+= man
.include <bsd.arch.inc.mk>

View file

@ -1,7 +1,7 @@
# $FreeBSD$
SUBDIR+= efi
SUBDIR+= libstand32
SUBDIR+= libsa32
SUBDIR+= zfs
SUBDIR+= userboot

View file

@ -1,7 +1,7 @@
# $FreeBSD$
SUBDIR+= efi
SUBDIR+= libstand32
SUBDIR+= libsa32
SUBDIR+= zfs
.if !defined(LOADER_NO_GELI_SUPPORT)

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