Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3518217pxb; Mon, 24 Jan 2022 11:14:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIR+AsakSF1sVrTZ1ILLgor8NLm8nbxyfxxfIM1cl5Goel1fLXALps3QZgteAYU73Xeb+C X-Received: by 2002:a17:902:9343:b0:148:a2e7:fb5f with SMTP id g3-20020a170902934300b00148a2e7fb5fmr16649223plp.160.1643051654283; Mon, 24 Jan 2022 11:14:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051654; cv=none; d=google.com; s=arc-20160816; b=kazBNBJ00wepPF5W/LGg/EkoH+Hw09eRXfqYHPwafGU4aN63Lisx72Uj6zCz+WchBM SNB/qlsLAzGUKiGS5VH1zl9JVMgaFREO49YJY4N+91u2YCCGO7I/R12YXY1dHnzeAKxI Jf3zIrYWY6BYMpQW4QBMfqcsK7CJgZN+GfRgUTpNJ8u1GhH8PUQNcISREEfrIE/yC/hf n1c7uy+OB2r+30AFp/xKfbSC+HuY6spU7hoZNEbrUjVaOGw9xDKPEQJP197KPqpNxq9+ pcJe6JUJHC98mTx4Y6QxsJyCYQXybIhPDXZgEPBw8JwxlzRlpOluwyo9xnojOkJmp372 7rgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=x5ecBuC7MonKzv7DzwAwOHcqa0NDKL3Y+5oF7BCdZUM=; b=hANZo1bfvKz3BJGQygR4gn6jbaBc38pz0EVLr1/cxMoiAusAKSmpXUCLvZG9G/dgUX +m/CBsOgmYmFaF9iEyrH1aLZ3ML4r7jEcjH6XmFIr4/tyRVC1AsJXoO5wqLJF+jCxxQK FqQdFDyERB+FPd469IPysekumGnYpEjcsTrrzpRcRotw6PCY5XDKRCGiRWhvQ34pC0oe LMax5sKY+ILC3Xk78l5Zx+qdU0f7boOuODKLcIsFyT2zYgMAhnrGLXRmaBLoXgoLgEsw DN4msS9A4VizTloUt3H+vBbX6BwjVb1svX+29XSVo3W2tWYZ2WfwAZ6lUZv8myWZQI9w GR2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nl10si227104pjb.62.2022.01.24.11.14.01; Mon, 24 Jan 2022 11:14:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242729AbiAXM5j (ORCPT + 99 others); Mon, 24 Jan 2022 07:57:39 -0500 Received: from foss.arm.com ([217.140.110.172]:32930 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242240AbiAXM5j (ORCPT ); Mon, 24 Jan 2022 07:57:39 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 74692ED1; Mon, 24 Jan 2022 04:57:38 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.43.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2C56E3F774; Mon, 24 Jan 2022 04:57:34 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, hch@infradead.org, akpm@linux-foundation.org, Anshuman Khandual , Thomas Bogendoerfer , linux-mips@vger.kernel.org Subject: [RFC V1 07/31] mips/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 24 Jan 2022 18:26:44 +0530 Message-Id: <1643029028-12710-8-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1643029028-12710-1-git-send-email-anshuman.khandual@arm.com> References: <1643029028-12710-1-git-send-email-anshuman.khandual@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This defines and exports a platform specific custom vm_get_page_prot() via subscribing ARCH_HAS_VM_GET_PAGE_PROT. Subsequently all __SXXX and __PXXX macros can be dropped which are no longer needed. Cc: Thomas Bogendoerfer Cc: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/mips/Kconfig | 1 + arch/mips/include/asm/pgtable.h | 22 ----------- arch/mips/mm/cache.c | 65 ++++++++++++++++++++------------- 3 files changed, 41 insertions(+), 47 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 058446f01487..fcbfc52a1567 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -13,6 +13,7 @@ config MIPS select ARCH_HAS_STRNLEN_USER select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UBSAN_SANITIZE_ALL + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_KEEP_MEMBLOCK select ARCH_SUPPORTS_UPROBES diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index 7b8037f25d9e..bf193ad4f195 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -41,28 +41,6 @@ struct vm_area_struct; * by reasonable means.. */ -/* - * Dummy values to fill the table in mmap.c - * The real values will be generated at runtime - */ -#define __P000 __pgprot(0) -#define __P001 __pgprot(0) -#define __P010 __pgprot(0) -#define __P011 __pgprot(0) -#define __P100 __pgprot(0) -#define __P101 __pgprot(0) -#define __P110 __pgprot(0) -#define __P111 __pgprot(0) - -#define __S000 __pgprot(0) -#define __S001 __pgprot(0) -#define __S010 __pgprot(0) -#define __S011 __pgprot(0) -#define __S100 __pgprot(0) -#define __S101 __pgprot(0) -#define __S110 __pgprot(0) -#define __S111 __pgprot(0) - extern unsigned long _page_cachable_default; extern void __update_cache(unsigned long address, pte_t pte); diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c index 830ab91e574f..06e29982965a 100644 --- a/arch/mips/mm/cache.c +++ b/arch/mips/mm/cache.c @@ -159,30 +159,6 @@ EXPORT_SYMBOL(_page_cachable_default); #define PM(p) __pgprot(_page_cachable_default | (p)) -static inline void setup_protection_map(void) -{ - protection_map[0] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); - protection_map[1] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC); - protection_map[2] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); - protection_map[3] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC); - protection_map[4] = PM(_PAGE_PRESENT); - protection_map[5] = PM(_PAGE_PRESENT); - protection_map[6] = PM(_PAGE_PRESENT); - protection_map[7] = PM(_PAGE_PRESENT); - - protection_map[8] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); - protection_map[9] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC); - protection_map[10] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | - _PAGE_NO_READ); - protection_map[11] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE); - protection_map[12] = PM(_PAGE_PRESENT); - protection_map[13] = PM(_PAGE_PRESENT); - protection_map[14] = PM(_PAGE_PRESENT | _PAGE_WRITE); - protection_map[15] = PM(_PAGE_PRESENT | _PAGE_WRITE); -} - -#undef PM - void cpu_cache_init(void) { if (cpu_has_3k_cache) { @@ -206,6 +182,45 @@ void cpu_cache_init(void) octeon_cache_init(); } +} - setup_protection_map(); +pgprot_t vm_get_page_prot(unsigned long vm_flags) +{ + switch (vm_flags & (VM_READ | VM_WRITE | VM_EXEC | VM_SHARED)) { + case VM_NONE: + return PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); + case VM_READ: + return PM(_PAGE_PRESENT | _PAGE_NO_EXEC); + case VM_WRITE: + return PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); + case VM_READ | VM_WRITE: + return PM(_PAGE_PRESENT | _PAGE_NO_EXEC); + case VM_EXEC: + return PM(_PAGE_PRESENT); + case VM_EXEC | VM_READ: + return PM(_PAGE_PRESENT); + case VM_EXEC | VM_WRITE: + return PM(_PAGE_PRESENT); + case VM_EXEC | VM_READ | VM_WRITE: + return PM(_PAGE_PRESENT); + case VM_SHARED: + return PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); + case VM_SHARED | VM_READ: + return PM(_PAGE_PRESENT | _PAGE_NO_EXEC); + case VM_SHARED | VM_WRITE: + return PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | _PAGE_NO_READ); + case VM_SHARED | VM_READ | VM_WRITE: + return PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE); + case VM_SHARED | VM_EXEC: + return PM(_PAGE_PRESENT); + case VM_SHARED | VM_EXEC | VM_READ: + return PM(_PAGE_PRESENT); + case VM_SHARED | VM_EXEC | VM_WRITE: + return PM(_PAGE_PRESENT | _PAGE_WRITE); + case VM_SHARED | VM_EXEC | VM_READ | VM_WRITE: + return PM(_PAGE_PRESENT | _PAGE_WRITE); + default: + BUILD_BUG(); + } } +EXPORT_SYMBOL(vm_get_page_prot); -- 2.25.1