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

crypto: lib/blake2s - Split up test function to halve stack usage

Reduce the stack usage further by splitting up the test function.

Also squash blocks and unaligned_blocks into one array.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+22 -3
+22 -3
lib/crypto/blake2s-selftest.c
··· 545 545 0xd6, 0x98, 0x6b, 0x07, 0x10, 0x65, 0x52, 0x65, }, 546 546 }; 547 547 548 - bool __init blake2s_selftest(void) 548 + static bool __init noinline_for_stack blake2s_digest_test(void) 549 549 { 550 550 u8 key[BLAKE2S_KEY_SIZE]; 551 551 u8 buf[ARRAY_SIZE(blake2s_testvecs)]; ··· 589 589 } 590 590 } 591 591 592 + return success; 593 + } 594 + 595 + static bool __init noinline_for_stack blake2s_random_test(void) 596 + { 597 + struct blake2s_state state; 598 + bool success = true; 599 + int i, l; 600 + 592 601 for (i = 0; i < 32; ++i) { 593 602 enum { TEST_ALIGNMENT = 16 }; 594 - u8 unaligned_block[BLAKE2S_BLOCK_SIZE + TEST_ALIGNMENT - 1] 603 + u8 blocks[BLAKE2S_BLOCK_SIZE * 2 + TEST_ALIGNMENT - 1] 595 604 __aligned(TEST_ALIGNMENT); 596 - u8 blocks[BLAKE2S_BLOCK_SIZE * 2]; 605 + u8 *unaligned_block = blocks + BLAKE2S_BLOCK_SIZE; 597 606 struct blake2s_state state1, state2; 598 607 599 608 get_random_bytes(blocks, sizeof(blocks)); ··· 636 627 } 637 628 } 638 629 } 630 + 631 + return success; 632 + } 633 + 634 + bool __init blake2s_selftest(void) 635 + { 636 + bool success; 637 + 638 + success = blake2s_digest_test(); 639 + success &= blake2s_random_test(); 639 640 640 641 return success; 641 642 }