Changeset View
Changeset View
Standalone View
Standalone View
sys/opencrypto/crypto.c
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/taskqueue.h> | #include <sys/taskqueue.h> | ||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <ddb/ddb.h> | #include <ddb/ddb.h> | ||||
#include <machine/vmparam.h> | |||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <crypto/intake.h> | #include <crypto/intake.h> | ||||
#include <opencrypto/cryptodev.h> | #include <opencrypto/cryptodev.h> | ||||
#include <opencrypto/xform_auth.h> | #include <opencrypto/xform_auth.h> | ||||
#include <opencrypto/xform_enc.h> | #include <opencrypto/xform_enc.h> | ||||
#include <sys/kobj.h> | #include <sys/kobj.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include "cryptodev_if.h" | #include "cryptodev_if.h" | ||||
▲ Show 20 Lines • Show All 1,145 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
switch (cb->cb_type) { | switch (cb->cb_type) { | ||||
case CRYPTO_BUF_CONTIG: | case CRYPTO_BUF_CONTIG: | ||||
return (cb->cb_buf_len); | return (cb->cb_buf_len); | ||||
case CRYPTO_BUF_MBUF: | case CRYPTO_BUF_MBUF: | ||||
if (cb->cb_mbuf->m_flags & M_PKTHDR) | if (cb->cb_mbuf->m_flags & M_PKTHDR) | ||||
return (cb->cb_mbuf->m_pkthdr.len); | return (cb->cb_mbuf->m_pkthdr.len); | ||||
return (m_length(cb->cb_mbuf, NULL)); | return (m_length(cb->cb_mbuf, NULL)); | ||||
#if PMAP_HAS_DMAP | |||||
case CRYPTO_BUF_VMPAGE: | |||||
return (cb->cb_vm_page_len); | |||||
#endif | |||||
case CRYPTO_BUF_UIO: | case CRYPTO_BUF_UIO: | ||||
return (cb->cb_uio->uio_resid); | return (cb->cb_uio->uio_resid); | ||||
default: | default: | ||||
return (0); | return (0); | ||||
} | } | ||||
} | } | ||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
/* Various sanity checks on crypto requests. */ | /* Various sanity checks on crypto requests. */ | ||||
static void | static void | ||||
cb_sanity(struct crypto_buffer *cb, const char *name) | cb_sanity(struct crypto_buffer *cb, const char *name) | ||||
{ | { | ||||
KASSERT(cb->cb_type > CRYPTO_BUF_NONE && cb->cb_type <= CRYPTO_BUF_LAST, | KASSERT(cb->cb_type > CRYPTO_BUF_NONE && cb->cb_type <= CRYPTO_BUF_LAST, | ||||
("incoming crp with invalid %s buffer type", name)); | ("incoming crp with invalid %s buffer type", name)); | ||||
if (cb->cb_type == CRYPTO_BUF_CONTIG) | switch (cb->cb_type) { | ||||
case CRYPTO_BUF_CONTIG: | |||||
KASSERT(cb->cb_buf_len >= 0, | KASSERT(cb->cb_buf_len >= 0, | ||||
("incoming crp with -ve %s buffer length", name)); | ("incoming crp with -ve %s buffer length", name)); | ||||
break; | |||||
#if PMAP_HAS_DMAP | |||||
case CRYPTO_BUF_VMPAGE: | |||||
KASSERT(PMAP_HAS_DMAP, | |||||
("incoming crp uses dmap on supported arch")); | |||||
KASSERT(cb->cb_vm_page_len >= 0, | |||||
("incoming crp with -ve %s buffer length", name)); | |||||
KASSERT(cb->cb_vm_page_offset >= 0, | |||||
("incoming crp with -ve %s buffer offset", name)); | |||||
KASSERT(cb->cb_vm_page_offset < PAGE_SIZE, | |||||
("incoming crp with %s buffer offset greater than page size" | |||||
, name)); | |||||
break; | |||||
#endif | |||||
default: | |||||
break; | |||||
} | |||||
} | } | ||||
static void | static void | ||||
crp_sanity(struct cryptop *crp) | crp_sanity(struct cryptop *crp) | ||||
{ | { | ||||
struct crypto_session_params *csp; | struct crypto_session_params *csp; | ||||
struct crypto_buffer *out; | struct crypto_buffer *out; | ||||
size_t ilen, len, olen; | size_t ilen, len, olen; | ||||
▲ Show 20 Lines • Show All 998 Lines • Show Last 20 Lines |