Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp2054369ybj; Wed, 6 May 2020 09:47:29 -0700 (PDT) X-Google-Smtp-Source: APiQypIyciU+5ubi8QpOXBlSl+S36mYZRxFLYlIpwjjlGobHN0Yom6wZTO0vos4pik+YFymkPzNc X-Received: by 2002:a50:e806:: with SMTP id e6mr8138509edn.153.1588783649425; Wed, 06 May 2020 09:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588783649; cv=none; d=google.com; s=arc-20160816; b=ad2NsRgRCx7LuQ+nkGQCN4RkodC9hsO7UuLjVg/tILzEV4TubKY8vfLd8VrtpVPsm5 Swkd0tMazXMsqME9+RtWu0RePBPgaJ5uebr4tfdxN2jzPTBq6xLeZzK2owOir8LceyNJ kqNMwbbdY1+9RBfdpeKM1CXUiWZIqzz3KTuVgKWVCY/qHJwCpXvdGiEZmmdl8HOAkbik BZJFPdwCib2lmsb1nVMCV962+5nDgEb8Sfp/1ONMX2KDkodqNg3Eu6datGNJPA07TBZ2 8W55UyodPCIh1NFF80hC8yqwwpoz0qRTmKnrQay/taPLa3Jgev8QvJl/Mu/omNxb6kQO A5kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=0oIeCC+0/EiI9sm7qFQDhCkikI6og9UeKJJkXjCNEh4=; b=cOdCZdTGPWhQ34PvkeEvl+IrvEr5NhBHvQu5Gc03qc1jB6LpVCKNqP0NuWo8kRtFje /M+kn0crENTPBhfhV3z+VAqa5GbEjxwpEU37kCRmhhFw/1NWVATjkMOawq59cr4hL2Ll OHiKaDKuEECy6xODTLs0q7eZrqv7ru1apHJ1lJz2RTIZfmNUpsRB8O9DvbguPdWZ9RDy T7/pHZ/D1f6zQ1JuxI+WWjbRYsLQYMaMPvQzODKnfCavS3S6Ix8FoDi3usbvDsEQt0Ei N65DMai8o65vEytaSFY4CLxdrMUE8fWOpmQ9lFweaH577cktKhpJZvIIyJKY9/7xL306 mZAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="O/ilkMXA"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si1494444edc.303.2020.05.06.09.47.06; Wed, 06 May 2020 09:47:29 -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=@linaro.org header.s=google header.b="O/ilkMXA"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729706AbgEFQmt (ORCPT + 99 others); Wed, 6 May 2020 12:42:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727984AbgEFQmt (ORCPT ); Wed, 6 May 2020 12:42:49 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0E06C061A0F for ; Wed, 6 May 2020 09:42:48 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id u16so3482661wmc.5 for ; Wed, 06 May 2020 09:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0oIeCC+0/EiI9sm7qFQDhCkikI6og9UeKJJkXjCNEh4=; b=O/ilkMXARUeK2D3ICsAU4LxK79OJT0MBJTCLZkow0BNCeXP0XnQLIR/feAtb8UBZN+ 3wfBIP1Jk9Oy8l+t4VgxtRWpsgAGmez4XRquO5zOS9zprjlLf+Cq9NX1fsd9O1karj2l fvRRo8c8dIBVe7ZYolmUmk/lDRGT8AGC4qjoIr4HMn+PyiCzUyPkviui+9wHq+MXGg+3 o4GoIUAmJ0bWO11IEL308Icc81nqK4l3czpdFYqYd5eeaCOuuVJsrmxlWNjcvXbekhM7 qOQBxEgzEE7iawm0ZBkb0nsdrfTL0Hj/W+A0typua7DtMwCcaXeO3p1FOxPB+EIFOotF Y+XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0oIeCC+0/EiI9sm7qFQDhCkikI6og9UeKJJkXjCNEh4=; b=moFkfDLRt+PG2qvTPPm9exl4ipXhcTddEbHC3jWUVhHMByy2FqqeQ4nD2ReVSL3Md1 /rBcVGNl0mYs2a8vIV0fv7QyjQxNkLidRowt2Wf7l9bay8fO8qb+3YNswBlFAe21Y5GI u6DyA6sZy7hOwbTB8fm8sho9/GhVdn4h6OQ8WwAK4PFCygcOdG2A6rl7nW478JkxAwkJ yl43JjU3j1IegmoRA0up/Bj+vf4GVOuoBRPJyj6PVoi1a0mPM7AablLzBAT3Rpbw0K8I csyZ8+sykG/r+ICESfmjsluH4uJxNGZyv+MRuJ4RBfVUyz25PiGfjIOYQ8U0LMXT5SZE P8Tg== X-Gm-Message-State: AGi0PuapDGhTf4pyOo2XQ2Cart4OxVvBGbu6sdKzsbXiQSAUNLSE8Ghk E50OVm0szpWPNcgHFqTvvHAXig== X-Received: by 2002:a05:600c:2f88:: with SMTP id t8mr5212647wmn.46.1588783367518; Wed, 06 May 2020 09:42:47 -0700 (PDT) Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id z132sm920713wmc.29.2020.05.06.09.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 09:42:46 -0700 (PDT) From: Daniel Thompson To: Jason Wessel , Douglas Anderson Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org, Will Deacon Subject: [PATCH] kgdb: Fix spurious true from in_dbg_master() Date: Wed, 6 May 2020 17:42:23 +0100 Message-Id: <20200506164223.2875760-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); base-commit: 6a8b55ed4056ea5559ebe4f6a4b247f627870d4c -- 2.25.1