Skip to contentSkip to conversation

fix APIC errors on oprofile restore

PATCH New John Levon 1 participant 1 message Nov 1, 2002

lore
Share & tools
lore

John Levon

author
#0 lore raw

PATCH 1/1 fix APIC errors on oprofile restore

See comment. Please apply. By Philippe Elie

tested on two UP boxen and my SMP box

thanks
john

arch/i386/oprofile/nmi_int.c +10 -0
diff -Naur -X dontdiff linux-linus/arch/i386/oprofile/nmi_int.c linux/arch/i386/oprofile/nmi_int.c
@@ -135,9 +135,19 @@
 
 static void nmi_cpu_shutdown(void * dummy)
 {
+	unsigned int v;
 	int cpu = smp_processor_id();
 	struct op_msrs * msrs = &cpu_msrs[cpu];
+ 
+	/* restoring APIC_LVTPC can trigger an apic error because the delivery
+	 * mode and vector nr combination can be illegal. That's by design: on
+	 * power on apic lvt contain a zero vector nr which are legal only for
+	 * NMI delivery mode. So inhibit apic err before restoring lvtpc
+	 */
+	v = apic_read(APIC_LVTERR);
+	apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
 	apic_write(APIC_LVTPC, saved_lvtpc[cpu]);
+	apic_write(APIC_LVTERR, v);
 	nmi_restore_registers(msrs);
 }