Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp951297ybg; Wed, 29 Jul 2020 01:50:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmvtytc9J2oQIfze4zTvNvXK3sNMgmawa2azOGcF2V/N5bLEYm4H6bTb4Vg/4CgcwPy5Oq X-Received: by 2002:a17:906:aad2:: with SMTP id kt18mr11559742ejb.537.1596012636721; Wed, 29 Jul 2020 01:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596012636; cv=none; d=google.com; s=arc-20160816; b=Ihoy9372Odfp4eT9DRy2/Q9k7XSZdgVNI6N+QxkwrtEq6TkKu8CZtd27XMyAoi/Jg+ KlFdVZhAzmpyj9suSSay/atS8Ouul3gowJGiH60fHjoYEohaM2VI1rXORw6HlA6GeG5x eLW3uHdQetkO68TVSIDjAj+nfMIZg4FB7EJMlOaOV/Keo+S46Pl4X1iWIJQ1lwHdIq0x 6nG9I+6cQFlzOOB0BpGGRTOa/RStG2O9IKLFC88ajBhC+rgwTS7nK6dInh3NepCui6q/ dMnmmqJxaXLciapRc666FJaCGoGkm9hQDgVyAIu+f8q2/uEeQZ9iMAzsp9oeW9NgQYxZ L4vQ== 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=6doAh1qguYtZHcO6gHIS2SyAHj8bF03MyqeLpi3tHN0=; b=0qgnHB7CqO+4AibOt40epVdfOmRE/6UjRTeKdmBzdmhsM6JQHJZQld5JC/9wFcH/Be g5KDoaTx0YillNjEMY37VUcaziqFh6GGYQNxM9ojBlgIIp4N2Q8FIsrbzV9RrJByFk7f uGC56UX0j3B9WAntbMXcIr1Wx0GNinQ8Uy0TpvPt2Fl7no/p1Wpw2a9wUFTTpDzJRqdB XWAp2HWWw3+QXAkGc7bQcbgOd6klT07MncCtdy3ZQWGgpkZEO9CSCF2DU6pq4TLsJlVG 7aIZsZS3rfcqZV2FmSu8vHbga6bI+qokKPpO/OzCBDEG7v+EeVME/qn0TamRyvEOIYyy Us/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=cMUotIed; 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 u12si677819eja.373.2020.07.29.01.50.14; Wed, 29 Jul 2020 01:50:36 -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=casper.20170209 header.b=cMUotIed; 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 S1726737AbgG2IuF (ORCPT + 99 others); Wed, 29 Jul 2020 04:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgG2IuF (ORCPT ); Wed, 29 Jul 2020 04:50:05 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC78C061794 for ; Wed, 29 Jul 2020 01:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=6doAh1qguYtZHcO6gHIS2SyAHj8bF03MyqeLpi3tHN0=; b=cMUotIedINHNHLeg6fxFHwiKm7 tzsUup7U4Wi1Je0WNlnlCFmzkGVqRk5kuZjc+YvTMPmhaq4HpnR7iRus2OhNtvt2PeamjLVWFifVH TLGEUwqcwcKTWvNsoHjAU9ZMePEj50IgAx9fx3kfPKMqx4T01Ps0+X5iDbjLe6YhQq+fRUfXnSTv5 i8F0WrRNlb8hFg+Pn3Bql0V2v5c2ohZgdGx6DWlAK5VcxDZdZ1xYBauXcijc48gAO2ByE/CiZ/V00 RDoPhcvk8Zc/BiJbj2mdAiBdkySQLbceXO/A6jFlqINaHDc+gpcyFjuWPYc8aOyQjS42ZARSEaRJ/ om2ejxGQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0hmW-0002KJ-ME; Wed, 29 Jul 2020 08:49:49 +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 5C736304B6D; Wed, 29 Jul 2020 10:49:47 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 466D52BD93BFD; Wed, 29 Jul 2020 10:49:47 +0200 (CEST) Date: Wed, 29 Jul 2020 10:49:47 +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: <20200729084947.GY119549@hirez.programming.kicks-ass.net> References: <1595021700-68460-1-git-send-email-fenghua.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1595021700-68460-1-git-send-email-fenghua.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c > index b038695f36c5..58725567da39 100644 > --- a/arch/x86/kernel/traps.c > +++ b/arch/x86/kernel/traps.c > @@ -812,6 +812,16 @@ static void handle_debug(struct pt_regs *regs, unsigned long dr6, bool user) > if (!user && !dr6) > return; > > + /* Handle bus lock. */ > + if (!(dr6 & DR_BUS_LOCK)) { > + cond_local_irq_enable(regs); > + if (user) > + handle_user_bus_lock(regs); > + else > + handle_kernel_bus_lock(regs); > + goto out; > + } > + > /* > * If dr6 has no reason to give us about the origin of this trap, > * then it's very likely the result of an icebp/int01 trap. 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.