提交 d9cee5d4 编写于 作者: L Linus Torvalds

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
...@@ -57,7 +57,7 @@ static void bcm63xx_rng_cleanup(struct hwrng *rng) ...@@ -57,7 +57,7 @@ static void bcm63xx_rng_cleanup(struct hwrng *rng)
val &= ~RNG_EN; val &= ~RNG_EN;
__raw_writel(val, priv->regs + RNG_CTRL); __raw_writel(val, priv->regs + RNG_CTRL);
clk_didsable_unprepare(prov->clk); clk_disable_unprepare(priv->clk);
} }
static int bcm63xx_rng_data_present(struct hwrng *rng, int wait) static int bcm63xx_rng_data_present(struct hwrng *rng, int wait)
...@@ -97,14 +97,14 @@ static int bcm63xx_rng_probe(struct platform_device *pdev) ...@@ -97,14 +97,14 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)
priv->rng.name = pdev->name; priv->rng.name = pdev->name;
priv->rng.init = bcm63xx_rng_init; priv->rng.init = bcm63xx_rng_init;
priv->rng.cleanup = bcm63xx_rng_cleanup; priv->rng.cleanup = bcm63xx_rng_cleanup;
prov->rng.data_present = bcm63xx_rng_data_present; priv->rng.data_present = bcm63xx_rng_data_present;
priv->rng.data_read = bcm63xx_rng_data_read; priv->rng.data_read = bcm63xx_rng_data_read;
priv->clk = devm_clk_get(&pdev->dev, "ipsec"); priv->clk = devm_clk_get(&pdev->dev, "ipsec");
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->clk)) {
error = PTR_ERR(priv->clk); ret = PTR_ERR(priv->clk);
dev_err(&pdev->dev, "no clock for device: %d\n", error); dev_err(&pdev->dev, "no clock for device: %d\n", ret);
return error; return ret;
} }
if (!devm_request_mem_region(&pdev->dev, r->start, if (!devm_request_mem_region(&pdev->dev, r->start,
...@@ -120,11 +120,11 @@ static int bcm63xx_rng_probe(struct platform_device *pdev) ...@@ -120,11 +120,11 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
error = devm_hwrng_register(&pdev->dev, &priv->rng); ret = devm_hwrng_register(&pdev->dev, &priv->rng);
if (error) { if (ret) {
dev_err(&pdev->dev, "failed to register rng device: %d\n", dev_err(&pdev->dev, "failed to register rng device: %d\n",
error); ret);
return error; return ret;
} }
dev_info(&pdev->dev, "registered RNG driver\n"); dev_info(&pdev->dev, "registered RNG driver\n");
......
...@@ -9,10 +9,24 @@ ...@@ -9,10 +9,24 @@
+ __GNUC_MINOR__ * 100 \ + __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__) + __GNUC_PATCHLEVEL__)
/* Optimization barrier */ /* Optimization barrier */
/* The "volatile" is due to gcc bugs */ /* The "volatile" is due to gcc bugs */
#define barrier() __asm__ __volatile__("": : :"memory") #define barrier() __asm__ __volatile__("": : :"memory")
/*
* This version is i.e. to prevent dead stores elimination on @ptr
* where gcc and llvm may behave differently when otherwise using
* normal barrier(): while gcc behavior gets along with a normal
* barrier(), llvm needs an explicit input variable to be assumed
* clobbered. The issue is as follows: while the inline asm might
* access any memory it wants, the compiler could have fit all of
* @ptr into memory registers instead, and since @ptr never escaped
* from that, it proofed that the inline asm wasn't touching any of
* it. This version works well with both compilers, i.e. we're telling
* the compiler that the inline asm absolutely may see the contents
* of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
*/
#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
/* /*
* This macro obfuscates arithmetic on a variable address so that gcc * This macro obfuscates arithmetic on a variable address so that gcc
......
...@@ -13,9 +13,12 @@ ...@@ -13,9 +13,12 @@
/* Intel ECC compiler doesn't support gcc specific asm stmts. /* Intel ECC compiler doesn't support gcc specific asm stmts.
* It uses intrinsics to do the equivalent things. * It uses intrinsics to do the equivalent things.
*/ */
#undef barrier_data
#undef RELOC_HIDE #undef RELOC_HIDE
#undef OPTIMIZER_HIDE_VAR #undef OPTIMIZER_HIDE_VAR
#define barrier_data(ptr) barrier()
#define RELOC_HIDE(ptr, off) \ #define RELOC_HIDE(ptr, off) \
({ unsigned long __ptr; \ ({ unsigned long __ptr; \
__ptr = (unsigned long) (ptr); \ __ptr = (unsigned long) (ptr); \
......
...@@ -169,6 +169,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); ...@@ -169,6 +169,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
# define barrier() __memory_barrier() # define barrier() __memory_barrier()
#endif #endif
#ifndef barrier_data
# define barrier_data(ptr) barrier()
#endif
/* Unreachable code */ /* Unreachable code */
#ifndef unreachable #ifndef unreachable
# define unreachable() do { } while (1) # define unreachable() do { } while (1)
......
...@@ -607,7 +607,7 @@ EXPORT_SYMBOL(memset); ...@@ -607,7 +607,7 @@ EXPORT_SYMBOL(memset);
void memzero_explicit(void *s, size_t count) void memzero_explicit(void *s, size_t count)
{ {
memset(s, 0, count); memset(s, 0, count);
barrier(); barrier_data(s);
} }
EXPORT_SYMBOL(memzero_explicit); EXPORT_SYMBOL(memzero_explicit);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册