Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp373731rwd; Tue, 16 May 2023 02:11:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7w1Vh6OKYR5qt9u0FmczHfjrD98yH1u/ZJimhLFRax8pZAKJgQ5dyjBWqCPVosrwvABeSY X-Received: by 2002:a05:6a20:4658:b0:ec:8f81:e9f7 with SMTP id eb24-20020a056a20465800b000ec8f81e9f7mr40311175pzb.16.1684228312586; Tue, 16 May 2023 02:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684228312; cv=none; d=google.com; s=arc-20160816; b=WGJPGEAaOVI993rwdgUrOKvRG/h/Ely/b/21wTG2pgK4Z/0mC9p4NbAntOjxqEBBKu c0tX2JZxt46T77Y+nrbc0zaO7zz7/i8TKVJjT+CnHHf6JncpEs+BGWn+x9K6UgwjoXyl E0uAvKNJBfkhtkXsRNJA9OaLyJy41aPg9Ym1yJaqKVV/K6GtGDClwhfGK+FCkPTn89+v 6bvs0Twhb8VAwOEUPFPfxa+LGV5SKgJ9LZXrlnpAKp6rIEMQioXqXQ2uKDdYXFsWFY8z U0q5z0y6vuOfhBg6hjsYCioxGXT/KgXksnqIaNb1fMQo1MmMC3OncVt9SrkIJ1FGh3NQ TrQg== 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 header.b=f4joasLO; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c83-20020a624e56000000b0063d2b810fc6si19524652pfb.305.2023.05.16.02.11.33; Tue, 16 May 2023 02:11:52 -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 header.b=f4joasLO; 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 S231855AbjEPJKg (ORCPT + 99 others); Tue, 16 May 2023 05:10:36 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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;