]>
Commit | Line | Data |
---|---|---|
035dbe67 FG |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Elena Reshetova <elena.reshetova@intel.com> | |
3 | Date: Mon, 4 Sep 2017 13:11:43 +0300 | |
4 | Subject: [PATCH] locking/barriers: introduce new memory barrier gmb() | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | CVE-2017-5753 | |
10 | CVE-2017-5715 | |
11 | ||
12 | In constrast to existing mb() and rmb() barriers, | |
13 | gmb() barrier is arch-independent and can be used to | |
14 | implement any type of memory barrier. | |
15 | In x86 case, it is either lfence or mfence, based on | |
16 | processor type. ARM and others can define it according | |
17 | to their needs. | |
18 | ||
19 | Suggested-by: Arjan van de Ven <arjan@linux.intel.com> | |
20 | Signed-off-by: Elena Reshetova <elena.reshetova@intel.com> | |
21 | Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com> | |
22 | Signed-off-by: Andy Whitcroft <apw@canonical.com> | |
23 | Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com> | |
24 | (cherry picked from commit 6834bd7e6159da957a6c01deebf16132a694bc23) | |
25 | Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> | |
26 | --- | |
27 | arch/x86/include/asm/barrier.h | 3 +++ | |
28 | include/asm-generic/barrier.h | 4 ++++ | |
29 | 2 files changed, 7 insertions(+) | |
30 | ||
31 | diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h | |
32 | index bfb28caf97b1..aae78054cae2 100644 | |
33 | --- a/arch/x86/include/asm/barrier.h | |
34 | +++ b/arch/x86/include/asm/barrier.h | |
35 | @@ -23,6 +23,9 @@ | |
36 | #define wmb() asm volatile("sfence" ::: "memory") | |
37 | #endif | |
38 | ||
39 | +#define gmb() alternative_2("", "mfence", X86_FEATURE_MFENCE_RDTSC, \ | |
40 | + "lfence", X86_FEATURE_LFENCE_RDTSC); | |
41 | + | |
42 | #ifdef CONFIG_X86_PPRO_FENCE | |
43 | #define dma_rmb() rmb() | |
44 | #else | |
45 | diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h | |
46 | index fe297b599b0a..0ee1345c9222 100644 | |
47 | --- a/include/asm-generic/barrier.h | |
48 | +++ b/include/asm-generic/barrier.h | |
49 | @@ -42,6 +42,10 @@ | |
50 | #define wmb() mb() | |
51 | #endif | |
52 | ||
53 | +#ifndef gmb | |
54 | +#define gmb() do { } while (0) | |
55 | +#endif | |
56 | + | |
57 | #ifndef dma_rmb | |
58 | #define dma_rmb() rmb() | |
59 | #endif | |
60 | -- | |
61 | 2.14.2 | |
62 |