18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * IDT Winchip specific Machine Check Exception Reporting 48c2ecf20Sopenharmony_ci * (C) Copyright 2002 Alan Cox <alan@lxorguk.ukuu.org.uk> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 78c2ecf20Sopenharmony_ci#include <linux/kernel.h> 88c2ecf20Sopenharmony_ci#include <linux/types.h> 98c2ecf20Sopenharmony_ci#include <linux/hardirq.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/processor.h> 128c2ecf20Sopenharmony_ci#include <asm/traps.h> 138c2ecf20Sopenharmony_ci#include <asm/tlbflush.h> 148c2ecf20Sopenharmony_ci#include <asm/mce.h> 158c2ecf20Sopenharmony_ci#include <asm/msr.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include "internal.h" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* Machine check handler for WinChip C6: */ 208c2ecf20Sopenharmony_cistatic noinstr void winchip_machine_check(struct pt_regs *regs) 218c2ecf20Sopenharmony_ci{ 228c2ecf20Sopenharmony_ci instrumentation_begin(); 238c2ecf20Sopenharmony_ci pr_emerg("CPU0: Machine Check Exception.\n"); 248c2ecf20Sopenharmony_ci add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE); 258c2ecf20Sopenharmony_ci instrumentation_end(); 268c2ecf20Sopenharmony_ci} 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Set up machine check reporting on the Winchip C6 series */ 298c2ecf20Sopenharmony_civoid winchip_mcheck_init(struct cpuinfo_x86 *c) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci u32 lo, hi; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci machine_check_vector = winchip_machine_check; 348c2ecf20Sopenharmony_ci /* Make sure the vector pointer is visible before we enable MCEs: */ 358c2ecf20Sopenharmony_ci wmb(); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci rdmsr(MSR_IDT_FCR1, lo, hi); 388c2ecf20Sopenharmony_ci lo |= (1<<2); /* Enable EIERRINT (int 18 MCE) */ 398c2ecf20Sopenharmony_ci lo &= ~(1<<4); /* Enable MCE */ 408c2ecf20Sopenharmony_ci wrmsr(MSR_IDT_FCR1, lo, hi); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci cr4_set_bits(X86_CR4_MCE); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci pr_info("Winchip machine check reporting enabled on CPU#0.\n"); 458c2ecf20Sopenharmony_ci} 46