Skip to content

Commit e209950

Browse files
author
Russell King
committed
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>
1 parent 945aceb commit e209950

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

‎arch/arm/include/asm/proc-fns.h‎

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct mm_struct;
2323
/*
2424
* Don't change this structure - ASM code relies on it.
2525
*/
26-
extern struct processor {
26+
struct processor {
2727
/* MISC
2828
* get data abort address/flags
2929
*/
@@ -79,9 +79,13 @@ extern struct processor {
7979
unsigned int suspend_size;
8080
void (*do_suspend)(void *);
8181
void (*do_resume)(void *);
82-
} processor;
82+
};
8383

8484
#ifndef MULTI_CPU
85+
static inline void init_proc_vtable(const struct processor *p)
86+
{
87+
}
88+
8589
extern void cpu_proc_init(void);
8690
extern void cpu_proc_fin(void);
8791
extern int cpu_do_idle(void);
@@ -98,18 +102,27 @@ extern void cpu_reset(unsigned long addr, bool hvc) __attribute__((noreturn));
98102
extern void cpu_do_suspend(void *);
99103
extern void cpu_do_resume(void *);
100104
#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
109105

110-
/* These three are private to arch/arm/kernel/suspend.c */
111-
#define cpu_do_suspend processor.do_suspend
112-
#define cpu_do_resume processor.do_resume
106+
extern struct processor processor;
107+
#define PROC_VTABLE(f) processor.f
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)
113126
#endif
114127

115128
extern void cpu_resume(void);

‎arch/arm/kernel/setup.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,7 @@ static void __init setup_processor(void)
693693
cpu_name = list->cpu_name;
694694
__cpu_architecture = __get_cpu_architecture();
695695

696-
#ifdef MULTI_CPU
697-
processor = *list->proc;
698-
#endif
696+
init_proc_vtable(list->proc);
699697
#ifdef MULTI_TLB
700698
cpu_tlb = *list->tlb;
701699
#endif

0 commit comments

Comments
 (0)