Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1432114ybg; Wed, 29 Jul 2020 14:10:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfujkl1wOw5x4dIqSXb5gKzEneSagEj2K0qUxExg36ANVvYG1Qw4Bk4GtZiccXbb5XLRZT X-Received: by 2002:a17:906:1ec3:: with SMTP id m3mr250461ejj.197.1596057031794; Wed, 29 Jul 2020 14:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596057031; cv=none; d=google.com; s=arc-20160816; b=SHJ54H3V+TKY7iWa2MBPOKlC8Dyle64LoJImVv8AgkZ+EOQsRPQvLLfJXA4RO4ALVD Q3QSRiVFRFlagjgnbg0v38Eci6GK6BQGFyxUQidCe+SfGYTuBSsUnTAtYz9tlaeNrJph eVSqDVU6jgoZiykjgoVwKxkjKd41H7pJ2rzBrJxerdi/UTUs/ZVlGiIghyykIPztKgXF ANbT0oMeUxVXN9cRY6pqM1hFwvkt5syOwdq5JsAdZ5kubgn3lj1n3w/m5kCSIYjIaIb1 SyzeRidBe8H4fEFjQkG7nWxJRnoXQWYWcl57wdyZF5cW1XK2mz3gP7JGMz6zp/xpIl5s Vcdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ldeactPP2MK53RYxP/W+cgHYIxH/k2Qar+sK5RkMayk=; b=EVIdEl9IDchTYmc51pqoQJA2/Yrhl/WrKX4ZQGm0SwbxwtIlc04dp82G7YAQKzdG35 lwaBm47Q98Iy62OV+eSigGrxxQGfTEclmYAOmyKLogXrP8MnUqHr4EIQbn3lo3HM9FLl ejChYlKu3c3e/Pu+MY0WSrpeHD6eX7cAQG5o2t6p+AEAk0ImtQpiCBv0hNBG0d46oc5q qHdF4B+A0OGdeBu4rfyf2PDoWakbXmcrI9aeDjY4xJYPJJfDlEYuI28Xae9gBwAAOHkT DS+kPbo1YHCNGol+Thf1TO77wk1QM6XEEjyf3NtsqpXO7N8dYsY23a+R88CpmB6/VOkM oDRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Kyk5tFIQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si840737edt.316.2020.07.29.14.10.09; Wed, 29 Jul 2020 14:10:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Kyk5tFIQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbgG2VJq (ORCPT + 99 others); Wed, 29 Jul 2020 17:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726476AbgG2VJq (ORCPT ); Wed, 29 Jul 2020 17:09:46 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBDB8C061794 for ; Wed, 29 Jul 2020 14:09:45 -0700 (PDT) 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; bh=ldeactPP2MK53RYxP/W+cgHYIxH/k2Qar+sK5RkMayk=; b=Kyk5tFIQBUsugNqJFDyrrX6A9i QrpTpj/seDaVNothU/mPzdCb4H78qVfvxVOg9vi+UXmCAteIEeUG7h4CnQvb0vole3qVXIztWbvGp F2b07+7kC6xAUxJ4Cb8gQlm3+hT0+TTnGIn46aaUGb6e/OWGBJ9aLxZlQeyXWFEoKsLffa78zw9jE w/OzAiXcuIBkjEaU+ArvkjjhSScm0INsZ8ZxNpsFWW5j3NEXgPyz7gSDhOH43F6hok8TsxsDWpyo/ Vyo+5upX3hLo3XRgv+t6g4Ec+uJfcKVRLO4Yc7r/ssRmrIvaxYsPrWIqtDSseWXY0ms0iCHMVgLfY mBm9nDdg==; 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 1k0tKT-00027f-Sh; Wed, 29 Jul 2020 21:09:38 +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 757D230411F; Wed, 29 Jul 2020 23:09:35 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 658482B60F0CB; Wed, 29 Jul 2020 23:09:35 +0200 (CEST) Date: Wed, 29 Jul 2020 23:09:35 +0200 From: peterz@infradead.org To: Fenghua Yu Cc: Thomas Gleixner , Borislav Petkov , Ingo Molnar , Tony Luck , H Peter Anvin , Andy Lutomirski , Ravi V Shankar , Xiaoyao Li , x86 , linux-kernel Subject: Re: [PATCH RFC] x86/bus_lock: Enable bus lock detection Message-ID: <20200729210935.GE2655@hirez.programming.kicks-ass.net> References: <1595021700-68460-1-git-send-email-fenghua.yu@intel.com> <20200729084947.GY119549@hirez.programming.kicks-ass.net> <20200729204057.GB318595@otcwcpicx6.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200729204057.GB318595@otcwcpicx6.sc.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 29, 2020 at 08:40:57PM +0000, Fenghua Yu wrote: > On Wed, Jul 29, 2020 at 10:49:47AM +0200, peterz@infradead.org wrote: > > On Fri, Jul 17, 2020 at 02:35:00PM -0700, Fenghua Yu wrote: > > > > > #DB for bus lock detect fixes all issues in #AC for split lock detect: > > > 1) It's architectural ... just need to look at one CPUID bit to know it > > > exists > > > 2) The IA32_DEBUGCTL MSR, which reports bus lock in #DB, is per-thread. > > > So each process or guest can have different behavior. > > > > And it generates a whole new problem due to #DB being an IST, and > > we very much rely on #DB never recursing, which we carefully crafted by > > disallowing hardare breakpoints on noinstr code and clearing DR7 early. > > > > But now it can... please keep the pieces. > > Can we disable Bus Lock Detection before handle it and re-enable it > after handle it? Will that resolve the recursion issue? Because WRMSR is cheap, right? You have to unconditionally {dis,en}able it on #DB entry/exit. Not only when it's a DR_BUS_LOCK, _always_. Then maybe. I'm too tired to think through the IST mess. IST's suck, they're horrible crap. Suppose we get a #DB, then we get an NMI right before it does WRMSR, so BUS_LOCK is still on, then the NMI does a dodgy LOCK op, we die. So that means, you get to disable it on every NMI-like exception too, but we happen to care about performance for those, you loose. Also, what happens if you have a hardware watchpoint on the instruction that causes DR_BUS_LOCK? Does that work as expected?