diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2018-07-19 07:17:38 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2018-11-12 05:51:01 -0500 |
commit | e209950fdd065d2cc46e6338e47e52841b830cba (patch) | |
tree | 750f1350edd2beea0ebeb9edf254a4b82eac2398 | |
parent | 945aceb1db8885d3a35790cf2e810f681db52756 (diff) |
ARM: add PROC_VTABLE and PROC_TABLE macros
Allow the way we access members of the processor vtable to be changed
at compile time. We will need to move to per-CPU vtables to fix the
Spectre variant 2 issues on big.Little systems.
However, we have a couple of calls that do not need the vtable
treatment, and indeed cause a kernel warning due to the (later) use
of smp_processor_id(), so also introduce the PROC_TABLE macro for
these which always use CPU 0's function pointers.
Reviewed-by: Julien Thierry <julien.thierry@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r-- | arch/arm/include/asm/proc-fns.h | 39 | ||||
-rw-r--r-- | arch/arm/kernel/setup.c | 4 |
2 files changed, 27 insertions, 16 deletions
diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index 30c499146320..c259cc49c641 100644 --- a/arch/arm/include/asm/proc-fns.h +++ b/arch/arm/include/asm/proc-fns.h | |||
@@ -23,7 +23,7 @@ struct mm_struct; | |||
23 | /* | 23 | /* |
24 | * Don't change this structure - ASM code relies on it. | 24 | * Don't change this structure - ASM code relies on it. |
25 | */ | 25 | */ |
26 | extern struct processor { | 26 | struct processor { |
27 | /* MISC | 27 | /* MISC |
28 | * get data abort address/flags | 28 | * get data abort address/flags |
29 | */ | 29 | */ |
@@ -79,9 +79,13 @@ extern struct processor { | |||
79 | unsigned int suspend_size; | 79 | unsigned int suspend_size; |
80 | void (*do_suspend)(void *); | 80 | void (*do_suspend)(void *); |
81 | void (*do_resume)(void *); | 81 | void (*do_resume)(void *); |
82 | } processor; | 82 | }; |
83 | 83 | ||
84 | #ifndef MULTI_CPU | 84 | #ifndef MULTI_CPU |
85 | static inline void init_proc_vtable(const struct processor *p) | ||
86 | { | ||
87 | } | ||
88 | |||
85 | extern void cpu_proc_init(void); | 89 | extern void cpu_proc_init(void); |
86 | extern void cpu_proc_fin(void); | 90 | extern void cpu_proc_fin(void); |
87 | extern int cpu_do_idle(void); | 91 | extern int cpu_do_idle(void); |
@@ -98,18 +102,27 @@ extern void cpu_reset(unsigned long addr, bool hvc) __attribute__((noreturn)); | |||
98 | extern void cpu_do_suspend(void *); | 102 | extern void cpu_do_suspend(void *); |
99 | extern void cpu_do_resume(void *); | 103 | extern void cpu_do_resume(void *); |
100 | #else | 104 | #else |
101 | #define cpu_proc_init processor._proc_init | ||
102 | #define cpu_check_bugs processor.check_bugs | ||
103 | #define cpu_proc_fin processor._proc_fin | ||
104 | #define cpu_reset processor.reset | ||
105 | #define cpu_do_idle processor._do_idle | ||
106 | #define cpu_dcache_clean_area processor.dcache_clean_area | ||
107 | #define cpu_set_pte_ext processor.set_pte_ext | ||
108 | #define cpu_do_switch_mm processor.switch_mm | ||
109 | 105 | ||
110 | /* These three are private to arch/arm/kernel/suspend.c */ | 106 | extern struct processor processor; |
111 | #define cpu_do_suspend processor.do_suspend | 107 | #define PROC_VTABLE(f) processor.f |
112 | #define cpu_do_resume processor.do_resume | 108 | #define PROC_TABLE(f) processor.f |
109 | static inline void init_proc_vtable(const struct processor *p) | ||
110 | { | ||
111 | processor = *p; | ||
112 | } | ||
113 | |||
114 | #define cpu_proc_init PROC_VTABLE(_proc_init) | ||
115 | #define cpu_check_bugs PROC_VTABLE(check_bugs) | ||
116 | #define cpu_proc_fin PROC_VTABLE(_proc_fin) | ||
117 | #define cpu_reset PROC_VTABLE(reset) | ||
118 | #define cpu_do_idle PROC_VTABLE(_do_idle) | ||
119 | #define cpu_dcache_clean_area PROC_TABLE(dcache_clean_area) | ||
120 | #define cpu_set_pte_ext PROC_TABLE(set_pte_ext) | ||
121 | #define cpu_do_switch_mm PROC_VTABLE(switch_mm) | ||
122 | |||
123 | /* These two are private to arch/arm/kernel/suspend.c */ | ||
124 | #define cpu_do_suspend PROC_VTABLE(do_suspend) | ||
125 | #define cpu_do_resume PROC_VTABLE(do_resume) | ||
113 | #endif | 126 | #endif |
114 | 127 | ||
115 | extern void cpu_resume(void); | 128 | extern void cpu_resume(void); |
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 05a4eb6b0d01..c214bd14a1fe 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c | |||
@@ -693,9 +693,7 @@ static void __init setup_processor(void) | |||
693 | cpu_name = list->cpu_name; | 693 | cpu_name = list->cpu_name; |
694 | __cpu_architecture = __get_cpu_architecture(); | 694 | __cpu_architecture = __get_cpu_architecture(); |
695 | 695 | ||
696 | #ifdef MULTI_CPU | 696 | init_proc_vtable(list->proc); |
697 | processor = *list->proc; | ||
698 | #endif | ||
699 | #ifdef MULTI_TLB | 697 | #ifdef MULTI_TLB |
700 | cpu_tlb = *list->tlb; | 698 | cpu_tlb = *list->tlb; |
701 | #endif | 699 | #endif |