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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fixes from Herbert Xu:
"This fixes a build problem with bcm63xx and yet another fix to the
memzero_explicit function to ensure that the memset is not elided"

* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
hwrng: bcm63xx - Fix driver compilation
lib: make memzero_explicit more robust against dead store elimination

+32 -11
+9 -9
drivers/char/hw_random/bcm63xx-rng.c
··· 57 57 val &= ~RNG_EN; 58 58 __raw_writel(val, priv->regs + RNG_CTRL); 59 59 60 - clk_didsable_unprepare(prov->clk); 60 + clk_disable_unprepare(priv->clk); 61 61 } 62 62 63 63 static int bcm63xx_rng_data_present(struct hwrng *rng, int wait) ··· 97 97 priv->rng.name = pdev->name; 98 98 priv->rng.init = bcm63xx_rng_init; 99 99 priv->rng.cleanup = bcm63xx_rng_cleanup; 100 - prov->rng.data_present = bcm63xx_rng_data_present; 100 + priv->rng.data_present = bcm63xx_rng_data_present; 101 101 priv->rng.data_read = bcm63xx_rng_data_read; 102 102 103 103 priv->clk = devm_clk_get(&pdev->dev, "ipsec"); 104 104 if (IS_ERR(priv->clk)) { 105 - error = PTR_ERR(priv->clk); 106 - dev_err(&pdev->dev, "no clock for device: %d\n", error); 107 - return error; 105 + ret = PTR_ERR(priv->clk); 106 + dev_err(&pdev->dev, "no clock for device: %d\n", ret); 107 + return ret; 108 108 } 109 109 110 110 if (!devm_request_mem_region(&pdev->dev, r->start, ··· 120 120 return -ENOMEM; 121 121 } 122 122 123 - error = devm_hwrng_register(&pdev->dev, &priv->rng); 124 - if (error) { 123 + ret = devm_hwrng_register(&pdev->dev, &priv->rng); 124 + if (ret) { 125 125 dev_err(&pdev->dev, "failed to register rng device: %d\n", 126 - error); 127 - return error; 126 + ret); 127 + return ret; 128 128 } 129 129 130 130 dev_info(&pdev->dev, "registered RNG driver\n");
+15 -1
include/linux/compiler-gcc.h
··· 9 9 + __GNUC_MINOR__ * 100 \ 10 10 + __GNUC_PATCHLEVEL__) 11 11 12 - 13 12 /* Optimization barrier */ 13 + 14 14 /* The "volatile" is due to gcc bugs */ 15 15 #define barrier() __asm__ __volatile__("": : :"memory") 16 + /* 17 + * This version is i.e. to prevent dead stores elimination on @ptr 18 + * where gcc and llvm may behave differently when otherwise using 19 + * normal barrier(): while gcc behavior gets along with a normal 20 + * barrier(), llvm needs an explicit input variable to be assumed 21 + * clobbered. The issue is as follows: while the inline asm might 22 + * access any memory it wants, the compiler could have fit all of 23 + * @ptr into memory registers instead, and since @ptr never escaped 24 + * from that, it proofed that the inline asm wasn't touching any of 25 + * it. This version works well with both compilers, i.e. we're telling 26 + * the compiler that the inline asm absolutely may see the contents 27 + * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495 28 + */ 29 + #define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory") 16 30 17 31 /* 18 32 * This macro obfuscates arithmetic on a variable address so that gcc
+3
include/linux/compiler-intel.h
··· 13 13 /* Intel ECC compiler doesn't support gcc specific asm stmts. 14 14 * It uses intrinsics to do the equivalent things. 15 15 */ 16 + #undef barrier_data 16 17 #undef RELOC_HIDE 17 18 #undef OPTIMIZER_HIDE_VAR 19 + 20 + #define barrier_data(ptr) barrier() 18 21 19 22 #define RELOC_HIDE(ptr, off) \ 20 23 ({ unsigned long __ptr; \
+4
include/linux/compiler.h
··· 169 169 # define barrier() __memory_barrier() 170 170 #endif 171 171 172 + #ifndef barrier_data 173 + # define barrier_data(ptr) barrier() 174 + #endif 175 + 172 176 /* Unreachable code */ 173 177 #ifndef unreachable 174 178 # define unreachable() do { } while (1)
+1 -1
lib/string.c
··· 607 607 void memzero_explicit(void *s, size_t count) 608 608 { 609 609 memset(s, 0, count); 610 - barrier(); 610 + barrier_data(s); 611 611 } 612 612 EXPORT_SYMBOL(memzero_explicit); 613 613