Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8254407imu; Fri, 28 Dec 2018 13:50:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN7/fSFdF/061a5yOLjfHiZxal0YjmuDk/CpX7FMF/vNsw9jBkSOj8WMykmxs73kHAqxMCqr X-Received: by 2002:a63:7512:: with SMTP id q18mr25677493pgc.231.1546033803557; Fri, 28 Dec 2018 13:50:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546033803; cv=none; d=google.com; s=arc-20160816; b=FSAChBNKKj4X5m9A7R7Rot5VXN1pErEICbau/DOUuv55tT9r8a3c8/xMHhO7DCAlMJ uhynHMuOc5orEcbTIQu9EH+rSNMRYMTmbp7jIc/rdRMgvv/N1IGCeMhbggk34mhF3ER4 pH2LSNjzDg54jwifaq3QywVhN4804odjEd89+/JEtRPCNFANRRGb0YS7jH9XCvrzpqOC HImxjme0MD+bKxWsIqqfNXV+oHu9W6FUDl7QlHiTeOnNwIoeApTtsHsstDzLpF+ZMNzx EZ0dAaixVfQGrIiMdXrU5FuhUeSttASW8qw2O6PB1XEOtQtJX9e+EsHau9qhHaVLXn7O OouQ== 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=GYK2mp58+21bQTMbCkO0+btzYENtwTQam3wZFI16VQQ=; b=dcAmQ79BwY+hj/Kgp1iDjXgp8TV1MQ8IvseChqqHWaWk5uOiBO+TZWXpU0wJ1JCTgI QV5dh7++1axGvocGWpEH1a07FE8cnr+VGr7Wdqvnd13fNtSeNIBuLTxSYigrSkZLjJLt s+ZEhc8t3x2CExlGI4Z2iDrBboQMtczD1akjWCB8D4Jakm9M1JjzGXU1zpWUZNZSvlxO bgz/glf8DOYNroOItnAV129bkRps540aOAHz/5lF7va4Duy8W2+Gc68QzE1jFlmT/Www g6b5PjiSmV2FtGnwRxox6kCYcktQ0p2Dif05CxtL/vmMSYxXfrERhUCBrzdldooFe5rg ouew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=itoZRdF4; 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 w12si36559493ply.404.2018.12.28.13.49.47; Fri, 28 Dec 2018 13:50:03 -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=itoZRdF4; 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 S1731085AbeL1MOc (ORCPT + 99 others); Fri, 28 Dec 2018 07:14:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:33318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731029AbeL1MO1 (ORCPT ); Fri, 28 Dec 2018 07:14:27 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 B5D0C218FD; Fri, 28 Dec 2018 12:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545999266; bh=mzOY71yJtGJ8JGykn0/VUKLVRFxpfOH4Bj0uX6Dmwxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=itoZRdF4aXO1pmcYDLK8P6BHcy7iP4SNbsgle+12aO39/v4lVEvaBZv3t3OwuI8SV Xsub+AgBX4y/BjSK8vukzbBIK23nUVdDbQQikrmen7yRzzd/HDV3DmtFwOIL2vZ4e4 RzstPrJJSL6SiayXlau6GfpmI+I5kORfx/gCeHs8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Reinette Chatre , Borislav Petkov , "H. Peter Anvin" , Fenghua Yu , Ingo Molnar , Thomas Gleixner , Tony Luck , gavin.hindman@intel.com, jithu.joseph@intel.com, x86-ml Subject: [PATCH 4.19 29/46] x86/intel_rdt: Ensure a CPU remains online for the regions pseudo-locking sequence Date: Fri, 28 Dec 2018 12:52:23 +0100 Message-Id: <20181228113126.499269358@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181228113124.971620049@linuxfoundation.org> References: <20181228113124.971620049@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Reinette Chatre commit 80b71c340f17705ec145911b9a193ea781811b16 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 4 ++++ 1 file changed, 4 insertions(+) --- 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 k 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 k out: rdtgroup_kn_unlock(of->kn); + cpus_read_unlock(); return ret ?: nbytes; }