Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13476588ybl; Sun, 29 Dec 2019 12:50:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwYFxkBrTkD4TDF69b/cjEmWyTd//wcv28n/vlvV3I/tzTAu7SgrgEDo+p9pOrq2LOt/2aV X-Received: by 2002:a05:6830:22e6:: with SMTP id t6mr73568174otc.244.1577652612028; Sun, 29 Dec 2019 12:50:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652612; cv=none; d=google.com; s=arc-20160816; b=E3VuXXmZPO7UlAP6skytiCuyIXzhgw+Tc5rKVtK80H0ug7/FLxytYJBTJVcqa2kfjO HwssBfb1AzyetTO8WxTO2GNyXM0irLK4hh0Wr+lW4D9cR+XKjMD5qmIEBgt4vqWW5U7b NYe1hHBplUifz6f8lFvb3fc0TmmqqxlxdCkY0rek8kwiuXGnhqWJiOINGe74FUyE3hIf kFm0eibHWrdQ6YuOPvCXfCs2FiPAOgsAS5GpD/kJD2ChB08gfGrVPVL8rB+oOA/WIs9L qJjfTS4qKBO6PANNCSjFt3eBz2m2YxP4Iuk6P86zT70K3iFF9zNnGF7G3bgWbXyCMpnE d1FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NEVuFI0JcJIVBcvepGWEA4oQg59tGoidbtzshEcJaYk=; b=0UiKkqHWjnUtRLQeet3IiNx6GesJsN9djGMXAznsY1JmodKpqvXj8yOYjjo5sUPInL k+NcZOMBc9/NJba+hA8qd0zWk89IESaQzOeV/6xYZ2gkJfDssUEgrqebjJ/3kC+5nhif 7ycc/plJcHdDYdEh+RdSVYGrafq89utxwTfXhYjcINFBjvX2bVd1dQEBNfVrJGxrnbJP ACx9B2CvnhJDAX0Luj2fe6d7uv6Ua2C2/gbO3H6cEe256GdKM60xlCvuQYWAF5UsFO5N 6FiM99IGCqkGsHhWZgcgj+h6TWXgGXmSY9zK8man97CAJ3JsyWrc4J/yTpbFgPThVrkX Ydfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nq1e6kNO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si21055866otn.294.2019.12.29.12.50.00; Sun, 29 Dec 2019 12:50:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nq1e6kNO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387622AbfL2R6u (ORCPT + 99 others); Sun, 29 Dec 2019 12:58:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:50078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387607AbfL2R6t (ORCPT ); Sun, 29 Dec 2019 12:58:49 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0830206A4; Sun, 29 Dec 2019 17:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577642328; bh=jjSDoosDC2f5Hfu0htQLEoNtBfuF1F+entclPo6rXTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nq1e6kNOEd5IQw5yVhIOezwGAFrHWFTR/rKe8DxTFW2iZ/rfmp4mMFj9GFf+RYxGJ 6Ag7Or4SbvkzbeDHWpTcftxiCbS6VUfqWO/KtJWV2Lj4zEZVSpJnXiF4tgFrPlt41t wqqhZmdh74F9ZePBOgGevCaxNCGAUyDEJBcEfH7U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Khlebnikov , Borislav Petkov , Yazen Ghannam , "H. Peter Anvin" , Ingo Molnar , linux-edac , Thomas Gleixner , Tony Luck , x86-ml Subject: [PATCH 5.4 421/434] x86/MCE/AMD: Do not use rdmsr_safe_on_cpu() in smca_configure() Date: Sun, 29 Dec 2019 18:27:54 +0100 Message-Id: <20191229172731.058586083@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Konstantin Khlebnikov commit 246ff09f89e54fdf740a8d496176c86743db3ec7 upstream. ... because interrupts are disabled that early and sending IPIs can deadlock: BUG: sleeping function called from invalid context at kernel/sched/completion.c:99 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1 no locks held by swapper/1/0. irq event stamp: 0 hardirqs last enabled at (0): [<0000000000000000>] 0x0 hardirqs last disabled at (0): [] copy_process+0x8b9/0x1ca0 softirqs last enabled at (0): [] copy_process+0x8b9/0x1ca0 softirqs last disabled at (0): [<0000000000000000>] 0x0 Preemption disabled at: [] start_secondary+0x3b/0x190 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.5.0-rc2+ #1 Hardware name: GIGABYTE MZ01-CE1-00/MZ01-CE1-00, BIOS F02 08/29/2018 Call Trace: dump_stack ___might_sleep.cold.92 wait_for_completion ? generic_exec_single rdmsr_safe_on_cpu ? wrmsr_on_cpus mce_amd_feature_init mcheck_cpu_init identify_cpu identify_secondary_cpu smp_store_cpu_info start_secondary secondary_startup_64 The function smca_configure() is called only on the current CPU anyway, therefore replace rdmsr_safe_on_cpu() with atomic rdmsr_safe() and avoid the IPI. [ bp: Update commit message. ] Signed-off-by: Konstantin Khlebnikov Signed-off-by: Borislav Petkov Reviewed-by: Yazen Ghannam Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: linux-edac Cc: Cc: Thomas Gleixner Cc: Tony Luck Cc: x86-ml Link: https://lkml.kernel.org/r/157252708836.3876.4604398213417262402.stgit@buzz Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/mce/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -269,7 +269,7 @@ static void smca_configure(unsigned int if (smca_banks[bank].hwid) return; - if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) { + if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) { pr_warn("Failed to read MCA_IPID for bank %d\n", bank); return; }