From owner-freebsd-stable@freebsd.org Mon Feb 8 15:48:50 2021 Return-Path: Delivered-To: freebsd-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BF13153785B for ; Mon, 8 Feb 2021 15:48:50 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4DZ9Rk43c1z4Qpt for ; Mon, 8 Feb 2021 15:48:50 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mailman.nyi.freebsd.org (Postfix) id 8B3BB5378BA; Mon, 8 Feb 2021 15:48:50 +0000 (UTC) Delivered-To: stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8AFE053785A for ; Mon, 8 Feb 2021 15:48:50 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DZ9Rk3K21z3wX7; Mon, 8 Feb 2021 15:48:50 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qk1-x72f.google.com with SMTP id h8so4565770qkk.6; Mon, 08 Feb 2021 07:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FqGwgR02lwkHegIi5WXv1uBSZSnONj/qj9Zik5H4l1k=; b=cBvp7lslftlir93WqfNo4ztPB5mk87uZ/cu7CB3krRt2p6tFAGqEeA6MMMg/aNPD4z k98AYn3vpTVbzJwNfG3eAWFtLOfmv6bECrZXYkpHVy8/SAFtR9C9/EMck9Hb8OidCxhu /gRWn6+NJ5AF1HZjr31KnxAl+Wk4NT6LVJBFEAXniLmk1+ZaUV+j4FJgEM8rIZrOf4Ns TrYV7c5CCYENwRpE+0fK2l68Pek41JtDwdUcNoJyLlKSwY7xRnnTjxJYnIveHM09n5Kw O2C2xcOAizetVsy9SaA3u8eInO9H/dkBsb5YX+oxdA3De1ERVdEt3cQKeKy90LIH9Afu 71VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=FqGwgR02lwkHegIi5WXv1uBSZSnONj/qj9Zik5H4l1k=; b=AWBQH1WYper8m3Zmg8winN2PffT4FEoIkHpj1oodxXdHDGG+QuClYHlpocKaLafUMK Lp2ATD10NkUmN7WijdqAEteqiD4vSGU+zNzOQrN05o6IIXlUCvA2UM2UH8gW+X+TXE/G wZCUstuy/+PdGdyDlc/yeHihT1r8rnGEmZiAQ2XpTpA05GSflfcFpTeL3TirUWNrQpTg cD4N/36FeoJjq+LgyKk9j/nsfe/G3TKpeWonvRa87acObIugZTFYasNwFQCfB+UPtERu 3VUkcbpbI91Vo3k6bnYktjtvvrWEm9k9B9NFhrjOngitYbrKGGSBJ3KYvteNPnYNcr5I zyYA== X-Gm-Message-State: AOAM533zYTBfMav6t7/O4m/XIzh6IZGsbRmFbqU44cgg8axomxpKa1G7 SJTxcMZ2oo/6Y7eMuFNk9DA= X-Google-Smtp-Source: ABdhPJx9RmXpDkcZHi5+mMTD96biGI+Y7BBI4wphP57D9gLZYLfBzUK3butOdkQ4m2Ehopi8hjyN6g== X-Received: by 2002:a05:620a:389:: with SMTP id q9mr16976635qkm.323.1612799329442; Mon, 08 Feb 2021 07:48:49 -0800 (PST) Received: from raichu ([142.126.164.150]) by smtp.gmail.com with ESMTPSA id o45sm15391382qto.91.2021.02.08.07.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 07:48:48 -0800 (PST) Sender: Mark Johnston Date: Mon, 8 Feb 2021 10:48:46 -0500 From: Mark Johnston To: Konstantin Belousov Cc: Alan Somers , Matthew Macy , FreeBSD Stable ML Subject: Re: Page fault in _mca_init during startup Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4DZ9Rk3K21z3wX7 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2021 15:48:50 -0000 On Mon, Feb 08, 2021 at 05:33:22PM +0200, Konstantin Belousov wrote: > On Mon, Feb 08, 2021 at 10:03:59AM -0500, Mark Johnston wrote: > > On Mon, Feb 08, 2021 at 12:18:12AM +0200, Konstantin Belousov wrote: > > > On Sun, Feb 07, 2021 at 02:33:11PM -0700, Alan Somers wrote: > > > > Upgrading the BIOS fixed the problem, by clearing the MCG_CMCI_P bit on all > > > > processors. I don't have strong opinions about whether we should commit > > > > kib's patch too. Kib, what do you think? > > > > > > The patch causes some memory over-use. > > > > > > If this issue is not too widely experienced, I prefer to not commit the patch. > > > > Couldn't we short-circuit cmci_monitor() if the BSP did not allocate > > anything? > > > > diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c > > index 03100e77d45..0619a41b128 100644 > > --- a/sys/x86/x86/mca.c > > +++ b/sys/x86/x86/mca.c > I think something should be printed in this case, at least once. > I believe printf() already works, because spin locks do. Indeed, the printf() below should only fire on an AP during SI_SUB_SMP. Access to the static flag is synchronized by mca_lock. diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index 03100e77d45..8098bcfb4bd 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -1065,11 +1065,26 @@ mca_setup(uint64_t mcg_cap) static void cmci_monitor(int i) { + static bool first = true; struct cmc_state *cc; uint64_t ctl; KASSERT(i < mca_banks, ("CPU %d has more MC banks", PCPU_GET(cpuid))); + /* + * It is possible for some APs to report CMCI support even if the BSP + * does not, apparently due to a BIOS bug. + */ + if (cmc_state == NULL) { + if (first) { + printf( + "AP %d reports CMCI support but the BSP does not\n", + PCPU_GET(cpuid)); + first = false; + } + return; + } + ctl = rdmsr(MSR_MC_CTL2(i)); if (ctl & MC_CTL2_CMCI_EN) /* Already monitored by another CPU. */ @@ -1114,6 +1129,10 @@ cmci_resume(int i) KASSERT(i < mca_banks, ("CPU %d has more MC banks", PCPU_GET(cpuid))); + /* See cmci_monitor(). */ + if (cmc_state == NULL) + return; + /* Ignore banks not monitored by this CPU. */ if (!(PCPU_GET(cmci_mask) & 1 << i)) return;