Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: tcrypt - remove all multibuffer ahash tests

The multibuffer algorithms was removed already in 2018, so it is
necessary to clear the test code left by tcrypt.

Suggested-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Tianjia Zhang and committed by
Herbert Xu
388ac25e 16d20a08

-224
-224
crypto/tcrypt.c
··· 724 724 return crypto_wait_req(ret, wait); 725 725 } 726 726 727 - struct test_mb_ahash_data { 728 - struct scatterlist sg[XBUFSIZE]; 729 - char result[64]; 730 - struct ahash_request *req; 731 - struct crypto_wait wait; 732 - char *xbuf[XBUFSIZE]; 733 - }; 734 - 735 - static inline int do_mult_ahash_op(struct test_mb_ahash_data *data, u32 num_mb, 736 - int *rc) 737 - { 738 - int i, err = 0; 739 - 740 - /* Fire up a bunch of concurrent requests */ 741 - for (i = 0; i < num_mb; i++) 742 - rc[i] = crypto_ahash_digest(data[i].req); 743 - 744 - /* Wait for all requests to finish */ 745 - for (i = 0; i < num_mb; i++) { 746 - rc[i] = crypto_wait_req(rc[i], &data[i].wait); 747 - 748 - if (rc[i]) { 749 - pr_info("concurrent request %d error %d\n", i, rc[i]); 750 - err = rc[i]; 751 - } 752 - } 753 - 754 - return err; 755 - } 756 - 757 - static int test_mb_ahash_jiffies(struct test_mb_ahash_data *data, int blen, 758 - int secs, u32 num_mb) 759 - { 760 - unsigned long start, end; 761 - int bcount; 762 - int ret = 0; 763 - int *rc; 764 - 765 - rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL); 766 - if (!rc) 767 - return -ENOMEM; 768 - 769 - for (start = jiffies, end = start + secs * HZ, bcount = 0; 770 - time_before(jiffies, end); bcount++) { 771 - ret = do_mult_ahash_op(data, num_mb, rc); 772 - if (ret) 773 - goto out; 774 - } 775 - 776 - pr_cont("%d operations in %d seconds (%llu bytes)\n", 777 - bcount * num_mb, secs, (u64)bcount * blen * num_mb); 778 - 779 - out: 780 - kfree(rc); 781 - return ret; 782 - } 783 - 784 - static int test_mb_ahash_cycles(struct test_mb_ahash_data *data, int blen, 785 - u32 num_mb) 786 - { 787 - unsigned long cycles = 0; 788 - int ret = 0; 789 - int i; 790 - int *rc; 791 - 792 - rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL); 793 - if (!rc) 794 - return -ENOMEM; 795 - 796 - /* Warm-up run. */ 797 - for (i = 0; i < 4; i++) { 798 - ret = do_mult_ahash_op(data, num_mb, rc); 799 - if (ret) 800 - goto out; 801 - } 802 - 803 - /* The real thing. */ 804 - for (i = 0; i < 8; i++) { 805 - cycles_t start, end; 806 - 807 - start = get_cycles(); 808 - ret = do_mult_ahash_op(data, num_mb, rc); 809 - end = get_cycles(); 810 - 811 - if (ret) 812 - goto out; 813 - 814 - cycles += end - start; 815 - } 816 - 817 - pr_cont("1 operation in %lu cycles (%d bytes)\n", 818 - (cycles + 4) / (8 * num_mb), blen); 819 - 820 - out: 821 - kfree(rc); 822 - return ret; 823 - } 824 - 825 - static void test_mb_ahash_speed(const char *algo, unsigned int secs, 826 - struct hash_speed *speed, u32 num_mb) 827 - { 828 - struct test_mb_ahash_data *data; 829 - struct crypto_ahash *tfm; 830 - unsigned int i, j, k; 831 - int ret; 832 - 833 - data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL); 834 - if (!data) 835 - return; 836 - 837 - tfm = crypto_alloc_ahash(algo, 0, 0); 838 - if (IS_ERR(tfm)) { 839 - pr_err("failed to load transform for %s: %ld\n", 840 - algo, PTR_ERR(tfm)); 841 - goto free_data; 842 - } 843 - 844 - for (i = 0; i < num_mb; ++i) { 845 - if (testmgr_alloc_buf(data[i].xbuf)) 846 - goto out; 847 - 848 - crypto_init_wait(&data[i].wait); 849 - 850 - data[i].req = ahash_request_alloc(tfm, GFP_KERNEL); 851 - if (!data[i].req) { 852 - pr_err("alg: hash: Failed to allocate request for %s\n", 853 - algo); 854 - goto out; 855 - } 856 - 857 - ahash_request_set_callback(data[i].req, 0, crypto_req_done, 858 - &data[i].wait); 859 - 860 - sg_init_table(data[i].sg, XBUFSIZE); 861 - for (j = 0; j < XBUFSIZE; j++) { 862 - sg_set_buf(data[i].sg + j, data[i].xbuf[j], PAGE_SIZE); 863 - memset(data[i].xbuf[j], 0xff, PAGE_SIZE); 864 - } 865 - } 866 - 867 - pr_info("\ntesting speed of multibuffer %s (%s)\n", algo, 868 - get_driver_name(crypto_ahash, tfm)); 869 - 870 - for (i = 0; speed[i].blen != 0; i++) { 871 - /* For some reason this only tests digests. */ 872 - if (speed[i].blen != speed[i].plen) 873 - continue; 874 - 875 - if (speed[i].blen > XBUFSIZE * PAGE_SIZE) { 876 - pr_err("template (%u) too big for tvmem (%lu)\n", 877 - speed[i].blen, XBUFSIZE * PAGE_SIZE); 878 - goto out; 879 - } 880 - 881 - if (klen) 882 - crypto_ahash_setkey(tfm, tvmem[0], klen); 883 - 884 - for (k = 0; k < num_mb; k++) 885 - ahash_request_set_crypt(data[k].req, data[k].sg, 886 - data[k].result, speed[i].blen); 887 - 888 - pr_info("test%3u " 889 - "(%5u byte blocks,%5u bytes per update,%4u updates): ", 890 - i, speed[i].blen, speed[i].plen, 891 - speed[i].blen / speed[i].plen); 892 - 893 - if (secs) { 894 - ret = test_mb_ahash_jiffies(data, speed[i].blen, secs, 895 - num_mb); 896 - cond_resched(); 897 - } else { 898 - ret = test_mb_ahash_cycles(data, speed[i].blen, num_mb); 899 - } 900 - 901 - 902 - if (ret) { 903 - pr_err("At least one hashing failed ret=%d\n", ret); 904 - break; 905 - } 906 - } 907 - 908 - out: 909 - for (k = 0; k < num_mb; ++k) 910 - ahash_request_free(data[k].req); 911 - 912 - for (k = 0; k < num_mb; ++k) 913 - testmgr_free_buf(data[k].xbuf); 914 - 915 - crypto_free_ahash(tfm); 916 - 917 - free_data: 918 - kfree(data); 919 - } 920 - 921 727 static int test_ahash_jiffies_digest(struct ahash_request *req, int blen, 922 728 char *out, int secs) 923 729 { ··· 2378 2572 fallthrough; 2379 2573 case 422: 2380 2574 test_ahash_speed("sm3", sec, generic_hash_speed_template); 2381 - if (mode > 400 && mode < 500) break; 2382 - fallthrough; 2383 - case 450: 2384 - test_mb_ahash_speed("sha1", sec, generic_hash_speed_template, 2385 - num_mb); 2386 - if (mode > 400 && mode < 500) break; 2387 - fallthrough; 2388 - case 451: 2389 - test_mb_ahash_speed("sha256", sec, generic_hash_speed_template, 2390 - num_mb); 2391 - if (mode > 400 && mode < 500) break; 2392 - fallthrough; 2393 - case 452: 2394 - test_mb_ahash_speed("sha512", sec, generic_hash_speed_template, 2395 - num_mb); 2396 - if (mode > 400 && mode < 500) break; 2397 - fallthrough; 2398 - case 453: 2399 - test_mb_ahash_speed("sm3", sec, generic_hash_speed_template, 2400 - num_mb); 2401 - if (mode > 400 && mode < 500) break; 2402 - fallthrough; 2403 - case 454: 2404 - test_mb_ahash_speed("streebog256", sec, 2405 - generic_hash_speed_template, num_mb); 2406 - if (mode > 400 && mode < 500) break; 2407 - fallthrough; 2408 - case 455: 2409 - test_mb_ahash_speed("streebog512", sec, 2410 - generic_hash_speed_template, num_mb); 2411 2575 if (mode > 400 && mode < 500) break; 2412 2576 fallthrough; 2413 2577 case 499: