|
111 | 111 | #else |
112 | 112 | #define debug(format, arg...) |
113 | 113 | #endif |
| 114 | + |
| 115 | +#ifdef DEBUG |
| 116 | +#include <linux/highmem.h> |
| 117 | + |
| 118 | +static void dbg_dump_sg(const char *level, const char *prefix_str, |
| 119 | + int prefix_type, int rowsize, int groupsize, |
| 120 | + struct scatterlist *sg, size_t tlen, bool ascii, |
| 121 | + bool may_sleep) |
| 122 | +{ |
| 123 | + struct scatterlist *it; |
| 124 | + void *it_page; |
| 125 | + size_t len; |
| 126 | + void *buf; |
| 127 | + |
| 128 | + for (it = sg; it != NULL && tlen > 0 ; it = sg_next(sg)) { |
| 129 | + /* |
| 130 | + * make sure the scatterlist's page |
| 131 | + * has a valid virtual memory mapping |
| 132 | + */ |
| 133 | + it_page = kmap_atomic(sg_page(it)); |
| 134 | + if (unlikely(!it_page)) { |
| 135 | + printk(KERN_ERR "dbg_dump_sg: kmap failed\n"); |
| 136 | + return; |
| 137 | + } |
| 138 | + |
| 139 | + buf = it_page + it->offset; |
| 140 | + len = min(tlen, it->length); |
| 141 | + print_hex_dump(level, prefix_str, prefix_type, rowsize, |
| 142 | + groupsize, buf, len, ascii); |
| 143 | + tlen -= len; |
| 144 | + |
| 145 | + kunmap_atomic(it_page); |
| 146 | + } |
| 147 | +} |
| 148 | +#endif |
| 149 | + |
114 | 150 | static struct list_head alg_list; |
115 | 151 |
|
116 | 152 | struct caam_alg_entry { |
@@ -1982,9 +2018,9 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err, |
1982 | 2018 | print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ", |
1983 | 2019 | DUMP_PREFIX_ADDRESS, 16, 4, req->info, |
1984 | 2020 | edesc->src_nents > 1 ? 100 : ivsize, 1); |
1985 | | - print_hex_dump(KERN_ERR, "dst @"__stringify(__LINE__)": ", |
1986 | | - DUMP_PREFIX_ADDRESS, 16, 4, sg_virt(req->src), |
1987 | | - edesc->dst_nents > 1 ? 100 : req->nbytes, 1); |
| 2021 | + dbg_dump_sg(KERN_ERR, "dst @"__stringify(__LINE__)": ", |
| 2022 | + DUMP_PREFIX_ADDRESS, 16, 4, req->dst, |
| 2023 | + edesc->dst_nents > 1 ? 100 : req->nbytes, 1, true); |
1988 | 2024 | #endif |
1989 | 2025 |
|
1990 | 2026 | ablkcipher_unmap(jrdev, edesc, req); |
@@ -2014,9 +2050,9 @@ static void ablkcipher_decrypt_done(struct device *jrdev, u32 *desc, u32 err, |
2014 | 2050 | print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ", |
2015 | 2051 | DUMP_PREFIX_ADDRESS, 16, 4, req->info, |
2016 | 2052 | ivsize, 1); |
2017 | | - print_hex_dump(KERN_ERR, "dst @"__stringify(__LINE__)": ", |
2018 | | - DUMP_PREFIX_ADDRESS, 16, 4, sg_virt(req->src), |
2019 | | - edesc->dst_nents > 1 ? 100 : req->nbytes, 1); |
| 2053 | + dbg_dump_sg(KERN_ERR, "dst @"__stringify(__LINE__)": ", |
| 2054 | + DUMP_PREFIX_ADDRESS, 16, 4, req->dst, |
| 2055 | + edesc->dst_nents > 1 ? 100 : req->nbytes, 1, true); |
2020 | 2056 | #endif |
2021 | 2057 |
|
2022 | 2058 | ablkcipher_unmap(jrdev, edesc, req); |
@@ -2171,12 +2207,15 @@ static void init_ablkcipher_job(u32 *sh_desc, dma_addr_t ptr, |
2171 | 2207 | int len, sec4_sg_index = 0; |
2172 | 2208 |
|
2173 | 2209 | #ifdef DEBUG |
| 2210 | + bool may_sleep = ((req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | |
| 2211 | + CRYPTO_TFM_REQ_MAY_SLEEP)) != 0); |
2174 | 2212 | print_hex_dump(KERN_ERR, "presciv@"__stringify(__LINE__)": ", |
2175 | 2213 | DUMP_PREFIX_ADDRESS, 16, 4, req->info, |
2176 | 2214 | ivsize, 1); |
2177 | | - print_hex_dump(KERN_ERR, "src @"__stringify(__LINE__)": ", |
2178 | | - DUMP_PREFIX_ADDRESS, 16, 4, sg_virt(req->src), |
2179 | | - edesc->src_nents ? 100 : req->nbytes, 1); |
| 2215 | + printk(KERN_ERR "asked=%d, nbytes%d\n", (int)edesc->src_nents ? 100 : req->nbytes, req->nbytes); |
| 2216 | + dbg_dump_sg(KERN_ERR, "src @"__stringify(__LINE__)": ", |
| 2217 | + DUMP_PREFIX_ADDRESS, 16, 4, req->src, |
| 2218 | + edesc->src_nents ? 100 : req->nbytes, 1, may_sleep); |
2180 | 2219 | #endif |
2181 | 2220 |
|
2182 | 2221 | len = desc_len(sh_desc); |
@@ -2228,12 +2267,14 @@ static void init_ablkcipher_giv_job(u32 *sh_desc, dma_addr_t ptr, |
2228 | 2267 | int len, sec4_sg_index = 0; |
2229 | 2268 |
|
2230 | 2269 | #ifdef DEBUG |
| 2270 | + bool may_sleep = ((req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | |
| 2271 | + CRYPTO_TFM_REQ_MAY_SLEEP)) != 0); |
2231 | 2272 | print_hex_dump(KERN_ERR, "presciv@" __stringify(__LINE__) ": ", |
2232 | 2273 | DUMP_PREFIX_ADDRESS, 16, 4, req->info, |
2233 | 2274 | ivsize, 1); |
2234 | | - print_hex_dump(KERN_ERR, "src @" __stringify(__LINE__) ": ", |
2235 | | - DUMP_PREFIX_ADDRESS, 16, 4, sg_virt(req->src), |
2236 | | - edesc->src_nents ? 100 : req->nbytes, 1); |
| 2275 | + dbg_dump_sg(KERN_ERR, "src @" __stringify(__LINE__) ": ", |
| 2276 | + DUMP_PREFIX_ADDRESS, 16, 4, req->src, |
| 2277 | + edesc->src_nents ? 100 : req->nbytes, 1, may_sleep); |
2237 | 2278 | #endif |
2238 | 2279 |
|
2239 | 2280 | len = desc_len(sh_desc); |
@@ -2503,18 +2544,20 @@ static int aead_decrypt(struct aead_request *req) |
2503 | 2544 | u32 *desc; |
2504 | 2545 | int ret = 0; |
2505 | 2546 |
|
| 2547 | +#ifdef DEBUG |
| 2548 | + bool may_sleep = ((req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | |
| 2549 | + CRYPTO_TFM_REQ_MAY_SLEEP)) != 0); |
| 2550 | + dbg_dump_sg(KERN_ERR, "dec src@"__stringify(__LINE__)": ", |
| 2551 | + DUMP_PREFIX_ADDRESS, 16, 4, req->src, |
| 2552 | + req->assoclen + req->cryptlen, 1, may_sleep); |
| 2553 | +#endif |
| 2554 | + |
2506 | 2555 | /* allocate extended descriptor */ |
2507 | 2556 | edesc = aead_edesc_alloc(req, AUTHENC_DESC_JOB_IO_LEN, |
2508 | 2557 | &all_contig, false); |
2509 | 2558 | if (IS_ERR(edesc)) |
2510 | 2559 | return PTR_ERR(edesc); |
2511 | 2560 |
|
2512 | | -#ifdef DEBUG |
2513 | | - print_hex_dump(KERN_ERR, "dec src@"__stringify(__LINE__)": ", |
2514 | | - DUMP_PREFIX_ADDRESS, 16, 4, sg_virt(req->src), |
2515 | | - req->assoclen + req->cryptlen, 1); |
2516 | | -#endif |
2517 | | - |
2518 | 2561 | /* Create and submit job descriptor*/ |
2519 | 2562 | init_authenc_job(req, edesc, all_contig, false); |
2520 | 2563 | #ifdef DEBUG |
|
0 commit comments