Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752737AbbFBU1w (ORCPT ); Tue, 2 Jun 2015 16:27:52 -0400 Received: from mail-by2on0115.outbound.protection.outlook.com ([207.46.100.115]:11392 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751834AbbFBU0R (ORCPT ); Tue, 2 Jun 2015 16:26:17 -0400 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; alien8.de; dkim=none (message not signed) header.d=none; X-WSS-ID: 0NPC3FM-08-TLB-02 X-M-MSG: From: Aravind Gopalakrishnan To: , , CC: , , Subject: [PATCH V2 2/9] edac, mce_amd_inj: Rework sanity check for inj_bank_set Date: Tue, 2 Jun 2015 15:35:55 -0500 Message-ID: <1433277362-10911-3-git-send-email-Aravind.Gopalakrishnan@amd.com> X-Mailer: git-send-email 2.4.0 In-Reply-To: <1433277362-10911-1-git-send-email-Aravind.Gopalakrishnan@amd.com> References: <1433277362-10911-1-git-send-email-Aravind.Gopalakrishnan@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD056;1:QweMwPHZiuXUMWK/eUUvtKZvuwR3xMpJyg+b2u44rBm6S5lqFoWNClaf+V0tclvuVOt2vCsD+k64LLiWtrxD5foYeS0ZYq9w86zN47mTJmzsVoVa83VvQvA1lPvE+xykgLSjHOtiWdzpup6IKkg3uDFAhIfQNbM1ni7u+fhRqh3LfQtUJ3yg0a1KcsWNi17U/QZMNzBQ8OnQiUsFqY3Y76YBfEALWRvRIn8I12LjxM+wtOVV1uzg+F3ccl0WgiPQ13RSlkiw6SRs5szrwQoSLg== X-Forefront-Antispam-Report: CIP:165.204.84.222;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(428002)(199003)(189002)(5001770100001)(2201001)(4001540100001)(5001860100001)(229853001)(106466001)(97736004)(48376002)(68736005)(5001830100001)(2950100001)(92566002)(189998001)(86362001)(87936001)(50226001)(77096005)(19580395003)(105586002)(53416004)(76176999)(36756003)(77156002)(19580405001)(50466002)(47776003)(62966003)(101416001)(50986999)(46102003)(64706001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR02MB1117;H:atltwp02.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR02MB1117; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:CY1PR02MB1117;BCL:0;PCL:0;RULEID:;SRVR:CY1PR02MB1117; X-Forefront-PRVS: 05954A7C45 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2015 20:26:14.5929 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.222];Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR02MB1117 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1604 Lines: 57 The number of banks for a given processor is encoded in MSR_IA32_MCG_CAP. So, use this to obtain the value and for sanity checking in inj_bank_set() instead of requiring a family/model check. Signed-off-by: Aravind Gopalakrishnan --- drivers/edac/mce_amd_inj.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c index 7f3a97a..15f6aa1 100644 --- a/drivers/edac/mce_amd_inj.c +++ b/drivers/edac/mce_amd_inj.c @@ -25,6 +25,8 @@ static struct mce i_mce; static struct dentry *dfs_inj; +static u8 n_banks; + #define MCE_INJECT_SET(reg) \ static int inj_##reg##_set(void *data, u64 val) \ { \ @@ -174,11 +176,9 @@ static int inj_bank_set(void *data, u64 val) { struct mce *m = (struct mce *)data; - if (val > 5) { - if (boot_cpu_data.x86 != 0x15 || val > 6) { - pr_err("Non-existent MCE bank: %llu\n", val); - return -EINVAL; - } + if (val >= n_banks) { + pr_err("Non-existent MCE bank: %llu\n", val); + return -EINVAL; } m->bank = val; @@ -207,6 +207,10 @@ static struct dfs_node { static int __init init_mce_inject(void) { int i; + u64 cap; + + rdmsrl(MSR_IA32_MCG_CAP, cap); + n_banks = cap & MCG_BANKCNT_MASK; dfs_inj = debugfs_create_dir("mce-inject", NULL); if (!dfs_inj) -- 2.4.0 -- 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/