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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 EF4B8C433E0 for ; Mon, 8 Feb 2021 17:39:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 87D6064E7E for ; Mon, 8 Feb 2021 17:39:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87D6064E7E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B24666B0006; Mon, 8 Feb 2021 12:39:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD4086B006C; Mon, 8 Feb 2021 12:39:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EAA26B006E; Mon, 8 Feb 2021 12:39:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 8AE366B0006 for ; Mon, 8 Feb 2021 12:39:49 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 58C5F8248047 for ; Mon, 8 Feb 2021 17:39:49 +0000 (UTC) X-FDA: 77795813298.28.cap80_411232627600 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 3B2326C33 for ; Mon, 8 Feb 2021 17:39:49 +0000 (UTC) X-HE-Tag: cap80_411232627600 X-Filterd-Recvd-Size: 3206 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 8 Feb 2021 17:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2LaNn/qF13ah973xAp5scg/XoCXhEtsM5ZWpiwsnd4Q=; b=hyYX+n70bqbLDJg9Sqx10LdePn jbkVmtfoZx7vzottT/YxNc/v0guqB0G0eHUBAtuhfQNUUlUW3m6jk6e2CvOuWw3zpIyOqOl53SQ1W ih2oN1FeVLsRoPrZOtiVvkuCaTg4AMNXlbQGNZjDFL1jR2kF1ibYPt5RWQVpLZlaDwD3Jf42O269r 7VIP7AcZmCAbSYvo3wPj2uLetU/4uTgfM/gtpHZBWf4DF0DjZ0+HgpRquHFYh1MVjaDLnuD3p0up1 2ImztteZI+qFVTakUg6I8H8jv352DUazF8XIF4cnBzuBwbYV2oqLrByIqf5g1cpTphNlYcXlZ6g2+ W0LzlqPg==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l9AVc-006IA0-Vy; Mon, 08 Feb 2021 17:39:39 +0000 Date: Mon, 8 Feb 2021 17:39:36 +0000 From: Christoph Hellwig To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, jgg@ziepe.ca, linux-mm@kvack.org, Andrew Morton , dan.j.williams@intel.com Subject: Re: [PATCH 1/2] mm: provide a sane PTE walking API for modules Message-ID: <20210208173936.GA1496438@infradead.org> References: <20210205103259.42866-1-pbonzini@redhat.com> <20210205103259.42866-2-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210205103259.42866-2-pbonzini@redhat.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html 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: > +int follow_invalidate_pte(struct mm_struct *mm, unsigned long address, > + struct mmu_notifier_range *range, pte_t **ptepp, pmd_t **pmdpp, > + spinlock_t **ptlp); This adds a very pointless overy long line. > +/** > + * follow_pte - look up PTE at a user virtual address > + * @vma: memory mapping > + * @address: user virtual address > + * @ptepp: location to store found PTE > + * @ptlp: location to store the lock for the PTE > + * > + * On a successful return, the pointer to the PTE is stored in @ptepp; > + * the corresponding lock is taken and its location is stored in @ptlp. > + * The contents of the PTE are only stable until @ptlp is released; > + * any further use, if any, must be protected against invalidation > + * with MMU notifiers. > + * > + * Only IO mappings and raw PFN mappings are allowed. The mmap semaphore > + * should be taken for read. > + * > + * Return: zero on success, -ve otherwise. > + */ > +int follow_pte(struct mm_struct *mm, unsigned long address, > + pte_t **ptepp, spinlock_t **ptlp) > +{ > + return follow_invalidate_pte(mm, address, NULL, ptepp, NULL, ptlp); > +} > +EXPORT_SYMBOL_GPL(follow_pte); I still don't think this is good as a general API. Please document this as KVM only for now, and hopefully next merge window I'll finish an export variant restricting us to specific modules.