From nobody Mon Feb 9 17:25:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571764575; cv=none; d=zoho.com; s=zohoarc; b=LcF3YINLXKUIHBcmBo3Rub+klV0edJO/XfiKHhrJp4nNWRaKCtZ+XBhOPMYlvkyB1RLFat/PDiEGjMldldWOn4b3IS3QWgZQ/o2PznVyjU+0Wmq6DNLd+Mn3IDfdBcpgJ67296A1ak7pNuPEcLf8hEpl1sM8vRtBw9+hps+WJzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571764575; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7qBuVY/j6CkCjE+PuGdkkC7UnWer7ycF4Q23b3uVgvs=; b=a08y0q8c8LMsf0hmd1cR+WOi6EM42h2qto01HbM8LlwssbyL4CGBk9JiUYsOruhve7V7r6KDEupMrqyfo83388uq2EHWXpdzMhY08gS3IAmgpPl7pifYZo7CVP/T6NT4yGO/9tHMWsfp5o59XplpVtvdgc4bn/SsoHgUb04/chE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571764575206479.6350757566021; Tue, 22 Oct 2019 10:16:15 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMxkR-0006IE-7h; Tue, 22 Oct 2019 17:15:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMxkP-0006Hp-AW for xen-devel@lists.xenproject.org; Tue, 22 Oct 2019 17:15:05 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.61]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 7cfe5ad2-f4ef-11e9-8aca-bc764e2007e4; Tue, 22 Oct 2019 17:15:04 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-70-YJOMV_QcOSaZIfSzPrmgMA-1; Tue, 22 Oct 2019 13:15:02 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B09B7107AD33; Tue, 22 Oct 2019 17:14:56 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-248.ams2.redhat.com [10.36.116.248]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F8885ED21; Tue, 22 Oct 2019 17:14:35 +0000 (UTC) X-Inumbo-ID: 7cfe5ad2-f4ef-11e9-8aca-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571764504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zE4LVhifWdhxYyHhzJkYl/3tgDX3L2GHdaIdArSMoio=; b=hiaH9oarstddvZbnyK3sVT3D3oPdu47WGdtsUe6nvwLGC76+40GGzUHPcZPUyWzpNwcFBj oQu87zXv+5hJm8JfJ1/E/LYYHYtOj8bxV7s2BhEzTrLTpZoVeBcSJV6j0B5qP8JdlwcbU3 Oor9L7C4zCXm+m/++Mp5cNA7qpC593U= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Tue, 22 Oct 2019 19:12:32 +0200 Message-Id: <20191022171239.21487-6-david@redhat.com> In-Reply-To: <20191022171239.21487-1-david@redhat.com> References: <20191022171239.21487-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: YJOMV_QcOSaZIfSzPrmgMA-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH RFC v1 05/12] vfio/type1: Prepare is_invalid_reserved_pfn() for PG_reserved changes X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kate Stewart , Sasha Levin , linux-hyperv@vger.kernel.org, Michal Hocko , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org, David Hildenbrand , KarimAllah Ahmed , Benjamin Herrenschmidt , Dave Hansen , Alexander Duyck , Michal Hocko , Paul Mackerras , linux-mm@kvack.org, Pavel Tatashin , Paul Mackerras , Michael Ellerman , "H. Peter Anvin" , Wanpeng Li , Alexander Duyck , "K. Y. Srinivasan" , Fabio Estevam , Ben Chan , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , Mike Rapoport , Madhumitha Prabakaran , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Nishka Dasgupta , Anthony Yznaga , Oscar Salvador , Dan Carpenter , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , =?UTF-8?q?Simon=20Sandstr=C3=B6m?= , Dan Williams , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Todd Poynor , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Vandana BN , Jeremy Sowden , Greg Kroah-Hartman , Cornelia Huck , Pavel Tatashin , Mel Gorman , Sean Christopherson , Rob Springer , Thomas Gleixner , Johannes Weiner , Paolo Bonzini , Andrew Morton , linuxppc-dev@lists.ozlabs.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Right now, ZONE_DEVICE memory is always set PG_reserved. We want to change that. KVM has this weird use case that you can map anything from /dev/mem into the guest. pfn_valid() is not a reliable check whether the memmap was initialized and can be touched. pfn_to_online_page() makes sure that we have an initialized memmap. Note that ZONE_DEVICE memory is never online (IOW, managed by the buddy). Switching to pfn_to_online_page() keeps the existing behavior for PFNs without a memmap and for ZONE_DEVICE memory. They are treated as reserved and the page is not touched (e.g., to set it dirty or accessed). Cc: Alex Williamson Cc: Cornelia Huck Signed-off-by: David Hildenbrand --- drivers/vfio/vfio_iommu_type1.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type= 1.c index 2ada8e6cdb88..f8ce8c408ba8 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -299,9 +299,15 @@ static int vfio_lock_acct(struct vfio_dma *dma, long n= page, bool async) */ static bool is_invalid_reserved_pfn(unsigned long pfn) { - if (pfn_valid(pfn)) - return PageReserved(pfn_to_page(pfn)); + struct page *page =3D pfn_to_online_page(pfn); =20 + /* + * We treat any pages that are not online (not managed by the buddy) + * as reserved - this includes ZONE_DEVICE pages and pages without + * a memmap (e.g., mapped via /dev/mem). + */ + if (page) + return PageReserved(page); return true; } =20 --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel