Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp531772imu; Tue, 11 Dec 2018 03:25:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKh76nX+EBzizWoO4NdIvuBclbOwAP8BRBp4zG9ZDeMD+PrqnXUaosy/p9SKJZSYZkq3Af X-Received: by 2002:a17:902:7896:: with SMTP id q22mr15951867pll.280.1544527558694; Tue, 11 Dec 2018 03:25:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544527558; cv=none; d=google.com; s=arc-20160816; b=mIjk+kUWjEfPKfGRVV2so+WQ3mhstI65TFcz3YrznfhDMESPmphaUibs/iPaVsNC0K oWgofPKc+oLj9dp8fg52xLeNyXnFJemfeADZxt8uxo8y8pC5RvbdCFwmenTtoaWVogNT 9jC2K0DMDYFM8AWF7wPYfczFye2AAncjIJKzuCORYN0Ut6kRFQ2XhVHLOXN30ZUdrc0Q 2KuiO7oTQ472jr5Utlvrxmh/SqQFE0ojHQMVQveGvArjMQvYkbD1URUdoxh6xdm/JEdJ wVgyfn7ln+Mfu5lHxKXZ9nJLKgk8aSpTOwmdzJf79RchfSpDTPptU6xjkwhcerijoad9 06EQ== 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:references :in-reply-to:message-id; bh=BsRsh4cTZyi0ces6vYXS87lJYQirdxoPIu6vNc8IPVE=; b=ub7bFEBuIIU/0jHPwo+o0J4RLXceXZtb2BEbWSBhfkcmMLw4VOR6r0S3Ru6+CUNysE F1ikxuM1Btg1qDBP0Bam08CMN1JfXAMmSkaRB7xQBUn3DuMlxHsbtK8/tkgkduf0xrX9 JBjymTOIyrpSS+Ges/iVfeVE4UinOqHuO4mWQqrG4Sxd8U6NZBkhTas6D5+6PfQFX6BS 3j+wS9QyMiWXcamBXftJz1JlZIehTsZHDjvue5I5D8IH6t4MgHCgQtIRoCj83G3m/k2k 8ssXndrMBQV9EG3b7GuNHf+/Y9XtrVYPnLerW52G/9AlAs3HQSHVM/irtMVC6rLqEwGj IFEQ== 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 p5si11658755pga.352.2018.12.11.03.25.44; Tue, 11 Dec 2018 03:25:58 -0800 (PST) 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 S1726394AbeLKLX5 (ORCPT + 99 others); Tue, 11 Dec 2018 06:23:57 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:26126 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726212AbeLKLXz (ORCPT ); Tue, 11 Dec 2018 06:23:55 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43Dcyc3Ng5zB09bC; Tue, 11 Dec 2018 12:23:52 +0100 (CET) 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 Iu_1_KTjI0F2; Tue, 11 Dec 2018 12:23:52 +0100 (CET) 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 43Dcyc2tvBzB09b7; Tue, 11 Dec 2018 12:23:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 5B94F8B7EB; Tue, 11 Dec 2018 12:23:53 +0100 (CET) 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 Gin37YTydpmC; Tue, 11 Dec 2018 12:23:53 +0100 (CET) Received: from PO15451.localdomain (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id CF4EE8B7E7; Tue, 11 Dec 2018 12:23:52 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 0) id 8FECD71702; Tue, 11 Dec 2018 11:23:52 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [RFC PATCH v1 1/3] powerpc/32: prepare for CONFIG_VMAP_STACK To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 11 Dec 2018 11:23:52 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To support CONFIG_VMAP_STACK, the kernel must be able to activate Data MMU Translation for accessing the stack. Before doing that it must save SRR0, SRR1 and DAR in order to not loose them in case there is a Data TLB Miss once the translation is reactivated. This patch defines fields in the thread struct for saving those registers. It also prepares entry_32.S to handle exception entry with Data MMU Translation enabled. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/processor.h | 5 +++++ arch/powerpc/include/asm/thread_info.h | 5 +++++ arch/powerpc/kernel/asm-offsets.c | 5 +++++ arch/powerpc/kernel/entry_32.S | 16 ++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index 8179b64871ed..e839a1231b17 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -218,6 +218,11 @@ struct thread_struct { #ifdef CONFIG_PPC32 void *pgdir; /* root of page-table tree */ unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */ +#ifdef CONFIG_VMAP_STACK + unsigned long dar; + unsigned long srr0; + unsigned long srr1; +#endif #endif /* Debug Registers */ struct debug_reg debug; diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h index 8e1d0195ac36..488d5c4670ff 100644 --- a/arch/powerpc/include/asm/thread_info.h +++ b/arch/powerpc/include/asm/thread_info.h @@ -10,10 +10,15 @@ #define _ASM_POWERPC_THREAD_INFO_H #include +#include #ifdef __KERNEL__ +#if defined(CONFIG_VMAP_STACK) && CONFIG_THREAD_SHIFT < PAGE_SHIFT +#define THREAD_SHIFT PAGE_SHIFT +#else #define THREAD_SHIFT CONFIG_THREAD_SHIFT +#endif #define THREAD_SIZE (1 << THREAD_SHIFT) diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 03439785c2ea..985523ef23e8 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -128,6 +128,11 @@ int main(void) OFFSET(KSP_VSID, thread_struct, ksp_vsid); #else /* CONFIG_PPC64 */ OFFSET(PGDIR, thread_struct, pgdir); +#ifdef CONFIG_VMAP_STACK + OFFSET(SRR0, thread_struct, srr0); + OFFSET(SRR1, thread_struct, srr1); + OFFSET(DAR, thread_struct, dar); +#endif #ifdef CONFIG_SPE OFFSET(THREAD_EVR0, thread_struct, evr[0]); OFFSET(THREAD_ACC, thread_struct, acc); diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 52a061f14c7d..6e2c45fdd2c0 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -150,8 +150,13 @@ transfer_to_handler: stw r12,_CTR(r11) stw r2,_XER(r11) mfspr r12,SPRN_SPRG_THREAD +#ifdef CONFIG_VMAP_STACK + tovirt(r12, r12) +#endif addi r2,r12,-THREAD +#ifndef CONFIG_VMAP_STACK tovirt(r2,r2) /* set r2 to current */ +#endif beq 2f /* if from user, fix up THREAD.regs */ addi r11,r1,STACK_FRAME_OVERHEAD stw r11,PT_REGS(r12) @@ -179,9 +184,13 @@ transfer_to_handler: stw r12,4(r11) #endif #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE +#ifdef CONFIG_VMAP_STACK + ACCOUNT_CPU_USER_ENTRY(r2, r11, r12) +#else tophys(r9, r2) ACCOUNT_CPU_USER_ENTRY(r9, r11, r12) #endif +#endif b 3f @@ -193,8 +202,12 @@ transfer_to_handler: ble- stack_ovf /* then the kernel stack overflowed */ 5: #if defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500) +#ifdef CONFIG_VMAP_STACK + lwz r12, TI_LOCAL_FLAGS(r2) +#else tophys(r9,r2) /* check local flags */ lwz r12,TI_LOCAL_FLAGS(r9) +#endif mtcrf 0x01,r12 bt- 31-TLF_NAPPING,4f bt- 31-TLF_SLEEPING,7f @@ -203,6 +216,9 @@ transfer_to_handler: transfer_to_handler_cont: 3: mflr r9 +#ifdef CONFIG_VMAP_STACK + tovirt(r9,r9) +#endif lwz r11,0(r9) /* virtual address of handler */ lwz r9,4(r9) /* where to go when done */ #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS) -- 2.13.3