Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3599593pxb; Mon, 21 Feb 2022 01:27:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJywh1fH7zz91kciqKuAdsVW1ZkeLR5zLnANCAy+yNjCIdI1LyyCPG9mMXA+mdEZSeoqVdMI X-Received: by 2002:a17:90b:4b8e:b0:1b9:6a19:30da with SMTP id lr14-20020a17090b4b8e00b001b96a1930damr24476147pjb.21.1645435633064; Mon, 21 Feb 2022 01:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645435633; cv=none; d=google.com; s=arc-20160816; b=CpUg9TySdu9vFCp7DF4mydOJHvTcfM27noeWN8lb4ohiryOSxDRIKb8QJLFb9DSDRW 4NhuHnE561mkZesq6gqlv4CS6G5MJQ6yQbyrYp6W4SNWx/QUzfaOrrJCzgRNcJm5decY uRjyekKOgyMHnORqfwiPXiAOQzhhdgUyuCel6PL7HS9EEqy9jyjmvdgF8aMHFNKL2gKc ZFkp+MQ1nNoK4EDnkuc/TF7CmYmzVccFg5xPBS7sVl64LlirXjEyVmVV/Jpm7ggAxv8w WuzQ4X56IMqgotEQ9wLS/YuOC3kgcahQzst+vnX/LbqJ4+469snBiBqj2K/cyOOVmMqT dLTA== 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=Ya9q4FGuZwhxTwaLxOJj+5C3HsxPuvfjU44B+ESV4rU=; b=SyPICk77Ivrl7q3u6LjT3e9qHw0QvHBJMOfp7of2rR62MG67wDMO/b4hu91N9G13BX dt2IcvKVc5QnNEADNoPz0uKO5VZhhNQG08FdW+5Xly3dK64EMbMVy2wfezzHpnPuWg3q i5aHxYqOUrtmfijqH+e8qANFbsOHHWVNfLEv1UAQ7tVxUAp1e9LiRtv9qX2mhsMCKmpq P1NqfPmTIyKKHXyxnR2fr/0lUUlLWUQYRQ7M/bKnOEON/T05FbXK5ijqXAg8HyX9boRY ujyhcawoBizUAEaoSK3UcZVRNOwAh03glk6twOXiKCfuRCll+G69HLsnE12F6rGux5ty f+CA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 22si9314880pgf.601.2022.02.21.01.26.59; Mon, 21 Feb 2022 01:27:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1345527AbiBUGmp (ORCPT + 99 others); Mon, 21 Feb 2022 01:42:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345370AbiBUGlV (ORCPT ); Mon, 21 Feb 2022 01:41:21 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3BE5D4505D; Sun, 20 Feb 2022 22:40:04 -0800 (PST) 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 B58CE1509; Sun, 20 Feb 2022 22:40:04 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.49.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 278023F70D; Sun, 20 Feb 2022 22:40:01 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Anshuman Khandual , Christoph Hellwig , linux-arch@vger.kernel.org, Jeff Dike , linux-um@lists.infradead.org Subject: [PATCH V2 23/30] um/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 21 Feb 2022 12:08:32 +0530 Message-Id: <1645425519-9034-24-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1645425519-9034-1-git-send-email-anshuman.khandual@arm.com> References: <1645425519-9034-1-git-send-email-anshuman.khandual@arm.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: Jeff Dike Cc: linux-um@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/um/Kconfig | 1 + arch/um/include/asm/pgtable.h | 17 ----------------- arch/um/kernel/mem.c | 35 +++++++++++++++++++++++++++++++++++ arch/x86/um/mem_32.c | 2 +- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/arch/um/Kconfig b/arch/um/Kconfig index 4d398b80aea8..5836296868a8 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig @@ -9,6 +9,7 @@ config UML select ARCH_HAS_KCOV select ARCH_HAS_STRNCPY_FROM_USER select ARCH_HAS_STRNLEN_USER + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_NO_PREEMPT select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_SECCOMP_FILTER diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h index b9e20bbe2f75..d982622c0708 100644 --- a/arch/um/include/asm/pgtable.h +++ b/arch/um/include/asm/pgtable.h @@ -68,23 +68,6 @@ extern unsigned long end_iomem; * Also, write permissions imply read permissions. This is the closest we can * get.. */ -#define __P000 PAGE_NONE -#define __P001 PAGE_READONLY -#define __P010 PAGE_COPY -#define __P011 PAGE_COPY -#define __P100 PAGE_READONLY -#define __P101 PAGE_READONLY -#define __P110 PAGE_COPY -#define __P111 PAGE_COPY - -#define __S000 PAGE_NONE -#define __S001 PAGE_READONLY -#define __S010 PAGE_SHARED -#define __S011 PAGE_SHARED -#define __S100 PAGE_READONLY -#define __S101 PAGE_READONLY -#define __S110 PAGE_SHARED -#define __S111 PAGE_SHARED /* * ZERO_PAGE is a global shared page that is always zero: used diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 15295c3237a0..37c6c7b9dadc 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -197,3 +197,38 @@ void *uml_kmalloc(int size, int flags) { return kmalloc(size, flags); } + +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: + case VM_WRITE | VM_READ: + return PAGE_COPY; + case VM_EXEC: + case VM_EXEC | VM_READ: + return PAGE_READONLY; + case VM_EXEC | VM_WRITE: + case VM_EXEC | VM_WRITE | VM_READ: + return PAGE_COPY; + case VM_SHARED: + return PAGE_NONE; + case VM_SHARED | VM_READ: + return PAGE_READONLY; + case VM_SHARED | VM_WRITE: + case VM_SHARED | VM_WRITE | VM_READ: + return PAGE_SHARED; + case VM_SHARED | VM_EXEC: + case VM_SHARED | VM_EXEC | VM_READ: + return PAGE_READONLY; + case VM_SHARED | VM_EXEC | VM_WRITE: + case VM_SHARED | VM_EXEC | VM_WRITE | VM_READ: + return PAGE_SHARED; + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c index 19c5dbd46770..cafd01f730da 100644 --- a/arch/x86/um/mem_32.c +++ b/arch/x86/um/mem_32.c @@ -17,7 +17,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 = PAGE_READONLY; return 0; } -- 2.25.1