Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1415578ybg; Wed, 29 Jul 2020 13:41:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzol2wcFxiFszt2WyzJTr0UkmNi4BXKmKfqch9dZwo5eVjXZdETTV4/K2y1Wk1iQYwTa6Jo X-Received: by 2002:a17:906:17c1:: with SMTP id u1mr155931eje.536.1596055291052; Wed, 29 Jul 2020 13:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596055291; cv=none; d=google.com; s=arc-20160816; b=uAcitinPB5XEYyRsbqNIBfAlq+10156RbjgtHKuuuW2qN0M/1XLbM5MNMBqx1wno5n xeAPUGbFRsvpA+oC0yB5VLRLeV41Q1InJIiKldr46BTDbgN4sLuK540RCyarWVacwR40 lyv0ysKdWgfMSu1OhurXwUoFNC268vfnUZQytiE/9znZrws+jP4ALn1njTPSKDtfSFlC a4HRy3M2AlvSFPFOmuFLYShdbR1e5bfnCnI0DKmtpjukrU/m4BSctTEY4YZbix6f+T2o bh0dabHghOHveEyfSftvbL/I3cSxQq93FGodpWWT/sCxFdm2Vjk8RdQYNrmbPlkHFful hozg== 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 :ironport-sdr:ironport-sdr; bh=5zxJLbE+WqMt8IQ723EOyCCJ7bO1dDDVjGs3IIMKPS0=; b=LHwBjjscZpQ1NJjvpMa42un8tfEvTGIAfsD/K22ipqujzhuJC+bnONp4YFvuvZaL6b OvrkQfNFmBO987niapI2BcJfbMWOU5oo1zCCBnPbuFeHUoYwLtE04TtHQfV1//+bH0p7 j3EkVgQjoPUSLhGkF9voG7Pl+QRIDnVIpmJdXdOXY/4tanz9uYp6uOa8A1JkG1VLWmgq bCoEnU56HvjMcEjVdgR1Y7ajFxnlvZ2eg24S49ucrze2qt/lRG4WPJs2ag14ochJ2tYs jJkqHlkZCrn7NgjxhKPKTT/Jf4JW0hM+CyM2hxGF1dCCO+a1W0hzcIhPViGf5hSbnuS1 uFBw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y19si1904342eje.548.2020.07.29.13.41.08; Wed, 29 Jul 2020 13:41: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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbgG2Uk7 (ORCPT + 99 others); Wed, 29 Jul 2020 16:40:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:6863 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726476AbgG2Uk7 (ORCPT ); Wed, 29 Jul 2020 16:40:59 -0400 IronPort-SDR: IlclRdZ/dBHb+STlDvBZu9yxeteqsh63vbHdzoI91hcGP8DAejxu48+5e9PFIvmPwGZb1bRjpc 0E/IXcRuhwsw== X-IronPort-AV: E=McAfee;i="6000,8403,9697"; a="213027585" X-IronPort-AV: E=Sophos;i="5.75,411,1589266800"; d="scan'208";a="213027585" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 13:40:58 -0700 IronPort-SDR: f2Oxby9co8guUXawubDpyXpSuYqAnvH1MxNMVgFG1KeFEl3QKBohgwatooPdO6785yPW2i6ivU Psq5ocl7x5dQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,411,1589266800"; d="scan'208";a="328762989" Received: from otcwcpicx6.sc.intel.com ([172.25.55.29]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jul 2020 13:40:57 -0700 Date: Wed, 29 Jul 2020 20:40:57 +0000 From: Fenghua Yu To: peterz@infradead.org Cc: Fenghua Yu , 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: <20200729204057.GB318595@otcwcpicx6.sc.intel.com> References: <1595021700-68460-1-git-send-email-fenghua.yu@intel.com> <20200729084947.GY119549@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200729084947.GY119549@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Peter, 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 > > > 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. Can we disable Bus Lock Detection before handle it and re-enable it after handle it? Will that resolve the recursion issue? Thanks. -Fenghua