]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0019-sh-cpu-Switch-to-arch_cpu_finalize_init.patch
add fixes for downfall
[pve-kernel.git] / patches / kernel / 0019-sh-cpu-Switch-to-arch_cpu_finalize_init.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Wed, 14 Jun 2023 01:39:33 +0200
4 Subject: [PATCH] sh/cpu: Switch to arch_cpu_finalize_init()
5
6 check_bugs() is about to be phased out. Switch over to the new
7 arch_cpu_finalize_init() implementation.
8
9 No functional change.
10
11 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
12 Link: https://lore.kernel.org/r/20230613224545.371697797@linutronix.de
13
14 (cherry picked from commit 01eb454e9bfe593f320ecbc9aaec60bf87cd453d)
15 CVE-2022-40982
16 Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
17 Acked-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
18 Acked-by: Stefan Bader <stefan.bader@canonical.com>
19 Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
20 (cherry picked from commit 5228732d7ec3b9d13ee33b613dd3ed9c7f6a4695)
21 Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
22 ---
23 arch/sh/Kconfig | 1 +
24 arch/sh/include/asm/bugs.h | 74 ---------------------------------
25 arch/sh/include/asm/processor.h | 2 +
26 arch/sh/kernel/idle.c | 1 +
27 arch/sh/kernel/setup.c | 55 ++++++++++++++++++++++++
28 5 files changed, 59 insertions(+), 74 deletions(-)
29 delete mode 100644 arch/sh/include/asm/bugs.h
30
31 diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
32 index 101a0d094a66..b0284730e761 100644
33 --- a/arch/sh/Kconfig
34 +++ b/arch/sh/Kconfig
35 @@ -7,6 +7,7 @@ config SUPERH
36 select ARCH_HAVE_CUSTOM_GPIO_H
37 select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
38 select ARCH_HAS_BINFMT_FLAT if !MMU
39 + select ARCH_HAS_CPU_FINALIZE_INIT
40 select ARCH_HAS_CURRENT_STACK_POINTER
41 select ARCH_HAS_GIGANTIC_PAGE
42 select ARCH_HAS_GCOV_PROFILE_ALL
43 diff --git a/arch/sh/include/asm/bugs.h b/arch/sh/include/asm/bugs.h
44 deleted file mode 100644
45 index fe52abb69cea..000000000000
46 --- a/arch/sh/include/asm/bugs.h
47 +++ /dev/null
48 @@ -1,74 +0,0 @@
49 -/* SPDX-License-Identifier: GPL-2.0 */
50 -#ifndef __ASM_SH_BUGS_H
51 -#define __ASM_SH_BUGS_H
52 -
53 -/*
54 - * This is included by init/main.c to check for architecture-dependent bugs.
55 - *
56 - * Needs:
57 - * void check_bugs(void);
58 - */
59 -
60 -/*
61 - * I don't know of any Super-H bugs yet.
62 - */
63 -
64 -#include <asm/processor.h>
65 -
66 -extern void select_idle_routine(void);
67 -
68 -static void __init check_bugs(void)
69 -{
70 - extern unsigned long loops_per_jiffy;
71 - char *p = &init_utsname()->machine[2]; /* "sh" */
72 -
73 - select_idle_routine();
74 -
75 - current_cpu_data.loops_per_jiffy = loops_per_jiffy;
76 -
77 - switch (current_cpu_data.family) {
78 - case CPU_FAMILY_SH2:
79 - *p++ = '2';
80 - break;
81 - case CPU_FAMILY_SH2A:
82 - *p++ = '2';
83 - *p++ = 'a';
84 - break;
85 - case CPU_FAMILY_SH3:
86 - *p++ = '3';
87 - break;
88 - case CPU_FAMILY_SH4:
89 - *p++ = '4';
90 - break;
91 - case CPU_FAMILY_SH4A:
92 - *p++ = '4';
93 - *p++ = 'a';
94 - break;
95 - case CPU_FAMILY_SH4AL_DSP:
96 - *p++ = '4';
97 - *p++ = 'a';
98 - *p++ = 'l';
99 - *p++ = '-';
100 - *p++ = 'd';
101 - *p++ = 's';
102 - *p++ = 'p';
103 - break;
104 - case CPU_FAMILY_UNKNOWN:
105 - /*
106 - * Specifically use CPU_FAMILY_UNKNOWN rather than
107 - * default:, so we're able to have the compiler whine
108 - * about unhandled enumerations.
109 - */
110 - break;
111 - }
112 -
113 - printk("CPU: %s\n", get_cpu_subtype(&current_cpu_data));
114 -
115 -#ifndef __LITTLE_ENDIAN__
116 - /* 'eb' means 'Endian Big' */
117 - *p++ = 'e';
118 - *p++ = 'b';
119 -#endif
120 - *p = '\0';
121 -}
122 -#endif /* __ASM_SH_BUGS_H */
123 diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h
124 index 85a6c1c3c16e..73fba7c922f9 100644
125 --- a/arch/sh/include/asm/processor.h
126 +++ b/arch/sh/include/asm/processor.h
127 @@ -166,6 +166,8 @@ extern unsigned int instruction_size(unsigned int insn);
128 #define instruction_size(insn) (2)
129 #endif
130
131 +void select_idle_routine(void);
132 +
133 #endif /* __ASSEMBLY__ */
134
135 #include <asm/processor_32.h>
136 diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
137 index f59814983bd5..a80b2a5b25c7 100644
138 --- a/arch/sh/kernel/idle.c
139 +++ b/arch/sh/kernel/idle.c
140 @@ -14,6 +14,7 @@
141 #include <linux/irqflags.h>
142 #include <linux/smp.h>
143 #include <linux/atomic.h>
144 +#include <asm/processor.h>
145 #include <asm/smp.h>
146 #include <asm/bl_bit.h>
147
148 diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
149 index af977ec4ca5e..cf7c0f72f293 100644
150 --- a/arch/sh/kernel/setup.c
151 +++ b/arch/sh/kernel/setup.c
152 @@ -43,6 +43,7 @@
153 #include <asm/smp.h>
154 #include <asm/mmu_context.h>
155 #include <asm/mmzone.h>
156 +#include <asm/processor.h>
157 #include <asm/sparsemem.h>
158 #include <asm/platform_early.h>
159
160 @@ -354,3 +355,57 @@ int test_mode_pin(int pin)
161 {
162 return sh_mv.mv_mode_pins() & pin;
163 }
164 +
165 +void __init arch_cpu_finalize_init(void)
166 +{
167 + char *p = &init_utsname()->machine[2]; /* "sh" */
168 +
169 + select_idle_routine();
170 +
171 + current_cpu_data.loops_per_jiffy = loops_per_jiffy;
172 +
173 + switch (current_cpu_data.family) {
174 + case CPU_FAMILY_SH2:
175 + *p++ = '2';
176 + break;
177 + case CPU_FAMILY_SH2A:
178 + *p++ = '2';
179 + *p++ = 'a';
180 + break;
181 + case CPU_FAMILY_SH3:
182 + *p++ = '3';
183 + break;
184 + case CPU_FAMILY_SH4:
185 + *p++ = '4';
186 + break;
187 + case CPU_FAMILY_SH4A:
188 + *p++ = '4';
189 + *p++ = 'a';
190 + break;
191 + case CPU_FAMILY_SH4AL_DSP:
192 + *p++ = '4';
193 + *p++ = 'a';
194 + *p++ = 'l';
195 + *p++ = '-';
196 + *p++ = 'd';
197 + *p++ = 's';
198 + *p++ = 'p';
199 + break;
200 + case CPU_FAMILY_UNKNOWN:
201 + /*
202 + * Specifically use CPU_FAMILY_UNKNOWN rather than
203 + * default:, so we're able to have the compiler whine
204 + * about unhandled enumerations.
205 + */
206 + break;
207 + }
208 +
209 + pr_info("CPU: %s\n", get_cpu_subtype(&current_cpu_data));
210 +
211 +#ifndef __LITTLE_ENDIAN__
212 + /* 'eb' means 'Endian Big' */
213 + *p++ = 'e';
214 + *p++ = 'b';
215 +#endif
216 + *p = '\0';
217 +}