From patchwork Mon Oct 21 10:10:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 177039 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3197684ill; Mon, 21 Oct 2019 03:11:07 -0700 (PDT) X-Received: by 2002:a5d:4112:: with SMTP id l18mr5945216wrp.123.1571652667858; Mon, 21 Oct 2019 03:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571652667; cv=none; d=google.com; s=arc-20160816; b=IX//SlX5YyjwIxmLNx84fYGzD0JWbImGPIltlNE/kSxCiyReqO/brHCtnk5W/h2O8Y n7CQrI32yvmKAybda1DWjm/pJ6I9zVr57kLunG6SR8BX04Wam84jgvYWdmBwpwTawXAw Ec453c9m/gQJN66HR5M2EJZ9Hk6WJucWVpfAG/nzYNejFj61BHl0/H1HxRjvRyrAGsNr q06cD+ySdA1s6JmTinVrVhjvdD8sBQFGG9z10UCNX541WsUpuHTADwg88pFJqOI0abwz mgOb8X5dbw5s/8VsebfqDzgv0AubZqlejLCTxZO52kIuZVy6aEHzLIwD/q0VVhtzeF6h KsDg== 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=ejY+9Vm9aWJOs97zrA807+W9n/23O9nYbfu1WQqsyN4=; b=m1g1rclWqtHOjBiogC0ln5pw4dfIEkSTbmxxoMrZ/Pk+QTarDm3GagYoSsOMuhEz8Z gKKEMZpgzb+tJfYmenOaXgR3WfrW7AV5adUbvXlMeCQhmQVJXVlyi4y7Mw2A9Hwbn7iY 8zvXby2xXIzZaoxZrbh1469Xun+/EgdjuhDrBxHMbyz3EcimRqqTpBSRzwww45JXNtAT SA8pZyGMOUOJln0kII/6LTH15cpl9TrOKFuLztflhGJxN74mmkpF2172OQ+cHKQc6Pr9 GWW3z2DREDKCAu0eJne36CK972OIcIeotSJiBYlB2Po/HiPaNbVuwV4KYWvPo+Y9EJve 4SHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z67VptU0; 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 g200sor5350086wme.26.2019.10.21.03.11.07 for (Google Transport Security); Mon, 21 Oct 2019 03:11:07 -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=Z67VptU0; 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=ejY+9Vm9aWJOs97zrA807+W9n/23O9nYbfu1WQqsyN4=; b=Z67VptU0dpTYTmG3ohv8pDSd0+CsFi7qspyxYHYbGvD4wdiRDK3vqJVHPZPaqGXGOm uiLYWy/FZwE/YhpSsGe+Sl426PcGkC6fMRTzwDAHXswSlrMcjOkTambq8295/tCALvGN rKKL5+SWYo8AmXf6bCtgIPSZ2htVNwBaq/RYG1N2EpqnkLXR1qUvuOSfxPAs8j7Wf7kD 3ll16iGmFYL4xgfA8RE0S8f7n+faLm8GMFfaXf3OxL6zXNAX5JcGExaSdX2c1FHiTUTH qMKjwTektqUZvXtXiNWR0tqZbofdwnfpfpP7aVIwRxsGnEe4DScDdboA2uBjKM8tZt8Q 6KiA== 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=ejY+9Vm9aWJOs97zrA807+W9n/23O9nYbfu1WQqsyN4=; b=Uc7fdVT7P6OrkprxaHKfqdv1PF5STDr9kOEJmKtiqYfK3scopAv8ZTd8zPJosPSp4c yS8wrtcCCm3Lb7kJQaAdrpi47ZE9zYow3OjtROUMSCti5QzwEz+It7qrKNH6B6Mj28i7 ag5gv/kN+UM6d2s7ToodNs4198LIOpvYwUVHcELHfXmnUEardKCY+jSdXRwunBw2psHl bbmfCAnKssfHfGefrfZM1OCC55Mydo5C3rZqFzrdNJZ9E6oDlfC0BAVRkUeIm7cWMpuO EI23zsJ2bRCw3dVaH5lKNW6e7LunMi3nj9KfzuGhvHoqxB48mJVC+kNqnXCQNOQsInae PZ0g== X-Gm-Message-State: APjAAAUR4iJz6ML/mkkPGUN9ZVHCH9m3GO2oTThdh7hyCxHphu5KzJIs YbiqSgrSy6RaEyKYtM4Kzmi7vvrW4EIn4Jju X-Google-Smtp-Source: APXvYqz6f/D7+PFLZCxKK/K5eWFiAXnAStPWGTZJu/8oCjOA5TUh20GOlE1d4q4CuQdJrKGrqV6Xcg== X-Received: by 2002:a1c:2884:: with SMTP id o126mr20068584wmo.153.1571652667359; Mon, 21 Oct 2019 03:11:07 -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 j63sm15978535wmj.46.2019.10.21.03.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:11:06 -0700 (PDT) From: Daniel Thompson To: Douglas Anderson , Jason Wessel Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org, kbuild test robot Subject: [PATCH v2] kdb: Avoid array subscript warnings on non-SMP builds Date: Mon, 21 Oct 2019 11:10:56 +0100 Message-Id: <20191021101057.23861-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Recent versions of gcc (reported on gcc-7.4) issue array subscript warnings for builds where SMP is not enabled. kernel/debug/debug_core.c: In function 'kdb_dump_stack_on_cpu': kernel/debug/debug_core.c:452:17: warning: array subscript is outside array +bounds [-Warray-bounds] if (!(kgdb_info[cpu].exception_state & DCPU_IS_SLAVE)) { ~~~~~~~~~^~~~~ kernel/debug/debug_core.c:469:33: warning: array subscript is outside array +bounds [-Warray-bounds] kgdb_info[cpu].exception_state |= DCPU_WANT_BT; kernel/debug/debug_core.c:470:18: warning: array subscript is outside array +bounds [-Warray-bounds] while (kgdb_info[cpu].exception_state & DCPU_WANT_BT) There is no bug here but there is scope to improve the code generation for non-SMP systems (whilst also silencing the warning). Reported-by: kbuild test robot Fixes: 2277b492582d ("kdb: Fix stack crawling on 'running' CPUs that aren't the master") Signed-off-by: Daniel Thompson --- Notes: Changes in v2: - Moved the IS_ENABLED(CONFIG_SMP) test to the first (slightly easier to read the code, improves code generation a little) - Sent out as a proper patch e-mail ;-) kernel/debug/debug_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.21.0 Reviewed-by: Douglas Anderson diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 70e86b4b4932..2b7c9b67931d 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -444,7 +444,7 @@ int dbg_remove_all_break(void) #ifdef CONFIG_KGDB_KDB void kdb_dump_stack_on_cpu(int cpu) { - if (cpu == raw_smp_processor_id()) { + if (cpu == raw_smp_processor_id() || !IS_ENABLED(CONFIG_SMP)) { dump_stack(); return; }