Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp568605ybl; Thu, 12 Dec 2019 01:02:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxfiGTjebGjh1DL8s6vhXarl6kkzv1kxaWBS3dIioDBuIND0DwaNc8dalYAaV8uMGy3duzS X-Received: by 2002:a05:6830:16c6:: with SMTP id l6mr7219080otr.186.1576141340618; Thu, 12 Dec 2019 01:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576141340; cv=none; d=google.com; s=arc-20160816; b=qVday46T9Kf9hLavEMKTlyuEFVKW+mqX0jVY5aSFWU2MVUiKbtb9h6iHutJbDpdJNW vI1t3an5bDEuvgtKDaqvjpXBN07BrO09s9HsLwCbB3I4PMWlbwXv977+J0v6jTXUR8cK /9DoNe68VgHrPYv2sQ5alOnyWPIvlIax3DvDW/5BnmG0B3YmsSe4uU4JqOHZDBC1nGJ5 RhOCn3j/1XeNtcZf9W0CD09bq1IujMl7I4M9ur/e6DIlNDoA3jnhY3kMd2O525jBGoXz hPMNtfv6zmcAm+UyXxC5Yx3oG1fmKLz+tJRjQ8093OLaHPT4pcRhIxaQ5IVX5Wvtb6BL tjZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+PW0GaE1o80mz9BCaP0NnRe4uaLh9xJ18z0GQzHpTvo=; b=C+2JZwvEdw0rPkFpbFpLBwp1MhO85HepvuenHkw3oq2/+cIThJTgd6F9ZD4qWlyngQ 4bnuhlqjFHQlWUPi/NAv5BmqVOR52Li+ntw6lCZMDfpeApqUQTnx6snYBvDwr27+xF5K rXivPAJxuJjUmdm1qpiWv8OCfU+BeqOCbp0a4j7UqyO834eHvGySdizP9U0eWAeCDSAn MYUTGZ4r8+JnUVluK4/KniRfDZrbevte3uYFBTgFqLNPqF4xHnk0bC30DySLhHNyY9Tj bBrgwasx3c1kP39vEdHdyhE4CbyNIm5oZ0WmlX9L2mEZrfUSvZHCzUwe7HAo1u+p3V2d u8nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=n4rcgivh; 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 r22si2484018otn.192.2019.12.12.01.02.03; Thu, 12 Dec 2019 01:02:20 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=n4rcgivh; 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 S1728274AbfLLJAB (ORCPT + 99 others); Thu, 12 Dec 2019 04:00:01 -0500 Received: from merlin.infradead.org ([205.233.59.134]:37916 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbfLLJAB (ORCPT ); Thu, 12 Dec 2019 04:00:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+PW0GaE1o80mz9BCaP0NnRe4uaLh9xJ18z0GQzHpTvo=; b=n4rcgivhDeuNxhFil6/XCfbjg vSMK6qquyiYvdkVlLV7Zv7cKTkgkGx5iC02MdRNWs6d9y5GLqqEkv3RSTI3+F6vL8xQXjragjhMwJ UoSCfCbSl1BJh6ekrX4uUpHHTC0tTAa/1TcHImDeuEeEf7AGyjImf/hC7syDbN0lhNGntqtIDyjhQ 7RjaF+SFWaD66rcND57OE6TsN1+vcxTZue1Pgf8sIXlLl9wOQXfzQAs4edndaRC/9U/3NIDnzUsHI KGl9IK5NBxYidjD/ZibvgNRbmQg7xyvg6r9qzVm8trsFhxxQ+R4SY7xQ+/zasBEuyhS0hjf4axvi+ cESbWO2qQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifKK7-0006AX-8n; Thu, 12 Dec 2019 08:59:51 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 92461305E21; Thu, 12 Dec 2019 09:58:28 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D581A2B18D264; Thu, 12 Dec 2019 09:59:48 +0100 (CET) Date: Thu, 12 Dec 2019 09:59:48 +0100 From: Peter Zijlstra To: Sean Christopherson Cc: "Luck, Tony" , Ingo Molnar , Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Ashok Raj , Ravi V Shankar , linux-kernel , x86 Subject: Re: [PATCH v10 6/6] x86/split_lock: Enable split lock detection by kernel parameter Message-ID: <20191212085948.GS2827@hirez.programming.kicks-ass.net> References: <1574297603-198156-1-git-send-email-fenghua.yu@intel.com> <1574297603-198156-7-git-send-email-fenghua.yu@intel.com> <20191121060444.GA55272@gmail.com> <20191121130153.GS4097@hirez.programming.kicks-ass.net> <20191121171214.GD12042@gmail.com> <20191121173444.GA5581@agluck-desk2.amr.corp.intel.com> <20191122105141.GY4114@hirez.programming.kicks-ass.net> <20191122152715.GA1909@hirez.programming.kicks-ass.net> <20191123003056.GA28761@agluck-desk2.amr.corp.intel.com> <20191125161348.GA12178@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191125161348.GA12178@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 25, 2019 at 08:13:48AM -0800, Sean Christopherson wrote: > On Fri, Nov 22, 2019 at 04:30:56PM -0800, Luck, Tony wrote: > > On Fri, Nov 22, 2019 at 04:27:15PM +0100, Peter Zijlstra wrote: > > > > This all looks dubious on an HT system .... three snips > > from your patch: > > > > > +static bool __sld_msr_set(bool on) > > > +{ > > > + u64 test_ctrl_val; > > > + > > > + if (rdmsrl_safe(MSR_TEST_CTRL, test_ctrl_val)) > > > + return false; > > > + > > > + if (on) > > > + test_ctrl_val |= MSR_TEST_CTRL_SPLIT_LOCK_DETECT; > > > + else > > > + test_ctrl_val &= ~MSR_TEST_CTRL_SPLIT_LOCK_DETECT; > > > + > > > + if (wrmsrl_safe(MSR_TEST_CTRL, test_ctrl_val)) > > > + return false; > > > + > > > + return true; > > > +} > > > > > +void switch_sld(struct task_struct *prev) > > > +{ > > > + __sld_set_msr(true); > > > + clear_tsk_thread_flag(current, TIF_CLD); > > > +} > > > > > @@ -654,6 +654,9 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p) > > > /* Enforce MSR update to ensure consistent state */ > > > __speculation_ctrl_update(~tifn, tifn); > > > } > > > + > > > + if (tifp & _TIF_SLD) > > > + switch_sld(prev_p); > > > } > > > > Don't you have some horrible races between the two logical > > processors on the same core as they both try to set/clear the > > MSR that is shared at the core level? > > Yes and no. Yes, there will be races, but they won't be fatal in any way. > > - Only the split-lock bit is supported by the kernel, so there isn't a > risk of corrupting other bits as both threads will rewrite the current > hardware value. > > - Toggling of split-lock is only done in "warn" mode. Worst case > scenario of a race is that a misbehaving task will generate multiple > #AC exceptions on the same instruction. And this race will only occur > if both siblings are running tasks that generate split-lock #ACs, e.g. > a race where sibling threads are writing different values will only > occur if CPUx is disabling split-lock after an #AC and CPUy is > re-enabling split-lock after *its* previous task generated an #AC. > > - Transitioning between modes at runtime isn't supported and disabling > is tracked per task, so hardware will always reach a steady state that > matches the configured mode. I.e. split-lock is guaranteed to be > enabled in hardware once all _TIF_SLD threads have been scheduled out. Just so, thanks for clarifying.