Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp22740ybj; Wed, 6 May 2020 10:40:12 -0700 (PDT) X-Google-Smtp-Source: APiQypLFR5T4kAAK1zutQmyQk61x+uCW2iUnPUz/bH+UoEyjzsINqKRpqsq/0L+mgMhcscDRZuv+ X-Received: by 2002:aa7:cb43:: with SMTP id w3mr7923045edt.95.1588786812393; Wed, 06 May 2020 10:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588786812; cv=none; d=google.com; s=arc-20160816; b=pVvVSt9zDuudVyO+Po5TXXMv7IIGeqtmRcoR/PMZnDdjQwUiO97D8F2nZfMGcxpI3k sZ7juaLU0u4KYujZiJb+AoctlmMMdZq8mWvVTzUPpH1iw5IjjZgD75Fmk0CFoCuUPDJG KZBfjz1YbrWaro3wjZlkOnpJgnsrh05poO52NCp9xHRsZJtkJQNH6kZvG/smAd8e9lFZ RPwXrQrj8BtxKklIhWML2lUg9oFifeHNUIzjSwpZ9VNLK7J0wzV5CFptoXaK0RO3eltt axo7px3W0sWRNknahzFVHvYvadyb0n/ZoqbViHwmnWEVa3yojeGBGyccjc1WeNHiEKBe l+vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8a5zVBKejAgld7VXzNaF8qHJFaoZBo2UQTEJWN0/Pas=; b=zGscVFjl4GOP28b1lUKPB9oHK4RY82Eq60UldojGDgitW+L5TI184QTCEVDsr/EmyG XYlE3iwitPUJnXiFxSICEwCn6O3S/ldIh8dznfK+8P5MLVMWmGeHlRbi9gfOCQ+3+1ND 5z16o2AApg8NIjEsHSwGGKNem/kF16ttuNWbOWE6ScLTQX4e+zSQYk2uedhQkO1ExBOq nZwHWg7RMXbNMjd+LFkqYLezknDSts3APVYNsa+sBTKg7Lsxa/AnohGZ2MoS1//d4tho zbgeg5S8bVDgalj1yRq++hIBcuQ49gUYYalVdhKMCZj+0K2cxv0CyleAFnLMmaUoZaYA SAtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ECGhwMJF; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si1642306eja.496.2020.05.06.10.39.48; Wed, 06 May 2020 10:40:12 -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=@chromium.org header.s=google header.b=ECGhwMJF; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbgEFRiL (ORCPT + 99 others); Wed, 6 May 2020 13:38:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728047AbgEFRiL (ORCPT ); Wed, 6 May 2020 13:38:11 -0400 Received: from mail-vs1-xe44.google.com (mail-vs1-xe44.google.com [IPv6:2607:f8b0:4864:20::e44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA161C061A0F for ; Wed, 6 May 2020 10:38:10 -0700 (PDT) Received: by mail-vs1-xe44.google.com with SMTP id m24so1551105vsq.10 for ; Wed, 06 May 2020 10:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8a5zVBKejAgld7VXzNaF8qHJFaoZBo2UQTEJWN0/Pas=; b=ECGhwMJFfElWGMQN6/BzuvU4toFz9t7sCKONntpXpgyTmUVrganDLiAX/JlOezV9MQ v0ZNSoJ+RYvhi10KmB3EhaeHUbcH3Cdf9MmAvDRRODJ6v0moR/ADr9ynPi6ZiHninbhx axqnRj1QFSWECx6NxDenAzW44t5GBcDUwJa8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8a5zVBKejAgld7VXzNaF8qHJFaoZBo2UQTEJWN0/Pas=; b=HgfZF3cveAJQK+XthMFWpAKoIE28Nvk9CL10N609Gg0RFHWf5YnYqysn9SlUTxvGj5 a5O+m7YuAkiWzq0wkLsBb1pV0JrmX/4CsL0OYp4Si+xUfkF9BIhI3r/4L5F+nn9hBK4M owz1j+RpGjBQ3jDAnlmUMSNSV5Aa9kYVjVHgnJAJ+n2sxX+xQq7GF3yeXSR5PyB9HFji SPEFDmQy/MQ6f94t23q6LbK5ojDWiupsapSjzNCW5R1rHVeaQUgA5NgVL6DhLoh9s7sc DfVWRIv5tbsbwB9DgbEHiGNw/8LSBG7pp9sNCiRiuy0fKTK2jw+J3PE0lnQB9vMnFZRm 67TA== X-Gm-Message-State: AGi0Pubf+OKpNrwxIWjG2o3fUHyFXuPe4J8UOeH7VLWLiJV/gpQvrZ1L zm8A4B8Wh6B9UWxDSNfvr4osB5ki6Qs= X-Received: by 2002:a67:6487:: with SMTP id y129mr8905842vsb.48.1588786689536; Wed, 06 May 2020 10:38:09 -0700 (PDT) Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com. [209.85.217.45]) by smtp.gmail.com with ESMTPSA id t23sm1019637vsm.31.2020.05.06.10.38.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 May 2020 10:38:08 -0700 (PDT) Received: by mail-vs1-f45.google.com with SMTP id u12so1682035vsq.0 for ; Wed, 06 May 2020 10:38:08 -0700 (PDT) X-Received: by 2002:a67:c40c:: with SMTP id c12mr8798801vsk.106.1588786687950; Wed, 06 May 2020 10:38:07 -0700 (PDT) MIME-Version: 1.0 References: <20200506164223.2875760-1-daniel.thompson@linaro.org> In-Reply-To: <20200506164223.2875760-1-daniel.thompson@linaro.org> From: Doug Anderson Date: Wed, 6 May 2020 10:37:56 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kgdb: Fix spurious true from in_dbg_master() To: Daniel Thompson Cc: Jason Wessel , kgdb-bugreport@lists.sourceforge.net, LKML , Patch Tracking , Will Deacon Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, May 6, 2020 at 9:42 AM 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); Reviewed-by: Douglas Anderson