Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1309353pxb; Thu, 14 Apr 2022 03:20:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcQBzBkhO0vPTrnmr4p5FFELBj5pRNIvm1/P90AQE/sChk6cgEG2VkZOqKOEv3xaRFHAL/ X-Received: by 2002:a50:9b11:0:b0:419:a8f:580c with SMTP id o17-20020a509b11000000b004190a8f580cmr2158199edi.292.1649931646687; Thu, 14 Apr 2022 03:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649931646; cv=none; d=google.com; s=arc-20160816; b=fThi5/8+KDjsRw1/Pdk4pQFcmAuxyH3VsPue+9kbukq3K2OcDxzQQEnmWS1k3E8MOp oLd8IV3neIhUFkTKoEUbNTtCnGHDQfxkJ/ChsHcoNe0oVB7D2nxy3bUGzzDlRJozKQ+O xZ5kTTpE/Dx1V9Nz8vYv9WYgk5QhXQlrgTaRzxD64sB0jj/+GRmIvu+gGNhsLtkfmbbv kyM+s6nAhuOKOgO0xTciiQqNYg4MkrWiG8w4vVCZxp8FgO+XWtsxHw6Jd7bhg29nzvTD mdsclKRkB/sNoRvruMkNsqSfKBLrveOCXAdt+gqCra8FJOHUszXQo7ZjdKz77fTJJ8LP 7r0w== 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=p+O6n6Z3Yxtug5CMKm8LfVu4PlDMItDjhIquSNsVyMM=; b=KleK/P47z8A2U/bELkSPo3iwIPbE/jfkrTgCXM6olZ+R7jYzUy6LuBxxafH79nUU6o YuX9RCUcYXp8W0aRCIsGU7dOftgp1ak+SLjliLrxjDT/NYjszrOAksBPZmS7c5PNn4ar jHkFC5mAJAo786de2o5MjtbABASB0fT/dmrn9DZEW9aYPDVnNIs8FujWZ50ejG7rpqVH hUhpwpIf+Xo4yr47b/f9bZA0bOUbjvEtn5gYwtPFVge/x7MWvH26cVDTQJ6reF7lYkhg 6Hb05rP4R93IpSaD3TxJSZ3t0z5VmB36JKu6FBHayY82IqmtxGGvwoD7aFnHMH4orlYp JJ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=sDF1578h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a17090630c400b006e89f35bd27si1761644ejb.874.2022.04.14.03.20.21; Thu, 14 Apr 2022 03:20:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=sDF1578h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234653AbiDMO4a (ORCPT + 99 others); Wed, 13 Apr 2022 10:56:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230122AbiDMO41 (ORCPT ); Wed, 13 Apr 2022 10:56:27 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A9A644C3; Wed, 13 Apr 2022 07:54:06 -0700 (PDT) Received: from zn.tnic (p2e55d808.dip0.t-ipconnect.de [46.85.216.8]) (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 5EA361EC0576; Wed, 13 Apr 2022 16:54:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1649861640; 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=p+O6n6Z3Yxtug5CMKm8LfVu4PlDMItDjhIquSNsVyMM=; b=sDF1578hXLIXVkm/8HIg6ZBmxbHEt6W1Sm19vAmd+U0Xkpqvno3UhlkhDDSz+NxC2pSH62 jF5k8i2QLiNVHY3XCh5gB0DscgTBmSIFaT33mR202pROLGUMNbM3Umz3ToBn4V/M7ydYv7 3U5B41KzPg06si35Uh3YI9ocq+arpu8= Date: Wed, 13 Apr 2022 16:54:00 +0200 From: Borislav Petkov To: Yazen Ghannam Cc: Smita Koralahalli , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Tony Luck , hpa@zytor.com, Dave Hansen Subject: Re: [PATCH v5 2/2] x86/mce: Add support for Extended Physical Address MCA changes Message-ID: References: <20220412154038.261750-1-Smita.KoralahalliChannabasappa@amd.com> <20220412154038.261750-3-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 13, 2022 at 02:10:30PM +0000, Yazen Ghannam wrote: > This function gets called from __mcheck_cpu_init_early() so that the info is > available before the MCA banks are polled in __mcheck_cpu_init_generic(). Would that work? I've moved first bank polling into __mcheck_cpu_init_clear_banks() because, well, this function is clearing the banks so it might as well poll them first. First bank polling in a init_generic function doesn't make too much sense anyway. And __mcheck_cpu_check_banks() functionality is moved into __mcheck_cpu_init_clear_banks() because, well, silly. On a quick scan, I don't see problems with such move but the devil is in the detail. Hmm? --- diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 99e3ff9607a3..345e068215c4 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1732,21 +1732,8 @@ static void __mcheck_cpu_cap_init(void) static void __mcheck_cpu_init_generic(void) { - enum mcp_flags m_fl = 0; - mce_banks_t all_banks; u64 cap; - if (!mca_cfg.bootlog) - m_fl = MCP_DONTLOG; - - /* - * Log the machine checks left over from the previous reset. Log them - * only, do not start processing them. That will happen in mcheck_late_init() - * when all consumers have been registered on the notifier chain. - */ - bitmap_fill(all_banks, MAX_NR_BANKS); - machine_check_poll(MCP_UC | MCP_QUEUE_LOG | m_fl, &all_banks); - cr4_set_bits(X86_CR4_MCE); rdmsrl(MSR_IA32_MCG_CAP, cap); @@ -1757,33 +1744,21 @@ static void __mcheck_cpu_init_generic(void) static void __mcheck_cpu_init_clear_banks(void) { struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); + enum mcp_flags m_fl = 0; + mce_banks_t all_banks; + u64 msrval; int i; - for (i = 0; i < this_cpu_read(mce_num_banks); i++) { - struct mce_bank *b = &mce_banks[i]; - - if (!b->init) - continue; - wrmsrl(mca_msr_reg(i, MCA_CTL), b->ctl); - wrmsrl(mca_msr_reg(i, MCA_STATUS), 0); - } -} + if (!mca_cfg.bootlog) + m_fl = MCP_DONTLOG; -/* - * Do a final check to see if there are any unused/RAZ banks. - * - * This must be done after the banks have been initialized and any quirks have - * been applied. - * - * Do not call this from any user-initiated flows, e.g. CPU hotplug or sysfs. - * Otherwise, a user who disables a bank will not be able to re-enable it - * without a system reboot. - */ -static void __mcheck_cpu_check_banks(void) -{ - struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); - u64 msrval; - int i; + /* + * Log the machine checks left over from the previous reset. Log them + * only, do not start processing them. That will happen in mcheck_late_init() + * when all consumers have been registered on the notifier chain. + */ + bitmap_fill(all_banks, MAX_NR_BANKS); + machine_check_poll(MCP_UC | MCP_QUEUE_LOG | m_fl, &all_banks); for (i = 0; i < this_cpu_read(mce_num_banks); i++) { struct mce_bank *b = &mce_banks[i]; @@ -1791,6 +1766,9 @@ static void __mcheck_cpu_check_banks(void) if (!b->init) continue; + wrmsrl(mca_msr_reg(i, MCA_CTL), b->ctl); + wrmsrl(mca_msr_reg(i, MCA_STATUS), 0); + rdmsrl(mca_msr_reg(i, MCA_CTL), msrval); b->init = !!msrval; } @@ -2159,7 +2137,6 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c) __mcheck_cpu_init_generic(); __mcheck_cpu_init_vendor(c); __mcheck_cpu_init_clear_banks(); - __mcheck_cpu_check_banks(); __mcheck_cpu_setup_timer(); } -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette