Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3519494pxb; Mon, 24 Jan 2022 11:15:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm+VaKUskRv+oLwq8lQfmezuteRwv0JE9P/jtXUQNYx0/BnpZQKmf4PLmbpieSyxc5dmxn X-Received: by 2002:a63:7983:: with SMTP id u125mr12656406pgc.569.1643051756539; 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=UcLaU1wT1WXjGnaA4jvjbrCsADDn90TimJ5O/lDr9DXzGotdhu2LcPWQKT9uCWoMJ5 MCXrg49uHyRM28vOVSmADHT4oqUQ1eRMBOIfaXTGzfFz/QUuoJK0x9Xy5QjDeyvEPefX yXU7ykkdVB/XOClx4MoQGtbUBh1CXgOsFQ2VgDmd8chZvxs1GplmjnxwAPp3hYmcuyGi XpgHlr6Lqvkcb6X106JuF+e06su/tdmNouQunu7QM+xpMK/CY7M6j8OK0CaG5MkpZqSJ qgLgP4dHA5Eyz4bGU2fS1g93TlAnEv3UxagTmQuIz20xx2yWPo7SJJmZnHSgfgg5XqvC epIw== 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=igkw345YJP+DrItbYUNHFS6sH2gkLTYhMtbxCjKWz4M=; b=zcgLBmxEJMr4+FjMK0LhUkAJ7sv8wCvtuqCt8RxKYCAENQbM98Pkk0kF8t332yCFmV cyxhavZrdNaR6oPt9xo6MoSoIHAhlIkouD6kHDE8FRGJsdVLOdOIvCQg/CnM6SJFs85u fSl6Whm7CP9DSbIFpazU4XWvz81bPgnX4wu+SwX6nIWzlptMNJA1BV0EzrRhjOUgKyYw ByeTx4zOJm6WjRGygG+qGmGD22PCkP+DhV6c214QJUzkrK5rY5YqBnLaDcPdd6qAz13S mURM1sqlgG6uoDZv2Ij3j/eoh+V00BLvUE6y04JEEkcruhDqjIyZ27TaOCAhUD7Fo5ab MJgA== 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 t2si14712725pfj.48.2022.01.24.11.15.42; 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 S242747AbiAXM7X (ORCPT + 99 others); Mon, 24 Jan 2022 07:59:23 -0500 Received: from foss.arm.com ([217.140.110.172]:33268 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242842AbiAXM7D (ORCPT ); Mon, 24 Jan 2022 07:59:03 -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 9FE6B11B3; Mon, 24 Jan 2022 04:59:02 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.43.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6FE3F3F774; Mon, 24 Jan 2022 04:58:59 -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 , linux-ia64@vger.kernel.org Subject: [RFC V1 28/31] ia64/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 24 Jan 2022 18:27:05 +0530 Message-Id: <1643029028-12710-29-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: linux-ia64@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/pgtable.h | 17 ------------- arch/ia64/mm/init.c | 43 ++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 703952819e10..516c426e7606 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -11,6 +11,7 @@ config IA64 select ARCH_HAS_DMA_MARK_CLEAN select ARCH_HAS_STRNCPY_FROM_USER select ARCH_HAS_STRNLEN_USER + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO select ACPI diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h index 9584b2c5f394..8154c78bba56 100644 --- a/arch/ia64/include/asm/pgtable.h +++ b/arch/ia64/include/asm/pgtable.h @@ -161,23 +161,6 @@ * attempts to write to the page. */ /* xwr */ -#define __P000 PAGE_NONE -#define __P001 PAGE_READONLY -#define __P010 PAGE_READONLY /* write to priv pg -> copy & make writable */ -#define __P011 PAGE_READONLY /* ditto */ -#define __P100 __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_X_RX) -#define __P101 __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX) -#define __P110 PAGE_COPY_EXEC -#define __P111 PAGE_COPY_EXEC - -#define __S000 PAGE_NONE -#define __S001 PAGE_READONLY -#define __S010 PAGE_SHARED /* we don't have (and don't need) write-only */ -#define __S011 PAGE_SHARED -#define __S100 __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_X_RX) -#define __S101 __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX) -#define __S110 __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RWX) -#define __S111 __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RWX) #define pgd_ERROR(e) printk("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e)) #if CONFIG_PGTABLE_LEVELS == 4 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index 5d165607bf35..124bdf6fbf7b 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -273,7 +273,7 @@ static int __init gate_vma_init(void) gate_vma.vm_start = FIXADDR_USER_START; gate_vma.vm_end = FIXADDR_USER_END; gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC; - gate_vma.vm_page_prot = __P101; + gate_vma.vm_page_prot = __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX); return 0; } @@ -492,3 +492,44 @@ void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) __remove_pages(start_pfn, nr_pages, altmap); } #endif + +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_READONLY; + case VM_WRITE: + return PAGE_READONLY; + case VM_READ | VM_WRITE: + return PAGE_READONLY; + case VM_EXEC: + return __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_X_RX); + case VM_EXEC | VM_READ: + return __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX); + case VM_EXEC | VM_WRITE: + return PAGE_COPY_EXEC; + case VM_EXEC | VM_READ | VM_WRITE: + return PAGE_COPY_EXEC; + case VM_SHARED: + return PAGE_NONE; + case VM_SHARED | VM_READ: + return PAGE_READONLY; + case VM_SHARED | VM_WRITE: + return PAGE_SHARED; + case VM_SHARED | VM_READ | VM_WRITE: + return PAGE_SHARED; + case VM_SHARED | VM_EXEC: + return __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_X_RX); + case VM_SHARED | VM_EXEC | VM_READ: + return __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX); + case VM_SHARED | VM_EXEC | VM_WRITE: + return __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RWX); + case VM_SHARED | VM_EXEC | VM_READ | VM_WRITE: + return __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RWX); + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); -- 2.25.1