Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3050477rdb; Fri, 22 Sep 2023 17:10:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBp/7B1AS9qRbXj5LIFUTaBeUqvyOoVXuwNYFTN0OdXrAP+Tb7wA/oLibkn/owa036DxvP X-Received: by 2002:a17:90a:af82:b0:274:7fbc:3f62 with SMTP id w2-20020a17090aaf8200b002747fbc3f62mr1512711pjq.16.1695427818126; Fri, 22 Sep 2023 17:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695427818; cv=none; d=google.com; s=arc-20160816; b=jaMYpG3XbJ1i+Wt3DDINqxj5k3OqhxyMUANycpcvqFSsutthC1A/FEgwSLqhPPyBkT fkO9+8WGNubrFXRYwgyubH0RV9WjmmFTOseD2amrK5UCES4z/OrGAUDPKPBYxO5WyeJA IPKfkYx89ggpx/IewUaDJbYlxO4hej43OBubi3FtPVtcW8MBDLFZSsoN8zokcClXQNpY Ua5SVYT2N07j+wOhxt8tXxGs8Xnrr+uOmBycBPggdr6r7J2qZlnMsGVB9W9q/jpD1e0v ugb04ebi5qemkjcNzO91MBvZ2XcsNwo9MeLFzDpp76m0o4sB0zqOvh/owszbMGO/2AmX zpFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=+Aj65HqLVsJc6wr0Ei1R71U4rjFdiu/xCjSOuKtCaao=; fh=9VP0M4rgL4iNQ15T4EwNFsP+O5WU2yy2tx/+QRUnj5k=; b=P1hwlPE5d/ek6+QzpOg5uX/ETYryFzcJYlJzHBrhyfQ34oSPzFl3dTU3f1oEeAo520 hIADfCd0jfJaBtcHdWu3xlxiYC0wyfuJAS0RPy7xm8bE95pgt/C2YPLj6O2xojvT+1oo Z0dO9YnSl0J8Q00Y3NTchFlBYJa0xkK4znC8oW77hSW9oS/mRgk/PO/A5FIPavg3xbI0 K0tcplJ+6NY/Kh7V8BzMTldMp6/v5kYOH6AJ0EfbH1ltpsZKzhwBNffVYyzYXGts4F2R gf82UHJcsGdO+qzCKu0XaGQSP6VR2T01uOYl2E3lCbPMfxRieJy47Qs/NaCdud9X88FH iwYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CJ8yte6b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y3-20020a17090a86c300b00276945c92a1si7004577pjv.88.2023.09.22.17.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 17:10:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CJ8yte6b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B9AA881A7AEC; Fri, 22 Sep 2023 14:37:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbjIVVhO (ORCPT + 99 others); Fri, 22 Sep 2023 17:37:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbjIVVhN (ORCPT ); Fri, 22 Sep 2023 17:37:13 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28ABAC1 for ; Fri, 22 Sep 2023 14:37:07 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c108e106f0so48266161fa.1 for ; Fri, 22 Sep 2023 14:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695418625; x=1696023425; darn=vger.kernel.org; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:from:to:cc:subject:date:message-id :reply-to; bh=+Aj65HqLVsJc6wr0Ei1R71U4rjFdiu/xCjSOuKtCaao=; b=CJ8yte6b26LQu4zqa93wujjDdKSomyXRjKL7TAQnyoY9XbaX7UhLBOK7n2XTzVAK1V /nWJge/v5RQQQx7abcwGCnEV/sSiG9pPHqwGsVqwLbDOBDFbB0mf6D5vkgHXfm/rfYrY XCBqs0BH9wWneGd0ELj6shgRD7o17NZdqGMc8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695418625; x=1696023425; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+Aj65HqLVsJc6wr0Ei1R71U4rjFdiu/xCjSOuKtCaao=; b=GxNhuKc4VFJoUb1m+RDzo0ILMva0zi3+k69zpDib8dguHffLOYJzdZKIUPho3y15IT VPmvE0VhybozdBZdsGeYNhsQ30rey9rMuEj8scPeYBZ6BOP0ildaYX2kxhzWpQKnzLfQ fV9jvs8CR0ERVfe/M8ipwsKxwxByXa3hrUt32TbgmtKgtcjRIiPnWJ7D2kc1ohytpWHj diL+LP/8VpsCCbrNf9NdOXb6igrQFTdGUVlf+4qxjPSA90mCk2s2eTW+QWPQ25hg980z QxLACBIEOP9EgjB/xSCGQObtO+C2ViQRubji7dtkn6CFxjxKxcpgRgpPgaLt3Y4g2IbF tMwA== X-Gm-Message-State: AOJu0YxN3n1PAO52H1ttGUSry12GWvZmoll6pPY21seIHIQPsSxeJ/u5 8gQuHGDkruz26ByGTwcJAB9VbLBHykJvY+V76SRe3hRrjfyJYQlS X-Received: by 2002:a2e:7305:0:b0:2c0:7e0:2a1 with SMTP id o5-20020a2e7305000000b002c007e002a1mr372196ljc.41.1695418625229; Fri, 22 Sep 2023 14:37:05 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 22 Sep 2023 14:37:04 -0700 MIME-Version: 1.0 In-Reply-To: <20230921161634.4063233-1-mark.rutland@arm.com> References: <20230921161634.4063233-1-mark.rutland@arm.com> From: Stephen Boyd User-Agent: alot/0.10 Date: Fri, 22 Sep 2023 14:37:04 -0700 Message-ID: Subject: Re: [PATCH v2] lkdtm/bugs: add test for panic() with stuck secondary CPUs To: Mark Rutland , linux-kernel@vger.kernel.org Cc: dianders@chromium.org, keescook@chromium.org, sumit.garg@linaro.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 14:37:13 -0700 (PDT) Quoting Mark Rutland (2023-09-21 09:16:34) > Upon a panic() the kernel will use either smp_send_stop() or > crash_smp_send_stop() to attempt to stop secondary CPUs via an IPI, > which may or may not be an NMI. Generally it's preferable that this is an > NMI so that CPUs can be stopped in as many situations as possible, but > it's not always possible to provide an NMI, and there are cases where > CPUs may be unable to handle the NMI regardless. > > This patch adds a test for panic() where all other CPUs are stuck with > interrupts disabled, which can be used to check whether the kernel > gracefully handles CPUs failing to respond to a stop, and whether NMIs > actually work to stop CPUs. > > For example, on arm64 *without* an NMI, this results in: > > | # echo PANIC_STOP_IRQOFF > /sys/kernel/debug/provoke-crash/DIRECT > | lkdtm: Performing direct entry PANIC_STOP_IRQOFF > | Kernel panic - not syncing: panic stop irqoff test > | CPU: 2 PID: 24 Comm: migration/2 Not tainted 6.5.0-rc3-00077-ge6c782389895-dirty #4 > | Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015 > | Stopper: multi_cpu_stop+0x0/0x1a0 <- stop_machine_cpuslocked+0x158/0x1a4 > | Call trace: > | dump_backtrace+0x94/0xec > | show_stack+0x18/0x24 > | dump_stack_lvl+0x74/0xc0 > | dump_stack+0x18/0x24 > | panic+0x358/0x3e8 > | lkdtm_PANIC+0x0/0x18 > | multi_cpu_stop+0x9c/0x1a0 > | cpu_stopper_thread+0x84/0x118 > | smpboot_thread_fn+0x224/0x248 > | kthread+0x114/0x118 > | ret_from_fork+0x10/0x20 > | SMP: stopping secondary CPUs > | SMP: failed to stop secondary CPUs 0-3 > | Kernel Offset: 0x401cf3490000 from 0xffff80008000000c0 > | PHYS_OFFSET: 0x40000000 > | CPU features: 0x00000000,68c167a1,cce6773f > | Memory Limit: none > | ---[ end Kernel panic - not syncing: panic stop irqoff test ]--- > > Note the "failed to stop secondary CPUs 0-3" message. > > On arm64 *with* an NMI, this results in: > > | # echo PANIC_STOP_IRQOFF > /sys/kernel/debug/provoke-crash/DIRECT > | lkdtm: Performing direct entry PANIC_STOP_IRQOFF > | Kernel panic - not syncing: panic stop irqoff test > | CPU: 1 PID: 19 Comm: migration/1 Not tainted 6.5.0-rc3-00077-ge6c782389895-dirty #4 > | Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015 > | Stopper: multi_cpu_stop+0x0/0x1a0 <- stop_machine_cpuslocked+0x158/0x1a4 > | Call trace: > | dump_backtrace+0x94/0xec > | show_stack+0x18/0x24 > | dump_stack_lvl+0x74/0xc0 > | dump_stack+0x18/0x24 > | panic+0x358/0x3e8 > | lkdtm_PANIC+0x0/0x18 > | multi_cpu_stop+0x9c/0x1a0 > | cpu_stopper_thread+0x84/0x118 > | smpboot_thread_fn+0x224/0x248 > | kthread+0x114/0x118 > | ret_from_fork+0x10/0x20 > | SMP: stopping secondary CPUs > | Kernel Offset: 0x55a9c0bc0000 from 0xffff800080000000 > | PHYS_OFFSET: 0x40000000 > | CPU features: 0x00000000,68c167a1,fce6773f > | Memory Limit: none > | ---[ end Kernel panic - not syncing: panic stop irqoff test ]--- > > Note the absence of a "failed to stop secondary CPUs" message, since we > don't log anything when secondary CPUs are successfully stopped. > > Signed-off-by: Mark Rutland > Cc: Douglas Anderson > Cc: Kees Cook > Cc: Stephen Boyd Cc: Sumit Garg > Reviewed-by: Kees Cook > Reviewed-by: Douglas Anderson > --- Reviewed-by: Stephen Boyd