Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp2837810pjo; Mon, 16 Mar 2020 05:39:17 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuoBdkmz4u8ubS63ZOZt91pgeLXkNGhsayd5CO440T81E2hHinYKxycYPbpS8wyJ7tyljcH X-Received: by 2002:a9d:5e04:: with SMTP id d4mr21689778oti.36.1584362357426; Mon, 16 Mar 2020 05:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584362357; cv=none; d=google.com; s=arc-20160816; b=y8TSolAldm2VwMp1fWu7612AFdDV54GOaD3rART7KpTlOS7oWVNGcEzIuptykqG9kx GhekCBXXOskxgz1AcbaudZQ5zVPo6p7bVd67JQoFn2ppzxG6VEQxFysYYU3tQTMgd+ra Oy+B4Nm1xEUyhfkTR+LJE0DTLXs6Pj9DE2X/qj9K9U9P3nx6n+87fXL/P5Flnv3hO90s HRfQR0mifbnSLzxxnvD8znIwg2B94+RypZYjh9AKbtfkJIBnC8tvW7Y9H5RtdQQpJ0VD QdzkcM5jNguIctMilVVYP+1ruN9HRg3+Lb2qYRtNWt/4H5UxyaXa3sGm3+Xkd0mglxTY zPyA== 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:dkim-signature; bh=gY/Mk0vN0+WJ+x6VBQ4y39+tHOIY/jIZw/0BD7lLXqs=; b=obXrKBHTh/dPceFycismpMHkqw35RIo+QpTIMb0z+pgYAbb0XI+5yRMNy07hskakP2 Ts/f3Qc7uZwDXwOVlHAprhAJwakMGo+5mcytQUiBCKkdER0e/blAG9LfD/qHvZCGDfcm lxIUHIbbauYcjXGamXKoMUEzWKL9qnq4q8hg9KnHC4aXJokvI5ju6oYaY5YMiSj9gFF1 3ueJm8mfAS8lwMg4LXuZawJWNU5GTLXQmnJE1PfLSYxvaXCu2M0ofJFTSWl2QdyN8UKQ NDOF5WmZksmREzsejjcnEMPsor9YswJ4l4ALdOIbqZGo2TXLUlDJ+QFSPBtKgTDnKIVG z/XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=dngXK29n; 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 g19si7846499otn.219.2020.03.16.05.39.04; Mon, 16 Mar 2020 05:39:17 -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=dngXK29n; 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 S1731414AbgCPMhO (ORCPT + 99 others); Mon, 16 Mar 2020 08:37:14 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:11865 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731232AbgCPMgV (ORCPT ); Mon, 16 Mar 2020 08:36:21 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48gwlL4WLDz9v02h; Mon, 16 Mar 2020 13:36:14 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=dngXK29n; 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 AFRMHRxVMBQw; Mon, 16 Mar 2020 13:36:14 +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 48gwlL3TnCz9v02f; Mon, 16 Mar 2020 13:36:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1584362174; bh=gY/Mk0vN0+WJ+x6VBQ4y39+tHOIY/jIZw/0BD7lLXqs=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=dngXK29n8HICIfD/xjA8bDnNz6ijvMJckhWYhogCaKZ+b+L7EyR+6eINlGZ5TU+Eb LlmFEc4kDgFyfA4cnroaSFhPLz3hDla21xLgutr0jgUpBYFF72fhKz+di9FZrX4HNL dMKR0dOofSjBH/FAcS+PVB0un73ZSr5lu05pj4OM= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 572C68B7D0; Mon, 16 Mar 2020 13:36:19 +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 DB5y7GiQf_Ej; Mon, 16 Mar 2020 13:36:19 +0100 (CET) Received: from pc16570vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 29C0C8B7CB; Mon, 16 Mar 2020 13:36:19 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 1DFC265595; Mon, 16 Mar 2020 12:36:19 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 33/46] powerpc/8xx: Always pin TLBs at startup. To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 16 Mar 2020 12:36:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At startup, map 32 Mbytes of memory through 4 pages of 8M, and PIN them inconditionnaly. They need to be pinned because KASAN is using page tables early and the TLBs might be dynamically replaced otherwise. Remove RSV4I flag after installing mappings unless CONFIG_PIN_TLB_XXXX is selected. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_8xx.S | 31 +++++++++++++++++-------------- arch/powerpc/mm/nohash/8xx.c | 19 +------------------ 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S index 6a1a74e9b011..7ed866e83545 100644 --- a/arch/powerpc/kernel/head_8xx.S +++ b/arch/powerpc/kernel/head_8xx.S @@ -761,6 +761,14 @@ start_here: ori r0, r0, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | \ _PAGE_NO_CACHE | _PAGE_PRESENT mtspr SPRN_MD_RPN, r0 +#endif +#ifndef CONFIG_PIN_TLB_TEXT + li r0, 0 + mtspr SPRN_MI_CTR, r0 +#endif +#if !defined(CONFIG_PIN_TLB_DATA) && !defined(CONFIG_PIN_TLB_IMMR) + lis r0, MD_TWAM@h + mtspr SPRN_MD_CTR, r0 #endif tlbia /* Clear all TLB entries */ sync /* wait for tlbia/tlbie to finish */ @@ -798,10 +806,6 @@ initial_mmu: mtspr SPRN_MD_CTR, r10 /* remove PINNED DTLB entries */ tlbia /* Invalidate all TLB entries */ -#ifdef CONFIG_PIN_TLB_DATA - oris r10, r10, MD_RSV4I@h - mtspr SPRN_MD_CTR, r10 /* Set data TLB control */ -#endif lis r8, MI_APG_INIT@h /* Set protection modes */ ori r8, r8, MI_APG_INIT@l @@ -810,33 +814,32 @@ initial_mmu: ori r8, r8, MD_APG_INIT@l mtspr SPRN_MD_AP, r8 - /* Now map the lower RAM (up to 32 Mbytes) into the ITLB. */ -#ifdef CONFIG_PIN_TLB_TEXT + /* Map the lower RAM (up to 32 Mbytes) into the ITLB and DTLB */ lis r8, MI_RSV4I@h ori r8, r8, 0x1c00 -#endif + oris r12, r10, MD_RSV4I@h + ori r12, r12, 0x1c00 li r9, 4 /* up to 4 pages of 8M */ mtctr r9 lis r9, KERNELBASE@h /* Create vaddr for TLB */ li r10, MI_PS8MEG | MI_SVALID /* Set 8M byte page */ li r11, MI_BOOTINIT /* Create RPN for address 0 */ - lis r12, _einittext@h - ori r12, r12, _einittext@l 1: -#ifdef CONFIG_PIN_TLB_TEXT mtspr SPRN_MI_CTR, r8 /* Set instruction MMU control */ addi r8, r8, 0x100 -#endif - ori r0, r9, MI_EVALID /* Mark it valid */ mtspr SPRN_MI_EPN, r0 mtspr SPRN_MI_TWC, r10 mtspr SPRN_MI_RPN, r11 /* Store TLB entry */ + mtspr SPRN_MD_CTR, r12 + addi r12, r12, 0x100 + mtspr SPRN_MD_EPN, r0 + mtspr SPRN_MD_TWC, r10 + mtspr SPRN_MD_RPN, r11 addis r9, r9, 0x80 addis r11, r11, 0x80 - cmpl cr0, r9, r12 - bdnzf gt, 1b + bdnz 1b /* Since the cache is enabled according to the information we * just loaded into the TLB, invalidate and enable the caches here. diff --git a/arch/powerpc/mm/nohash/8xx.c b/arch/powerpc/mm/nohash/8xx.c index 2a55904986c6..0956bc92b19c 100644 --- a/arch/powerpc/mm/nohash/8xx.c +++ b/arch/powerpc/mm/nohash/8xx.c @@ -61,23 +61,6 @@ unsigned long p_block_mapped(phys_addr_t pa) */ void __init MMU_init_hw(void) { - /* PIN up to the 3 first 8Mb after IMMR in DTLB table */ - if (IS_ENABLED(CONFIG_PIN_TLB_DATA)) { - unsigned long ctr = mfspr(SPRN_MD_CTR) & 0xfe000000; - unsigned long flags = 0xf0 | MD_SPS16K | _PAGE_SH | _PAGE_DIRTY; - int i = 28; - unsigned long addr = 0; - unsigned long mem = total_lowmem; - - for (; i < 32 && mem >= LARGE_PAGE_SIZE_8M; i++) { - mtspr(SPRN_MD_CTR, ctr | (i << 8)); - mtspr(SPRN_MD_EPN, (unsigned long)__va(addr) | MD_EVALID); - mtspr(SPRN_MD_TWC, MD_PS8MEG | MD_SVALID); - mtspr(SPRN_MD_RPN, addr | flags | _PAGE_PRESENT); - addr += LARGE_PAGE_SIZE_8M; - mem -= LARGE_PAGE_SIZE_8M; - } - } } static bool immr_is_mapped __initdata; @@ -222,7 +205,7 @@ void __init setup_initial_memory_limit(phys_addr_t first_memblock_base, BUG_ON(first_memblock_base != 0); /* 8xx can only access 32MB at the moment */ - memblock_set_current_limit(min_t(u64, first_memblock_size, 0x02000000)); + memblock_set_current_limit(min_t(u64, first_memblock_size, SZ_32M)); } /* -- 2.25.0