From patchwork Tue Aug 28 14:57:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCF0E5A4 for ; Tue, 28 Aug 2018 14:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDF502A4B8 for ; Tue, 28 Aug 2018 14:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B27F62A4C8; Tue, 28 Aug 2018 14:57:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34F482A4B8 for ; Tue, 28 Aug 2018 14:57:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C91C6B46E2; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 276606B46E4; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18F246B46E5; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id CD7836B46E2 for ; Tue, 28 Aug 2018 10:57:40 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id n17-v6so1052476pff.17 for ; Tue, 28 Aug 2018 07:57:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=MPOh18HfFI3D3qSQeEm7RAc4dBhfYVRBxG/Jp7MGb8U=; b=KLz32YcabADMP1ZpM1JFpuVLFBxkQSOC0B5jDUTtwx8J3Kdvugv/efHETGu+Y1sxhn H5ov0e/DIo6xoVSCikLNm4+xNG9105mwsaMPoVZXDihKyWYDif5DFbKT1WWKAlnXWfnr X4Rcv8EryrEeCbpwXfFjqe/pue7tmKJH2qsaMb//KBHfdxIAlyevjHNU2V5qcd6g1qA2 3iKUk6rQSbU8IA244aucalDHCEzB6CceDSODT1qRThYQ2TiihG35TaGjlgdFKPDfAudm y4nstoyUsUg53uuuJmH0X2YuErN2hWp7qQ+BaFtmQTgoaSgNHFymVJz6OdDHm9jC1xb5 faVA== X-Gm-Message-State: APzg51ARRgHCajyHHw7vljpovnweKlDjg1WZRT9cMyYM5koJluUW6GC2 9S5SAY923zS3lPbWQLCvPAKGla5L8jVxjGEroNLak8GUq/v6vs+KCJbW8BaiUuCkXop7hBOlHKL /kJvRsI9l7XRLAb3DVE2QZ1LYJ3wnxNZzE+3s66cGpC5t8lHYp/eh1mpWKzt+XRbBXg== X-Received: by 2002:a63:1316:: with SMTP id i22-v6mr1904524pgl.86.1535468260516; Tue, 28 Aug 2018 07:57:40 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda/iHPLD0YOKR+SrRU+MyXbO8YqW3OYsjgSJpI2KCoDwwpJi1gCcw10dStx4XT/Rl0F2IYL X-Received: by 2002:a63:1316:: with SMTP id i22-v6mr1904487pgl.86.1535468259722; Tue, 28 Aug 2018 07:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468259; cv=none; d=google.com; s=arc-20160816; b=tHD/UpQbC5uSvHloj+GlmzXLOH3V3MBl7xFA4wGwSG5NJWUa17MF0u9tEUeKhOr3Qh 7NHd+RI0+p5spP7uzhoZ97vugVYMUSXGx8baqNgSZ+FQRkITtFN1hNd/RpvElowRXWAl qxOoNocmQikk1vi4cAU2cD/180180UA4pT+rOCw3a8gfoKV8Xnlflx0oyZNzobGsDJX7 NWGoC/JJ0CT96rTIWXztU4uxTmimLd9+UcKNHlVf1CFjHut++7QLWq8wqlUvlp5bRyrs ZWwwCyrgKmF0HfF1ayGPXibRRXVc7GSPXY8ZNxL+CPSCtys8CHWCtgzYLOFXNimcxoyC 1rhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=MPOh18HfFI3D3qSQeEm7RAc4dBhfYVRBxG/Jp7MGb8U=; b=C4rzBvN/fd6jvIltgRNq+d0SvruJ3FF1RJ2xFfR50AsNKoTnBXW0J8Pdw7prIpxi99 4JA5cZLID6GC9THsNYnjWK9qq2PxEDaluZJiM+zIehU1K9WE1/IXvgc1+0PxHMEVOpB8 t5R6bMsMdlaMy/0hibq+MmibZdQSlbr2ESwJq6Yu2TO07HKWKCXRuJBluDSuxUDKoGel Ppxpa25yI2mLXT1xxuhG6Tw76wUnBAFKs4tEDtEJAspgeO+G8oHA1K2dj3v+pbVcUu55 Efhda1nsJDZwbX8IyDBRGbJD9KCdfv7di0K8bFHv3+nVDmLQrHExf8ISDqp+8DWISy1D tW0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gwdwUXwV; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id z5-v6si1216249plo.130.2018.08.28.07.57.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gwdwUXwV; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MPOh18HfFI3D3qSQeEm7RAc4dBhfYVRBxG/Jp7MGb8U=; b=gwdwUXwVHUb+yjYLSQ7uXxNle iTvkBjjB7hHT5jDlE+qxrDsLGOah2ss92jz8D9z6XrjY4jPWf2sYnDQDkhIE6sku/mnWtWUEipAa9 VfHlXoNmqxiU95qUu3La02KpeJNy+fKAi4/070Syd/XRVbO5yfW7Q5r745sRB7wjipfbb7AszP4x2 VklhihwljeMySBvKD1VMO41Tv3mOjXQVQdeKK9ZU4CAtzXSP76x9ARjgt+zfqg5yFHdMlnWVtJ2nX W66fZC2Uw9oLb76QpHxz2XzzQwEkwlQ7GyJg8XWlBgbWkHNx+nv3TylSI/AencqXcST+LjtB1WFMd 4mU+/iLqA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR3-0003An-N6; Tue, 28 Aug 2018 14:57:37 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , Nicolas Pitre , Souptick Joarder , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/10] mm: Introduce vmf_insert_pfn_prot Date: Tue, 28 Aug 2018 07:57:21 -0700 Message-Id: <20180828145728.11873-4-willy@infradead.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180828145728.11873-1-willy@infradead.org> References: <20180828145728.11873-1-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Like vm_insert_pfn_prot(), but returns a vm_fault_t instead of an errno. Also unexport vm_insert_pfn_prot as it has no modular users. Signed-off-by: Matthew Wilcox --- include/linux/mm.h | 2 ++ mm/memory.c | 47 ++++++++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ce1b24376d72..e8bc1a16d44c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2482,6 +2482,8 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn); int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot); +vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, pgprot_t pgprot); vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma, diff --git a/mm/memory.c b/mm/memory.c index f0b123a94426..8c116c0f64d8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1843,21 +1843,6 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_pfn); -/** - * vm_insert_pfn_prot - insert single pfn into user vma with specified pgprot - * @vma: user vma to map to - * @addr: target user address of this page - * @pfn: source kernel pfn - * @pgprot: pgprot flags for the inserted page - * - * This is exactly like vm_insert_pfn, except that it allows drivers to - * to override pgprot on a per-page basis. - * - * This only makes sense for IO mappings, and it makes no sense for - * cow mappings. In general, using multiple vmas is preferable; - * vm_insert_pfn_prot should only be used if using multiple VMAs is - * impractical. - */ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot) { @@ -1887,7 +1872,37 @@ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, return ret; } -EXPORT_SYMBOL(vm_insert_pfn_prot); + +/** + * vmf_insert_pfn_prot - insert single pfn into user vma with specified pgprot + * @vma: user vma to map to + * @addr: target user address of this page + * @pfn: source kernel pfn + * @pgprot: pgprot flags for the inserted page + * + * This is exactly like vmf_insert_pfn(), except that it allows drivers to + * to override pgprot on a per-page basis. + * + * This only makes sense for IO mappings, and it makes no sense for + * COW mappings. In general, using multiple vmas is preferable; + * vm_insert_pfn_prot should only be used if using multiple VMAs is + * impractical. + * + * Return: vm_fault_t value. + */ +vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, pgprot_t pgprot) +{ + int err = vm_insert_pfn_prot(vma, addr, pfn, pgprot); + + if (err == -ENOMEM) + return VM_FAULT_OOM; + if (err < 0 && err != -EBUSY) + return VM_FAULT_SIGBUS; + + return VM_FAULT_NOPAGE; +} +EXPORT_SYMBOL(vmf_insert_pfn_prot); static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) {