Received: by 10.223.185.116 with SMTP id b49csp1051462wrg; Wed, 21 Feb 2018 11:13:31 -0800 (PST) X-Google-Smtp-Source: AH8x225megjSez5/CgvrfJzK7BfbUMACioz5yyOYDWfymv2uxyoVUOxxZFn5IGkF7U88/KmECuio X-Received: by 2002:a17:902:42a3:: with SMTP id h32-v6mr4124632pld.231.1519240411154; Wed, 21 Feb 2018 11:13:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519240411; cv=none; d=google.com; s=arc-20160816; b=R/swflzp+yQcgIIaNP+1+SjpG2GZQlNTD3e0tfClzQxGOwoyWTzZHlXngiX/8PKLOj NkMHynf8QCjuZUPfnkQRgokWlJqXUW1kqyIKgLzK8RabKNU9Ih30s0ugi6YvT36WhXLT Fn7//K7xe25dKWxpzO2kvFQSuIcEQ4uAnsh+9BZxO5DBgwXKZNSDL5ZH8F5C3Br97qrb 09SlwNo2PeoY67qRc1XQ+gzrt72MpmOimGuELJl2l7Xfm/8OBQ4XfDnc6RjC7lT97O1q 1DqMyY5GJ3VzXU0yLvYd4xFcb9wch1oOFZuDSOzE6Fxc4TbfZ34wRWaw7TsKyEWTcNtZ dLUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=2RU7tKINiL8s0lG7tjxUQTlF1kREGGCHU8il0HBqBtQ=; b=mWaRQ+lipQyLBThFJXaQEbIUp585tVUmgNOLxciTDf4ugg+w9tVhQ5GHvisTIfFXQo aPrg2mV+mM4NoqcrJJwA2MytFe+LWTs2Ul17JT/Xy5Y3PTuoVMbUYJQjkWvAImN1TOug y6WYyniz0Zkv5BGSwXsekV7SflLWlcaVBZC/WJ4AqpMKnkftADb3pwOX69644LesHCY+ 3CjV0a2cawoCnxlX0OMrswZZLK4Ft8WI018b9NQXqjBGPLo8y7vJ/ik4AQmC4Uiy/163 C27szhiQeaC3t8STwXCyTi7+SVuziS579xjqg3tZ1tFFgxYIRz4iT+odjZaL13oUaiw5 ctqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si4928019pgs.208.2018.02.21.11.13.17; Wed, 21 Feb 2018 11:13:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753059AbeBUSCM (ORCPT + 99 others); Wed, 21 Feb 2018 13:02:12 -0500 Received: from terminus.zytor.com ([198.137.202.136]:33713 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938970AbeBUSCK (ORCPT ); Wed, 21 Feb 2018 13:02:10 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1LI1ZI8007650; Wed, 21 Feb 2018 10:01:35 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1LI1Zkv007647; Wed, 21 Feb 2018 10:01:35 -0800 Date: Wed, 21 Feb 2018 10:01:35 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yazen Ghannam Message-ID: Cc: linux-kernel@vger.kernel.org, tony.luck@intel.com, torvalds@linux-foundation.org, yazen.ghannam@amd.com, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, bp@suse.de, peterz@infradead.org, mingo@kernel.org, linux-edac@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, tony.luck@intel.com, torvalds@linux-foundation.org, yazen.ghannam@amd.com, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, bp@suse.de, peterz@infradead.org, linux-edac@vger.kernel.org, mingo@kernel.org In-Reply-To: <20180215210943.11530-4-Yazen.Ghannam@amd.com> References: <20180215210943.11530-4-Yazen.Ghannam@amd.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:ras/core] x86/mce/AMD: Carve out SMCA get_block_address() code Git-Commit-ID: 8a331f4a0863bea758561c921b94b4d28f7c4029 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 8a331f4a0863bea758561c921b94b4d28f7c4029 Gitweb: https://git.kernel.org/tip/8a331f4a0863bea758561c921b94b4d28f7c4029 Author: Yazen Ghannam AuthorDate: Wed, 21 Feb 2018 11:19:00 +0100 Committer: Ingo Molnar CommitDate: Wed, 21 Feb 2018 17:00:55 +0100 x86/mce/AMD: Carve out SMCA get_block_address() code Carve out the SMCA code in get_block_address() into a separate helper function. No functional change. Signed-off-by: Yazen Ghannam [ Save an indentation level. ] Signed-off-by: Borislav Petkov Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tony Luck Cc: linux-edac Link: http://lkml.kernel.org/r/20180215210943.11530-4-Yazen.Ghannam@amd.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/mcheck/mce_amd.c | 57 ++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 12bc286..f7666ee 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c @@ -431,6 +431,35 @@ static void deferred_error_interrupt_enable(struct cpuinfo_x86 *c) wrmsr(MSR_CU_DEF_ERR, low, high); } +static u32 smca_get_block_address(unsigned int cpu, unsigned int bank, + unsigned int block) +{ + u32 low, high; + u32 addr = 0; + + if (smca_get_bank_type(bank) == SMCA_RESERVED) + return addr; + + if (!block) + return MSR_AMD64_SMCA_MCx_MISC(bank); + + /* + * For SMCA enabled processors, BLKPTR field of the first MISC register + * (MCx_MISC0) indicates presence of additional MISC regs set (MISC1-4). + */ + if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high)) + return addr; + + if (!(low & MCI_CONFIG_MCAX)) + return addr; + + if (!rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high) && + (low & MASK_BLKPTR_LO)) + return MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1); + + return addr; +} + static u32 get_block_address(unsigned int cpu, u32 current_addr, u32 low, u32 high, unsigned int bank, unsigned int block) { @@ -451,32 +480,8 @@ static u32 get_block_address(unsigned int cpu, u32 current_addr, u32 low, u32 hi } } - if (mce_flags.smca) { - if (smca_get_bank_type(bank) == SMCA_RESERVED) - return addr; - - if (!block) { - addr = MSR_AMD64_SMCA_MCx_MISC(bank); - } else { - /* - * For SMCA enabled processors, BLKPTR field of the - * first MISC register (MCx_MISC0) indicates presence of - * additional MISC register set (MISC1-4). - */ - u32 low, high; - - if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high)) - return addr; - - if (!(low & MCI_CONFIG_MCAX)) - return addr; - - if (!rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high) && - (low & MASK_BLKPTR_LO)) - addr = MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1); - } - return addr; - } + if (mce_flags.smca) + return smca_get_block_address(cpu, bank, block); /* Fall back to method we used for older processors: */ switch (block) {