Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1216674pxb; Fri, 6 Nov 2020 04:12:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJx65EMODftEIPrM0irDpkcu2twp1b6x1JL8pQs94uvfD7NvJ0x0XP5TZ1005/ZomoqmnCQS X-Received: by 2002:a17:906:1643:: with SMTP id n3mr1663725ejd.459.1604664747858; Fri, 06 Nov 2020 04:12:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604664747; cv=none; d=google.com; s=arc-20160816; b=lFbEQM8K/JwtgQFNlXFcgCRIBTz4oUVRwzBUeqr5mMvllG2NGFMB3QmTsLDNgdTqo/ h07xEdj33FtM4eRn/O+aAnLX65NRObAeJahKSVtcHJ3H8lrNqFh5LhGy04Wk3vQqBwP6 kkcu6+Qk/HaI/3pXUQNI3YVomcEVlHkcJ3JzI929wtgbUdKaFpq0UwOg+LYptss5o/bz WXy08BsFcILBE2k3o89923T7Pb3VwZVxO3Gp/HgF1QgTlrr8olkuMknNlSwDJNxiMlUx NJPD89dcpES161kEpXntsAEj+FpoNZYeHrv3vUcajrKAUkTKmhPpWnJU1GyEa7Smvp0V pvyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3Ci7oTqucUEYbCOxujDfl/9l+12eKuq8wK76UMHgU9Y=; b=WkqD+LfFo+gdmwJX35H8BtunQq3pYi2zEJELvs1gMrGho+TNK44wsBW9u17YAGaGSm Hz15DlMJQ+8zAeVD9z3INSjhXUTufbHbTSOEoiFX2an0dyGExeefYcai9BIIUcr3m3U3 5ZVpEvau8sbivQwioyzUVePNeue8NNJ63oL2+cjlxMSup5rI10GMtfgyNJeU3qXJYdti RlJHoQzHq0tWBpdaCi/A41Z5LHxme6GHU8vsN5pZ94PcvtNan/wCv8is9Fju9R8pOU4Y /UCDlWc5KcWhx7dgimVi94Qwlm8d82eFY/mR33/bpnWr/h3g8WZkrUppCzCdDowuJIem kAHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="MvI/6O8q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si738967ejx.118.2020.11.06.04.12.02; Fri, 06 Nov 2020 04:12:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="MvI/6O8q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727214AbgKFMJm (ORCPT + 99 others); Fri, 6 Nov 2020 07:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgKFMJl (ORCPT ); Fri, 6 Nov 2020 07:09:41 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91DF0C0613CF; Fri, 6 Nov 2020 04:09:41 -0800 (PST) Received: from zn.tnic (p200300ec2f0d1f002c83f8cfec6c8cbe.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:1f00:2c83:f8cf:ec6c:8cbe]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id DFACC1EC0472; Fri, 6 Nov 2020 13:09:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1604664580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=3Ci7oTqucUEYbCOxujDfl/9l+12eKuq8wK76UMHgU9Y=; b=MvI/6O8ql2JPvklh62TEq6HDldWkesRPzhwI2utlOiEmi7ukBo1NKFoJkSL/GYa7OAes+g MDo1gDgwVVhZXH1LIcqpK/M4uenUh4Vq+DQHgMYuX895azCn/xh/b+Ef3a3Py0OJbhP/x7 pJRd5mD+SiELlRHYootUvkBRJHkorWE= Date: Fri, 6 Nov 2020 13:09:23 +0100 From: Borislav Petkov To: Smita Koralahalli Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org, Tony Luck , "Rafael J . Wysocki" , Len Brown , Ard Biesheuvel , Punit Agrawal , Yazen Ghannam Subject: Re: [PATCH v5] cper, apei, mce: Pass x86 CPER through the MCA handling chain Message-ID: <20201106120923.GB14914@zn.tnic> References: <20201103164952.5126-1-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201103164952.5126-1-Smita.KoralahalliChannabasappa@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 03, 2020 at 10:49:52AM -0600, Smita Koralahalli wrote: > diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c > index af8d37962586..f56f0bc147e2 100644 > --- a/arch/x86/kernel/cpu/mce/apei.c > +++ b/arch/x86/kernel/cpu/mce/apei.c > @@ -51,6 +51,62 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err) > } > EXPORT_SYMBOL_GPL(apei_mce_report_mem_error); > > +int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) > +{ > + const u64 *i_mce = ((const u64 *) (ctx_info + 1)); > + unsigned int cpu; > + struct mce m; > + > + if (!boot_cpu_has(X86_FEATURE_SMCA)) > + return -EINVAL; > + > + /* > + * The starting address of the Register Array extracted from BERT > + * must match with the first expected register in the register > + * layout of MCAX address space. In SMCA systems this address > + * corresponds to banks's MCA_STATUS register. So which is it "MCAX" or "SMCA"? They both denote the same thing but let's stick to one to avoid unnecessary confusion. I'm guessing to "SMCA" because it is more wide-spread in the kernel... > + * > + * The Register array size must be large enough to include all > + * the SMCA registers which we want to extract. > + * > + * The number of registers in the Register Array is determined > + * by Register Array Size/8 as defined in UEFI spec v2.8, sec > + * N.2.4.2.2. The register layout is fixed and currently the raw > + * data in the register array includes 6 SMCA registers which the > + * kernel can extract. > + */ > + > + if ((ctx_info->msr_addr & MSR_AMD64_SMCA_MC0_STATUS) != > + MSR_AMD64_SMCA_MC0_STATUS || ctx_info->reg_arr_size < 48) > + return -EINVAL; Split that if in two consecutive if-statements. Also, why the ANDing and not simply do: if (ctx_info->msr_addr == MSR_AMD64_SMCA_MC0_STATUS) ? I'm guessing you wanna match *all* MCi_STATUS MSRs - not only MC0, yes? If so, document that with in the comment above it. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette