Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/ras/mce_amd_inj: Trigger deferred and thresholding errors interrupts

Add the capability to trigger deferred error interrupts and
threshold interrupts in order to test the APIC interrupt handler
functionality for these type of errors.

Update README section about the same too.

Reported by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
[ Cleanup comments. ]
[ Include asm/irq_vectors.h directly so that misc randbuilds don't fail. ]
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Link: http://lkml.kernel.org/r/1443190851-2172-3-git-send-email-Aravind.Gopalakrishnan@amd.com
Link: http://lkml.kernel.org/r/1444641762-9437-4-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Aravind Gopalakrishnan and committed by
Ingo Molnar
a1300e50 85c9306d

+41 -1
+41 -1
arch/x86/ras/mce_amd_inj.c
··· 17 17 #include <linux/cpu.h> 18 18 #include <linux/string.h> 19 19 #include <linux/uaccess.h> 20 + 20 21 #include <asm/mce.h> 22 + #include <asm/irq_vectors.h> 21 23 22 24 #include "../kernel/cpu/mcheck/mce-internal.h" 23 25 ··· 36 34 enum injection_type { 37 35 SW_INJ = 0, /* SW injection, simply decode the error */ 38 36 HW_INJ, /* Trigger a #MC */ 37 + DFR_INT_INJ, /* Trigger Deferred error interrupt */ 38 + THR_INT_INJ, /* Trigger threshold interrupt */ 39 39 N_INJ_TYPES, 40 40 }; 41 41 42 42 static const char * const flags_options[] = { 43 43 [SW_INJ] = "sw", 44 44 [HW_INJ] = "hw", 45 + [DFR_INT_INJ] = "df", 46 + [THR_INT_INJ] = "th", 45 47 NULL 46 48 }; 47 49 ··· 188 182 asm volatile("int $18"); 189 183 } 190 184 185 + static void trigger_dfr_int(void *info) 186 + { 187 + asm volatile("int %0" :: "i" (DEFERRED_ERROR_VECTOR)); 188 + } 189 + 190 + static void trigger_thr_int(void *info) 191 + { 192 + asm volatile("int %0" :: "i" (THRESHOLD_APIC_VECTOR)); 193 + } 194 + 191 195 static void do_inject(void) 192 196 { 193 197 u64 mcg_status = 0; ··· 217 201 218 202 if (!(i_mce.status & MCI_STATUS_PCC)) 219 203 mcg_status |= MCG_STATUS_RIPV; 204 + 205 + /* 206 + * Ensure necessary status bits for deferred errors: 207 + * - MCx_STATUS[Deferred]: make sure it is a deferred error 208 + * - MCx_STATUS[UC] cleared: deferred errors are _not_ UC 209 + */ 210 + if (inj_type == DFR_INT_INJ) { 211 + i_mce.status |= MCI_STATUS_DEFERRED; 212 + i_mce.status |= (i_mce.status & ~MCI_STATUS_UC); 213 + } 220 214 221 215 get_online_cpus(); 222 216 if (!cpu_online(cpu)) ··· 248 222 249 223 toggle_hw_mce_inject(cpu, false); 250 224 251 - smp_call_function_single(cpu, trigger_mce, NULL, 0); 225 + switch (inj_type) { 226 + case DFR_INT_INJ: 227 + smp_call_function_single(cpu, trigger_dfr_int, NULL, 0); 228 + break; 229 + case THR_INT_INJ: 230 + smp_call_function_single(cpu, trigger_thr_int, NULL, 0); 231 + break; 232 + default: 233 + smp_call_function_single(cpu, trigger_mce, NULL, 0); 234 + } 252 235 253 236 err: 254 237 put_online_cpus(); ··· 322 287 "\t handle the error. Be warned: might cause system panic if MCi_STATUS[PCC] \n" 323 288 "\t is set. Therefore, consider setting (debugfs_mountpoint)/mce/fake_panic \n" 324 289 "\t before injecting.\n" 290 + "\t - \"df\": Trigger APIC interrupt for Deferred error. Causes deferred \n" 291 + "\t error APIC interrupt handler to handle the error if the feature is \n" 292 + "\t is present in hardware. \n" 293 + "\t - \"th\": Trigger APIC interrupt for Threshold errors. Causes threshold \n" 294 + "\t APIC interrupt handler to handle the error. \n" 325 295 "\n"; 326 296 327 297 static ssize_t