Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp541963ybj; Thu, 7 May 2020 01:42:45 -0700 (PDT) X-Google-Smtp-Source: APiQypKdFqAFDs/KE3l2K3+SQekhN+3iwh7Cd61/PhSx6mg2S1PdYSz82sitG8nJEvXREkWiGJf/ X-Received: by 2002:a05:6402:310b:: with SMTP id dc11mr10379614edb.143.1588840965351; Thu, 07 May 2020 01:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588840965; cv=none; d=google.com; s=arc-20160816; b=GPWqphFkIVDFMN2OylVmKoxlwkGqn1QDnIaKqHUKa6tPzjllBu1rdMebzpExmgKGxY yBl1fGfD1fIteJ2pf8fd2WrrjBVNl4BLaF/LXnyRH3QkmKGiKFyBabBFTZdnAGmtYxWB V5fEnErgVulVExQKMQgwd/T+kyDvKwHw8BZdbYJgqDB1de73mGEKPjXkqYIxuegXmwIQ qjM7vPLv24F+aLFixwpyEhh0da8AXr3Ch4AgmgvrZ8lJYuq3uiWlKG4A7cMyj8/iuaRw IcOgDVyq+6JxGrshzO+G8B945wNI4wBnvpZMgeaXlW0uugiTyVFlK7a5otGUAM/1ARi2 HI9g== 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=E0XkTfAqabVzP/gfTdussAa0KRB+MIubD7Q1T3FvNQ8=; b=Ju20YcKCT1dl/UpwCd/AHtRtS4V9zgXyKaI/7h/vQ/27QuJTfsCkwSmo93Ks6c0BZp /jWy+sp9jLad7PVfN31Sh9nPfV+tsb2GCkj6ttP+wX0I1tlPhTKSmkfsPWjk0lpsEd5b bqaxKZTAmPmXkdkpYDqeZrFf+j1QHjMZMZ/FTEGJFhVc7R1TtCThKN7qxnWCY7p0FXHY 1hGckpuvmj27p+9bmL8gpwX2ICkP4FUPVUisfXzc2uigUfrwk7VjZW7f93wGDWf8awJg GkKPKIE0IMX1ZeTgIqb/cTd7UoEzVfyCaqYuEAZJgM9lYK6fpX19AGjAR6H6jd+adrIQ 8X6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ro9/oIOy"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz5si2614013edb.127.2020.05.07.01.42.21; Thu, 07 May 2020 01:42:45 -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=pass header.i=@kernel.org header.s=default header.b="ro9/oIOy"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726751AbgEGIjg (ORCPT + 99 others); Thu, 7 May 2020 04:39:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:46292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgEGIje (ORCPT ); Thu, 7 May 2020 04:39:34 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (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 1F3782080D; Thu, 7 May 2020 08:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588840774; bh=Ld4HmaMz+uu6ugfeoP8TBmKNgDCsNouPkgsc7oqJvJ4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ro9/oIOy26gDdLHjpEUoFtciNshEP2GerzmgbWkGIanFXpQygbI2/v8W6P3WCmgyy 7Kr7vpMASvV958hsQEWu3oTRmchj+Ts2GFYBk2xWWCVepWBbLyZKBdzQ0rQ2GEjw1n ALYvEew8+AvUNXKIKXDXpWcgpWnYLJsD2/+bcOoc= Date: Thu, 7 May 2020 09:39:30 +0100 From: Will Deacon To: Daniel Thompson Cc: Jason Wessel , Douglas Anderson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org Subject: Re: [PATCH] kgdb: Fix spurious true from in_dbg_master() Message-ID: <20200507083929.GC28215@willie-the-truck> References: <20200506164223.2875760-1-daniel.thompson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200506164223.2875760-1-daniel.thompson@linaro.org> 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 Wed, May 06, 2020 at 05:42:23PM +0100, Daniel Thompson wrote: > Currently there is a small window where a badly timed migration could > cause in_dbg_master() to spuriously return true. Specifically if we > migrate to a new core after reading the processor id and the previous > core takes a breakpoint then we will evaluate true if we read > kgdb_active before we get the IPI to bring us to halt. > > Fix this by checking irqs_disabled() first. Interrupts are always > disabled when we are executing the kgdb trap so this is an acceptable > prerequisite. This also allows us to replace raw_smp_processor_id() > with smp_processor_id() since the short circuit logic will prevent > warnings from PREEMPT_DEBUG. > > Fixes: dcc7871128e9 ("kgdb: core changes to support kdb") > Suggested-by: Will Deacon > Signed-off-by: Daniel Thompson > --- > include/linux/kgdb.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h > index b072aeb1fd78..4d6fe87fd38f 100644 > --- a/include/linux/kgdb.h > +++ b/include/linux/kgdb.h > @@ -323,7 +323,7 @@ extern void gdbstub_exit(int status); > extern int kgdb_single_step; > extern atomic_t kgdb_active; > #define in_dbg_master() \ > - (raw_smp_processor_id() == atomic_read(&kgdb_active)) > + (irqs_disabled() && (smp_processor_id() == atomic_read(&kgdb_active))) > extern bool dbg_is_early; > extern void __init dbg_late_init(void); > extern void kgdb_panic(const char *msg); Cheers, Daniel. I assume you'll route this one via the kgdb tree? I can live with the "small window" in the arm64 for-next/core branch ;) Will