| @@ -1,479 +1,479 @@ | | | @@ -1,479 +1,479 @@ |
1 | /* $NetBSD: errata.c,v 1.23.10.2 2023/07/25 09:15:28 martin Exp $ */ | | 1 | /* $NetBSD: errata.c,v 1.23.10.3 2023/07/27 16:42:04 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Detect, report on, and work around known errata with x86 CPUs. | | 33 | * Detect, report on, and work around known errata with x86 CPUs. |
34 | * | | 34 | * |
35 | * This currently only handles AMD CPUs, and is generalised because | | 35 | * This currently only handles AMD CPUs, and is generalised because |
36 | * there are quite a few problems that the BIOS can patch via MSR, | | 36 | * there are quite a few problems that the BIOS can patch via MSR, |
37 | * but it is not known if the OS can patch these yet. The list is | | 37 | * but it is not known if the OS can patch these yet. The list is |
38 | * expected to grow over time. | | 38 | * expected to grow over time. |
39 | * | | 39 | * |
40 | * The data here are from: Revision Guide for AMD Athlon 64 and | | 40 | * The data here are from: Revision Guide for AMD Athlon 64 and |
41 | * AMD Opteron Processors, Publication #25759, Revision: 3.69, | | 41 | * AMD Opteron Processors, Publication #25759, Revision: 3.69, |
42 | * Issue Date: September 2006 | | 42 | * Issue Date: September 2006 |
43 | * | | 43 | * |
44 | * XXX This should perhaps be integrated with the identcpu code. | | 44 | * XXX This should perhaps be integrated with the identcpu code. |
45 | */ | | 45 | */ |
46 | | | 46 | |
47 | #include <sys/cdefs.h> | | 47 | #include <sys/cdefs.h> |
48 | __KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.23.10.2 2023/07/25 09:15:28 martin Exp $"); | | 48 | __KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.23.10.3 2023/07/27 16:42:04 martin Exp $"); |
49 | | | 49 | |
50 | #include <sys/types.h> | | 50 | #include <sys/types.h> |
51 | #include <sys/systm.h> | | 51 | #include <sys/systm.h> |
52 | | | 52 | |
53 | #include <machine/cpu.h> | | 53 | #include <machine/cpu.h> |
54 | #include <machine/cpufunc.h> | | 54 | #include <machine/cpufunc.h> |
55 | #include <machine/specialreg.h> | | 55 | #include <machine/specialreg.h> |
56 | | | 56 | |
57 | #include <x86/cpuvar.h> | | 57 | #include <x86/cpuvar.h> |
58 | #include <x86/cputypes.h> | | 58 | #include <x86/cputypes.h> |
59 | | | 59 | |
60 | typedef struct errata { | | 60 | typedef struct errata { |
61 | u_short e_num; | | 61 | u_short e_num; |
62 | u_short e_reported; | | 62 | u_short e_reported; |
63 | u_int e_data1; | | 63 | u_int e_data1; |
64 | const uint8_t *e_set; | | 64 | const uint8_t *e_set; |
65 | bool (*e_act)(struct cpu_info *, struct errata *); | | 65 | bool (*e_act)(struct cpu_info *, struct errata *); |
66 | uint64_t e_data2; | | 66 | uint64_t e_data2; |
67 | } errata_t; | | 67 | } errata_t; |
68 | | | 68 | |
69 | typedef enum cpurev { | | 69 | typedef enum cpurev { |
70 | BH_E4, CH_CG, CH_D0, DH_CG, DH_D0, DH_E3, DH_E6, JH_E1, | | 70 | BH_E4, CH_CG, CH_D0, DH_CG, DH_D0, DH_E3, DH_E6, JH_E1, |
71 | JH_E6, SH_B0, SH_B3, SH_C0, SH_CG, SH_D0, SH_E4, SH_E5, | | 71 | JH_E6, SH_B0, SH_B3, SH_C0, SH_CG, SH_D0, SH_E4, SH_E5, |
72 | DR_BA, DR_B2, DR_B3, RB_C2, RB_C3, BL_C2, BL_C3, DA_C2, | | 72 | DR_BA, DR_B2, DR_B3, RB_C2, RB_C3, BL_C2, BL_C3, DA_C2, |
73 | DA_C3, HY_D0, HY_D1, HY_D1_G34R1, PH_E0, LN_B0, KB_A1, | | 73 | DA_C3, HY_D0, HY_D1, HY_D1_G34R1, PH_E0, LN_B0, KB_A1, |
74 | ML_A1, ZP_B1, ZP_B2, PiR_B2, Rome_B0, Z2_XB, Z2_Ren, | | 74 | ML_A1, ZP_B1, ZP_B2, PiR_B2, Rome_B0, Z2_XB, Z2_Ren, |
75 | Z2_Luc, Z2_Mat, Z2_VG, Z2_Men, Milan_B1, Milan_B2, Genoa_B1, | | 75 | Z2_Luc, Z2_Mat, Z2_VG, Z2_Men, Milan_B1, Milan_B2, Genoa_B1, |
76 | OINK | | 76 | OINK |
77 | } cpurev_t; | | 77 | } cpurev_t; |
78 | | | 78 | |
79 | /* These names match names from various AMD Errata/Revision Guides. */ | | 79 | /* These names match names from various AMD Errata/Revision Guides. */ |
80 | static const u_int cpurevs[] = { | | 80 | static const u_int cpurevs[] = { |
81 | BH_E4, 0x0020fb1, CH_CG, 0x0000f82, CH_CG, 0x0000fb2, | | 81 | BH_E4, 0x0020fb1, CH_CG, 0x0000f82, CH_CG, 0x0000fb2, |
82 | CH_D0, 0x0010f80, CH_D0, 0x0010fb0, DH_CG, 0x0000fc0, | | 82 | CH_D0, 0x0010f80, CH_D0, 0x0010fb0, DH_CG, 0x0000fc0, |
83 | DH_CG, 0x0000fe0, DH_CG, 0x0000ff0, DH_D0, 0x0010fc0, | | 83 | DH_CG, 0x0000fe0, DH_CG, 0x0000ff0, DH_D0, 0x0010fc0, |
84 | DH_D0, 0x0010ff0, DH_E3, 0x0020fc0, DH_E3, 0x0020ff0, | | 84 | DH_D0, 0x0010ff0, DH_E3, 0x0020fc0, DH_E3, 0x0020ff0, |
85 | DH_E6, 0x0020fc2, DH_E6, 0x0020ff2, JH_E1, 0x0020f10, | | 85 | DH_E6, 0x0020fc2, DH_E6, 0x0020ff2, JH_E1, 0x0020f10, |
86 | JH_E6, 0x0020f12, JH_E6, 0x0020f32, SH_B0, 0x0000f40, | | 86 | JH_E6, 0x0020f12, JH_E6, 0x0020f32, SH_B0, 0x0000f40, |
87 | SH_B3, 0x0000f51, SH_C0, 0x0000f48, SH_C0, 0x0000f58, | | 87 | SH_B3, 0x0000f51, SH_C0, 0x0000f48, SH_C0, 0x0000f58, |
88 | SH_CG, 0x0000f4a, SH_CG, 0x0000f5a, SH_CG, 0x0000f7a, | | 88 | SH_CG, 0x0000f4a, SH_CG, 0x0000f5a, SH_CG, 0x0000f7a, |
89 | SH_D0, 0x0010f40, SH_D0, 0x0010f50, SH_D0, 0x0010f70, | | 89 | SH_D0, 0x0010f40, SH_D0, 0x0010f50, SH_D0, 0x0010f70, |
90 | SH_E4, 0x0020f51, SH_E4, 0x0020f71, SH_E5, 0x0020f42, | | 90 | SH_E4, 0x0020f51, SH_E4, 0x0020f71, SH_E5, 0x0020f42, |
91 | DR_BA, 0x0100f2a, DR_B2, 0x0100f22, DR_B3, 0x0100f23, | | 91 | DR_BA, 0x0100f2a, DR_B2, 0x0100f22, DR_B3, 0x0100f23, |
92 | RB_C2, 0x0100f42, RB_C3, 0x0100f43, BL_C2, 0x0100f52, | | 92 | RB_C2, 0x0100f42, RB_C3, 0x0100f43, BL_C2, 0x0100f52, |
93 | BL_C3, 0x0100f53, DA_C2, 0x0100f62, DA_C3, 0x0100f63, | | 93 | BL_C3, 0x0100f53, DA_C2, 0x0100f62, DA_C3, 0x0100f63, |
94 | HY_D0, 0x0100f80, HY_D1, 0x0100f81, HY_D1_G34R1, 0x0100f91, | | 94 | HY_D0, 0x0100f80, HY_D1, 0x0100f81, HY_D1_G34R1, 0x0100f91, |
95 | PH_E0, 0x0100fa0, LN_B0, 0x0300f10, KB_A1, 0x0700F01, | | 95 | PH_E0, 0x0100fa0, LN_B0, 0x0300f10, KB_A1, 0x0700F01, |
96 | ML_A1, 0x0730F01, ZP_B1, 0x0800F11, ZP_B2, 0x0800F12, | | 96 | ML_A1, 0x0730F01, ZP_B1, 0x0800F11, ZP_B2, 0x0800F12, |
97 | PiR_B2, 0x0800F82, Rome_B0, 0x0830F10, | | 97 | PiR_B2, 0x0800F82, Rome_B0, 0x0830F10, |
98 | /* XXX client Zen2 names aren't known yet. */ | | 98 | /* XXX client Zen2 names aren't known yet. */ |
99 | Z2_XB, 0x0840F70, Z2_Ren, 0x0860F80, Z2_Luc, 0x0870F10, | | 99 | Z2_XB, 0x0840F70, Z2_Ren, 0x0860F01, Z2_Luc, 0x0860F81, |
100 | Z2_Mat, 0x0890F70, Z2_VG, 0x0890F80, Z2_Men, 0x08A0F10, | | 100 | Z2_Mat, 0x0870F10, Z2_VG, 0x0890F02, Z2_Men, 0x08A0F00, |
101 | Milan_B1, 0x0A00F11, Milan_B2, 0x0A00F12, | | 101 | Milan_B1, 0x0A00F11, Milan_B2, 0x0A00F12, |
102 | Genoa_B1, 0x0A10F11, | | 102 | Genoa_B1, 0x0A10F11, |
103 | OINK | | 103 | OINK |
104 | }; | | 104 | }; |
105 | | | 105 | |
106 | static const uint8_t x86_errata_set1[] = { | | 106 | static const uint8_t x86_errata_set1[] = { |
107 | SH_B3, SH_C0, SH_CG, DH_CG, CH_CG, OINK | | 107 | SH_B3, SH_C0, SH_CG, DH_CG, CH_CG, OINK |
108 | }; | | 108 | }; |
109 | | | 109 | |
110 | static const uint8_t x86_errata_set2[] = { | | 110 | static const uint8_t x86_errata_set2[] = { |
111 | SH_B3, SH_C0, SH_CG, DH_CG, CH_CG, SH_D0, DH_D0, CH_D0, OINK | | 111 | SH_B3, SH_C0, SH_CG, DH_CG, CH_CG, SH_D0, DH_D0, CH_D0, OINK |
112 | }; | | 112 | }; |
113 | | | 113 | |
114 | static const uint8_t x86_errata_set3[] = { | | 114 | static const uint8_t x86_errata_set3[] = { |
115 | JH_E1, DH_E3, OINK | | 115 | JH_E1, DH_E3, OINK |
116 | }; | | 116 | }; |
117 | | | 117 | |
118 | static const uint8_t x86_errata_set4[] = { | | 118 | static const uint8_t x86_errata_set4[] = { |
119 | SH_C0, SH_CG, DH_CG, CH_CG, SH_D0, DH_D0, CH_D0, JH_E1, | | 119 | SH_C0, SH_CG, DH_CG, CH_CG, SH_D0, DH_D0, CH_D0, JH_E1, |
120 | DH_E3, SH_E4, BH_E4, SH_E5, DH_E6, JH_E6, OINK | | 120 | DH_E3, SH_E4, BH_E4, SH_E5, DH_E6, JH_E6, OINK |
121 | }; | | 121 | }; |
122 | | | 122 | |
123 | static const uint8_t x86_errata_set5[] = { | | 123 | static const uint8_t x86_errata_set5[] = { |
124 | SH_B3, OINK | | 124 | SH_B3, OINK |
125 | }; | | 125 | }; |
126 | | | 126 | |
127 | static const uint8_t x86_errata_set6[] = { | | 127 | static const uint8_t x86_errata_set6[] = { |
128 | SH_C0, SH_CG, DH_CG, CH_CG, OINK | | 128 | SH_C0, SH_CG, DH_CG, CH_CG, OINK |
129 | }; | | 129 | }; |
130 | | | 130 | |
131 | static const uint8_t x86_errata_set7[] = { | | 131 | static const uint8_t x86_errata_set7[] = { |
132 | SH_C0, SH_CG, DH_CG, CH_CG, SH_D0, DH_D0, CH_D0, OINK | | 132 | SH_C0, SH_CG, DH_CG, CH_CG, SH_D0, DH_D0, CH_D0, OINK |
133 | }; | | 133 | }; |
134 | | | 134 | |
135 | static const uint8_t x86_errata_set8[] = { | | 135 | static const uint8_t x86_errata_set8[] = { |
136 | BH_E4, CH_CG, CH_CG, CH_D0, CH_D0, DH_CG, DH_CG, DH_CG, | | 136 | BH_E4, CH_CG, CH_CG, CH_D0, CH_D0, DH_CG, DH_CG, DH_CG, |
137 | DH_D0, DH_D0, DH_E3, DH_E3, DH_E6, DH_E6, JH_E1, JH_E6, | | 137 | DH_D0, DH_D0, DH_E3, DH_E3, DH_E6, DH_E6, JH_E1, JH_E6, |
138 | JH_E6, SH_B0, SH_B3, SH_C0, SH_C0, SH_CG, SH_CG, SH_CG, | | 138 | JH_E6, SH_B0, SH_B3, SH_C0, SH_C0, SH_CG, SH_CG, SH_CG, |
139 | SH_D0, SH_D0, SH_D0, SH_E4, SH_E4, SH_E5, OINK | | 139 | SH_D0, SH_D0, SH_D0, SH_E4, SH_E4, SH_E5, OINK |
140 | }; | | 140 | }; |
141 | | | 141 | |
142 | static const uint8_t x86_errata_set9[] = { | | 142 | static const uint8_t x86_errata_set9[] = { |
143 | DR_BA, DR_B2, OINK | | 143 | DR_BA, DR_B2, OINK |
144 | }; | | 144 | }; |
145 | | | 145 | |
146 | static const uint8_t x86_errata_set10[] = { | | 146 | static const uint8_t x86_errata_set10[] = { |
147 | DR_BA, DR_B2, DR_B3, OINK | | 147 | DR_BA, DR_B2, DR_B3, OINK |
148 | }; | | 148 | }; |
149 | | | 149 | |
150 | static const uint8_t x86_errata_set11[] = { | | 150 | static const uint8_t x86_errata_set11[] = { |
151 | DR_BA, DR_B2, DR_B3, RB_C2, RB_C3, BL_C2, BL_C3, DA_C2, | | 151 | DR_BA, DR_B2, DR_B3, RB_C2, RB_C3, BL_C2, BL_C3, DA_C2, |
152 | DA_C3, HY_D0, HY_D1, HY_D1_G34R1, PH_E0, LN_B0, OINK | | 152 | DA_C3, HY_D0, HY_D1, HY_D1_G34R1, PH_E0, LN_B0, OINK |
153 | }; | | 153 | }; |
154 | | | 154 | |
155 | static const uint8_t x86_errata_set12[] = { | | 155 | static const uint8_t x86_errata_set12[] = { |
156 | KB_A1, OINK | | 156 | KB_A1, OINK |
157 | }; | | 157 | }; |
158 | | | 158 | |
159 | static const uint8_t x86_errata_set13[] = { | | 159 | static const uint8_t x86_errata_set13[] = { |
160 | ZP_B1, ZP_B2, PiR_B2, OINK | | 160 | ZP_B1, ZP_B2, PiR_B2, OINK |
161 | }; | | 161 | }; |
162 | | | 162 | |
163 | static const uint8_t x86_errata_set14[] = { | | 163 | static const uint8_t x86_errata_set14[] = { |
164 | ZP_B1, OINK | | 164 | ZP_B1, OINK |
165 | }; | | 165 | }; |
166 | | | 166 | |
167 | static const uint8_t x86_errata_set15[] = { | | 167 | static const uint8_t x86_errata_set15[] = { |
168 | KB_A1, ML_A1, OINK | | 168 | KB_A1, ML_A1, OINK |
169 | }; | | 169 | }; |
170 | | | 170 | |
171 | static const uint8_t x86_errata_set16[] = { | | 171 | static const uint8_t x86_errata_set16[] = { |
172 | Rome_B0, Z2_XB, Z2_Ren, Z2_Luc, Z2_Mat, Z2_VG, Z2_Men, OINK | | 172 | Rome_B0, Z2_XB, Z2_Ren, Z2_Luc, Z2_Mat, Z2_VG, Z2_Men, OINK |
173 | }; | | 173 | }; |
174 | | | 174 | |
175 | static bool x86_errata_setmsr(struct cpu_info *, errata_t *); | | 175 | static bool x86_errata_setmsr(struct cpu_info *, errata_t *); |
176 | static bool x86_errata_testmsr(struct cpu_info *, errata_t *); | | 176 | static bool x86_errata_testmsr(struct cpu_info *, errata_t *); |
177 | | | 177 | |
178 | static errata_t errata[] = { | | 178 | static errata_t errata[] = { |
179 | /* | | 179 | /* |
180 | * 81: Cache Coherency Problem with Hardware Prefetching | | 180 | * 81: Cache Coherency Problem with Hardware Prefetching |
181 | * and Streaming Stores | | 181 | * and Streaming Stores |
182 | */ | | 182 | */ |
183 | { | | 183 | { |
184 | 81, FALSE, MSR_DC_CFG, x86_errata_set5, | | 184 | 81, FALSE, MSR_DC_CFG, x86_errata_set5, |
185 | x86_errata_testmsr, DC_CFG_DIS_SMC_CHK_BUF | | 185 | x86_errata_testmsr, DC_CFG_DIS_SMC_CHK_BUF |
186 | }, | | 186 | }, |
187 | /* | | 187 | /* |
188 | * 86: DRAM Data Masking Feature Can Cause ECC Failures | | 188 | * 86: DRAM Data Masking Feature Can Cause ECC Failures |
189 | */ | | 189 | */ |
190 | { | | 190 | { |
191 | 86, FALSE, MSR_NB_CFG, x86_errata_set1, | | 191 | 86, FALSE, MSR_NB_CFG, x86_errata_set1, |
192 | x86_errata_testmsr, NB_CFG_DISDATMSK | | 192 | x86_errata_testmsr, NB_CFG_DISDATMSK |
193 | }, | | 193 | }, |
194 | /* | | 194 | /* |
195 | * 89: Potential Deadlock With Locked Transactions | | 195 | * 89: Potential Deadlock With Locked Transactions |
196 | */ | | 196 | */ |
197 | { | | 197 | { |
198 | 89, FALSE, MSR_NB_CFG, x86_errata_set8, | | 198 | 89, FALSE, MSR_NB_CFG, x86_errata_set8, |
199 | x86_errata_testmsr, NB_CFG_DISIOREQLOCK | | 199 | x86_errata_testmsr, NB_CFG_DISIOREQLOCK |
200 | }, | | 200 | }, |
201 | /* | | 201 | /* |
202 | * 94: Sequential Prefetch Feature May Cause Incorrect | | 202 | * 94: Sequential Prefetch Feature May Cause Incorrect |
203 | * Processor Operation | | 203 | * Processor Operation |
204 | */ | | 204 | */ |
205 | { | | 205 | { |
206 | 94, FALSE, MSR_IC_CFG, x86_errata_set1, | | 206 | 94, FALSE, MSR_IC_CFG, x86_errata_set1, |
207 | x86_errata_testmsr, IC_CFG_DIS_SEQ_PREFETCH | | 207 | x86_errata_testmsr, IC_CFG_DIS_SEQ_PREFETCH |
208 | }, | | 208 | }, |
209 | /* | | 209 | /* |
210 | * 97: 128-Bit Streaming Stores May Cause Coherency | | 210 | * 97: 128-Bit Streaming Stores May Cause Coherency |
211 | * Failure | | 211 | * Failure |
212 | * | | 212 | * |
213 | * XXX "This workaround must not be applied to processors | | 213 | * XXX "This workaround must not be applied to processors |
214 | * prior to revision C0." We don't apply it, but if it | | 214 | * prior to revision C0." We don't apply it, but if it |
215 | * can't be applied, it shouldn't be reported. | | 215 | * can't be applied, it shouldn't be reported. |
216 | */ | | 216 | */ |
217 | { | | 217 | { |
218 | 97, FALSE, MSR_DC_CFG, x86_errata_set6, | | 218 | 97, FALSE, MSR_DC_CFG, x86_errata_set6, |
219 | x86_errata_testmsr, DC_CFG_DIS_CNV_WC_SSO | | 219 | x86_errata_testmsr, DC_CFG_DIS_CNV_WC_SSO |
220 | }, | | 220 | }, |
221 | /* | | 221 | /* |
222 | * 104: DRAM Data Masking Feature Causes ChipKill ECC | | 222 | * 104: DRAM Data Masking Feature Causes ChipKill ECC |
223 | * Failures When Enabled With x8/x16 DRAM Devices | | 223 | * Failures When Enabled With x8/x16 DRAM Devices |
224 | */ | | 224 | */ |
225 | { | | 225 | { |
226 | 104, FALSE, MSR_NB_CFG, x86_errata_set7, | | 226 | 104, FALSE, MSR_NB_CFG, x86_errata_set7, |
227 | x86_errata_testmsr, NB_CFG_DISDATMSK | | 227 | x86_errata_testmsr, NB_CFG_DISDATMSK |
228 | }, | | 228 | }, |
229 | /* | | 229 | /* |
230 | * 113: Enhanced Write-Combining Feature Causes System Hang | | 230 | * 113: Enhanced Write-Combining Feature Causes System Hang |
231 | */ | | 231 | */ |
232 | { | | 232 | { |
233 | 113, FALSE, MSR_BU_CFG, x86_errata_set3, | | 233 | 113, FALSE, MSR_BU_CFG, x86_errata_set3, |
234 | x86_errata_setmsr, BU_CFG_WBENHWSBDIS | | 234 | x86_errata_setmsr, BU_CFG_WBENHWSBDIS |
235 | }, | | 235 | }, |
236 | /* | | 236 | /* |
237 | * 69: Multiprocessor Coherency Problem with Hardware | | 237 | * 69: Multiprocessor Coherency Problem with Hardware |
238 | * Prefetch Mechanism | | 238 | * Prefetch Mechanism |
239 | */ | | 239 | */ |
240 | { | | 240 | { |
241 | 69, FALSE, MSR_BU_CFG, x86_errata_set5, | | 241 | 69, FALSE, MSR_BU_CFG, x86_errata_set5, |
242 | x86_errata_setmsr, BU_CFG_WBPFSMCCHKDIS | | 242 | x86_errata_setmsr, BU_CFG_WBPFSMCCHKDIS |
243 | }, | | 243 | }, |
244 | /* | | 244 | /* |
245 | * 101: DRAM Scrubber May Cause Data Corruption When Using | | 245 | * 101: DRAM Scrubber May Cause Data Corruption When Using |
246 | * Node-Interleaved Memory | | 246 | * Node-Interleaved Memory |
247 | */ | | 247 | */ |
248 | { | | 248 | { |
249 | 101, FALSE, 0, x86_errata_set2, | | 249 | 101, FALSE, 0, x86_errata_set2, |
250 | NULL, 0 | | 250 | NULL, 0 |
251 | }, | | 251 | }, |
252 | /* | | 252 | /* |
253 | * 106: Potential Deadlock with Tightly Coupled Semaphores | | 253 | * 106: Potential Deadlock with Tightly Coupled Semaphores |
254 | * in an MP System | | 254 | * in an MP System |
255 | */ | | 255 | */ |
256 | { | | 256 | { |
257 | 106, FALSE, MSR_LS_CFG, x86_errata_set2, | | 257 | 106, FALSE, MSR_LS_CFG, x86_errata_set2, |
258 | x86_errata_testmsr, LS_CFG_DIS_LS2_SQUISH | | 258 | x86_errata_testmsr, LS_CFG_DIS_LS2_SQUISH |
259 | }, | | 259 | }, |
260 | /* | | 260 | /* |
261 | * 107: Possible Multiprocessor Coherency Problem with | | 261 | * 107: Possible Multiprocessor Coherency Problem with |
262 | * Setting Page Table A/D Bits | | 262 | * Setting Page Table A/D Bits |
263 | */ | | 263 | */ |
264 | { | | 264 | { |
265 | 107, FALSE, MSR_BU_CFG, x86_errata_set2, | | 265 | 107, FALSE, MSR_BU_CFG, x86_errata_set2, |
266 | x86_errata_testmsr, BU_CFG_THRL2IDXCMPDIS | | 266 | x86_errata_testmsr, BU_CFG_THRL2IDXCMPDIS |
267 | }, | | 267 | }, |
268 | /* | | 268 | /* |
269 | * 122: TLB Flush Filter May Cause Coherency Problem in | | 269 | * 122: TLB Flush Filter May Cause Coherency Problem in |
270 | * Multiprocessor Systems | | 270 | * Multiprocessor Systems |
271 | */ | | 271 | */ |
272 | { | | 272 | { |
273 | 122, FALSE, MSR_HWCR, x86_errata_set4, | | 273 | 122, FALSE, MSR_HWCR, x86_errata_set4, |
274 | x86_errata_setmsr, HWCR_FFDIS | | 274 | x86_errata_setmsr, HWCR_FFDIS |
275 | }, | | 275 | }, |
276 | /* | | 276 | /* |
277 | * 254: Internal Resource Livelock Involving Cached TLB Reload | | 277 | * 254: Internal Resource Livelock Involving Cached TLB Reload |
278 | */ | | 278 | */ |
279 | { | | 279 | { |
280 | 254, FALSE, MSR_BU_CFG, x86_errata_set9, | | 280 | 254, FALSE, MSR_BU_CFG, x86_errata_set9, |
281 | x86_errata_testmsr, BU_CFG_ERRATA_254 | | 281 | x86_errata_testmsr, BU_CFG_ERRATA_254 |
282 | }, | | 282 | }, |
283 | /* | | 283 | /* |
284 | * 261: Processor May Stall Entering Stop-Grant Due to Pending Data | | 284 | * 261: Processor May Stall Entering Stop-Grant Due to Pending Data |
285 | * Cache Scrub | | 285 | * Cache Scrub |
286 | */ | | 286 | */ |
287 | { | | 287 | { |
288 | 261, FALSE, MSR_DC_CFG, x86_errata_set10, | | 288 | 261, FALSE, MSR_DC_CFG, x86_errata_set10, |
289 | x86_errata_testmsr, DC_CFG_ERRATA_261 | | 289 | x86_errata_testmsr, DC_CFG_ERRATA_261 |
290 | }, | | 290 | }, |
291 | /* | | 291 | /* |
292 | * 298: L2 Eviction May Occur During Processor Operation To Set | | 292 | * 298: L2 Eviction May Occur During Processor Operation To Set |
293 | * Accessed or Dirty Bit | | 293 | * Accessed or Dirty Bit |
294 | */ | | 294 | */ |
295 | { | | 295 | { |
296 | 298, FALSE, MSR_HWCR, x86_errata_set9, | | 296 | 298, FALSE, MSR_HWCR, x86_errata_set9, |
297 | x86_errata_testmsr, HWCR_TLBCACHEDIS | | 297 | x86_errata_testmsr, HWCR_TLBCACHEDIS |
298 | }, | | 298 | }, |
299 | { | | 299 | { |
300 | 298, FALSE, MSR_BU_CFG, x86_errata_set9, | | 300 | 298, FALSE, MSR_BU_CFG, x86_errata_set9, |
301 | x86_errata_testmsr, BU_CFG_ERRATA_298 | | 301 | x86_errata_testmsr, BU_CFG_ERRATA_298 |
302 | }, | | 302 | }, |
303 | /* | | 303 | /* |
304 | * 309: Processor Core May Execute Incorrect Instructions on | | 304 | * 309: Processor Core May Execute Incorrect Instructions on |
305 | * Concurrent L2 and Northbridge Response | | 305 | * Concurrent L2 and Northbridge Response |
306 | */ | | 306 | */ |
307 | { | | 307 | { |
308 | 309, FALSE, MSR_BU_CFG, x86_errata_set9, | | 308 | 309, FALSE, MSR_BU_CFG, x86_errata_set9, |
309 | x86_errata_testmsr, BU_CFG_ERRATA_309 | | 309 | x86_errata_testmsr, BU_CFG_ERRATA_309 |
310 | }, | | 310 | }, |
311 | /* | | 311 | /* |
312 | * 721: Processor May Incorrectly Update Stack Pointer | | 312 | * 721: Processor May Incorrectly Update Stack Pointer |
313 | */ | | 313 | */ |
314 | { | | 314 | { |
315 | 721, FALSE, MSR_DE_CFG, x86_errata_set11, | | 315 | 721, FALSE, MSR_DE_CFG, x86_errata_set11, |
316 | x86_errata_setmsr, DE_CFG_ERRATA_721 | | 316 | x86_errata_setmsr, DE_CFG_ERRATA_721 |
317 | }, | | 317 | }, |
318 | /* | | 318 | /* |
319 | * 776: Incorrect Processor Branch Prediction for Two Consecutive | | 319 | * 776: Incorrect Processor Branch Prediction for Two Consecutive |
320 | * Linear Pages | | 320 | * Linear Pages |
321 | */ | | 321 | */ |
322 | { | | 322 | { |
323 | 776, FALSE, MSR_IC_CFG, x86_errata_set12, | | 323 | 776, FALSE, MSR_IC_CFG, x86_errata_set12, |
324 | x86_errata_setmsr, IC_CFG_ERRATA_776 | | 324 | x86_errata_setmsr, IC_CFG_ERRATA_776 |
325 | }, | | 325 | }, |
326 | /* | | 326 | /* |
327 | * 793: Specific Combination of Writes to Write Combined Memory | | 327 | * 793: Specific Combination of Writes to Write Combined Memory |
328 | * Types and Locked Instructions May Cause Core Hang | | 328 | * Types and Locked Instructions May Cause Core Hang |
329 | */ | | 329 | */ |
330 | { | | 330 | { |
331 | 793, FALSE, MSR_LS_CFG, x86_errata_set15, | | 331 | 793, FALSE, MSR_LS_CFG, x86_errata_set15, |
332 | x86_errata_setmsr, LS_CFG_ERRATA_793 | | 332 | x86_errata_setmsr, LS_CFG_ERRATA_793 |
333 | }, | | 333 | }, |
334 | /* | | 334 | /* |
335 | * 1021: Load Operation May Receive Stale Data From Older Store | | 335 | * 1021: Load Operation May Receive Stale Data From Older Store |
336 | * Operation | | 336 | * Operation |
337 | */ | | 337 | */ |
338 | { | | 338 | { |
339 | 1021, FALSE, MSR_DE_CFG, x86_errata_set13, | | 339 | 1021, FALSE, MSR_DE_CFG, x86_errata_set13, |
340 | x86_errata_setmsr, DE_CFG_ERRATA_1021 | | 340 | x86_errata_setmsr, DE_CFG_ERRATA_1021 |
341 | }, | | 341 | }, |
342 | /* | | 342 | /* |
343 | * 1033: A Lock Operation May Cause the System to Hang | | 343 | * 1033: A Lock Operation May Cause the System to Hang |
344 | */ | | 344 | */ |
345 | { | | 345 | { |
346 | 1033, FALSE, MSR_LS_CFG, x86_errata_set14, | | 346 | 1033, FALSE, MSR_LS_CFG, x86_errata_set14, |
347 | x86_errata_setmsr, LS_CFG_ERRATA_1033 | | 347 | x86_errata_setmsr, LS_CFG_ERRATA_1033 |
348 | }, | | 348 | }, |
349 | /* | | 349 | /* |
350 | * 1049: FCMOV Instruction May Not Execute Correctly | | 350 | * 1049: FCMOV Instruction May Not Execute Correctly |
351 | */ | | 351 | */ |
352 | { | | 352 | { |
353 | 1049, FALSE, MSR_FP_CFG, x86_errata_set13, | | 353 | 1049, FALSE, MSR_FP_CFG, x86_errata_set13, |
354 | x86_errata_setmsr, FP_CFG_ERRATA_1049 | | 354 | x86_errata_setmsr, FP_CFG_ERRATA_1049 |
355 | }, | | 355 | }, |
356 | #if 0 /* Should we apply this errata? The other OSes don't. */ | | 356 | #if 0 /* Should we apply this errata? The other OSes don't. */ |
357 | /* | | 357 | /* |
358 | * 1091: Address Boundary Crossing Load Operation May Receive | | 358 | * 1091: Address Boundary Crossing Load Operation May Receive |
359 | * Stale Data | | 359 | * Stale Data |
360 | */ | | 360 | */ |
361 | { | | 361 | { |
362 | 1091, FALSE, MSR_LS_CFG2, x86_errata_set13, | | 362 | 1091, FALSE, MSR_LS_CFG2, x86_errata_set13, |
363 | x86_errata_setmsr, LS_CFG2_ERRATA_1091 | | 363 | x86_errata_setmsr, LS_CFG2_ERRATA_1091 |
364 | }, | | 364 | }, |
365 | #endif | | 365 | #endif |
366 | /* | | 366 | /* |
367 | * 1095: Potential Violation of Read Ordering In Lock Operation | | 367 | * 1095: Potential Violation of Read Ordering In Lock Operation |
368 | * In SMT (Simultaneous Multithreading) Mode | | 368 | * In SMT (Simultaneous Multithreading) Mode |
369 | */ | | 369 | */ |
370 | { | | 370 | { |
371 | 1095, FALSE, MSR_LS_CFG, x86_errata_set13, | | 371 | 1095, FALSE, MSR_LS_CFG, x86_errata_set13, |
372 | x86_errata_setmsr, LS_CFG_ERRATA_1095 | | 372 | x86_errata_setmsr, LS_CFG_ERRATA_1095 |
373 | }, | | 373 | }, |
374 | /* | | 374 | /* |
375 | * Zenbleed: | | 375 | * Zenbleed: |
376 | * https://www.amd.com/en/resources/product-security/bulletin/amd-sb-7008.html | | 376 | * https://www.amd.com/en/resources/product-security/bulletin/amd-sb-7008.html |
377 | * https://github.com/google/security-research/security/advisories/GHSA-v6wh-rxpg-cmm8 | | 377 | * https://github.com/google/security-research/security/advisories/GHSA-v6wh-rxpg-cmm8 |
378 | * https://lock.cmpxchg8b.com/zenbleed.html | | 378 | * https://lock.cmpxchg8b.com/zenbleed.html |
379 | */ | | 379 | */ |
380 | { | | 380 | { |
381 | -1, FALSE, MSR_DE_CFG, x86_errata_set16, | | 381 | -1, FALSE, MSR_DE_CFG, x86_errata_set16, |
382 | x86_errata_setmsr, DE_CFG_ERRATA_ZENBLEED, | | 382 | x86_errata_setmsr, DE_CFG_ERRATA_ZENBLEED, |
383 | }, | | 383 | }, |
384 | }; | | 384 | }; |
385 | | | 385 | |
386 | static bool | | 386 | static bool |
387 | x86_errata_testmsr(struct cpu_info *ci, errata_t *e) | | 387 | x86_errata_testmsr(struct cpu_info *ci, errata_t *e) |
388 | { | | 388 | { |
389 | uint64_t val; | | 389 | uint64_t val; |
390 | | | 390 | |
391 | (void)ci; | | 391 | (void)ci; |
392 | | | 392 | |
393 | val = rdmsr_locked(e->e_data1); | | 393 | val = rdmsr_locked(e->e_data1); |
394 | if ((val & e->e_data2) != 0) | | 394 | if ((val & e->e_data2) != 0) |
395 | return FALSE; | | 395 | return FALSE; |
396 | | | 396 | |
397 | e->e_reported = TRUE; | | 397 | e->e_reported = TRUE; |
398 | return TRUE; | | 398 | return TRUE; |
399 | } | | 399 | } |
400 | | | 400 | |
401 | static bool | | 401 | static bool |
402 | x86_errata_setmsr(struct cpu_info *ci, errata_t *e) | | 402 | x86_errata_setmsr(struct cpu_info *ci, errata_t *e) |
403 | { | | 403 | { |
404 | uint64_t val; | | 404 | uint64_t val; |
405 | | | 405 | |
406 | (void)ci; | | 406 | (void)ci; |
407 | | | 407 | |
408 | val = rdmsr_locked(e->e_data1); | | 408 | val = rdmsr_locked(e->e_data1); |
409 | if ((val & e->e_data2) != 0) | | 409 | if ((val & e->e_data2) != 0) |
410 | return FALSE; | | 410 | return FALSE; |
411 | wrmsr_locked(e->e_data1, val | e->e_data2); | | 411 | wrmsr_locked(e->e_data1, val | e->e_data2); |
412 | aprint_debug_dev(ci->ci_dev, "erratum %d patched\n", | | 412 | aprint_debug_dev(ci->ci_dev, "erratum %d patched\n", |
413 | e->e_num); | | 413 | e->e_num); |
414 | | | 414 | |
415 | return FALSE; | | 415 | return FALSE; |
416 | } | | 416 | } |
417 | | | 417 | |
418 | void | | 418 | void |
419 | x86_errata(void) | | 419 | x86_errata(void) |
420 | { | | 420 | { |
421 | struct cpu_info *ci; | | 421 | struct cpu_info *ci; |
422 | uint32_t descs[4]; | | 422 | uint32_t descs[4]; |
423 | errata_t *e, *ex; | | 423 | errata_t *e, *ex; |
424 | cpurev_t rev; | | 424 | cpurev_t rev; |
425 | int i, j, upgrade; | | 425 | int i, j, upgrade; |
426 | static int again; | | 426 | static int again; |
427 | | | 427 | |
428 | /* don't run if we are under a hypervisor */ | | 428 | /* don't run if we are under a hypervisor */ |
429 | if (cpu_feature[1] & CPUID2_RAZ) | | 429 | if (cpu_feature[1] & CPUID2_RAZ) |
430 | return; | | 430 | return; |
431 | | | 431 | |
432 | /* only for AMD */ | | 432 | /* only for AMD */ |
433 | if (cpu_vendor != CPUVENDOR_AMD) | | 433 | if (cpu_vendor != CPUVENDOR_AMD) |
434 | return; | | 434 | return; |
435 | | | 435 | |
436 | ci = curcpu(); | | 436 | ci = curcpu(); |
437 | | | 437 | |
438 | x86_cpuid(0x80000001, descs); | | 438 | x86_cpuid(0x80000001, descs); |
439 | | | 439 | |
440 | for (i = 0;; i += 2) { | | 440 | for (i = 0;; i += 2) { |
441 | if ((rev = cpurevs[i]) == OINK) | | 441 | if ((rev = cpurevs[i]) == OINK) |
442 | return; | | 442 | return; |
443 | if (cpurevs[i + 1] == descs[0]) | | 443 | if (cpurevs[i + 1] == descs[0]) |
444 | break; | | 444 | break; |
445 | } | | 445 | } |
446 | | | 446 | |
447 | ex = errata + __arraycount(errata); | | 447 | ex = errata + __arraycount(errata); |
448 | for (upgrade = 0, e = errata; e < ex; e++) { | | 448 | for (upgrade = 0, e = errata; e < ex; e++) { |
449 | if (e->e_reported) | | 449 | if (e->e_reported) |
450 | continue; | | 450 | continue; |
451 | if (e->e_set != NULL) { | | 451 | if (e->e_set != NULL) { |
452 | for (j = 0; e->e_set[j] != OINK; j++) | | 452 | for (j = 0; e->e_set[j] != OINK; j++) |
453 | if (e->e_set[j] == rev) | | 453 | if (e->e_set[j] == rev) |
454 | break; | | 454 | break; |
455 | if (e->e_set[j] == OINK) | | 455 | if (e->e_set[j] == OINK) |
456 | continue; | | 456 | continue; |
457 | } | | 457 | } |
458 | | | 458 | |
459 | aprint_debug_dev(ci->ci_dev, "testing for erratum %d\n", | | 459 | aprint_debug_dev(ci->ci_dev, "testing for erratum %d\n", |
460 | e->e_num); | | 460 | e->e_num); |
461 | | | 461 | |
462 | if (e->e_act == NULL) | | 462 | if (e->e_act == NULL) |
463 | e->e_reported = TRUE; | | 463 | e->e_reported = TRUE; |
464 | else if ((*e->e_act)(ci, e) == FALSE) | | 464 | else if ((*e->e_act)(ci, e) == FALSE) |
465 | continue; | | 465 | continue; |
466 | | | 466 | |
467 | aprint_verbose_dev(ci->ci_dev, "erratum %d present\n", | | 467 | aprint_verbose_dev(ci->ci_dev, "erratum %d present\n", |
468 | e->e_num); | | 468 | e->e_num); |
469 | upgrade = 1; | | 469 | upgrade = 1; |
470 | } | | 470 | } |
471 | | | 471 | |
472 | if (upgrade && !again) { | | 472 | if (upgrade && !again) { |
473 | again = 1; | | 473 | again = 1; |
474 | aprint_normal_dev(ci->ci_dev, "WARNING: errata present," | | 474 | aprint_normal_dev(ci->ci_dev, "WARNING: errata present," |
475 | " BIOS upgrade may be\n"); | | 475 | " BIOS upgrade may be\n"); |
476 | aprint_normal_dev(ci->ci_dev, "WARNING: necessary to ensure" | | 476 | aprint_normal_dev(ci->ci_dev, "WARNING: necessary to ensure" |
477 | " reliable operation\n"); | | 477 | " reliable operation\n"); |
478 | } | | 478 | } |
479 | } | | 479 | } |