Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1129256imu; Tue, 11 Dec 2018 13:14:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uvrs2YzDG1V4easDnEskfBI45o2241E0tWZwIMAAqZcwoBc58jZtuHGNBuNVZES5IXYgH4 X-Received: by 2002:a63:4d66:: with SMTP id n38mr16093234pgl.270.1544562881326; Tue, 11 Dec 2018 13:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544562881; cv=none; d=google.com; s=arc-20160816; b=uJJq7LROZjGnPx6bFkmK0PyFIiEdiBVnC3n2UMq/wq6OGX8WJVbwrUosuH/pzosxnv kEC7P1JYwmEtmTm7cpUtjU1U1YfNXLbgtjUcu6T5de6grFIzgdLLZdIIm2u6fTA82g3U tlKHvmUqFxjHiA0FimRGkNjwsmWEDuEIMJMAXJQTygyNzHJpQavXyMB4KG9tnwDub6Yi EcY4zzVFu8BhOo7xuF6fL6FuwiT/4MhmMmbJgTYseHou7w4u7jXMVwJt54qzauQVXpD4 +qp2AlzHp43VfXN+oeh3qPx4G/bW/TtH7pBEcZ0f6W77xPTN5vvyY7BPfiHGun3L0aP2 tJDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=PO3Oeket6cT3anL3aybYssizt70D9Pew5A8QECMYe8E=; b=E5RYgswSy26P7p1bw9epJYQH/7PRpMzJYmFoEQVBWTSMcAmjrQEsY97QCxCnTcC0Aq V9kXSDl+K1rj56ZvkOip7ZPlhMuOr5w3KW7qP0CTX2ywq0W4CAdH9hHCf2d+PHHAcURA d2uaqN7lJT+9c1TT+lLAo8QblCfWWXGZ1Kcioj/fFpF4xlPuIk+0fBv7Juu33m3ykxPb JSZIqqf4idCWc2I2h8aiVj5sDUZ+2LwZahu6erT2bAorTa2QyaYawm/ksLZevolR2G6o il3IWNZxdgI84VlTMpd0cdFwu5/21SxLRj+rWVcBOxpolDpMW3c9s0jpVBl4VEDllI9R 3gwg== ARC-Authentication-Results: i=1; mx.google.com; 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 m76si13530307pfj.48.2018.12.11.13.14.26; Tue, 11 Dec 2018 13:14:41 -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; 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 S1726298AbeLKVNX (ORCPT + 99 others); Tue, 11 Dec 2018 16:13:23 -0500 Received: from terminus.zytor.com ([198.137.202.136]:54491 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726134AbeLKVNW (ORCPT ); Tue, 11 Dec 2018 16:13:22 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id wBBLD7Df4154210 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 11 Dec 2018 13:13:07 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id wBBLD5Qh4154207; Tue, 11 Dec 2018 13:13:05 -0800 Date: Tue, 11 Dec 2018 13:13:05 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Reinette Chatre Message-ID: Cc: mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, reinette.chatre@intel.com, fenghua.yu@intel.com, mingo@redhat.com, hpa@zytor.com, bp@suse.de, tony.luck@intel.com, stable@vger.kernel.org, x86@kernel.org Reply-To: bp@suse.de, tony.luck@intel.com, stable@vger.kernel.org, x86@kernel.org, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, reinette.chatre@intel.com, fenghua.yu@intel.com, mingo@redhat.com, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/intel_rdt: Ensure a CPU remains online for the region's pseudo-locking sequence Git-Commit-ID: 80b71c340f17705ec145911b9a193ea781811b16 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 80b71c340f17705ec145911b9a193ea781811b16 Gitweb: https://git.kernel.org/tip/80b71c340f17705ec145911b9a193ea781811b16 Author: Reinette Chatre AuthorDate: Mon, 10 Dec 2018 13:21:54 -0800 Committer: Borislav Petkov CommitDate: Tue, 11 Dec 2018 21:59:01 +0100 x86/intel_rdt: Ensure a CPU remains online for the region's pseudo-locking sequence The user triggers the creation of a pseudo-locked region when writing the requested schemata to the schemata resctrl file. The pseudo-locking of a region is required to be done on a CPU that is associated with the cache on which the pseudo-locked region will reside. In order to run the locking code on a specific CPU, the needed CPU has to be selected and ensured to remain online during the entire locking sequence. At this time, the cpu_hotplug_lock is not taken during the pseudo-lock region creation and it is thus possible for a CPU to be selected to run the pseudo-locking code and then that CPU to go offline before the thread is able to run on it. Fix this by ensuring that the cpu_hotplug_lock is taken while the CPU on which code has to run needs to be controlled. Since the cpu_hotplug_lock is always taken before rdtgroup_mutex the lock order is maintained. Fixes: e0bdfe8e36f3 ("x86/intel_rdt: Support creation/removal of pseudo-locked region") Signed-off-by: Reinette Chatre Signed-off-by: Borislav Petkov Cc: "H. Peter Anvin" Cc: Fenghua Yu Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Tony Luck Cc: gavin.hindman@intel.com Cc: jithu.joseph@intel.com Cc: stable Cc: x86-ml Link: https://lkml.kernel.org/r/b7b17432a80f95a1fa21a1698ba643014f58ad31.1544476425.git.reinette.chatre@intel.com --- arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c index 27937458c231..efa4a519f5e5 100644 --- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c +++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c @@ -23,6 +23,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -310,9 +311,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, return -EINVAL; buf[nbytes - 1] = '\0'; + cpus_read_lock(); rdtgrp = rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { rdtgroup_kn_unlock(of->kn); + cpus_read_unlock(); return -ENOENT; } rdt_last_cmd_clear(); @@ -367,6 +370,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, out: rdtgroup_kn_unlock(of->kn); + cpus_read_unlock(); return ret ?: nbytes; }