diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2014-12-11 02:43:02 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2014-12-14 16:23:49 +0000 |
commit | ce2584379f31cfc44bbe770bb78430950a24156e (patch) | |
tree | b5853a291b235292e30c267492d1c75463e4a660 /include | |
parent | 79702f960693a85b2925dde7f73c623a034c8be4 (diff) |
compiler: Define OPTIMIZER_HIDE_VAR
Part of upstream commit fe8c8a126806 ('crypto: more robust
crypto_memneq'), needed by commit d4c5efdb9777 ('random: add and use
memzero_explicit() for clearing data').
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/compiler-gcc.h | 3 | ||||
-rw-r--r-- | include/linux/compiler-intel.h | 7 | ||||
-rw-r--r-- | include/linux/compiler.h | 4 |
3 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 5633053ac7c2..9ac1a7a977c2 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -37,6 +37,9 @@ __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ (typeof(ptr)) (__ptr + (off)); }) +/* Make the optimizer believe the variable can be manipulated arbitrarily. */ +#define OPTIMIZER_HIDE_VAR(var) __asm__ ("" : "=r" (var) : "0" (var)) + #ifdef __CHECKER__ #define __must_be_array(arr) 0 #else diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h index cba9593c4047..1a97cac7dcb2 100644 --- a/include/linux/compiler-intel.h +++ b/include/linux/compiler-intel.h @@ -15,6 +15,7 @@ */ #undef barrier #undef RELOC_HIDE +#undef OPTIMIZER_HIDE_VAR #define barrier() __memory_barrier() @@ -23,6 +24,12 @@ __ptr = (unsigned long) (ptr); \ (typeof(ptr)) (__ptr + (off)); }) +/* This should act as an optimization barrier on var. + * Given that this compiler does not have inline assembly, a compiler barrier + * is the best we can do. + */ +#define OPTIMIZER_HIDE_VAR(var) barrier() + /* Intel ECC compiler doesn't support __builtin_types_compatible_p() */ #define __must_be_array(a) 0 diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 320d6c94ff84..7c7546bf1c10 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -164,6 +164,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); (typeof(ptr)) (__ptr + (off)); }) #endif +#ifndef OPTIMIZER_HIDE_VAR +#define OPTIMIZER_HIDE_VAR(var) barrier() +#endif + #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ |