From patchwork Tue May 16 09:09:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 94578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp287330vqo; Tue, 16 May 2023 02:19:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Zp52IazEsCH/Y65nOXaQ5XEtti9mfmtk+tmezL6zNpLJDi/Ljkqh8sMa6E1+dPsTgc8Wf X-Received: by 2002:a05:6a20:2593:b0:101:2923:56cd with SMTP id k19-20020a056a20259300b00101292356cdmr29870839pzd.62.1684228785311; Tue, 16 May 2023 02:19:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684228785; cv=none; d=google.com; s=arc-20160816; b=zye8cLB+zLf+JpyWa+8EpIuu4u6OkgTFyMw65D+ydDCDUnkaD2e+RVRn/mL6EOcQ75 gMo0scEEcCyuyACCNhnI5DFZkexrh50KBp6URuKHiNQSxKR9LsoVh6j8ovH1qza7VjRq 7MSOCCQDeBAo2ZmxOGkBLcY2r1OQ5PN+8q5WlX31IriHEBakbrtxIn+w9juqjY4ViTEK HHIAAY4byCSpPIhxkxobKxQPy/9+AFjWmJmZNT70mqcx4nuoOZCh5SOWmnpvI0vOLM7h aoJwpglPHwDO5sIT+7GJ/kV/doQa3ioQVuoWYA/5nyJYG0ctua+Q40yAydJIr0hG/GH8 nUMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=pPk+J3aq3bXChS7qb82NQ2BLD6Yszz/2hu6XSw1UagY=; b=X7tbEaR+zJaBY9bwJfWzCM0iUY4VaGO3oqWSXmD8W+et6+ZeSSiwg3bXwHKns7Kdgz X23QWuwJmnwfKFuoj+zTI8TWSWt2wBvmHl89FlJB0MrMOf4oh+RJavZtCyXwNXXltXIv u5A2uiR7JFkJoP3gJYjNXujOlHKe5PWotSZNl/yfLhU3MfH2Ninc/X68SM7crm7hZhJD idyP3wE1Sc8kzAEEqIHkbbm5gS+fTYT5ZVkzJYmekeRGr5TDdvXF9mS7+pEKa70DRV1Z xaoU3id0IC+IzCatrJJ+6lQtbjWYfFdRsq8y577x3IDrwBlG2rvJoZ+Mbd1mVfCR5YtD k9WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XibnvBuo; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mn24-20020a17090b189800b002507107f730si1369585pjb.30.2023.05.16.02.19.31; Tue, 16 May 2023 02:19:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XibnvBuo; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231934AbjEPJKh (ORCPT + 99 others); Tue, 16 May 2023 05:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbjEPJKE (ORCPT ); Tue, 16 May 2023 05:10:04 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29635421A; Tue, 16 May 2023 02:10:00 -0700 (PDT) Date: Tue, 16 May 2023 09:09:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684228196; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pPk+J3aq3bXChS7qb82NQ2BLD6Yszz/2hu6XSw1UagY=; b=XibnvBuoh5+7xmwpAKdp9yb0QegERnx6wQs8daMYQHQPQlqZtQAwaAwUEqx73u7sfzsfR+ CYTYIFj/o3Xoq9kUMHrgsr8GLMfsrt9MZoQi4DmDUAMl0eD0trMmBrudvZt2kYBr8vj2Ey lVC8rTSREAPdPcQmcl52PD3asQF3J4m+zdjV+dm4oGdn2rgGNy5azkFgwwzSYCcEWnZl8G zQ95AOGxoRfV6ZCYBI8k4nxe2zsgX3fjCv/h5qjeZGyhqlXaBcuRaSuYj4psUMFFWYNY0u ChYDwDi1DYaEgGyNImn8N9PQSVh/l7INYtkKu+buLa1NzIlEOslA4RqKF2REeA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684228196; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pPk+J3aq3bXChS7qb82NQ2BLD6Yszz/2hu6XSw1UagY=; b=f4joasLOCZZKzHgL62N4mj6fXQNsvo4VPy75LJ1R4ziJucVklr9jcOabZQIebIrz1hMjQn XOn8t0GQlNhuLuAw== From: "tip-bot2 for David Woodhouse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] cpu/hotplug: Reset task stack state in _cpu_up() Cc: David Woodhouse , Thomas Gleixner , "Peter Zijlstra (Intel)" , Mark Rutland , Michael Kelley , Oleksandr Natalenko , Helge Deller , "Guilherme G. Piccoli" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230512205257.027075560@linutronix.de> References: <20230512205257.027075560@linutronix.de> MIME-Version: 1.0 Message-ID: <168422819576.404.15600821277186598321.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765724919555086221?= X-GMAIL-MSGID: =?utf-8?q?1766041882937720973?= The following commit has been merged into the smp/core branch of tip: Commit-ID: 6d712b9b3a58018259fb40ddd498d1f7dfa1f4ec Gitweb: https://git.kernel.org/tip/6d712b9b3a58018259fb40ddd498d1f7dfa1f4ec Author: David Woodhouse AuthorDate: Fri, 12 May 2023 23:07:43 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 15 May 2023 13:45:00 +02:00 cpu/hotplug: Reset task stack state in _cpu_up() Commit dce1ca0525bf ("sched/scs: Reset task stack state in bringup_cpu()") ensured that the shadow call stack and KASAN poisoning were removed from a CPU's stack each time that CPU is brought up, not just once. This is not incorrect. However, with parallel bringup the idle thread setup will happen at a different step. As a consequence the cleanup in bringup_cpu() would be too late. Move the SCS/KASAN cleanup to the generic _cpu_up() function instead, which already ensures that the new CPU's stack is available, purely to allow for early failure. This occurs when the CPU to be brought up is in the CPUHP_OFFLINE state, which should correctly do the cleanup any time the CPU has been taken down to the point where such is needed. Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Mark Rutland Tested-by: Mark Rutland Tested-by: Michael Kelley Tested-by: Oleksandr Natalenko Tested-by: Helge Deller # parisc Tested-by: Guilherme G. Piccoli # Steam Deck Link: https://lore.kernel.org/r/20230512205257.027075560@linutronix.de --- kernel/cpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 64b6242..0ab6a7d 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -771,12 +771,6 @@ static int bringup_cpu(unsigned int cpu) return -EAGAIN; /* - * Reset stale stack state from the last time this CPU was online. - */ - scs_task_reset(idle); - kasan_unpoison_task_stack(idle); - - /* * Some architectures have to walk the irq descriptors to * setup the vector space for the cpu which comes online. * @@ -1587,6 +1581,12 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target) ret = PTR_ERR(idle); goto out; } + + /* + * Reset stale stack state from the last time this CPU was online. + */ + scs_task_reset(idle); + kasan_unpoison_task_stack(idle); } cpuhp_tasks_frozen = tasks_frozen;