summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@mips.com>2017-12-12 04:57:47 -0500
committerPaul Burton <paul.burton@mips.com>2018-07-27 22:36:16 -0400
commit351fdddd366245c0fb4636f32edfb4198c8d6b8c (patch)
treef38034c7a4bdb213123e550302e04e3e3f4c2324
parent24babe69d7ff8d3845fac49b741b7257fb03f906 (diff)
MIPS: VDSO: Prevent use of smp_processor_id()
VDSO code should not be using smp_processor_id(), since it is executed in user mode. Introduce a VDSO-specific path which will cause a compile-time or link-time error (depending upon support for __compiletime_error) if the VDSO ever incorrectly attempts to use smp_processor_id(). [Matt Redfearn <matt.redfearn@imgtec.com>: Move before change to smp_processor_id in series] Signed-off-by: Paul Burton <paul.burton@mips.com> Signed-off-by: Matt Redfearn <matt.redfearn@mips.com> Patchwork: https://patchwork.linux-mips.org/patch/17932/ Cc: Ralf Baechle <ralf@linux-mips.org> Cc: James Hogan <jhogan@kernel.org> Cc: linux-mips@linux-mips.org
-rw-r--r--arch/mips/include/asm/smp.h12
-rw-r--r--arch/mips/vdso/Makefile3
2 files changed, 13 insertions, 2 deletions
diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h
index 88ebd83b3bf9..056a6bf13491 100644
--- a/arch/mips/include/asm/smp.h
+++ b/arch/mips/include/asm/smp.h
@@ -25,7 +25,17 @@ extern cpumask_t cpu_sibling_map[];
25extern cpumask_t cpu_core_map[]; 25extern cpumask_t cpu_core_map[];
26extern cpumask_t cpu_foreign_map[]; 26extern cpumask_t cpu_foreign_map[];
27 27
28#define raw_smp_processor_id() (current_thread_info()->cpu) 28static inline int raw_smp_processor_id(void)
29{
30#if defined(__VDSO__)
31 extern int vdso_smp_processor_id(void)
32 __compiletime_error("VDSO should not call smp_processor_id()");
33 return vdso_smp_processor_id();
34#else
35 return current_thread_info()->cpu;
36#endif
37}
38#define raw_smp_processor_id raw_smp_processor_id
29 39
30/* Map from cpu id to sequential logical cpu number. This will only 40/* Map from cpu id to sequential logical cpu number. This will only
31 not be idempotent when cpus failed to come on-line. */ 41 not be idempotent when cpus failed to come on-line. */
diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
index ce196046ac3e..477c463c89ec 100644
--- a/arch/mips/vdso/Makefile
+++ b/arch/mips/vdso/Makefile
@@ -7,7 +7,8 @@ ccflags-vdso := \
7 $(filter -I%,$(KBUILD_CFLAGS)) \ 7 $(filter -I%,$(KBUILD_CFLAGS)) \
8 $(filter -E%,$(KBUILD_CFLAGS)) \ 8 $(filter -E%,$(KBUILD_CFLAGS)) \
9 $(filter -mmicromips,$(KBUILD_CFLAGS)) \ 9 $(filter -mmicromips,$(KBUILD_CFLAGS)) \
10 $(filter -march=%,$(KBUILD_CFLAGS)) 10 $(filter -march=%,$(KBUILD_CFLAGS)) \
11 -D__VDSO__
11cflags-vdso := $(ccflags-vdso) \ 12cflags-vdso := $(ccflags-vdso) \
12 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 13 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
13 -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ 14 -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \