drivers/s390/crypto/zcrypt_ep11misc.c
Source file repositories/reference/linux-study-clean/drivers/s390/crypto/zcrypt_ep11misc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/crypto/zcrypt_ep11misc.c- Extension
.c- Size
- 42012 bytes
- Lines
- 1637
- Domain
- Driver Families
- Bucket
- drivers/s390
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/init.hlinux/mempool.hlinux/module.hlinux/random.hlinux/slab.hasm/zcrypt.hasm/pkey.hcrypto/aes.hap_bus.hzcrypt_api.hzcrypt_debug.hzcrypt_msgtype6.hzcrypt_ep11misc.hzcrypt_ccamisc.h
Detected Declarations
struct pl_headstruct ep11_info_req_plstruct ep11_info_rep_plstruct ep11_module_query_infostruct ep11_domain_query_infostruct keygen_req_plstruct keygen_rep_plstruct crypt_req_plstruct crypt_rep_plstruct uw_req_plstruct uw_rep_plstruct wk_req_plstruct wk_rep_plstruct wk_infofunction ep11_kb_splitfunction ep11_kb_decodefunction ep11_check_aes_key_with_hdrfunction ep11_check_ecc_key_with_hdrfunction fieldfunction free_cprbmemfunction asn1tag_writefunction prep_headfunction prep_urbfunction check_reply_plfunction check_reply_cprbfunction ep11_query_infofunction ep11_get_card_infofunction ep11_get_domain_infofunction _ep11_genaeskeyfunction ep11_genaeskeyfunction ep11_cryptsinglefunction _ep11_unwrapkeyfunction ep11_unwrapkeyfunction _ep11_wrapkeyfunction ep11_clr2keyblobfunction ep11_kblob2protkeyfunction ep11_findcard2function zcrypt_ep11misc_initfunction zcrypt_ep11misc_exitexport ep11_kb_wkvpexport ep11_check_aes_key_with_hdrexport ep11_check_ecc_key_with_hdrexport ep11_check_aes_keyexport ep11_get_card_infoexport ep11_get_domain_infoexport ep11_genaeskeyexport ep11_clr2keyblobexport ep11_kblob2protkey
Annotated Snippet
struct pl_head {
u8 tag;
u8 lenfmt;
u16 len;
u8 func_tag;
u8 func_len;
u32 func;
u8 dom_tag;
u8 dom_len;
u32 dom;
} __packed;
/* prep ep11 payload head helper function */
static inline void prep_head(struct pl_head *h,
size_t pl_size, int api, int func)
{
h->tag = 0x30;
h->lenfmt = 0x82;
h->len = pl_size - 4;
h->func_tag = 0x04;
h->func_len = sizeof(u32);
h->func = (api << 16) + func;
h->dom_tag = 0x04;
h->dom_len = sizeof(u32);
}
/* prep urb helper function */
static inline void prep_urb(struct ep11_urb *u,
struct ep11_target_dev *t, int nt,
struct ep11_cprb *req, size_t req_len,
struct ep11_cprb *rep, size_t rep_len)
{
memset(u, 0, sizeof(*u));
u->targets = (u8 __user *)t;
u->targets_num = nt;
u->req = (u8 __user *)req;
u->req_len = req_len;
u->resp = (u8 __user *)rep;
u->resp_len = rep_len;
}
/* Check ep11 reply payload, return 0 or suggested errno value. */
static int check_reply_pl(const u8 *pl, const char *func)
{
int len;
u32 ret;
/* start tag */
if (*pl++ != 0x30) {
ZCRYPT_DBF_ERR("%s reply start tag mismatch\n", func);
return -EIO;
}
/* payload length format */
if (*pl < 127) {
len = *pl;
pl++;
} else if (*pl == 0x81) {
pl++;
len = *pl;
pl++;
} else if (*pl == 0x82) {
pl++;
len = *((u16 *)pl);
pl += 2;
} else {
ZCRYPT_DBF_ERR("%s reply start tag lenfmt mismatch 0x%02hhx\n",
func, *pl);
return -EIO;
}
/* len should cover at least 3 fields with 32 bit value each */
if (len < 3 * 6) {
ZCRYPT_DBF_ERR("%s reply length %d too small\n", func, len);
return -EIO;
}
/* function tag, length and value */
if (pl[0] != 0x04 || pl[1] != 0x04) {
ZCRYPT_DBF_ERR("%s function tag or length mismatch\n", func);
return -EIO;
}
pl += 6;
/* dom tag, length and value */
if (pl[0] != 0x04 || pl[1] != 0x04) {
ZCRYPT_DBF_ERR("%s dom tag or length mismatch\n", func);
return -EIO;
}
pl += 6;
Annotation
- Immediate include surface: `linux/export.h`, `linux/init.h`, `linux/mempool.h`, `linux/module.h`, `linux/random.h`, `linux/slab.h`, `asm/zcrypt.h`, `asm/pkey.h`.
- Detected declarations: `struct pl_head`, `struct ep11_info_req_pl`, `struct ep11_info_rep_pl`, `struct ep11_module_query_info`, `struct ep11_domain_query_info`, `struct keygen_req_pl`, `struct keygen_rep_pl`, `struct crypt_req_pl`, `struct crypt_rep_pl`, `struct uw_req_pl`.
- Atlas domain: Driver Families / drivers/s390.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.