diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-12-13 19:25:46 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-01-25 17:25:18 -0500 |
commit | 43dbbaaad7b49036a507b7e04af67b766adc41be (patch) | |
tree | 1a52626d5d4a3d80736b0e33f1ac58532f768fab | |
parent | b46045f3fe71fad703ee7d689657af16925d78ca (diff) |
nvgpu: gpu: Add speculation barrier macro
Provide a macro for preventing CPU speculation.
bug 2039126
CVE-2017-5753
Change-Id: Ifa936c079d9f2a0231d0cf35c4d8bdd18d54b238
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1640497
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r-- | drivers/gpu/nvgpu/Makefile | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/barrier.h | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/linux/barrier.h | 2 |
3 files changed, 14 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index 680a9f4f..d70c44e8 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile | |||
@@ -14,6 +14,9 @@ ifeq ($(VERSION),4) | |||
14 | ccflags-y += -Wextra -Wno-unused-parameter -Wno-missing-field-initializers | 14 | ccflags-y += -Wextra -Wno-unused-parameter -Wno-missing-field-initializers |
15 | endif | 15 | endif |
16 | 16 | ||
17 | # Turn off when this is fixed upstream, if ever. | ||
18 | ccflags-y += -D__NVGPU_PREVENT_UNTRUSTED_SPECULATION | ||
19 | |||
17 | obj-$(CONFIG_GK20A) := nvgpu.o | 20 | obj-$(CONFIG_GK20A) := nvgpu.o |
18 | 21 | ||
19 | nvgpu-y := \ | 22 | nvgpu-y := \ |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/barrier.h b/drivers/gpu/nvgpu/include/nvgpu/barrier.h index 01bd3023..03a14a99 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/barrier.h +++ b/drivers/gpu/nvgpu/include/nvgpu/barrier.h | |||
@@ -47,4 +47,13 @@ | |||
47 | 47 | ||
48 | #define NV_ACCESS_ONCE(x) __NV_ACCESS_ONCE(x) | 48 | #define NV_ACCESS_ONCE(x) __NV_ACCESS_ONCE(x) |
49 | 49 | ||
50 | /* | ||
51 | * Sometimes we want to prevent speculation. | ||
52 | */ | ||
53 | #ifdef __NVGPU_PREVENT_UNTRUSTED_SPECULATION | ||
54 | #define nvgpu_speculation_barrier() __nvgpu_speculation_barrier() | ||
55 | #else | ||
56 | #define nvgpu_speculation_barrier() | ||
57 | #endif | ||
58 | |||
50 | #endif /* __NVGPU_BARRIER_H__ */ | 59 | #endif /* __NVGPU_BARRIER_H__ */ |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/barrier.h b/drivers/gpu/nvgpu/include/nvgpu/linux/barrier.h index b20f9462..ef867c44 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/linux/barrier.h +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/barrier.h | |||
@@ -32,4 +32,6 @@ | |||
32 | 32 | ||
33 | #define __NV_ACCESS_ONCE(x) ACCESS_ONCE(x) | 33 | #define __NV_ACCESS_ONCE(x) ACCESS_ONCE(x) |
34 | 34 | ||
35 | #define __nvgpu_speculation_barrier() speculation_barrier() | ||
36 | |||
35 | #endif /* __NVGPU_BARRIER_LINUX_H__ */ | 37 | #endif /* __NVGPU_BARRIER_LINUX_H__ */ |