From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38D7BC2D0B1 for ; Fri, 6 Dec 2019 08:24:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF4F224677 for ; Fri, 6 Dec 2019 08:24:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="YkhtrX0c" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF4F224677 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 84D166B14D4; Fri, 6 Dec 2019 03:24:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 82D906B14D6; Fri, 6 Dec 2019 03:24:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7128F6B14D5; Fri, 6 Dec 2019 03:24:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id 5CAC26B14D3 for ; Fri, 6 Dec 2019 03:24:43 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 1A2BA4DA7 for ; Fri, 6 Dec 2019 08:24:43 +0000 (UTC) X-FDA: 76234030446.21.knee84_633c42726835f X-HE-Tag: knee84_633c42726835f X-Filterd-Recvd-Size: 5863 Received: from pio-pvt-msa2.bahnhof.se (pio-pvt-msa2.bahnhof.se [79.136.2.41]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Dec 2019 08:24:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 0C2833F26D; Fri, 6 Dec 2019 09:24:40 +0100 (CET) Authentication-Results: pio-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=YkhtrX0c; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gHg2CEyS_O6z; Fri, 6 Dec 2019 09:24:39 +0100 (CET) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 1E7FB3F260; Fri, 6 Dec 2019 09:24:35 +0100 (CET) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 5C95436248A; Fri, 6 Dec 2019 09:24:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1575620675; bh=vaz4Fv+7GImw8+vcszuFMdA6P2YC6/2kJMWKMuBG2ZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YkhtrX0cdlFY/uXQGbmu6FwDrUf+pkXZee5ibUPmYxgy5YNt6UnC9GobHSO2Vv0Tu vx0rm/fpXq9Ulzsv0ZzUlS0n7s4xXoJ26AafBEHiBtDsLi6bgADq0Kn9nJt2q30T06 e8Jx5Nwta7vsEMfqqRXkNr+fqJIS6sauiGmHEmCo= From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m=20=28VMware=29?= To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: pv-drivers@vmware.com, linux-graphics-maintainer@vmware.com, Thomas Hellstrom , Andrew Morton , Michal Hocko , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Ralph Campbell , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [PATCH v3 1/2] mm: Add a vmf_insert_mixed_prot() function Date: Fri, 6 Dec 2019 09:24:25 +0100 Message-Id: <20191206082426.2958-2-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191206082426.2958-1-thomas_os@shipmail.org> References: <20191206082426.2958-1-thomas_os@shipmail.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: From: Thomas Hellstrom The TTM module today uses a hack to be able to set a different page protection than struct vm_area_struct::vm_page_prot. To be able to do this properly, add the needed vm functionality as vmf_insert_mixed_prot()= . Cc: Andrew Morton Cc: Michal Hocko Cc: "Matthew Wilcox (Oracle)" Cc: "Kirill A. Shutemov" Cc: Ralph Campbell Cc: "J=C3=A9r=C3=B4me Glisse" Cc: "Christian K=C3=B6nig" Signed-off-by: Thomas Hellstrom Acked-by: Christian K=C3=B6nig --- include/linux/mm.h | 2 ++ mm/memory.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index cc292273e6ba..29575d3c1e47 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2548,6 +2548,8 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struc= t *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot); vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long ad= dr, pfn_t pfn); +vm_fault_t vmf_insert_mixed_prot(struct vm_area_struct *vma, unsigned lo= ng addr, + pfn_t pfn, pgprot_t pgprot); vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsig= ned long len); diff --git a/mm/memory.c b/mm/memory.c index b1ca51a079f2..b9e7f1d56b1c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1719,9 +1719,9 @@ static bool vm_mixed_ok(struct vm_area_struct *vma,= pfn_t pfn) } =20 static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma, - unsigned long addr, pfn_t pfn, bool mkwrite) + unsigned long addr, pfn_t pfn, pgprot_t pgprot, + bool mkwrite) { - pgprot_t pgprot =3D vma->vm_page_prot; int err; =20 BUG_ON(!vm_mixed_ok(vma, pfn)); @@ -1764,10 +1764,16 @@ static vm_fault_t __vm_insert_mixed(struct vm_are= a_struct *vma, return VM_FAULT_NOPAGE; } =20 +vm_fault_t vmf_insert_mixed_prot(struct vm_area_struct *vma, unsigned lo= ng addr, + pfn_t pfn, pgprot_t pgprot) +{ + return __vm_insert_mixed(vma, addr, pfn, pgprot, false); +} + vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long ad= dr, pfn_t pfn) { - return __vm_insert_mixed(vma, addr, pfn, false); + return __vm_insert_mixed(vma, addr, pfn, vma->vm_page_prot, false); } EXPORT_SYMBOL(vmf_insert_mixed); =20 @@ -1779,7 +1785,7 @@ EXPORT_SYMBOL(vmf_insert_mixed); vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn) { - return __vm_insert_mixed(vma, addr, pfn, true); + return __vm_insert_mixed(vma, addr, pfn, vma->vm_page_prot, true); } EXPORT_SYMBOL(vmf_insert_mixed_mkwrite); =20 --=20 2.21.0