Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754394Ab2JHRMA (ORCPT ); Mon, 8 Oct 2012 13:12:00 -0400 Received: from mail.x86-64.org ([217.9.48.20]:60590 "EHLO mail.x86-64.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754286Ab2JHRLs (ORCPT ); Mon, 8 Oct 2012 13:11:48 -0400 From: Borislav Petkov To: Tony Luck Cc: EDAC devel , X86-ML , LKML , Borislav Petkov Subject: [PATCH 4/6] x86, RAS: Add function enabling direct writes to MCE MSRs Date: Mon, 8 Oct 2012 19:11:31 +0200 Message-Id: <1349716293-16723-5-git-send-email-bp@amd64.org> X-Mailer: git-send-email 1.8.0.rc0.18.gf84667d In-Reply-To: <1349716293-16723-1-git-send-email-bp@amd64.org> References: <1349716293-16723-1-git-send-email-bp@amd64.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1552 Lines: 53 From: Borislav Petkov Normally, writing to MCE MSRs causes a #GP. Add a function to enable direct accesses to those MSRs. Signed-off-by: Borislav Petkov --- arch/x86/ras/amd/mce-inject.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/x86/ras/amd/mce-inject.c b/arch/x86/ras/amd/mce-inject.c index 66969eab5591..c0c811579ce9 100644 --- a/arch/x86/ras/amd/mce-inject.c +++ b/arch/x86/ras/amd/mce-inject.c @@ -55,6 +55,30 @@ DEFINE_SIMPLE_ATTRIBUTE(misc_fops, inj_misc_get, inj_misc_set, "%llx\n"); DEFINE_SIMPLE_ATTRIBUTE(addr_fops, inj_addr_get, inj_addr_set, "%llx\n"); /* + * Caller needs to be make sure this cpu doesn't disappear + * from under us, i.e.: get_cpu/put_cpu. + */ +static int toggle_hw_mce_inject(unsigned int cpu, bool enable) +{ + u32 l, h; + int err; + + err = rdmsr_on_cpu(cpu, MSR_K7_HWCR, &l, &h); + if (err) { + pr_err("%s: error reading HWCR\n", __func__); + return err; + } + + enable ? (l |= BIT(18)) : (l &= ~BIT(18)); + + err = wrmsr_on_cpu(cpu, MSR_K7_HWCR, l, h); + if (err) + pr_err("%s: error writing HWCR\n", __func__); + + return err; +} + +/* * This denotes into which bank we're injecting and triggers * the injection, at the same time. */ -- 1.8.0.rc0.18.gf84667d -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/