From patchwork Tue Oct 19 23:36:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Smita Koralahalli X-Patchwork-Id: 12571383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 627F0C433EF for ; Tue, 19 Oct 2021 23:37:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D62C60EE3 for ; Tue, 19 Oct 2021 23:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230020AbhJSXja (ORCPT ); Tue, 19 Oct 2021 19:39:30 -0400 Received: from mail-bn8nam12on2063.outbound.protection.outlook.com ([40.107.237.63]:37922 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229814AbhJSXjY (ORCPT ); Tue, 19 Oct 2021 19:39:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RScuSZfE5hANaO02WJvjch4q2xNABRaOsJ85sIxkCw8iE+yflUWkmJdiHc27H1JllFeD//Dby8RGyYwd5LulmLM+lwVHrxtNoGa+kYMKwfmme50sECUcz5QoAhxtHPerdByzhpIRqPMpZPs3co+5M7m6+ca6v4wIgIFApjY2F7Kl4FwF+FACwPYlZ4foTEuBCaoVqniUZGmECle00XGEjvkGwSqGGJhZU+7CchmDL8E4NVLbEwdfTru0onYWNTNhlYe/mb9jL0MZUDq7BmPXsxPALEgszlyQzB9fYhujQTPrmThpOmwHCcKsw6AxjYGJ58zTZLsI/O7/999VU/fmVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FCHTXX1fvyjLnEG4TzbQaPhjeXeIDEkN9wTYuj6NUVE=; b=YdEVQLimqQnq2rirGts5/N7xN9yZHTE1niRESOSZzgPIhFxpvtw/rdi8iATkSynBE0VeNgQvP0eYeVMTXecoYDja14iZjsKhQP/XsKDNpfgd8LLBNZYO5lEKiMG2LUejCOS+sXbWP+EL8mnbcc4Bvn0G6lH2V6eumZzMqGD+vUAOwWK0tXR3SYOt+bHamntNtf9sQLoRtQlRuByUXD+3ojxVqDDceBaLb3bM2iooXOFC5o42sEwPtUxPyULNwv6dnj4DF3UfCRj/XgrZnJh7HxNmk4+ebntMfltYjtA8LuwoPS8phKVmR+ubFh64G7fOlhKyoT3lwD7D6bCqmH2p5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FCHTXX1fvyjLnEG4TzbQaPhjeXeIDEkN9wTYuj6NUVE=; b=Aj0aNf5psHpOzie9CkB0gus5Qp+SJpxZg8WBQSMXT06/YzkNJp6H1Ql7atv2t1BRiRv6+8bmJtKHaCCsNK/60M6zGzBBLGaFUU/sM1qHcLjmZoNNyQFqLvaYUXH60lX3pDhqm4xD2wCeRkRDk+DyhT+a7AItbKLHVKaXXJ7Od14= Received: from DM6PR17CA0035.namprd17.prod.outlook.com (2603:10b6:5:1b3::48) by SN6PR12MB2752.namprd12.prod.outlook.com (2603:10b6:805:78::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Tue, 19 Oct 2021 23:37:04 +0000 Received: from DM6NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b3:cafe::2) by DM6PR17CA0035.outlook.office365.com (2603:10b6:5:1b3::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 23:37:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT008.mail.protection.outlook.com (10.13.172.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 23:37:04 +0000 Received: from ethanolx50f7host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Tue, 19 Oct 2021 18:37:02 -0500 From: Smita Koralahalli To: , , CC: Tony Luck , "H . Peter Anvin" , , Subject: [PATCH v2 1/5] x86/mce/inject: Check if a bank is unpopulated before error injection Date: Tue, 19 Oct 2021 18:36:37 -0500 Message-ID: <20211019233641.140275-2-Smita.KoralahalliChannabasappa@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> References: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d4727575-f85a-4baa-305d-08d993595b37 X-MS-TrafficTypeDiagnostic: SN6PR12MB2752: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VEdcpGNxeiOlZry/zJM7pLWjvri5oxJVEBewKu04iC4vLn64jkUTzSuetFJZRtrDhuut8qZTellAvgzQf2yRNVb8HpeyfJdDTQ5vRHyVvCqZKKpJPDaLUlH5tf2esxFlfpxN90n+R+9uXEbHPL5CdPf1Dp+SAN/FgVv7dyqB26cVHAKE8CLZXSi0ZkfSGVI4E4a7SqIIkOGRk/9ieMMU6S8CsK1vEsBI/ZxLH5CgUMs0Z6vYDxgc7jt9qEojg7BeZAV8aCj0biVVgp4kgci22ssBv3843ErT2zNpnrjZdjLrnhVHrVyOiA8fEAFjxB8nDpfsqpCoZWC3qzXh5SJsgOUUmoIscQZQOukGCp8KLhU6W/NctiSXGXQpVY1A0YHlYyw6TwJ7T88eb3wbjwIkinH1DwAdiOr0R8D9Qp+r9+1C8hsKkJHTlG0HcgD3S6ObGTUzRiMubsLzEqOelnPRzhL3vcDW8wHA/Wd9ic6BONcy525jfl1yR3BE4HDZrS+CpM92756JSMbHtQcex7fItQ0+EeVsEsrFQfOOA9d85cTqgPXvv5oribHASoidyeWCjl5+CNhNrJ2ZjGESSwQ2e69/HVFxV5Xi+o/f0dAk0AAjOFQvTfRDcKMLtJnzFkHvnHrSbwSFiKRUZD1jLSAzhGd45cKiaGO49CB5eXyz7o+lUCOwDYisxixmrgK52I8068xTOcqiec2R1eMnq6+BJGFxWe58UbGtyW2n02EVBEs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(81166007)(316002)(1076003)(36756003)(83380400001)(47076005)(2906002)(110136005)(54906003)(7696005)(8676002)(70586007)(356005)(70206006)(5660300002)(36860700001)(426003)(336012)(16526019)(186003)(8936002)(15650500001)(86362001)(2616005)(26005)(6666004)(4326008)(82310400003)(508600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 23:37:04.0152 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4727575-f85a-4baa-305d-08d993595b37 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2752 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org 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. On a "hw" error injection check the value of this register before trying to inject the error. Do not impose any limitation on a "sw" injection and allow the user to test out all the decoding paths without relying on the available hardware, as its purpose is to just test the code. Signed-off-by: Smita Koralahalli Signed-off-by: Smita Koralahalli Signed-off-by: Borislav Petkov --- v2: simulate -> inject. Corrected according to kernel commenting style. boot_cpu_has() -> cpu_feature_enabled(). Error simulation not possible: Bank %llu unpopulated -> Cannot set IPID - bank %llu unpopulated. Used user provided IPID value on sw injection without checking underlying hardware and defined it under inj_ipid_set(). --- arch/x86/kernel/cpu/mce/inject.c | 39 +++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index 0bfc14041bbb..601efd104bb4 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -74,7 +74,6 @@ MCE_INJECT_SET(status); MCE_INJECT_SET(misc); MCE_INJECT_SET(addr); MCE_INJECT_SET(synd); -MCE_INJECT_SET(ipid); #define MCE_INJECT_GET(reg) \ static int inj_##reg##_get(void *data, u64 *val) \ @@ -89,13 +88,11 @@ MCE_INJECT_GET(status); MCE_INJECT_GET(misc); MCE_INJECT_GET(addr); MCE_INJECT_GET(synd); -MCE_INJECT_GET(ipid); DEFINE_SIMPLE_ATTRIBUTE(status_fops, inj_status_get, inj_status_set, "%llx\n"); DEFINE_SIMPLE_ATTRIBUTE(misc_fops, inj_misc_get, inj_misc_set, "%llx\n"); DEFINE_SIMPLE_ATTRIBUTE(addr_fops, inj_addr_get, inj_addr_set, "%llx\n"); DEFINE_SIMPLE_ATTRIBUTE(synd_fops, inj_synd_get, inj_synd_set, "%llx\n"); -DEFINE_SIMPLE_ATTRIBUTE(ipid_fops, inj_ipid_get, inj_ipid_set, "%llx\n"); static void setup_inj_struct(struct mce *m) { @@ -577,6 +574,25 @@ 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. + */ + if (cpu_feature_enabled(X86_FEATURE_SMCA)) { + + /* Check for user provided IPID value on a sw injection. */ + if (!m->ipid) { + rdmsrl_on_cpu(m->extcpu, MSR_AMD64_SMCA_MCx_IPID(val), + &m->ipid); + if (!m->ipid) { + pr_err("Cannot set IPID - bank %llu unpopulated\n", + val); + return -ENODEV; + } + } + } + do_inject(); /* Reset injection struct */ @@ -589,6 +605,23 @@ MCE_INJECT_GET(bank); DEFINE_SIMPLE_ATTRIBUTE(bank_fops, inj_bank_get, inj_bank_set, "%llu\n"); +/* Use the user provided IPID value on a sw injection. */ +static int inj_ipid_set(void *data, u64 val) +{ + struct mce *m = (struct mce *)data; + + if (cpu_feature_enabled(X86_FEATURE_SMCA)) { + if (val && inj_type == SW_INJ) + m->ipid = val; + } + + return 0; +} + +MCE_INJECT_GET(ipid); + +DEFINE_SIMPLE_ATTRIBUTE(ipid_fops, inj_ipid_get, inj_ipid_set, "%llx\n"); + static const char readme_msg[] = "Description of the files and their usages:\n" "\n" From patchwork Tue Oct 19 23:36:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Smita Koralahalli X-Patchwork-Id: 12571377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6697EC433FE for ; Tue, 19 Oct 2021 23:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 450D7611AE for ; Tue, 19 Oct 2021 23:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbhJSXjZ (ORCPT ); Tue, 19 Oct 2021 19:39:25 -0400 Received: from mail-mw2nam10on2071.outbound.protection.outlook.com ([40.107.94.71]:33310 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229668AbhJSXjW (ORCPT ); Tue, 19 Oct 2021 19:39:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OwhsPbzqtIwWzYLn1n7+TnI+ryCBFrEYggGpudYatqVnMLiZbywIuLsZDTXiz6du8vwljWPvja208I+LPkpoXee/1VoXbybwUaMeyZtp3/RC03BUF/g5SfxeZaC8eMN5OtktbHugBGqOvrLCwIJs1QtJdYIk7zvQx8ELCiUxeSJO7QfPXTqFT9xeLNpDM6nXUYpi5kuURx6gpqTdTWoj9rua+LIWIIhH9ouQZpjx2f+y8JMEP+Um98WnDGq9inFnoTDIBK/zBAOe7WRWcPhV63ClnCNP7p06N5XXP8gF7Ss66digvYDfyZPYaS5u8Iv5teO0ze7+uoVqNaD/FCdxrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6CXJRzD2/CSxXzMMsswy8apTDBXsl3luGd3usmANxe0=; b=E6KSCI038nsXic7jG4mJpDiRxU7uTRlbGu78CEu9UuVEipCv9fSjTJ2HxYEAyYkvj309gUr1D1G8DQkrOdvxAGuhxuITimm3Bv0B4UCebTvOMq7v0LlwbRevsgikHHGX2PwKBlv31Mu/NoZcmysZHftrV5wxyqP1RGXJ9Bo7IKJ1e2HEXtlbnIRjit/7wUOJVgjqS1q/3GgHFofXnq2ma+fm3hr6GvSkwcX9J7Qt0iedLZB5ABVZWLBN493NzKD4N58ZWy3l6lyKD81foJblrlsPekwCkOwqwo+FDTLTnCAbxac5g/RrLobjYDnVatrGGnX7bNd31OABejUTx5l+eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6CXJRzD2/CSxXzMMsswy8apTDBXsl3luGd3usmANxe0=; b=ZrMLfgmlK7sH7c7sLEYq1gSaicKckJEwg13v+02pxtT1+vItUwGE9rAcIiYArELrraaHGEN1p0pS48cvF76Ge16WRC5AebfmkMYtjs77hExRg1yRbra3kuN2Q3AaC8grVju9rsPrWx0HvVFHgSnZI78gYH9Y5Eyd5W4eaJALdhk= Received: from DM6PR17CA0036.namprd17.prod.outlook.com (2603:10b6:5:1b3::49) by DM6PR12MB3594.namprd12.prod.outlook.com (2603:10b6:5:11f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Tue, 19 Oct 2021 23:37:05 +0000 Received: from DM6NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b3:cafe::e5) by DM6PR17CA0036.outlook.office365.com (2603:10b6:5:1b3::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 23:37:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT008.mail.protection.outlook.com (10.13.172.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 23:37:05 +0000 Received: from ethanolx50f7host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Tue, 19 Oct 2021 18:37:04 -0500 From: Smita Koralahalli To: , , CC: Tony Luck , "H . Peter Anvin" , , Subject: [PATCH v2 2/5] x86/mce/inject: Warn the user on a not set valid bit in MCA_STATUS Date: Tue, 19 Oct 2021 18:36:38 -0500 Message-ID: <20211019233641.140275-3-Smita.KoralahalliChannabasappa@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> References: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80a549fb-a272-42c6-2ae9-08d993595c3f X-MS-TrafficTypeDiagnostic: DM6PR12MB3594: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5ykbMmHFN2QUAxHsO5Axzeoox00DXFs0nAH8ezxUPe1rJQAVqrPwXYDjVfTAV0uhuf8n8Uv/r2jVXqGdnvf1ZbRtgKo/6BiHgvIfn3vS9tQTe/bGCbnpQhXHcoNqbsywUV60hYQwL9by5MHKNx8zNUiaOcQr2Ye4OCQww1Y00JitE4yX+gJtOa5I8J+2a3tsPdfxBfNqnPfRVNYGJA+u5JM7dSkcspHlYtxkEvj0BOS6pGN5SD8wMm0vRVF9OY63ybeKtNPAzKTm+YoZas2oIGmE0YAXgg2OaRw8RNxoJMHuICSR0TGH/4CJUyb2foZDZBQbDL9zCSkJxGGihbom9SlX33CrJWbf86bBDjEWx0gykouiIhYy0Vx2N2JfTK7+lYMIAmNFyDW8mXl/EVavbChujhxYnJDHfBEmVyXLRB4PHhuYzgH0KCazpmeD2DHCgv1HMRzf4AnGZY2d0Mp+F1mn9yzuibpU/R5KC0WhybnNT1hHLFpAWtI3soRnCs9sbO6Dck8WF0CU9EoPgnpZ8lSQG4c3f0vtZBF1apG5r0iQC05aGKCtA9hgG1Xvu0lyxnJX5hb8f+Z9EBjMp8+nMiXDcyZ974m/uFLL7CiFB8jf0xEs/P3lyQw4U/lfnC3/hDrjljfBHJFnP1WpBZxfAtSpxMDSTS5t3Jv5gGoSpRHh3U6EOky5M57/ukC45ewXas0Ise+RDfwsM5I2fIYqT0S5/fQIIPCmgh2FnESKodk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(2906002)(6666004)(356005)(7696005)(47076005)(82310400003)(4326008)(8936002)(86362001)(5660300002)(508600001)(81166007)(36860700001)(1076003)(54906003)(110136005)(16526019)(8676002)(186003)(4744005)(316002)(336012)(70206006)(83380400001)(36756003)(70586007)(426003)(26005)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 23:37:05.6013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80a549fb-a272-42c6-2ae9-08d993595c3f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3594 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org MCA handlers check the valid bit in each status register (MCA_STATUS[Val]) and will likely ignore signatures if the valid bit is not set. Warn the user if the valid bit is not set before doing error injection. Signed-off-by: Smita Koralahalli --- v2: Added a warning statement instead of setting the valid bit. --- arch/x86/kernel/cpu/mce/inject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index 601efd104bb4..a993dc3d0333 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -487,6 +487,9 @@ static void do_inject(void) i_mce.tsc = rdtsc_ordered(); + if (!(i_mce.status & MCI_STATUS_VAL)) + pr_warn("Handlers might ignore signatures with Val=0 in MCA_STATUS\n"); + if (i_mce.misc) i_mce.status |= MCI_STATUS_MISCV; From patchwork Tue Oct 19 23:36:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Smita Koralahalli X-Patchwork-Id: 12571379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56832C433F5 for ; Tue, 19 Oct 2021 23:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3783560231 for ; Tue, 19 Oct 2021 23:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230029AbhJSXj1 (ORCPT ); Tue, 19 Oct 2021 19:39:27 -0400 Received: from mail-bn1nam07on2062.outbound.protection.outlook.com ([40.107.212.62]:21040 "EHLO NAM02-BN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229977AbhJSXjW (ORCPT ); Tue, 19 Oct 2021 19:39:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYmYfwStMa8tmskF23S67i49+Ei/whavj9W23IAUqsuzKN3VaFnvAN1aqDL4vSc5QClzw7KuMfmsCxoqm4qvgzJoipWuI3gxiE03i8jeUo1QqcKVn/EsX8Ij9603MB5fMsEHHPAZ7I1+lZtGdZpHDOgCgOUjRAauRzgNIiIVvY+JzrTQXoyC+A3G9l3HPaTUFzX9zVWZxPDKlAnJtj9tfHrG44cZf5j/z3fwRMVC/9j+RzoZ8OFuyu9otmKGgCnlq/Ika1oywpgsQ05lVrvfSb+DGu9LBom4b80iW/QmXY/0ZWco1qee7ehmCXk6d8VqelWQSxFo7r6OsKnS8zqFVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Aql1conarYYcOMMGPeZ8KzZEgRk0tWw7BKujuOwA64g=; b=nvPl9pZgTK+Idh9i1gH+6tWpqq1o3k3dVjsn8Paol1dfkMYcS88HI8rEnOn3pGSokB3qPZaQI2ijipX9q37EjKt0X+bOLFy2FXdQ6exnscSqSboEq9ZQ5eziz3MvrzT16O+M2vcYu7K2pRqWL4TnmkIcQn0kurZ32JybeEKFYj/Jivf9mgSCF6/BSz5xF3fasloNA2+N/Q1H0BF8IJQKO83Mdm4ndzgH2xVQ1AFK/GXmSvmMsCXTfx27yzcjt3MYGUaVDNq8/ngM2WEBK1TPEydnEcid88i5ja9VDBucz5IbPXLwkTJPAp15qUWHm11/CogM6YXxmotOfRmyJlVnZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Aql1conarYYcOMMGPeZ8KzZEgRk0tWw7BKujuOwA64g=; b=tA78vf8Kw/xZePDCxeLvQMGQXYEYWIdMOR+wxUEAnyJdpqbUpZWmHlbL/ZQ2nGj5BMNgwhLI14snmtaehJINqYr/6l4LD1rZ+cl3Rj5wY9BqVxCcfCdfSqit4uIh/d+vzYKnuYCm+ZxIeRnqejGLWqJFyulsuBIENGvCE5Dj24c= Received: from DM5PR2201CA0009.namprd22.prod.outlook.com (2603:10b6:4:14::19) by BN8PR12MB3425.namprd12.prod.outlook.com (2603:10b6:408:61::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Tue, 19 Oct 2021 23:37:07 +0000 Received: from DM6NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:4:14:cafe::1f) by DM5PR2201CA0009.outlook.office365.com (2603:10b6:4:14::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 23:37:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT023.mail.protection.outlook.com (10.13.173.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4628.16 via Frontend Transport; Tue, 19 Oct 2021 23:37:07 +0000 Received: from ethanolx50f7host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Tue, 19 Oct 2021 18:37:06 -0500 From: Smita Koralahalli To: , , CC: Tony Luck , "H . Peter Anvin" , , Subject: [PATCH v2 3/5] x86/mce: Use mca_msr_reg() in prepare_msrs() Date: Tue, 19 Oct 2021 18:36:39 -0500 Message-ID: <20211019233641.140275-4-Smita.KoralahalliChannabasappa@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> References: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5ad346f4-366d-448c-22af-08d993595d3c X-MS-TrafficTypeDiagnostic: BN8PR12MB3425: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lD9O3wosDHO+zwSpn/rKdMuiEYN4mw8o/+d3wBhv3TvtXh/e8p8dLOxi/GhjdLqvQN1VKGzMijGXYsk4hOgu4sL7JrThyf7YtEdEJU6GYa3HJjq2Xfp1EY9MwN19OdKcaeOPvF2NA4+/JUel/NK1h/TrZ+JTvKAUSCfxQvI5fdSkcFOTq6tL9C9Boyvti/N7ULnEeOVjT/waLxH44lB3FH4JBxyBarhaAQ45x+c/tRNYIQjGWss9U0haSRAqP6CC9cc0FV447TmRrFpi6Z0684y5weaXEVBFPS8D5cBb6TfpJaCHGiZiQAEoFyRh5S4GB1zU0B8lD0x3j2YZ8mehfS68B3huc2D3L31JpAL9vVuxcnucgppaA2l3jqk0M6T61mZscIK68JXg8iTTp6R5UilUTJyHlksYU4XfTAVWS9R4U8fHXXZFEnxNzJthTKu2tEVzK/XAF8b3J87KiHWvoY0xuvz/xefhWSvmDDhYKO83c8e5iLhTerMA9WHPWFXVxVKchAn5IGwK+xHSBtmp5Ix1Ng4YZuIqKDPIXPz5mjt1UQ0166hi4ADn0W6kCC3wwfmCmpeayHyfFp7WqPPV3YeLscxCkuHamK1ZTEJymNrjbXlwjdFsRkiUJXfd1bJJsG26palh51q4RVc+WYZ/rQEoCX/oJlzasllS6ZLly+K33LlsKxi2hyITipjLmza3wxJ1jpwm5tq8ePFnJNf4TYY6z/VGrH16FT+ZIWdAqng= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(82310400003)(356005)(86362001)(81166007)(83380400001)(316002)(186003)(7696005)(16526019)(26005)(70206006)(336012)(54906003)(110136005)(70586007)(426003)(2616005)(8936002)(5660300002)(6666004)(8676002)(36860700001)(1076003)(2906002)(508600001)(47076005)(36756003)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 23:37:07.4240 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ad346f4-366d-448c-22af-08d993595d3c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3425 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Replace MCx_{STATUS, ADDR, MISC} macros with mca_msr_reg(). Also, restructure the code to avoid multiple initializations for MCA registers. SMCA machines define a different set of MSRs for MCA registers and mca_msr_reg() returns the proper MSR address for SMCA and legacy processors. Initialize MCA_MISC and MCA_SYND registers at the end after initializing MCx_{STATUS, DESTAT} which is further explained in the next patch. Make mca_msr_reg() exportable in order to be accessible from mce-inject module. Signed-off-by: Smita Koralahalli --- v2: Replaced msr_ops -> mca_msr_reg(). --- arch/x86/kernel/cpu/mce/core.c | 1 + arch/x86/kernel/cpu/mce/inject.c | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 6ed365337a3b..fb4d8ac1cb4f 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -194,6 +194,7 @@ u32 mca_msr_reg(int bank, enum mca_msr reg) return 0; } +EXPORT_SYMBOL_GPL(mca_msr_reg); static void __print_mce(struct mce *m) { diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index a993dc3d0333..40d0bebe0cd2 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -461,22 +461,21 @@ static void prepare_msrs(void *info) wrmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus); - if (boot_cpu_has(X86_FEATURE_SMCA)) { - if (m.inject_flags == DFR_INT_INJ) { - wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(b), m.status); - wrmsrl(MSR_AMD64_SMCA_MCx_DEADDR(b), m.addr); - } else { - wrmsrl(MSR_AMD64_SMCA_MCx_STATUS(b), m.status); - wrmsrl(MSR_AMD64_SMCA_MCx_ADDR(b), m.addr); - } + if (boot_cpu_has(X86_FEATURE_SMCA) && + m.inject_flags == DFR_INT_INJ) { + wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(b), m.status); + wrmsrl(MSR_AMD64_SMCA_MCx_DEADDR(b), m.addr); + goto out; + } + + wrmsrl(mca_msr_reg(b, MCA_STATUS), m.status); + wrmsrl(mca_msr_reg(b, MCA_ADDR), m.addr); - wrmsrl(MSR_AMD64_SMCA_MCx_MISC(b), m.misc); +out: + wrmsrl(mca_msr_reg(b, MCA_MISC), m.misc); + + if (boot_cpu_has(X86_FEATURE_SMCA)) wrmsrl(MSR_AMD64_SMCA_MCx_SYND(b), m.synd); - } else { - wrmsrl(MSR_IA32_MCx_STATUS(b), m.status); - wrmsrl(MSR_IA32_MCx_ADDR(b), m.addr); - wrmsrl(MSR_IA32_MCx_MISC(b), m.misc); - } } static void do_inject(void) From patchwork Tue Oct 19 23:36:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Smita Koralahalli X-Patchwork-Id: 12571385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10518C433F5 for ; Tue, 19 Oct 2021 23:37:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9A7060EE3 for ; Tue, 19 Oct 2021 23:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbhJSXjh (ORCPT ); Tue, 19 Oct 2021 19:39:37 -0400 Received: from mail-mw2nam10on2040.outbound.protection.outlook.com ([40.107.94.40]:2017 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230070AbhJSXjd (ORCPT ); Tue, 19 Oct 2021 19:39:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ERaYm6Raps88EPvAwZSeTrfBGdF6VOzg8yA1ONKHoRPqbNQkckK31+bbC2fMYMrOxihkSHh6Zb+XlFd1qjZTGB7SF3BTvwb7Y8Qi+4oELJUOR2F1mse/3dsLk+EiotX18Lkhq5/tjFTOZw3lM5N1lLbmyca2Q3ZsB/K3PR4iHM6FnrSmojn1IQrKqkbcOts8Rvl2XpJsTbc8xmFKq2uRb0f2BXKU8FjNzOdAA3TXnfF5u8EGvibEQ39HEApI/7AKLDtXa6Fn6Ipx7BNX8Z6cF1HHeibnZciR4jX3DNgoafb4wfa+aEEPywXI3i2gFWyCX1fx9pNvDGHRO4JPkGnqig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nXphWJ19pEMHM3URayZ3YAvOqjE1u2Nobu3UpGIv9/c=; b=mRjNUY/Q1NDe2qSvfZlpXA49UzjHpk/zOi41O/ZhjJBLNZlV5rMd+JFnVX9t383YFZ9wnlYKirjwRoyFZrFcaO8vUN5exSrMF+NftePCS623Fk8P5TIdsRxVx/EDoiQ1l6ldrguNaqgnNncfYsTw604AN8yOtgqKYieM867x5T40kj3OLIbrLV27HXrXEFZAa1hAbNsJD9DPeDe07pBy18UVcCbuEXHtxa7P5Yx/JQ24+Ejsfa2dK865ktiV4atvnuNYQjsgyii4eWXsDB+pj3DqbRGm90b6FFZraqwGOombpxnF7oZuTXlVfWiGrWJF5ZVo2zhgksM6vNSkej+rVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nXphWJ19pEMHM3URayZ3YAvOqjE1u2Nobu3UpGIv9/c=; b=ykZ6OyNwAUdjQ0DQHS52kuP9X3aC4ZTWJG1hZxkzciQ4DLiEzmweYMgMBu5kGAAauLddQ/KyH5NxgtzJqbf91KQFgrXgxYz0+CKu3keNgmVoeCoUhmEHoVIEPM91Owetd5ZMeQUnTgCJLHHkQqImo2bc5Sx1XHU6iKYIyfoaDJg= Received: from DM6PR04CA0027.namprd04.prod.outlook.com (2603:10b6:5:334::32) by MWHPR1201MB0160.namprd12.prod.outlook.com (2603:10b6:301:50::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Tue, 19 Oct 2021 23:37:10 +0000 Received: from DM6NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:5:334:cafe::35) by DM6PR04CA0027.outlook.office365.com (2603:10b6:5:334::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 23:37:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT029.mail.protection.outlook.com (10.13.173.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4628.16 via Frontend Transport; Tue, 19 Oct 2021 23:37:10 +0000 Received: from ethanolx50f7host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Tue, 19 Oct 2021 18:37:08 -0500 From: Smita Koralahalli To: , , CC: Tony Luck , "H . Peter Anvin" , , Subject: [PATCH v2 4/5] x86/mce/inject: Check for writes ignored in status registers Date: Tue, 19 Oct 2021 18:36:40 -0500 Message-ID: <20211019233641.140275-5-Smita.KoralahalliChannabasappa@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> References: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c85b104-b289-40ed-1b98-08d993595ed2 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0160: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9BzVFaeSoJol0hs4t8toKfUPklINJ5UXZvZJCe6zyv0qRuhHTr75kN3Go6mGoUPceWl1MfF4ODpJOX94xgLnfMXQBUjt0DKeZ1LGOt5v91rOYnaBORhZu3xa1jt2Ikf+3bL77ioSs4e5fi0aR3WrcnCaiVgF6EzhyfeeDpjsjIk0qLj5LPO1xWq242Dol1UbpgZv930v15ccXbS2C1ynJWCjjHGGqTldnwzH/p+xDShIpDIK8PcqYSiAmnPQL73/HRIHauOrhG4lJo8iX0S3/XBidGQvKwHYPr5n6gWrnOR4pz34NLz1M75kZPoaOHOLyKlMi/TDwsME7bkq0nnpIlzyTt31QtYnLagGca/v6ExNV2MDid2YX5jTUS5DLZFH3Lk7IUqXIdxVtVR6szbZtgSvRd8fHHZnNQseP7MNI1qID+vhpmnMuOFppgzvT0v3ilQaR1n8KUp7SVrOaoWDh9EzFI/7mgH9N1rnkmq3jZRO/XiYkIsKNi2Ao5MESQofdAaWbIXeguo4L3DYDhMhHLrLWZhEDbyRnUIKhn6g0b7FcbNiJlsWmnrfm1VQP1BtL6YE96+q+QgIjecdNCo7pKdIxm7rH9+QqGUte215B9XmGvns8XP93B/7fqNIff3sS5mgBAFw+sRhY+m3UjhTsHpdm6FhD5w6ModCgtWJgASKilY/m2ODq4qkI1N6m4B/8vy180xKyCRf7fJRVMKWSxJgz0uHHt6/AFq/p9c2akHJkmg7awR1fB70cZ7VozTBCKGKVCreWBtt9RJ/hKuwJfigH8w/yxtFO7+CbaJhH5wIRhT99BcgPbk7IAC5b/YV X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(36860700001)(26005)(82310400003)(6666004)(186003)(16526019)(7696005)(70206006)(5660300002)(70586007)(110136005)(86362001)(4326008)(316002)(54906003)(2906002)(508600001)(426003)(8676002)(81166007)(2616005)(83380400001)(8936002)(47076005)(356005)(1076003)(336012)(966005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 23:37:10.0716 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c85b104-b289-40ed-1b98-08d993595ed2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0160 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org According to Section 2.1.16.3 under HWCR[McStatusWrEn] in "PPR for AMD Family 19h, Model 01h, Revision B1 Processors - 55898 Rev 0.35 - Feb 5, 2021", the status register may sometimes enforce write ignored behavior independent of the value of HWCR[McStatusWrEn] depending on the platform settings. Hence, evaluate for writes ignored for MCA_STATUS and MCA_DESTAT separately, before doing error injection. If true, return with an error code. Deferred errors on an SMCA platform use different MSR for MCA_DESTAT. Hence, evaluate MCA_DESTAT instead of MCA_STATUS on deferred errors, and do not modify the existing value in MCA_STATUS by writing and reading from it. Rearrange the calls and write to registers MCx_{ADDR, MISC, SYND} and MCG_STATUS only if error injection is available. Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 Signed-off-by: Smita Koralahalli --- v2: msr_ops -> mca_msr_reg(). simulation -> injection. pr_info() -> pr_err(). Aligned on "=". --- arch/x86/kernel/cpu/mce/inject.c | 39 ++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index 40d0bebe0cd2..72d29d26e033 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -454,24 +454,39 @@ static void toggle_nb_mca_mst_cpu(u16 nid) __func__, PCI_FUNC(F3->devfn), NBCFG); } +struct mce_err_handler { + struct mce *mce; + int err; +}; + +static struct mce_err_handler mce_err; + static void prepare_msrs(void *info) { - struct mce m = *(struct mce *)info; + struct mce_err_handler *i_mce_err = ((struct mce_err_handler *)info); + struct mce m = *i_mce_err->mce; u8 b = m.bank; - wrmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus); + u32 status_reg = mca_msr_reg(b, MCA_STATUS); + u32 addr_reg = mca_msr_reg(b, MCA_ADDR); if (boot_cpu_has(X86_FEATURE_SMCA) && m.inject_flags == DFR_INT_INJ) { - wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(b), m.status); - wrmsrl(MSR_AMD64_SMCA_MCx_DEADDR(b), m.addr); - goto out; + status_reg = MSR_AMD64_SMCA_MCx_DESTAT(b); + addr_reg = MSR_AMD64_SMCA_MCx_DEADDR(b); } - wrmsrl(mca_msr_reg(b, MCA_STATUS), m.status); - wrmsrl(mca_msr_reg(b, MCA_ADDR), m.addr); + wrmsrl(status_reg, m.status); + rdmsrl(status_reg, m.status); + + if (!m.status) { + pr_err("Error injection is not available\n"); + i_mce_err->err = -EINVAL; + return; + } -out: + wrmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus); + wrmsrl(addr_reg, m.addr); wrmsrl(mca_msr_reg(b, MCA_MISC), m.misc); if (boot_cpu_has(X86_FEATURE_SMCA)) @@ -484,6 +499,9 @@ static void do_inject(void) unsigned int cpu = i_mce.extcpu; u8 b = i_mce.bank; + mce_err.mce = &i_mce; + mce_err.err = 0; + i_mce.tsc = rdtsc_ordered(); if (!(i_mce.status & MCI_STATUS_VAL)) @@ -536,10 +554,13 @@ static void do_inject(void) i_mce.mcgstatus = mcg_status; i_mce.inject_flags = inj_type; - smp_call_function_single(cpu, prepare_msrs, &i_mce, 0); + smp_call_function_single(cpu, prepare_msrs, &mce_err, 0); toggle_hw_mce_inject(cpu, false); + if (mce_err.err) + goto err; + switch (inj_type) { case DFR_INT_INJ: smp_call_function_single(cpu, trigger_dfr_int, NULL, 0); From patchwork Tue Oct 19 23:36:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Smita Koralahalli X-Patchwork-Id: 12571381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2CB4C433F5 for ; Tue, 19 Oct 2021 23:37:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B499760F22 for ; Tue, 19 Oct 2021 23:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbhJSXj3 (ORCPT ); Tue, 19 Oct 2021 19:39:29 -0400 Received: from mail-dm6nam10on2063.outbound.protection.outlook.com ([40.107.93.63]:63072 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229987AbhJSXj1 (ORCPT ); Tue, 19 Oct 2021 19:39:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d0e1UkiA5fmc4N1Vvr+Ia5f+uVi19AYglR03LrlxgkRuoR2OyEsAp99PcPNbLFb0hF2p28NlPuHy3zqMvje56FV8a9N5D2l3kORFzADBWgmo1pbe8iNmWn7Jw1fhLb4SLM0IxCaAni1Gl+pbVWGRua9WbkzyD/3kuEWQlk8samgfp8ByxMpMEPCuerdUQ/q7FhsTMBXmv1naEXi5q+d2TAWIWdKP7TXuv9bOGKFgyYZXRdTvvj/7wmJq1JmfqrkKeAVoOYH55zohSFvmenyfHs6/gtkYpuzlCuAJJ/0DzlSkghS4lc2CZ4kXLiMCy8oIEWSYPX+02Nn3GP9KXWSqpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=573rEltmh+XVPiNULiPpaeAm3mWPH5l8jGUtKzx4bLg=; b=Gw7vk3CrBP+hee9AEDlZ+NQTvwL+nxmxu0a6fyDXXEHajLkW7IDjbMZK8ZwGrAK6NT72se3YzKt4o34rfPm+BqoU/HFG74eTuiMtZLVjw/l0DT6J1latzeg0AGbm3KGapg5J1ijGJT0l9AL7zul6Y4YLdT11P0Ui5PVyHSe+gSSoccnIe6+l9uEdJd2OgKwBq6da5J83tCFzUZJSbff3j/bOZOeI4Khj3ZxcVvG6WTmunAnSPdKS1nP9UFlnZwVozkh7dGEOEZ2WatWgr6+05LyVuXkzhUmQdEVkIOfoqqwy7F7LS3V5vYctvMgsmT0TJoLWWeSmezODUsbFgUleig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=573rEltmh+XVPiNULiPpaeAm3mWPH5l8jGUtKzx4bLg=; b=mhjU6YivkMGUBYLnDQ99LNMmCOe66WLamDWotiikxH4cSAHZCfeIHIQ3DcvGjpRN3NeKRqaSoz+dNNNHZ3BPxZmAnsDU7sEFudwLzm7SwuZXPdAO8piGYyW5OiLswT9zpvovx2g8DAT+sgzs6V7/AUg4sEn8Jv0hSWZHrN+9LtU= Received: from DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) by MN2PR12MB2928.namprd12.prod.outlook.com (2603:10b6:208:105::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Tue, 19 Oct 2021 23:37:12 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:3:c0:cafe::42) by DM5PR16CA0012.outlook.office365.com (2603:10b6:3:c0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 23:37:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 23:37:12 +0000 Received: from ethanolx50f7host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Tue, 19 Oct 2021 18:37:10 -0500 From: Smita Koralahalli To: , , CC: Tony Luck , "H . Peter Anvin" , , Subject: [PATCH v2 5/5] x86/mce/mce-inject: Return error code to userspace from mce-inject module Date: Tue, 19 Oct 2021 18:36:41 -0500 Message-ID: <20211019233641.140275-6-Smita.KoralahalliChannabasappa@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> References: <20211019233641.140275-1-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e2546310-daf5-4c13-6fdd-08d99359600d X-MS-TrafficTypeDiagnostic: MN2PR12MB2928: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2043; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NTArHuiI0X6kSfPqaN9IebuAI6zIJRM+tFtf7YkcaCcmxX0UZwmeUh7ApOluWk663WWNOKmTP3PxH/+NjtK/tLtS2X/UUEXIWImxEqzCaRQbXKYIZXmu0fPaY6lslxtho+QTjwsIguvItQGrFwHP6bzfROEhP+W/S4qdm+kO/TY6cYL5hMmkrOdLx6vafWjB2uGDtNy4L/UE3sMSWk2FfL9VJQaixztqRlzA6oEj8ShAbH4S7TWgI0as19a/RDNCzz647QbE6t3zIqFgifQPAdh1FKLclR/CONgLzaiDDkBCSMAWL9G5JQH7aQDKxe2T/UI8TUzmCg1cZQRHY5RfIdZOWix6Qqlrz+LPb37GhlZHOXSmVWhcP0cxPdPvme999Ei7/C/N+wSpV3hViCiKQ01MZRIYmo1OR9FcTnJTNDCfWkWBeF2k8CS9d7HdM1o1fKwGvw+ZuzCRbr9OUAnQR64rFefW7DY8C/eOpECy2FtQ1E9L1Oap8f0lz6uzgnqTHWmGt8FhRa2KQy8nDktMyk75ScfeWKEWJmJ1kqRp9lswL1r6geQ70BQb/7qpJAA/wSyShmFH0OxYp02G/DEp0p0JMXIwfHGn1tencLMLJqslN8SPCKoddnm3SgMEKzGAB/e0vM5dgL3+PlvcWPnLNFpKdfW4gY2/dfBu/bSRQbiX+Wk01MQn5VLlevsZ6tzKh3CGkMGoqMlxqxIUtFru+P/kJFaY/1ORfm7uORmMXsQ= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(36756003)(316002)(8936002)(2906002)(426003)(7696005)(5660300002)(1076003)(81166007)(47076005)(508600001)(70586007)(83380400001)(4326008)(2616005)(26005)(8676002)(86362001)(54906003)(110136005)(336012)(82310400003)(356005)(36860700001)(16526019)(70206006)(6666004)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 23:37:12.0722 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2546310-daf5-4c13-6fdd-08d99359600d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB2928 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Currently, the mce-inject module fails silently and user must look for kernel logs to determine if the injection has succeeded. Save time for the user and return error code from the module with appropriate error statements if error injection fails. Signed-off-by: Smita Koralahalli --- v2: Added pr_err() along with error code. --- arch/x86/kernel/cpu/mce/inject.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index 72d29d26e033..a1c3c1e0425f 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -547,8 +547,11 @@ static void do_inject(void) } cpus_read_lock(); - if (!cpu_online(cpu)) + if (!cpu_online(cpu)) { + pr_err("No online CPUs available for error injection\n"); + mce_err.err = -ENODEV; goto err; + } toggle_hw_mce_inject(cpu, true); @@ -621,7 +624,7 @@ static int inj_bank_set(void *data, u64 val) /* Reset injection struct */ setup_inj_struct(&i_mce); - return 0; + return mce_err.err; } MCE_INJECT_GET(bank);