diff options
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0032-x86-microcode-Sanitize-per-cpu-microcode-reloading-i.patch')
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0032-x86-microcode-Sanitize-per-cpu-microcode-reloading-i.patch | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0032-x86-microcode-Sanitize-per-cpu-microcode-reloading-i.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0032-x86-microcode-Sanitize-per-cpu-microcode-reloading-i.patch new file mode 100644 index 00000000..824c0394 --- /dev/null +++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0032-x86-microcode-Sanitize-per-cpu-microcode-reloading-i.patch | |||
@@ -0,0 +1,92 @@ | |||
1 | From 6a7d02f3957e572d5e35fc71df90a3a7311e383d Mon Sep 17 00:00:00 2001 | ||
2 | From: Borislav Petkov <borislav.petkov@amd.com> | ||
3 | Date: Thu, 21 Jun 2012 14:07:16 +0200 | ||
4 | Subject: [PATCH 32/73] x86, microcode: Sanitize per-cpu microcode reloading | ||
5 | interface | ||
6 | |||
7 | commit c9fc3f778a6a215ace14ee556067c73982b6d40f upstream. | ||
8 | |||
9 | Microcode reloading in a per-core manner is a very bad idea for both | ||
10 | major x86 vendors. And the thing is, we have such interface with which | ||
11 | we can end up with different microcode versions applied on different | ||
12 | cores of an otherwise homogeneous wrt (family,model,stepping) system. | ||
13 | |||
14 | So turn off the possibility of doing that per core and allow it only | ||
15 | system-wide. | ||
16 | |||
17 | This is a minimal fix which we'd like to see in stable too thus the | ||
18 | more-or-less arbitrary decision to allow system-wide reloading only on | ||
19 | the BSP: | ||
20 | |||
21 | $ echo 1 > /sys/devices/system/cpu/cpu0/microcode/reload | ||
22 | ... | ||
23 | |||
24 | and disable the interface on the other cores: | ||
25 | |||
26 | $ echo 1 > /sys/devices/system/cpu/cpu23/microcode/reload | ||
27 | -bash: echo: write error: Invalid argument | ||
28 | |||
29 | Also, allowing the reload only from one CPU (the BSP in | ||
30 | that case) doesn't allow the reload procedure to degenerate | ||
31 | into an O(n^2) deal when triggering reloads from all | ||
32 | /sys/devices/system/cpu/cpuX/microcode/reload sysfs nodes | ||
33 | simultaneously. | ||
34 | |||
35 | A more generic fix will follow. | ||
36 | |||
37 | Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br> | ||
38 | Cc: Peter Zijlstra <peterz@infradead.org> | ||
39 | Signed-off-by: Borislav Petkov <borislav.petkov@amd.com> | ||
40 | Link: http://lkml.kernel.org/r/1340280437-7718-2-git-send-email-bp@amd64.org | ||
41 | Signed-off-by: H. Peter Anvin <hpa@zytor.com> | ||
42 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | ||
43 | --- | ||
44 | arch/x86/kernel/microcode_core.c | 26 +++++++++++++++++++------- | ||
45 | 1 files changed, 19 insertions(+), 7 deletions(-) | ||
46 | |||
47 | diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c | ||
48 | index 19c7af1..29c95d7 100644 | ||
49 | --- a/arch/x86/kernel/microcode_core.c | ||
50 | +++ b/arch/x86/kernel/microcode_core.c | ||
51 | @@ -297,19 +297,31 @@ static ssize_t reload_store(struct sys_device *dev, | ||
52 | const char *buf, size_t size) | ||
53 | { | ||
54 | unsigned long val; | ||
55 | - int cpu = dev->id; | ||
56 | - ssize_t ret = 0; | ||
57 | + int cpu; | ||
58 | + ssize_t ret = 0, tmp_ret; | ||
59 | + | ||
60 | + /* allow reload only from the BSP */ | ||
61 | + if (boot_cpu_data.cpu_index != dev->id) | ||
62 | + return -EINVAL; | ||
63 | |||
64 | ret = kstrtoul(buf, 0, &val); | ||
65 | if (ret) | ||
66 | return ret; | ||
67 | |||
68 | - if (val == 1) { | ||
69 | - get_online_cpus(); | ||
70 | - if (cpu_online(cpu)) | ||
71 | - ret = reload_for_cpu(cpu); | ||
72 | - put_online_cpus(); | ||
73 | + if (val != 1) | ||
74 | + return size; | ||
75 | + | ||
76 | + get_online_cpus(); | ||
77 | + for_each_online_cpu(cpu) { | ||
78 | + tmp_ret = reload_for_cpu(cpu); | ||
79 | + if (tmp_ret != 0) | ||
80 | + pr_warn("Error reloading microcode on CPU %d\n", cpu); | ||
81 | + | ||
82 | + /* save retval of the first encountered reload error */ | ||
83 | + if (!ret) | ||
84 | + ret = tmp_ret; | ||
85 | } | ||
86 | + put_online_cpus(); | ||
87 | |||
88 | if (!ret) | ||
89 | ret = size; | ||
90 | -- | ||
91 | 1.7.7.6 | ||
92 | |||