From patchwork Wed May 6 16:42:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 186263 Delivered-To: patches@linaro.org Received: by 2002:a92:8d81:0:0:0:0:0 with SMTP id w1csp2317820ill; Wed, 6 May 2020 09:42:48 -0700 (PDT) X-Received: by 2002:a05:600c:215a:: with SMTP id v26mr1833921wml.101.1588783367946; Wed, 06 May 2020 09:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588783367; cv=none; d=google.com; s=arc-20160816; b=MyyvuqIUlVdWVOm2XLm50PHeYRyNjv8iwseJakwDuILCG1UcL4Ivqa8GHqTLkj73Fp C/2NAt7fo+JnfjA45vL0qlQoBZAVHKxx0VBJlxgruCdjAgq9OAcSF6brkfoBHE+nKNkb Jq98a1ZZ8VKDw0vzaaad3WKLuXltgKgLD9EebFWGj14+hgfhzcToq5KjaoR1yNMqmIpd VEbjSoiootnfoVg/Mj/85mzUwvTbofeJEpAzMhighM8ej31lSg5k0iFy8mkUqcTZy18+ 5WDwLzYTHZZRHta4blLp24OX2E29mOuv+pkCf8jHBPcOiuhV7pdYAeZVU7l1g5BkNhqr wrcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=0oIeCC+0/EiI9sm7qFQDhCkikI6og9UeKJJkXjCNEh4=; b=ACzDt3nu0lt6gF/Uw0QkA5btyaW4cnYPmS6ApiJHmdzVElpZEXxLNwkkpc8betgwzG gdcmef8EmOM6t2tGFCznBGa0drffMi86DzlM09K1SGZumNtTw3xD4QvhrpTAz2KjoFh4 tFZbaKExIwJ6G2ZZ2V6aEJLEaOfcThXo9NWdjMHXSM2lvBLQqXxA+Kr7mM5mvPYXlI9V k5ZONFoP7LqtsXoVSi4r8GBJJkBP/WDklyO8iNHUQPnyuDFrdAneNsyQllrgCPbYGLYc OBqfVcU8ZUY0PzqroIgxeFiITVZ+Sj9OtjwE9g1tpvHm14kSJjpPPCo4ZjUV4Qj5hP53 HsqQ== 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 daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b64sor2041794wmc.7.2020.05.06.09.42.47 for (Google Transport Security); Wed, 06 May 2020 09:42:47 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="O/ilkMXA"; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=HOYkvjyyr8xlHfvpGqJ2v90tnsqtRunHSHiwALeGYUdPnsHgUZkIGSTdoE1azXM5eY LfGDiJ+lLL9QEUzMJKD0XJqIP27JBcsOyYsJjC8/HSFcqJYihA6kHWrzZpzKSR6ylELP oaKIaKZ/s/hqy60z9dcEJQdtim1uYCHDu0unhldgHB98gAuBDilysVeWha/3HfQhq+HG iQdlvPxb/gIlIHSzD2zLoKMk7IyF1wv/cr9fDBSQfBbPyigttu3yBAA/oYSGYoCeTSm7 w4/GLBdkIyrOfbD7xQZUalt4mLgSW/rPXeneOJ4vbuai9b4tEMb0d4b5C9MYziGljvuC FVxw== X-Gm-Message-State: AGi0PuagIjio2kogLCNLb/YSaORq2IxqTir1g6yrjR6IvpnyMoyh9P2p DIMptRBz7w930CjJU5fTDZ8V1wv/ X-Google-Smtp-Source: APiQypLmV4ose9t9DElkNYLgYcNAXiarZ1Br8nv0JcfOv4Av1Zc/Cvy3tfs67XWkiIIaMRomr4d+yw== X-Received: by 2002:a05:600c:2f88:: with SMTP id t8mr5212647wmn.46.1588783367518; Wed, 06 May 2020 09:42:47 -0700 (PDT) Return-Path: 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 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(-) base-commit: 6a8b55ed4056ea5559ebe4f6a4b247f627870d4c -- 2.25.1 Reviewed-by: Douglas Anderson 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);