Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3519267pxb; Mon, 24 Jan 2022 11:15:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3UW6YImOPo7pcI6aHd9RxHrnw+jfCWQ2So7P00tUk+maTdu8So724RDSijyj1YyTEc3bV X-Received: by 2002:a17:902:8ec6:b0:14a:c625:eb2d with SMTP id x6-20020a1709028ec600b0014ac625eb2dmr15671816plo.26.1643051739006; Mon, 24 Jan 2022 11:15:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051739; cv=none; d=google.com; s=arc-20160816; b=Dg4oeYcQbPAKwTg62y1MXNgYIXkQ40Nx+spyYl8UyRA7beYWDG+4+5F3IgFHOnb8PZ up7ySGZF/4jI/Maj15fcxgk8jlnrzTHU9So1gR1J4IGksZBswPIulbm5T5W050nNIT4U uGxKwAizigp+5/lAOggBwA2tFvhB+q3cRqI1xSnaeJJMMhlvUu5XztZkEOu3VFocXoK5 BjYE4S8MLpAw0Kvr4E/A/KZCr5oyXGsSROA9SIBtwZQYobYAu/mlwz/+1UEoQvYkFR+p JPMLQ8Vt32AeDlXVFuQYfeDBwrUY+Jpdo9Kl/BWlv/AlfD3F7esbBXW9/3EXZQmAxeF+ 6NXg== 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=Kh55AJGrQB4ugp/wT+oEj0ZSWpML6o8mYdyiZbS1RyY=; b=WvDVrcRN6XtybstLZnbLjtaakRpYPHlkSrFt6ZAG12QRB49cgGYyTLDq46KCpN3jJs TUdaLvL7M7Yy5sEK72tUiSvf09JDBYaP9hpvD0KaovCwOWlLq+6y3NKIFXYwSMydtrvE 4Pi3F2V7oYJZJSbgu6wPfXGA/F3+wionFpkSI62mvpYL0Y8nMdipckQcIMIwAtGipjpT Ck1lE1yMbMXOuR9ybrBCHxFq5Rpm/LmMRStIvncdiHtopYWpw2H2kWPqinnsle0E1iLd oHKZ3RAdmGwAt8Z6MsyRXHys3aTOLAtvcYhAbmY9zcnFVRTx4/PjguJ5mO5wnQXMLic8 2yTg== 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 lp2si219356pjb.124.2022.01.24.11.15.25; Mon, 24 Jan 2022 11:15:38 -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 S242772AbiAXM63 (ORCPT + 99 others); Mon, 24 Jan 2022 07:58:29 -0500 Received: from foss.arm.com ([217.140.110.172]:33114 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242786AbiAXM60 (ORCPT ); Mon, 24 Jan 2022 07:58:26 -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 356BE101E; Mon, 24 Jan 2022 04:58:26 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.43.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1AB653F774; Mon, 24 Jan 2022 04:58:22 -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 , Geert Uytterhoeven , linux-csky@vger.kernel.org Subject: [RFC V1 19/31] csky/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 24 Jan 2022 18:26:56 +0530 Message-Id: <1643029028-12710-20-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: Geert Uytterhoeven Cc: linux-csky@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/csky/Kconfig | 1 + arch/csky/include/asm/pgtable.h | 18 --------------- arch/csky/mm/init.c | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index 132f43f12dd8..209dac5686dd 100644 --- a/arch/csky/Kconfig +++ b/arch/csky/Kconfig @@ -6,6 +6,7 @@ config CSKY select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_QUEUED_RWLOCKS select ARCH_WANT_FRAME_POINTERS if !CPU_CK610 && $(cc-option,-mbacktrace) diff --git a/arch/csky/include/asm/pgtable.h b/arch/csky/include/asm/pgtable.h index 151607ed5158..2c6b1cfb1cce 100644 --- a/arch/csky/include/asm/pgtable.h +++ b/arch/csky/include/asm/pgtable.h @@ -76,24 +76,6 @@ #define MAX_SWAPFILES_CHECK() \ BUILD_BUG_ON(MAX_SWAPFILES_SHIFT != 5) -#define __P000 PAGE_NONE -#define __P001 PAGE_READ -#define __P010 PAGE_READ -#define __P011 PAGE_READ -#define __P100 PAGE_READ -#define __P101 PAGE_READ -#define __P110 PAGE_READ -#define __P111 PAGE_READ - -#define __S000 PAGE_NONE -#define __S001 PAGE_READ -#define __S010 PAGE_WRITE -#define __S011 PAGE_WRITE -#define __S100 PAGE_READ -#define __S101 PAGE_READ -#define __S110 PAGE_WRITE -#define __S111 PAGE_WRITE - extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c index bf2004aa811a..55952d8f8abc 100644 --- a/arch/csky/mm/init.c +++ b/arch/csky/mm/init.c @@ -197,3 +197,44 @@ void __init fixaddr_init(void) vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; fixrange_init(vaddr, vaddr + PMD_SIZE, swapper_pg_dir); } + +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 PAGE_NONE; + case VM_READ: + return PAGE_READ; + case VM_WRITE: + return PAGE_READ; + case VM_READ | VM_WRITE: + return PAGE_READ; + case VM_EXEC: + return PAGE_READ; + case VM_EXEC | VM_READ: + return PAGE_READ; + case VM_EXEC | VM_WRITE: + return PAGE_READ; + case VM_EXEC | VM_READ | VM_WRITE: + return PAGE_READ; + case VM_SHARED: + return PAGE_NONE; + case VM_SHARED | VM_READ: + return PAGE_READ; + case VM_SHARED | VM_WRITE: + return PAGE_WRITE; + case VM_SHARED | VM_READ | VM_WRITE: + return PAGE_WRITE; + case VM_SHARED | VM_EXEC: + return PAGE_READ; + case VM_SHARED | VM_EXEC | VM_READ: + return PAGE_READ; + case VM_SHARED | VM_EXEC | VM_WRITE: + return PAGE_WRITE; + case VM_SHARED | VM_EXEC | VM_READ | VM_WRITE: + return PAGE_WRITE; + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); -- 2.25.1