Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6884217ybe; Wed, 18 Sep 2019 10:35:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyU00Alv3R1JheQn/1zL4BOHzgihlq9GEga4dYIoYcdOcouUJ3RQzdZABVLhZ7leSCGN/GZ X-Received: by 2002:a17:906:5ad8:: with SMTP id x24mr10304551ejs.107.1568828127303; Wed, 18 Sep 2019 10:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568828127; cv=none; d=google.com; s=arc-20160816; b=sUBj4sdZrj1RL3WrXYqmswuufUaW3HGW+Ax1nxbpY+RCVsxiugV90c/oWfCGwCWG+T 1Eq9DfoSyp26Pc3SOLJS4P+BkEtn8Qf2dH+FhO7timf+1LDV+Wn7RtMfcHKrV5r3+csb KlCwK7MGS0EPd1r/o06sd2VRQidc3rO+YM3OwXqNFE7ZDU++fmbsrkA5PCkWtJNd66cL HEcOUCiFkrahmQg6HPnWsadTrKcsDc1V/5aQbFJmzOCMmzwcvE9yqDHqrW4nkTq3f0EU ODTqEP1ALxSDhGPyzuI+QB52f9B70TGMfGX5z70v1OiIKji479rChzD7bG0cUP0ldqd9 beaA== 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 :dkim-signature; bh=RTNqVigtZCB9nfylpkba14XvqHQP0Sf91fjBXEqDk1o=; b=cC64JO9NjRnlgkYf3YXenDnxb5l1AeiZaA4Mt690mG2+cK9JPsoVarNV479Yq206z5 ECLMMbUq05t8uLG9rpc1X3i0QAoEyp4+U4bZKB+kTaOYo+4eGpSPRNelVw01zwkhJapf SE8RvKZvR/octyrfUF7B6xSSUFsZCNFVSX81NaC/Sb3FUap4kaq+wJCgLGbXeVKqgBNP cC7b73u2d4N5UQpnTapdvtumcN0X7jNuQw3bxS7OaeupHc7OpuJ8ucfcgWYEbi/GsbIO zao8Xtw6DQG5DP1A2bG6MOjozuHhVrnGQmGwICi0bkMQZUvf6l/KZ61OlcE1K7ZsGQo7 EMbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=NObndLFA; 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 r17si3147063ejh.315.2019.09.18.10.35.02; Wed, 18 Sep 2019 10:35:27 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b=NObndLFA; 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 S1731767AbfIRPsY (ORCPT + 99 others); Wed, 18 Sep 2019 11:48:24 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:59548 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728248AbfIRPsY (ORCPT ); Wed, 18 Sep 2019 11:48:24 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 46YPX45FbMz9vKGg; Wed, 18 Sep 2019 17:48:20 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=NObndLFA; dkim-adsp=pass; dkim-atps=neutral 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 jcKP-5oeem5n; Wed, 18 Sep 2019 17:48:20 +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 46YPX43wqRz9vBmq; Wed, 18 Sep 2019 17:48:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1568821700; bh=RTNqVigtZCB9nfylpkba14XvqHQP0Sf91fjBXEqDk1o=; h=From:Subject:To:Cc:Date:From; b=NObndLFAumn+R2H3U9fzOqoel5nFrwV8dAtLKFtpOpPBMOkxwZTeEDvVw5umBj8hx Hm8HYIFQOrU2AXQpgEjVfUVaUDWmPlw4ukk9rJbTKqk0+v+3Lh0tzcmaflBgbpJiod O9h0TF1s9QCsCwxt3DSdIs4IoW1lCu+vkuCZdkEA= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 527868B93D; Wed, 18 Sep 2019 17:48:21 +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 jNrIB4eKvEUb; Wed, 18 Sep 2019 17:48:21 +0200 (CEST) Received: from pc16032vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6964D8B93A; Wed, 18 Sep 2019 17:48:20 +0200 (CEST) Received: by pc16032vm.idsi0.si.c-s.fr (Postfix, from userid 0) id D16236B81B; Wed, 18 Sep 2019 15:48:19 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH v3 1/2] powerpc/irq: bring back ksp_limit management in C functions. To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , segher@kernel.crashing.org, npiggin@gmail.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Wed, 18 Sep 2019 15:48:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit cbc9565ee826 ("powerpc: Remove ksp_limit on ppc64") moved PPC32 ksp_limit handling in assembly functions call_do_softirq() and call_do_irq() as they are different for PPC32 and PPC64. In preparation of replacing these functions by inline assembly, partialy revert that commit to bring back ksp_limit assignment in the callers. To get and set ksp_limit without a forest of #ifdefs CONFIG_PPC32, use helpers that will void on PPC64. Signed-off-by: Christophe Leroy --- v2: added forward declaration of struct task_struct to avoid build failure. v3: included linux/sched.h, forward declaration is not enough. --- arch/powerpc/include/asm/irq.h | 22 ++++++++++++++++++++++ arch/powerpc/kernel/irq.c | 14 +++++++++++++- arch/powerpc/kernel/misc_32.S | 14 -------------- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h index 814dfab7e392..0c6469983c66 100644 --- a/arch/powerpc/include/asm/irq.h +++ b/arch/powerpc/include/asm/irq.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -64,5 +65,26 @@ extern void __do_irq(struct pt_regs *regs); int irq_choose_cpu(const struct cpumask *mask); +#ifdef CONFIG_PPC32 +static inline unsigned long get_ksp_limit(struct task_struct *tsk) +{ + return tsk->thread.ksp_limit; +} + +static inline void set_ksp_limit(struct task_struct *tsk, unsigned long limit) +{ + tsk->thread.ksp_limit = limit; +} +#else +static inline unsigned long get_ksp_limit(struct task_struct *tsk) +{ + return 0; +} + +static inline void set_ksp_limit(struct task_struct *tsk, unsigned long limit) +{ +} +#endif + #endif /* _ASM_IRQ_H */ #endif /* __KERNEL__ */ diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 5645bc9cbc09..04204be49577 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -646,6 +646,7 @@ void do_IRQ(struct pt_regs *regs) { struct pt_regs *old_regs = set_irq_regs(regs); void *cursp, *irqsp, *sirqsp; + unsigned long saved_ksp_limit = get_ksp_limit(current); /* Switch to the irq stack to handle this */ cursp = (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1)); @@ -658,9 +659,15 @@ void do_IRQ(struct pt_regs *regs) set_irq_regs(old_regs); return; } + /* Adjust the stack limit */ + set_ksp_limit(current, (unsigned long)irqsp); + /* Switch stack and call */ call_do_irq(regs, irqsp); + /* Restore stack limit */ + set_ksp_limit(current, saved_ksp_limit); + set_irq_regs(old_regs); } @@ -681,7 +688,12 @@ void *hardirq_ctx[NR_CPUS] __read_mostly; void do_softirq_own_stack(void) { - call_do_softirq(softirq_ctx[smp_processor_id()]); + void *irqsp = softirq_ctx[smp_processor_id()]; + unsigned long saved_ksp_limit = get_ksp_limit(current); + + set_ksp_limit(current, (unsigned long)irqsp); + call_do_softirq(irqsp); + set_ksp_limit(current, saved_ksp_limit); } irq_hw_number_t virq_to_hw(unsigned int virq) diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S index 82df4b09e79f..a5422f7782b3 100644 --- a/arch/powerpc/kernel/misc_32.S +++ b/arch/powerpc/kernel/misc_32.S @@ -33,23 +33,14 @@ .text -/* - * We store the saved ksp_limit in the unused part - * of the STACK_FRAME_OVERHEAD - */ _GLOBAL(call_do_softirq) mflr r0 stw r0,4(r1) - lwz r10,THREAD+KSP_LIMIT(r2) - stw r3, THREAD+KSP_LIMIT(r2) stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3) mr r1,r3 - stw r10,8(r1) bl __do_softirq - lwz r10,8(r1) lwz r1,0(r1) lwz r0,4(r1) - stw r10,THREAD+KSP_LIMIT(r2) mtlr r0 blr @@ -59,16 +50,11 @@ _GLOBAL(call_do_softirq) _GLOBAL(call_do_irq) mflr r0 stw r0,4(r1) - lwz r10,THREAD+KSP_LIMIT(r2) - stw r4, THREAD+KSP_LIMIT(r2) stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r4) mr r1,r4 - stw r10,8(r1) bl __do_irq - lwz r10,8(r1) lwz r1,0(r1) lwz r0,4(r1) - stw r10,THREAD+KSP_LIMIT(r2) mtlr r0 blr -- 2.13.3