Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2952374imm; Fri, 19 Oct 2018 02:30:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV62TNd/dxeH+yxA/S9C+onslHdJoRPW/trePhq33slPmJkjrP4yZN5qbYOTQxM9RcxehqkAS X-Received: by 2002:a62:509a:: with SMTP id g26-v6mr33569758pfj.62.1539941428061; Fri, 19 Oct 2018 02:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539941428; cv=none; d=google.com; s=arc-20160816; b=RGTi9OAH/EWiv8mGkO0Emf2QelgMtWgaYzQRAh1ZTWuuDCo/JJtmRzagzkRmHf3u4s 9jdTNJLqoSHU0DUpK2tleIJSfv3j971MCXrMZZddhJgrcsg13Emsfl0cjA9qhSnMXhBR prXIn5S48mM0Uui9gKYi7GUsNxTDejdAkVBDyEFYLta+1dCu24jWP3Ei97j1gEQ9nb2b VytNNRqSIsXP7VdB1cfjnvWErrPqlxRkc5tZddwSIeULtclkSEpXyMPS1mghu9p0O8vk 2SmXbxmRoYKe1uBg3HcslB2A7jOvPMv6jz4OlByF91SVNKVk4464SrPRsAnHKU4Si1+C wNtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id; bh=Q6Y/Rj0ZJ9abi3akx+Q2l3xUsFsC490yEbd28D7wM2Y=; b=OnuRNjBR4AMtn1fjWEfyYOyLYfJGfkFlBfda7mFNzMw0DZcvej4bPCa1wMunzOTcgZ L7HsmNI5a+HtF7mmQhLvvAmzXw+vyW5379vk7cV615dlLnKkl7NbUbmTTldq5r+oXiPz wUhoAtiOPvP3G9pX8mYruxi4DVfmgHTc1VgUynEULHFiLv+c8SYFG2HyLGAzrmofJyXy C/00aYVTfJEZ0tdPFU2IkQD4TmatLRnD6ImiAtwx0zCrRxcOafhqprKPqb8KKOlYw/oM z3PCbBLQSxyP7ZTrjEBZvrVOlpiCBjdS3ixvKAWrzy7Odm76AsahWmdu/Agt1xawnVnw l1nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd3-v6si23444229plb.399.2018.10.19.02.30.12; Fri, 19 Oct 2018 02:30:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727343AbeJSRe5 (ORCPT + 99 others); Fri, 19 Oct 2018 13:34:57 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:51628 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbeJSRe5 (ORCPT ); Fri, 19 Oct 2018 13:34:57 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 42c0wx3HM5z9ttFp; Fri, 19 Oct 2018 11:29:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id PTkX-FbHhTio; Fri, 19 Oct 2018 11:29:21 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 42c0wx1y8Nz9ttBP; Fri, 19 Oct 2018 11:29:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A18798B902; Fri, 19 Oct 2018 11:29:22 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 5_R4DiSewkGy; Fri, 19 Oct 2018 11:29:22 +0200 (CEST) Received: from pc13168vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 724CB8B8F6; Fri, 19 Oct 2018 11:29:22 +0200 (CEST) Received: by pc13168vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 4907B6F496; Fri, 19 Oct 2018 09:29:22 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry() To: Boris Ostrovsky , Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Peter Zijlstra Cc: x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org Date: Fri, 19 Oct 2018 09:29:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit d7880812b359 ("idle: Add the stack canary init to cpu_startup_entry()") added the call to boot_init_stack_canary() in cpu_startup_entry() in an #ifdef CONFIG_X86 statement, with the intention to remove that #ifdef later. While implementing stack protector for powerpc, it has been observed that calling boot_init_stack_canary() is also needed for powerpc which uses per task (TLS) stack canary like the X86. However, calling boot_init_stack_canary() would break arches using global stack canary (ARM, SH, MIPS and XTENSA). Instead of adding modifying the #ifdef in a implemented the call to boot_init_stack_canary() in the function calling cpu_startup_entry() On x86, we have two functions calling cpu_startup_entry(): - start_secondary() - cpu_bringup_and_idle() start_secondary() already calls boot_init_stack_canary(). This patch adds the call to boot_init_stack_canary() in cpu_bringup_and_idle() and removes it from cpu_startup_entry() Signed-off-by: Christophe Leroy --- arch/x86/xen/smp_pv.c | 1 + kernel/sched/idle.c | 15 --------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c index e3b18ad49889..0e05e8e23998 100644 --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -88,6 +88,7 @@ static void cpu_bringup(void) asmlinkage __visible void cpu_bringup_and_idle(void) { cpu_bringup(); + boot_init_stack_canary(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); } diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 16f84142f2f4..f5516bae0c1b 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -347,21 +347,6 @@ EXPORT_SYMBOL_GPL(play_idle); void cpu_startup_entry(enum cpuhp_state state) { - /* - * This #ifdef needs to die, but it's too late in the cycle to - * make this generic (ARM and SH have never invoked the canary - * init for the non boot CPUs!). Will be fixed in 3.11 - */ -#ifdef CONFIG_X86 - /* - * If we're the non-boot CPU, nothing set the stack canary up - * for us. The boot CPU already has it initialized but no harm - * in doing it again. This is a good place for updating it, as - * we wont ever return from this function (so the invalid - * canaries already on the stack wont ever trigger). - */ - boot_init_stack_canary(); -#endif arch_cpu_idle_prepare(); cpuhp_online_idle(state); while (1) -- 2.13.3