Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3519495pxb; Mon, 24 Jan 2022 11:15:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzK7GOOkRLuKeNk7ILH1gT1Ir6NyflMwBPLNpEMBzP0Fm3smo5+Om79s28DJrn1USSM1Mw4 X-Received: by 2002:a05:6a00:238c:b0:4ca:91aa:32ce with SMTP id f12-20020a056a00238c00b004ca91aa32cemr1473821pfc.36.1643051756556; Mon, 24 Jan 2022 11:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051756; cv=none; d=google.com; s=arc-20160816; b=TMLBP96GUJg9fyZZdIV1iWym7aCusZy+e4oV0vmTjYVjhicXaNkB9q9JCaT9cM4zio dV206QoNQ8Sd3bR/uCg9/wPbqgHPgs1tXd/frvJ4h0dIkqjaNZ7wk2prUjAPgpBl5/DP X4PcMK+BOPm83NeXvnNjMUcPCXeyiJ1rKN4UC3QpejhJQqqFjDoA7efGfk6AZBxEQhAG RnfoHnM+zDXUW3vF+EpsTFrgtGgWpKToFcBmhGwYua2zv/MmkrEE0c/bqB35wKT0EC4H G8F+L8ZzFfYxRNx4JPfjKRF+1/C/5B6ZsPY+fkObmtfYyFAwXB1yKT6oB7aq/3eLKG9S WmPQ== 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=IETiPSaNjfv/3EmB39hPW/FYQ6a12kQMMcZ6vKU8cH8=; b=SFwZMD5z1Sb6NY9SQuiqVSs/eNd2RZBFtaeFDOdZQzcqocXx6SFfHYVEUz+oTK5pw8 aYMdXPDtfG/53b/xcae8hxjFERyxliJN3LLWdd7iILLdnyXFIjjFRw2qsFTkBAJLt2oK KAOIVBYFrb54YPzGTpjG5suXyTgAeNDOYC6Y2NhOY6F74OOZxr+1bhRpIAppTyJtFIvC pSjG+GzkdAeNPAG8vlU3vxolh/1tURDcmU7/fWIFYmNOyL/AvhESkbT6simTYDsf/gzY G9fS/xSk1+GRVVA+h9va9mDO+sy650JJv9ZBfoiIXQ5Wfx37YBOCGfFvFGZ7/eGFt3fX U8JA== 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 o5si12673067pgu.13.2022.01.24.11.15.41; Mon, 24 Jan 2022 11:15:56 -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 S242905AbiAXM7I (ORCPT + 99 others); Mon, 24 Jan 2022 07:59:08 -0500 Received: from foss.arm.com ([217.140.110.172]:33230 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242887AbiAXM6z (ORCPT ); Mon, 24 Jan 2022 07:58:55 -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 1CAC111D4; Mon, 24 Jan 2022 04:58:55 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.43.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DF0203F774; Mon, 24 Jan 2022 04:58:51 -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 , Brian Cain , linux-hexagon@vger.kernel.org Subject: [RFC V1 26/31] hexagon/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 24 Jan 2022 18:27:03 +0530 Message-Id: <1643029028-12710-27-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: Brian Cain Cc: linux-hexagon@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/pgtable.h | 24 ----------------- arch/hexagon/mm/init.c | 42 ++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 15dd8f38b698..cdc5df32a1e3 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -6,6 +6,7 @@ config HEXAGON def_bool y select ARCH_32BIT_OFF_T select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_NO_PREEMPT select DMA_GLOBAL_POOL # Other pending projects/to-do items. diff --git a/arch/hexagon/include/asm/pgtable.h b/arch/hexagon/include/asm/pgtable.h index 18cd6ea9ab23..5eceddfe013d 100644 --- a/arch/hexagon/include/asm/pgtable.h +++ b/arch/hexagon/include/asm/pgtable.h @@ -127,31 +127,7 @@ extern unsigned long _dflt_cache_att; #define CACHEDEF (CACHE_DEFAULT << 6) /* Private (copy-on-write) page protections. */ -#define __P000 __pgprot(_PAGE_PRESENT | _PAGE_USER | CACHEDEF) -#define __P001 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | CACHEDEF) -#define __P010 __P000 /* Write-only copy-on-write */ -#define __P011 __P001 /* Read/Write copy-on-write */ -#define __P100 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ - _PAGE_EXECUTE | CACHEDEF) -#define __P101 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_EXECUTE | \ - _PAGE_READ | CACHEDEF) -#define __P110 __P100 /* Write/execute copy-on-write */ -#define __P111 __P101 /* Read/Write/Execute, copy-on-write */ - /* Shared page protections. */ -#define __S000 __P000 -#define __S001 __P001 -#define __S010 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ - _PAGE_WRITE | CACHEDEF) -#define __S011 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | \ - _PAGE_WRITE | CACHEDEF) -#define __S100 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ - _PAGE_EXECUTE | CACHEDEF) -#define __S101 __P101 -#define __S110 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ - _PAGE_EXECUTE | _PAGE_WRITE | CACHEDEF) -#define __S111 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | \ - _PAGE_EXECUTE | _PAGE_WRITE | CACHEDEF) extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; /* located in head.S */ diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c index f01e91e10d95..9f411e3eba68 100644 --- a/arch/hexagon/mm/init.c +++ b/arch/hexagon/mm/init.c @@ -236,3 +236,45 @@ void __init setup_arch_memory(void) * which is called by start_kernel() later on in the process */ } + +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 __pgprot(_PAGE_PRESENT|_PAGE_USER|CACHEDEF); + case VM_READ: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_READ|CACHEDEF); + case VM_WRITE: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|CACHEDEF); + case VM_READ | VM_WRITE: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_READ|CACHEDEF); + case VM_EXEC: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_EXECUTE|CACHEDEF); + case VM_EXEC | VM_READ: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_EXECUTE|_PAGE_READ|CACHEDEF); + case VM_EXEC | VM_WRITE: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_EXECUTE|CACHEDEF); + case VM_EXEC | VM_READ | VM_WRITE: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_EXECUTE|_PAGE_READ|CACHEDEF); + case VM_SHARED: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|CACHEDEF); + case VM_SHARED | VM_READ: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_READ|CACHEDEF); + case VM_SHARED | VM_WRITE: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_WRITE|CACHEDEF); + case VM_SHARED | VM_READ | VM_WRITE: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_READ|_PAGE_WRITE|CACHEDEF); + case VM_SHARED | VM_EXEC: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_EXECUTE|CACHEDEF); + case VM_SHARED | VM_EXEC | VM_READ: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_EXECUTE|_PAGE_READ|CACHEDEF); + case VM_SHARED | VM_EXEC | VM_WRITE: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_EXECUTE|_PAGE_WRITE|CACHEDEF); + case VM_SHARED | VM_EXEC | VM_READ | VM_WRITE: + return __pgprot(_PAGE_PRESENT|_PAGE_USER|_PAGE_READ|_PAGE_EXECUTE|_PAGE_WRITE| + CACHEDEF); + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); -- 2.25.1