Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1336462pxb; Fri, 24 Sep 2021 02:09:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA+FjMHFYJCCUND+41EUmtBE5umhOZWZsCHWEUcrzl/kRd80h9a6RaN35s5Uqv9bXyrXm+ X-Received: by 2002:a92:d2ca:: with SMTP id w10mr7214212ilg.222.1632474551647; Fri, 24 Sep 2021 02:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632474551; cv=none; d=google.com; s=arc-20160816; b=fJ55j34ukkR7q4x16SQGBrTC11N5BRJJkCDqyWMMYv6j7S4BsG3SpEw7go320EXac/ P7upTCNWOfw7PrLZ4QdLexCspkwkiaY1PYWLt22QyJOesklSr2chhOJNhmwjQaLBB+4Y A0kCpijhz3sdUhcvt0nQIuwnTR9M27dpyCxqKVQr1tp5vYsEpd0HcwSoGIfTGsPiQcwj 751BKVcrwRG/9y2iTtjQSXkeCaAExV/iP/j6QGD1Rv2QKeRHt8b1LRipFnZB7VPd8HYG pvSc5RlJmwNftEB8ZHOdm9ZRg8lQrkHZ8MMUYmwJt+9uvKUQ7xn1gE++G0imvsM9l3lc IzgA== 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=g/1DsUfNrsaU19xQFtLQJwlQ4Uaxt39oFO0ESRLhfiU=; b=sKDySqppJyHKuxuhjGgbP00oYPagc7fgGRC/j+HpiqOQvJ2jwj96eDLMioyYx1VyyB XAZLeiLE+DQ1Mo9PB7sxb7tp0MysEgwIFvDBL+JnhwH+702+CztOpzv0JCjpGffrR+FU hu81QBCga3k+ZUEj2w70RWk1nvfHrIhvHHMWXKVNa8gLf9aFGTxzv1AVAYPMn8omeUIk jtlGZ7avGbZ71jgPuSrDVrQHkfSm7bab9r03NMgXDLM2l+l+4O0DE6hW8H3RlU+QrEOv bJPpvAey9KsFcUIKeR3rFiGNrnVbymFbL2qXKe4PMge0xw86DotoWLUNTLemGQFpukDq 44mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=hmRf+Exp; 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 h2si9558895ilc.72.2021.09.24.02.09.00; Fri, 24 Sep 2021 02:09:11 -0700 (PDT) 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=hmRf+Exp; 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 S244727AbhIXI1t (ORCPT + 99 others); Fri, 24 Sep 2021 04:27:49 -0400 Received: from mail.skyhub.de ([5.9.137.197]:52462 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244708AbhIXI1s (ORCPT ); Fri, 24 Sep 2021 04:27:48 -0400 Received: from zn.tnic (p200300ec2f0dd600c2485b7778a62ff5.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:d600:c248:5b77:78a6:2ff5]) (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 CAE201EC0419; Fri, 24 Sep 2021 10:26:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1632471970; 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=g/1DsUfNrsaU19xQFtLQJwlQ4Uaxt39oFO0ESRLhfiU=; b=hmRf+Exp2Zacicxpd2yCqIJGcjPE7uKThAFdVvRM151B/U9vehxWmX/Rp0Z7ZHiO4iTaai 9Njn4QufrRtSjXqAKSDHC1aVBA+JGxEzY/jNnpygLITJCn7j75K/QokKRU8v9SMyJ+ISou zOxi0bAwCgIw4C00b0LJje5AFd7EY3Q= Date: Fri, 24 Sep 2021 10:26:03 +0200 From: Borislav Petkov To: Smita Koralahalli Cc: x86@kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Tony Luck , "H . Peter Anvin" , yazen.ghannam@amd.com Subject: Re: [PATCH 1/5] x86/mce/inject: Check if a bank is unpopulated before error simulation Message-ID: References: <20210915232739.6367-1-Smita.KoralahalliChannabasappa@amd.com> <20210915232739.6367-2-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210915232739.6367-2-Smita.KoralahalliChannabasappa@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 15, 2021 at 06:27:35PM -0500, Smita Koralahalli wrote: > The MCA_IPID register uniquely identifies a bank's type on Scalable MCA > (SMCA) systems. When an MCA bank is not populated, the MCA_IPID register > will read as zero and writes to it will be ignored. Check the value of > this register before trying to simulate the error. > > Signed-off-by: Smita Koralahalli > --- > arch/x86/kernel/cpu/mce/inject.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c > index 0bfc14041bbb..51ac575c4605 100644 > --- a/arch/x86/kernel/cpu/mce/inject.c > +++ b/arch/x86/kernel/cpu/mce/inject.c > @@ -577,6 +577,24 @@ static int inj_bank_set(void *data, u64 val) > } > > m->bank = val; > + > + /* Read IPID value to determine if a bank is unpopulated on the target > + * CPU. > + */ Kernel comments style format is: /* * A sentence ending with a full-stop. * Another sentence. ... * More sentences. ... */ > + if (boot_cpu_has(X86_FEATURE_SMCA)) { This whole thing belongs into inj_ipid_set() where you should verify whether the bank is set when you try to set the IPID for that bank. > + > + /* Check for user provided IPID value. */ > + if (!m->ipid) { > + rdmsrl_on_cpu(m->extcpu, MSR_AMD64_SMCA_MCx_IPID(val), > + &m->ipid); Oh well, one IPI per ipid write. We're doing injection so we can't be on a production machine so who cares about IPIs there. > + if (!m->ipid) { > + pr_err("Error simulation not possible: Bank %llu unpopulated\n", "Cannot set IPID for bank... - bank %d unpopulated\n" Also, in all your text, use "injection" instead of "simulation" so that there's no confusion. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette