From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919102; cv=none; d=zoho.com; s=zohoarc; b=O61WhfwaCgrOfevkeyaAN9a/2mrFAHy5P5JHdRFWUrbc7/dfeJz1wepwHRjxDnwZYjLkm8rwq5nDdxztrMxoPfptp9Vpn6cZZb5ECHp27TleDhRxK9Z9oTt0y8jheu0GXmjXSOmI8kAPfcNHR5Il04LWEen8kUdy5NT1mhjYBfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919102; 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=jq42HYmI/ixctqcZmPizd8H4lLQcO1VLEafdTBX/P+g=; b=DaxWlrLrzm6t9N9JzJirOeL3Ntxo6NiKtKTRggr0Ntd+RDy9k+Q3rSR9e0jXTrVBEh3qFOx4Cazv74I+S6JmIhIsN5pEyeux+Hf89kugbf7svTd2mnCHagaR5Zks7vh613HDIJCRm0rtYcJtxRlZDQ983Fjj/El/LlR2wCbbGDc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919102195290.2456379568147; Thu, 24 Oct 2019 05:11:42 -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 1iNbwp-0004n4-Bu; Thu, 24 Oct 2019 12:10:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbwo-0004mx-F7 for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:10:34 +0000 Received: from us-smtp-delivery-1.mimecast.com (unknown [205.139.110.61]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 47189400-f657-11e9-a531-bc764e2007e4; Thu, 24 Oct 2019 12:10:32 +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-190-OyS-w0OOPfCXkYu6xkkqOg-1; Thu, 24 Oct 2019 08:10:30 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17898800D49; Thu, 24 Oct 2019 12:10:23 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9159B52D1; Thu, 24 Oct 2019 12:10:01 +0000 (UTC) X-Inumbo-ID: 47189400-f657-11e9-a531-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919032; 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=ci8rTmGAQWvcufbTawC9IhJzwFepcNIlGotHVYhTC24=; b=ZsNhtg6+dHzPcwSVwjXIgwuRpJm6zYtwBax/d+6eoWSCur2yTWxbtJPLhhHmNn8DDxOdG/ FCV9fGARW7QmrSToNDPYny63UzkQ58We2FTFTsqO8pkYNPZaLTHaQ14kBMl/z67w471myj TbflBaG/0ZYtQfEUDZQeeIqqCd8W/nM= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:29 +0200 Message-Id: <20191024120938.11237-2-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: OyS-w0OOPfCXkYu6xkkqOg-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 01/10] mm/memory_hotplug: Don't allow to online/offline memory blocks with holes 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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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) Our onlining/offlining code is unnecessarily complicated. Only memory blocks added during boot can have holes (a range that is not IORESOURCE_SYSTEM_RAM). Hotplugged memory never has holes (e.g., see add_memory_resource()). All boot memory is alread online. Therefore, when we stop allowing to offline memory blocks with holes, we implicitly no longer have to deal with onlining memory blocks with holes. This allows to simplify the code. For example, we no longer have to worry about marking pages that fall into memory holes PG_reserved when onlining memory. We can stop setting pages PG_reserved. Offlining memory blocks added during boot is usually not guranteed to work either way (unmovable data might have easily ended up on that memory during boot). So stopping to do that should not really hurt (+ people are not even aware of a setup where that used to work and that the existing code still works correctly with memory holes). For the use case of offlining memory to unplug DIMMs, we should see no change. (holes on DIMMs would be weird). Please note that hardware errors (PG_hwpoison) are not memory holes and not affected by this change when offlining. Cc: Andrew Morton Cc: Michal Hocko Cc: Oscar Salvador Cc: Pavel Tatashin Cc: Dan Williams Cc: Anshuman Khandual Signed-off-by: David Hildenbrand Reviewed-by: Dan Williams --- mm/memory_hotplug.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 561371ead39a..8d81730cf036 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1447,10 +1447,19 @@ static void node_states_clear_node(int node, struct= memory_notify *arg) node_clear_state(node, N_MEMORY); } =20 +static int count_system_ram_pages_cb(unsigned long start_pfn, + unsigned long nr_pages, void *data) +{ + unsigned long *nr_system_ram_pages =3D data; + + *nr_system_ram_pages +=3D nr_pages; + return 0; +} + static int __ref __offline_pages(unsigned long start_pfn, unsigned long end_pfn) { - unsigned long pfn, nr_pages; + unsigned long pfn, nr_pages =3D 0; unsigned long offlined_pages =3D 0; int ret, node, nr_isolate_pageblock; unsigned long flags; @@ -1461,6 +1470,20 @@ static int __ref __offline_pages(unsigned long start= _pfn, =20 mem_hotplug_begin(); =20 + /* + * Don't allow to offline memory blocks that contain holes. + * Consecuently, memory blocks with holes can never get onlined + * (hotplugged memory has no holes and all boot memory is online). + * This allows to simplify the onlining/offlining code quite a lot. + */ + walk_system_ram_range(start_pfn, end_pfn - start_pfn, &nr_pages, + count_system_ram_pages_cb); + if (nr_pages !=3D end_pfn - start_pfn) { + ret =3D -EINVAL; + reason =3D "memory holes"; + goto failed_removal; + } + /* This makes hotplug much easier...and readable. we assume this for now. .*/ if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, @@ -1472,7 +1495,6 @@ static int __ref __offline_pages(unsigned long start_= pfn, =20 zone =3D page_zone(pfn_to_page(valid_start)); node =3D zone_to_nid(zone); - nr_pages =3D end_pfn - start_pfn; =20 /* set above range as isolated */ ret =3D start_isolate_page_range(start_pfn, end_pfn, --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919122; cv=none; d=zoho.com; s=zohoarc; b=IY+xY730pZFrT1/GMdfTtPUP5Uk8VOJ1fBM8PzMqbYn4AxrjU9pGNVThyO+PiFzABYMEDa9QCOAVqxOUouTriBVeXxMX+2ibEsjILh8zPLmXbB8iWD+135eSd91/thVACMLkIly8SbnV6PVctlmHr7QYGMbE9l54pyMQwpxpr6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919122; 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=pSKHVWUB5R2GPPTmAtuqhw9OziflK1wGENlcGO3vD5c=; b=EW/+TYEoYRzi7qn/DRnHCQCCOyFC+kZ7EQBbCEMRioDFY+8z3x7NbMxP+C99TEqqpz9yMUWuuupqwukVZcLVMZFECmbuoQIgtIPWMKBLA4w7GFWYlIcWwuNUdnI8LhZ5cI5JKWGxmYY3SsRA3kfCSyC2upWAyKpgEm7wTg4IEE0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 157191912209782.31837978925523; Thu, 24 Oct 2019 05:12:02 -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 1iNbxA-0004qe-Lz; Thu, 24 Oct 2019 12:10:56 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbx9-0004pO-16 for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:10:55 +0000 Received: from us-smtp-delivery-1.mimecast.com (unknown [205.139.110.61]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 52e7b464-f657-11e9-949f-12813bfff9fa; Thu, 24 Oct 2019 12:10:52 +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-44-KwvfWgdbN8Olk7KAgSZhkg-1; Thu, 24 Oct 2019 08:10:50 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 274885E4; Thu, 24 Oct 2019 12:10:43 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70C261C93D; Thu, 24 Oct 2019 12:10:23 +0000 (UTC) X-Inumbo-ID: 52e7b464-f657-11e9-949f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919052; 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=qUw+4OUStTuaq5ok3fmgq6nv+XIwZUDTl4O246f/KSo=; b=Mphi4odUz6rpOo7NfySpzAq1zpgNhKwMBhQoLlCqnbY2G01htLXPEwLdGshy6syP9B2P5U jsYZp33qMxwNjyrCNQ9Xhz+t3t4YgMDOGwpirF/Ha+jU+fryTpfjPbfhlC2IlpyhMAt0gM iHO6pBUIpg3bFN/yOVzeO/Ow/rmq04w= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:30 +0200 Message-Id: <20191024120938.11237-3-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: KwvfWgdbN8Olk7KAgSZhkg-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 02/10] KVM: x86/mmu: Prepare kvm_is_mmio_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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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 (and don't have ZONE_DEVICE memory). Rewrite kvm_is_mmio_pfn() to make sure the function produces the same result once we stop setting ZONE_DEVICE pages PG_reserved. Cc: Paolo Bonzini Cc: "Radim Kr=C4=8Dm=C3=A1=C5=99" Cc: Sean Christopherson Cc: Vitaly Kuznetsov Cc: Wanpeng Li Cc: Jim Mattson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: KarimAllah Ahmed Cc: Michal Hocko Cc: Dan Williams Signed-off-by: David Hildenbrand Reviewed-by: Dan Williams --- arch/x86/kvm/mmu.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 24c23c66b226..f03089a336de 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2962,20 +2962,25 @@ static bool mmu_need_write_protect(struct kvm_vcpu = *vcpu, gfn_t gfn, =20 static bool kvm_is_mmio_pfn(kvm_pfn_t pfn) { + struct page *page =3D pfn_to_online_page(pfn); + + /* + * ZONE_DEVICE pages are never online. Online pages that are reserved + * either indicate the zero page or MMIO pages. + */ + if (page) + return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn)); + + /* + * Anything with a valid (but not online) memmap could be ZONE_DEVICE. + * Treat only UC/UC-/WC pages as MMIO. + */ if (pfn_valid(pfn)) - return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn)) && - /* - * Some reserved pages, such as those from NVDIMM - * DAX devices, are not for MMIO, and can be mapped - * with cached memory type for better performance. - * However, the above check misconceives those pages - * as MMIO, and results in KVM mapping them with UC - * memory type, which would hurt the performance. - * Therefore, we check the host memory type in addition - * and only treat UC/UC-/WC pages as MMIO. - */ - (!pat_enabled() || pat_pfn_immune_to_uc_mtrr(pfn)); + return !pat_enabled() || pat_pfn_immune_to_uc_mtrr(pfn); =20 + /* + * Any RAM that has no memmap (e.g., mapped via /dev/mem) is not MMIO. + */ return !e820__mapped_raw_any(pfn_to_hpa(pfn), pfn_to_hpa(pfn + 1) - 1, E820_TYPE_RAM); --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919133; cv=none; d=zoho.com; s=zohoarc; b=IULgeeiyDGIDvBBAzd9WPlL0w1zjeSuKyZoBiMOYD3bzg5Ggk10w5doRWJOAvcQAyt1p6BJWVGDrfJE2wV0GTRwq/d8zBxUbR4yfWGVF9op45vYibsB7OO2a/pqO45fE3yF9nLAFGrWj4kCsbGSN5PGKjeimg0oMP0QEi6l8hdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919133; 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=BJNOxid5FsLs3ZnCMsPnJYTYnQWZs7Nbqe6ne4mc8YQ=; b=fIaKJ9Wm9O/W5d8t1pDozUNO7eJIO1lgJL2yHuTHQjhDJSRHSI8PKa9/KkPcM4HkOPfa/pQMmtgNr9w06CrFbzO/AijafBZ/ZfYXShhn70yI/4moWXys5Ty8nJT/vJiOh+Of/bWA1IrpFEJjGtXdXtsgD1d4Cyxyr+p/P6eOTJo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919133880762.0446443572963; Thu, 24 Oct 2019 05:12:13 -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 1iNbxT-0004ud-48; Thu, 24 Oct 2019 12:11:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbxS-0004uX-MS for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:11:14 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.61]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 5f562dd4-f657-11e9-a531-bc764e2007e4; Thu, 24 Oct 2019 12:11:13 +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-78-XqXphJdGOZKQf4BuJSlwgQ-1; Thu, 24 Oct 2019 08:11:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 040841005500; Thu, 24 Oct 2019 12:11:04 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E74A166A0; Thu, 24 Oct 2019 12:10:43 +0000 (UTC) X-Inumbo-ID: 5f562dd4-f657-11e9-a531-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919073; 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=Snv/eN2JSs1CKovdcEZrKtv3120OMPYnvMUKCAi50+E=; b=J8XNYJWRWQRNddlk0fbrEmhxGj3H4TXpUcBXAKchMcMV+JKZssNgeZKUmjwpQLK6IYldCJ 4ZK1cMzkkOgBP3D2tOT2X7BfQkCoddlrrR2/aWO+9ifPLDrufbu632xjVW3Nj9IZCftGQi hVrMoh/avbCjWD389HmGFY8CPBv16jU= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:31 +0200 Message-Id: <20191024120938.11237-4-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: XqXphJdGOZKQf4BuJSlwgQ-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 03/10] KVM: Prepare kvm_is_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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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 (and don't have ZONE_DEVICE memory). Rewrite kvm_is_reserved_pfn() to make sure the function produces the same result once we stop setting ZONE_DEVICE pages PG_reserved. Cc: Paolo Bonzini Cc: "Radim Kr=C4=8Dm=C3=A1=C5=99" Cc: Michal Hocko Cc: Dan Williams Cc: KarimAllah Ahmed Signed-off-by: David Hildenbrand --- virt/kvm/kvm_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index e9eb666eb6e8..9d18cc67d124 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -151,9 +151,15 @@ __weak int kvm_arch_mmu_notifier_invalidate_range(stru= ct kvm *kvm, =20 bool kvm_is_reserved_pfn(kvm_pfn_t 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 From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919163; cv=none; d=zoho.com; s=zohoarc; b=MNFtUmFEnk3Evt9PEq84UJtbG19IQKucJCIqQnoduSTGCdXekPSseBHEPtZVlqJh6FUVTJ634ym85Bq5O+dh6iMSj3S8JsEkl4N0RFYj+kVyKfW5Zvf6TGTwUS9j457TiRxDIC1CjsLC7tsu7os4jS7oirBLZJBqMPIw2FmGExQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919163; 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=TjWifftjsZqCuPFRWlslrl8eRDRQTFpVlX8o5M6qkAM=; b=WEr9o/hjoAyejvSuVhb58ElT//4rH5TSFAFjtlbz3qdH2Sw8HjLGA5Hk5n8eahTnw/DMky1RKBUu8eqgnbG/h1a8XmyL7gwyHbp+LJJ04ii4b3oCvTCUECyKmLmGisNOxkDOgqDopRTvY9D7fMXtr0+tAfY2KU5gYYkjZrDY1WQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919163103703.5103794789931; Thu, 24 Oct 2019 05:12:43 -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 1iNbxx-00052A-EH; Thu, 24 Oct 2019 12:11:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbxw-00051w-Dy for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:11:44 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.120]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 70c7654c-f657-11e9-8aca-bc764e2007e4; Thu, 24 Oct 2019 12:11:42 +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-148-f-AfDHaGNvuEBDYN5p3zWQ-1; Thu, 24 Oct 2019 08:11:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B5179801E5C; Thu, 24 Oct 2019 12:11:34 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D51552D5; Thu, 24 Oct 2019 12:11:04 +0000 (UTC) X-Inumbo-ID: 70c7654c-f657-11e9-8aca-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919102; 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=LoVG2BEnXVzgoLr0OSeQwtEbC1Paof07RzXqtGqnOKU=; b=C9bcJUN4TJC71eUimMATv1xQrZz6cWwCXXIvQpMlGU/vPa77sGUqcTgkqbBkJ7J4Zdxu8e XFIgW3Zw8PrDVJE5HCY4liyH0GqB3YE4oYtredlJx1JmXXLkEuBL6H21j5Yus/TWuWceCx L7Z9p6s3LQqk8G725n5tJVpSp+Gn0aQ= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:32 +0200 Message-Id: <20191024120938.11237-5-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: f-AfDHaGNvuEBDYN5p3zWQ-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 04/10] 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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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 (and don't have ZONE_DEVICE memory). Rewrite is_invalid_reserved_pfn() similar to kvm_is_reserved_pfn() to make sure the function produces the same result once we stop setting ZONE_DEVICE pages PG_reserved. 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 From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919192; cv=none; d=zoho.com; s=zohoarc; b=ib6kiBSEe/7RO27snTbyxtclMDZuJC0OBoe2o5u/xlaVAnvFHiWKxV1gCHv0a3qJxzQ5QFjhoLytjw4I7HZkq0KW6okWXRRQxfTP3jRqvUQhuuSm+MUKqsLeDfhtYcsPAtvKtv7hXNfIGX2z6dH2JClessQh4Dhw7Ikq/3t5S6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919192; 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=/zMh4jU8St1fjopCcqeAFHKuLKb1t5MvIy1Jtk68AT4=; b=dEi++WY2wIimx6KXfMsDLcjAzWW2pd35lXiAB9af3/uIUdWFfDiVq9o2/T/o4yc4bk0B/zoRx6qBZgJp0JcF8+aYrIn1egr6jx8ckLxNUGcKyQHHmqb5B9m81vRa1cxHn+GyOgae2yAqguwg07o/5Taei6bmO/Lpm5XnHaaIQPM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919192572101.23011934880424; Thu, 24 Oct 2019 05:13:12 -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 1iNbyM-00057G-Nf; Thu, 24 Oct 2019 12:12:10 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbyL-00056w-I9 for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:12:09 +0000 Received: from us-smtp-delivery-1.mimecast.com (unknown [205.139.110.120]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 804d19e5-f657-11e9-949f-12813bfff9fa; Thu, 24 Oct 2019 12:12:08 +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-282-4jB-26J_NR2cHntMTRc7Nw-1; Thu, 24 Oct 2019 08:12:06 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73C86801E5C; Thu, 24 Oct 2019 12:12:01 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10391196B2; Thu, 24 Oct 2019 12:11:34 +0000 (UTC) X-Inumbo-ID: 804d19e5-f657-11e9-949f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919128; 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=gYC6fNIGttIcUtgmCXmgJGRK+sWEvXrn/dTQBLMCSac=; b=dCSeCeM60hZGHiIn1XBNI7Y27vKvoCH3cd3+5v/mmyvfFOuV4I8zBYx2iIvDgPredrCUUe bq9miludVrpD6w2bbMzmeHKTGwO9zBJpTpQM1qElzNpJ+yCj7ZtUPUstxSJj45VHnNWg9C 2V5LvzoZRUqAWwRFN370VgSl6X5azf4= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:33 +0200 Message-Id: <20191024120938.11237-6-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 4jB-26J_NR2cHntMTRc7Nw-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 05/10] powerpc/book3s: Prepare kvmppc_book3s_instantiate_page() 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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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 (and don't have ZONE_DEVICE memory). Rewrite kvmppc_book3s_instantiate_page() similar to kvm_is_reserved_pfn() to make sure the function produces the same result once we stop setting ZONE_DEVICE pages PG_reserved. Cc: Paul Mackerras Cc: Benjamin Herrenschmidt Cc: Michael Ellerman Signed-off-by: David Hildenbrand --- arch/powerpc/kvm/book3s_64_mmu_radix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book= 3s_64_mmu_radix.c index 2d415c36a61d..05397c0561fc 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c @@ -801,12 +801,14 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *v= cpu, writing, upgrade_p); if (is_error_noslot_pfn(pfn)) return -EFAULT; - page =3D NULL; - if (pfn_valid(pfn)) { - page =3D pfn_to_page(pfn); - if (PageReserved(page)) - page =3D NULL; - } + /* + * 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). + */ + page =3D pfn_to_online_page(pfn); + if (page && PageReserved(page)) + page =3D NULL; } =20 /* --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919256; cv=none; d=zoho.com; s=zohoarc; b=cw9vTG0ajcUvxAB4PDqNWfYmqC56wH707j3mkjA8Zy53exE1leohdE9PKr8elCnLTfuJX/NqbVnatxQhEDtC7CeflaHOr1wR6rEW3LQKPsTOIKPG+eNfwGJC7cwhEKK7PX8V+Pl6tiblKiyn0KqNNCP9qjiQgGjL2VoN8NdUKEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919256; 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=o2rUdvSuk8BPIUOoHB6nwcA7kqGwyAiRp1vylMegXd4=; b=B081dPvtIXazvOa0CbfEWCpphRcksNQTRiXr/kteiABbaknJR5BuFnsuBZSnyKpm7P1/EmhrFMhOHn2wrCUhIqGkb1vG3EhE7d4B6DhXxAM3GbyuA4qepq1j9XlT7ldE/TQnrRH0wLAwimXpiyAKDzTRdXO2qOYKrOEtgpUtSvY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919256590528.3719834194062; Thu, 24 Oct 2019 05:14:16 -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 1iNbzL-0005Ie-3l; Thu, 24 Oct 2019 12:13:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbzJ-0005IQ-Cp for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:13:09 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.120]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id a3e6c120-f657-11e9-a531-bc764e2007e4; Thu, 24 Oct 2019 12:13:08 +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-344-Nt3QL1jGMwSMlYksEV1tZg-1; Thu, 24 Oct 2019 08:13:06 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCA6D107AD33; Thu, 24 Oct 2019 12:13:00 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id C43225F74; Thu, 24 Oct 2019 12:12:01 +0000 (UTC) X-Inumbo-ID: a3e6c120-f657-11e9-a531-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919188; 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=LRGcEG74kR2LEgOmaMjJgXKKQcoIUakiEQOjfGHgANM=; b=hSFwfwV9npnJGYIFMNIMIOIwZtuCNtXLMiFhvOj1OE2FnVeGL+OumNw5N/41KTf5v8wRq0 tRrMQQmhwn6SUNjNd5RZSrD0ogoECw4NShBFhW0BTyU+IcI8SXol8SR8aGIOQVvirIxa9I juYyp6q1W/O2hMw7gCWiec7e6oIbbaw= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:34 +0200 Message-Id: <20191024120938.11237-7-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: Nt3QL1jGMwSMlYksEV1tZg-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 06/10] powerpc/64s: Prepare hash_page_do_lazy_icache() 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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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. Rewrite hash_page_do_lazy_icache() to make sure the function produces the same result once we stop setting ZONE_DEVICE pages PG_reserved. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: "Aneesh Kumar K.V" Cc: Christophe Leroy Cc: Nicholas Piggin Cc: Andrew Morton Cc: Mike Rapoport Cc: YueHaibing Signed-off-by: David Hildenbrand --- arch/powerpc/mm/book3s64/hash_utils.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s= 64/hash_utils.c index 6c123760164e..a1566039e747 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -1084,13 +1084,15 @@ void hash__early_init_mmu_secondary(void) */ unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap) { - struct page *page; + struct page *page =3D pfn_to_online_page(pte_pfn(pte)); =20 - if (!pfn_valid(pte_pfn(pte))) + /* + * We ignore any pages that are not online (not managed by the buddy). + * This includes ZONE_DEVICE pages. + */ + if (!page) return pp; =20 - page =3D pte_page(pte); - /* page is dirty */ if (!test_bit(PG_arch_1, &page->flags) && !PageReserved(page)) { if (trap =3D=3D 0x400) { --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919275; cv=none; d=zoho.com; s=zohoarc; b=KiqWaoS0KjUtGS1O/I7ypgjFwgtkKd8wdYgyPNC0H+wn0SM0fHbLlAy1Fyz/3Dw5NftGBQmP2oLEewI+8E4uHAgOStSNJXkonwsW+CS9zVVorq7atN6cMAZhk8kidj/pKVR28797a/b9ieFq+1E0iGCVs8gX8hkcraWUyFGQXEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919275; 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=aRnsT63tc722MJs/c1NnYudvYsa+D06Ns+Z6tAwirWE=; b=D2PNGNmlCqhXT0IQ1bBupTH07LC6bmdbIKUEqkzxM2NyfOVsa8aA06fDFlt5+hwc5c5RaZH/+KtzQ+XAm/9A4eeELRy+XAEqYVDGi7zOluufFNIY7o4XjvpkAgRrtevn1YvdGGMJ81an0unn033d28Ku1uYuUuY5nPiKwQwfBIY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919275552768.1001569446788; Thu, 24 Oct 2019 05:14:35 -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 1iNbze-0005N8-DO; Thu, 24 Oct 2019 12:13:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbzc-0005Mi-N3 for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:13:28 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.120]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id af8ddb3a-f657-11e9-beca-bc764e2007e4; Thu, 24 Oct 2019 12:13:28 +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-154-uD3eMwCPNuyUH4oElpkK2Q-1; Thu, 24 Oct 2019 08:13:25 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89F6B1005500; Thu, 24 Oct 2019 12:13:20 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42A9952E0; Thu, 24 Oct 2019 12:13:01 +0000 (UTC) X-Inumbo-ID: af8ddb3a-f657-11e9-beca-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919207; 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=Uytp7CiQUykRNdQZX1bgaVZ4SH8DD/y5BnwPHrsxaAw=; b=AQP2lSzLyc9ZIev+fBOfCEqDRCN08aPf+CHQFSwrro7MP58ZEboHhWJNL4oXcAnUDhKzpG bpc2igJwFCIovpTbSDk4cMfJn3EnLh68YKdBEeK5NRY4+O7y3Mrd2WDB/xKtMDbVN+JtPY HL/x+VYafBryY4U0zkTD95UeroQB3mw= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:35 +0200 Message-Id: <20191024120938.11237-8-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: uD3eMwCPNuyUH4oElpkK2Q-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 07/10] powerpc/mm: Prepare maybe_pte_to_page() 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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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. Rewrite maybe_pte_to_page() to make sure the function produces the same result once we stop setting ZONE_DEVICE pages PG_reserved. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Christophe Leroy Cc: "Aneesh Kumar K.V" Cc: Allison Randal Cc: Nicholas Piggin Cc: Thomas Gleixner Signed-off-by: David Hildenbrand --- arch/powerpc/mm/pgtable.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index e3759b69f81b..613c98fa7dc0 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -55,10 +55,12 @@ static struct page *maybe_pte_to_page(pte_t pte) unsigned long pfn =3D pte_pfn(pte); struct page *page; =20 - if (unlikely(!pfn_valid(pfn))) - return NULL; - page =3D pfn_to_page(pfn); - if (PageReserved(page)) + /* + * We reject any pages that are not online (not managed by the buddy). + * This includes ZONE_DEVICE pages. + */ + page =3D pfn_to_online_page(pfn); + if (unlikely(!page || PageReserved(page))) return NULL; return page; } --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919294; cv=none; d=zoho.com; s=zohoarc; b=O+9q6FEvGMnPylvm3Aecblq0LI6LVCSaD1M8jXBoK65CFxPFBXdH91pREKgcFwMjAUnjcQCorsMg/xhpmr8GVoXErCJIJZkF3NYyHpg3Z70YE6wi2NimSY3OCU6h/o8pneny+HiFgqWgIPcK4XW6U9moWZtp8xl0WJkwDg2Z++c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919294; 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=9WDfF/uQMMvzWSyNAtMNXfiG6XqsHbCBN1kbfNDLgw8=; b=LPXab7SQC74UsmpGRpZJYW39cDgE7VmLYFo2hWb1VyWsscU9GXbC98CtppYRVURGf6fIpVXbz3F4U7SZ1RPZJYjtGHEcK984adTERzSX77fQytGbiMLFc1auBEO70mg5kdJSzGbbnfEiqhjOM6Em5YtmMJlwySiyURXajPImJpc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919294891666.1330967831566; Thu, 24 Oct 2019 05:14:54 -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 1iNbzy-0005Rr-S8; Thu, 24 Oct 2019 12:13:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbzx-0005Re-OO for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:13:49 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.120]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id bc00dd7c-f657-11e9-beca-bc764e2007e4; Thu, 24 Oct 2019 12:13:48 +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-12-cIgA3mrGO0GO4AgvS2Fldw-1; Thu, 24 Oct 2019 08:13:44 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2AC001800D6B; Thu, 24 Oct 2019 12:13:39 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEC7D1C93D; Thu, 24 Oct 2019 12:13:20 +0000 (UTC) X-Inumbo-ID: bc00dd7c-f657-11e9-beca-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919228; 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=63dkq1rIK4xjp2ay2ZA3DSxT4H+7TMBFb0GQYgs1fjs=; b=XFYiDn3P02tZ5xgoY4Gy52zBgW2X2jvYqWjQoxGuddoDndG4j7Yy87s1AK5fckj4g8c7T8 bIrF/NiWadvbFrTBsGxEUIW4G7BRMpzDr6gWp9NiYIYaHtTHTXkmvc3QUKyvqWWj40p+nF 6RuEDnpvUXL4cooyj66rvoGt9jIpIrE= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:36 +0200 Message-Id: <20191024120938.11237-9-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: cIgA3mrGO0GO4AgvS2Fldw-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 08/10] x86/mm: Prepare __ioremap_check_ram() 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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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. Rewrite __ioremap_check_ram() to make sure the function produces the same result once we stop setting ZONE_DEVICE pages PG_reserved. Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Signed-off-by: David Hildenbrand --- arch/x86/mm/ioremap.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index a39dcdb5ae34..db6913b48edf 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -77,10 +77,17 @@ static unsigned int __ioremap_check_ram(struct resource= *res) start_pfn =3D (res->start + PAGE_SIZE - 1) >> PAGE_SHIFT; stop_pfn =3D (res->end + 1) >> PAGE_SHIFT; if (stop_pfn > start_pfn) { - for (i =3D 0; i < (stop_pfn - start_pfn); ++i) - if (pfn_valid(start_pfn + i) && - !PageReserved(pfn_to_page(start_pfn + i))) + for (i =3D 0; i < (stop_pfn - start_pfn); ++i) { + struct page *page; + /* + * We treat any pages that are not online (not managed + * by the buddy) as not being RAM. This includes + * ZONE_DEVICE pages. + */ + page =3D pfn_to_online_page(start_pfn + i); + if (page && !PageReserved(page)) return IORES_MAP_SYSTEM_RAM; + } } =20 return 0; --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919323; cv=none; d=zoho.com; s=zohoarc; b=OVMCtrCz2C1FS0LdhWJ6Kttecmzw6uFwifngbnm8K1YT8Dj4u7iNos42/mpHrI/ybEfwBm81FKcHIkMw4VvzeLQAHp5LD3Shyc+mDT34qU0dhtG5HIjXcsTq1l7hhj7xPSveyFumpiZ1pEqQhiTdNelzRWz1iNJ3O2zpqoGzCTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919323; 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=uXClQ8bcyW8oSe1Sl/b8pUIF2RmXLY8DgfaK/jn82s8=; b=WsgRHltfkMTE53KYF+g6CtjXFmsdE/NJYWaFyO54blMRLZ+98fysSF0Kcj+vNQhS3yOxbjyQTTdT1KvqHb+9zGAW8ZIPI/Ltb5dryyzaU51yjYB6OqW3xPSaR+IyviNC98g7AQuw/5+NyjAEkQt9SoXUnIGpSfcByMGwEQWvjL8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919323217232.78763267667603; Thu, 24 Oct 2019 05:15:23 -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 1iNc0K-0005ZE-SL; Thu, 24 Oct 2019 12:14:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNc0K-0005Ye-1n for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:14:12 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.120]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id c6804a9e-f657-11e9-949f-12813bfff9fa; Thu, 24 Oct 2019 12:14:06 +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-376-cghgf-YzMZOgToF4kkZ_Ag-1; Thu, 24 Oct 2019 08:14:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEA09801E5C; Thu, 24 Oct 2019 12:13:57 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7969C8088; Thu, 24 Oct 2019 12:13:39 +0000 (UTC) X-Inumbo-ID: c6804a9e-f657-11e9-949f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919246; 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=BdHwj2SGut21P5mUR9vWZhfFecp/N83MWMVJ97x7s00=; b=T4nUTKuop9UVBTKArpbw/r4KDrADT1Mw4HZKgwSBG11GnyoBMVGQl/eq0jYD+n/mdG4J4Z NHmnQWAyvFIzQRPXmt5gjIrc3kqHt7Qp5f3pR66gzd/qwNpYfGv/0zbCRBU3Qb8higoJqT 4jaApMQWE5WvnLdHFSZ0Ehx08Fa9vEk= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:37 +0200 Message-Id: <20191024120938.11237-10-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: cghgf-YzMZOgToF4kkZ_Ag-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 09/10] mm/memory_hotplug: Don't mark pages PG_reserved when initializing the memmap 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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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) Everything should be prepared to stop setting pages PG_reserved when initializing the memmap on memory hotplug. Most importantly, we stop marking ZONE_DEVICE pages PG_reserved. a) We made sure that any code that relied on PG_reserved to detect ZONE_DEVICE memory will no longer rely on PG_reserved (especially, by relying on pfn_to_online_page() for now). Details can be found below. b) We made sure that memory blocks with holes cannot be offlined and therefore also not onlined. We have quite some code that relies on memory holes being marked PG_reserved. This is now not an issue anymore. generic_online_page() still calls __free_pages_core(), which performs __ClearPageReserved(p). AFAIKS, this should not hurt. It is worth nothing that the users of online_page_callback_t might see a change. E.g., until now, pages not freed to the buddy by the HyperV balloonm were set PG_reserved until freed via generic_online_page(). Now, they would look like ordinarily allocated pages (refcount =3D=3D 1). This callback is used by the XEN balloon and the HyperV balloon. To not introduce any silent errors, keep marking the pages PG_reserved. We can most probably stop doing that, but have to double check if there are issues (e.g., offlining code aborts right away in has_unmovable_pages() when it runs into a PageReserved(page)) Update the documentation at various places in the MM core. There are three PageReserved() users that might be affected by this change. - drivers/staging/gasket/gasket_page_table.c:gasket_release_page() -> We might (unlikely) set SetPageDirty() on a ZONE_DEVICE page -> I assume "we don't care" - drivers/staging/kpc2000/kpc_dma/fileops.c:transfer_complete_cb() -> We might (unlikely) set SetPageDirty() on a ZONE_DEVICE page -> I assume "we don't care" - mm/usercopy.c: check_page_span() -> According to Dan, non-HMM ZONE_DEVICE usage excluded this code since commit 52f476a323f9 ("libnvdimm/pmem: Bypass CONFIG_HARDENED_USERCOPY overhead") -> It is unclear whether we rally cared about ZONE_DEVICE here (HMM) or simply about "PG_reserved". The worst thing that could happen is a false negative with CONFIG_HARDENED_USERCOPY we should be able to identify easily. -> There is a discussion to rip out that code completely -> I assume "not relevant" / "we don't care" I audited the other PageReserved() users. They don't affect ZONE_DEVICE: - mm/page_owner.c:pagetypeinfo_showmixedcount_print() -> Never called for ZONE_DEVICE, (+ pfn_to_online_page(pfn)) - mm/page_owner.c:init_pages_in_zone() -> Never called for ZONE_DEVICE (!populated_zone(zone)) - mm/page_ext.c:free_page_ext() -> Only a BUG_ON(PageReserved(page)), not relevant - mm/page_ext.c:has_unmovable_pages() -> Not releveant for ZONE_DEVICE - mm/page_ext.c:pfn_range_valid_contig() -> pfn_to_online_page() already guards us - mm/mempolicy.c:queue_pages_pte_range() -> vm_normal_page() checks against pte_devmap() - mm/memory-failure.c:hwpoison_user_mappings() -> Not reached via memory_failure() due to pfn_to_online_page() -> Also not reached indirectly via memory_failure_hugetlb() - mm/hugetlb.c:gather_bootmem_prealloc() -> Only a WARN_ON(PageReserved(page)), not relevant - kernel/power/snapshot.c:saveable_highmem_page() -> pfn_to_online_page() already guards us - kernel/power/snapshot.c:saveable_page() -> pfn_to_online_page() already guards us - fs/proc/task_mmu.c:can_gather_numa_stats() -> vm_normal_page() checks against pte_devmap() - fs/proc/task_mmu.c:can_gather_numa_stats_pmd -> vm_normal_page_pmd() checks against pte_devmap() - fs/proc/page.c:stable_page_flags() -> The reserved bit is simply copied, irrelevant - drivers/firmware/memmap.c:release_firmware_map_entry() -> really only a check to detect bootmem. Not relevant for ZONE_DEVICE - arch/ia64/kernel/mca_drv.c - arch/mips/mm/init.c - arch/mips/mm/ioremap.c - arch/nios2/mm/ioremap.c - arch/parisc/mm/ioremap.c - arch/sparc/mm/tlb.c - arch/xtensa/mm/cache.c -> No ZONE_DEVICE support - arch/powerpc/mm/init_64.c:vmemmap_free() -> Special-cases memmap on altmap -> Only a check for bootmem - arch/x86/kernel/alternative.c:__text_poke() -> Only a WARN_ON(!PageReserved(pages[0])) to verify it is bootmem - arch/x86/mm/init_64.c -> Only a check for bootmem Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Stephen Hemminger Cc: Sasha Levin Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini Cc: Andrew Morton Cc: Alexander Duyck Cc: Pavel Tatashin Cc: Vlastimil Babka Cc: Johannes Weiner Cc: Anthony Yznaga Cc: Michal Hocko Cc: Oscar Salvador Cc: Dan Williams Cc: Mel Gorman Cc: Mike Rapoport Cc: Anshuman Khandual Cc: Matt Sickler Cc: Kees Cook Suggested-by: Michal Hocko Signed-off-by: David Hildenbrand --- drivers/hv/hv_balloon.c | 6 ++++++ drivers/xen/balloon.c | 7 +++++++ include/linux/page-flags.h | 8 +------- mm/memory_hotplug.c | 17 +++++++---------- mm/page_alloc.c | 11 ----------- 5 files changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index c722079d3c24..3214b0ef5247 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -670,6 +670,12 @@ static struct notifier_block hv_memory_nb =3D { /* Check if the particular page is backed and can be onlined and online it= . */ static void hv_page_online_one(struct hv_hotadd_state *has, struct page *p= g) { + /* + * TODO: The core used to mark the pages reserved. Most probably + * we can stop doing that now. + */ + __SetPageReserved(pg); + if (!has_pfn_is_backed(has, page_to_pfn(pg))) { if (!PageOffline(pg)) __SetPageOffline(pg); diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 4f2e78a5e4db..af69f057913a 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -374,6 +374,13 @@ static void xen_online_page(struct page *page, unsigne= d int order) mutex_lock(&balloon_mutex); for (i =3D 0; i < size; i++) { p =3D pfn_to_page(start_pfn + i); + /* + * TODO: The core used to mark the pages reserved. Most probably + * we can stop doing that now. However, especially + * alloc_xenballooned_pages() left PG_reserved set + * on pages that can get mapped to user space. + */ + __SetPageReserved(p); balloon_append(p); } mutex_unlock(&balloon_mutex); diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 3b8e5c5f7e1f..e9a7465219d1 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -30,24 +30,18 @@ * - Pages falling into physical memory gaps - not IORESOURCE_SYSRAM. Tryi= ng * to read/write these pages might end badly. Don't touch! * - The zero page(s) - * - Pages not added to the page allocator when onlining a section because - * they were excluded via the online_page_callback() or because they are - * PG_hwpoison. * - Pages allocated in the context of kexec/kdump (loaded kernel image, * control pages, vmcoreinfo) * - MMIO/DMA pages. Some architectures don't allow to ioremap pages that = are * not marked PG_reserved (as they might be in use by somebody else who = does * not respect the caching strategy). - * - Pages part of an offline section (struct pages of offline sections sh= ould - * not be trusted as they will be initialized when first onlined). * - MCA pages on ia64 * - Pages holding CPU notes for POWER Firmware Assisted Dump - * - Device memory (e.g. PMEM, DAX, HMM) * Some PG_reserved pages will be excluded from the hibernation image. * PG_reserved does in general not hinder anybody from dumping or swapping * and is no longer required for remap_pfn_range(). ioremap might require = it. * Consequently, PG_reserved for a page mapped into user space can indicate - * the zero page, the vDSO, MMIO pages or device memory. + * the zero page, the vDSO, or MMIO pages. * * The PG_private bitflag is set on pagecache pages if they contain filesy= stem * specific data (which is normally at page->private). It can be used by diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 8d81730cf036..2714edce98dd 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -501,9 +501,7 @@ static void __remove_section(unsigned long pfn, unsigne= d long nr_pages, * @altmap: alternative device page map or %NULL if default memmap is used * * Generic helper function to remove section mappings and sysfs entries - * for the section of the memory we are removing. Caller needs to make - * sure that pages are marked reserved and zones are adjust properly by - * calling offline_pages(). + * for the section of the memory we are removing. */ void __remove_pages(unsigned long pfn, unsigned long nr_pages, struct vmem_altmap *altmap) @@ -584,9 +582,9 @@ static int online_pages_range(unsigned long start_pfn, = unsigned long nr_pages, int order; =20 /* - * Online the pages. The callback might decide to keep some pages - * PG_reserved (to add them to the buddy later), but we still account - * them as being online/belonging to this zone ("present"). + * Online the pages. The callback might decide to not free some pages + * (to add them to the buddy later), but we still account them as + * being online/belonging to this zone ("present"). */ for (pfn =3D start_pfn; pfn < end_pfn; pfn +=3D 1ul << order) { order =3D min(MAX_ORDER - 1, get_order(PFN_PHYS(end_pfn - pfn))); @@ -659,8 +657,7 @@ static void __meminit resize_pgdat_range(struct pglist_= data *pgdat, unsigned lon } /* * Associate the pfn range with the given zone, initializing the memmaps - * and resizing the pgdat/zone data to span the added pages. After this - * call, all affected pages are PG_reserved. + * and resizing the pgdat/zone data to span the added pages. */ void __ref move_pfn_range_to_zone(struct zone *zone, unsigned long start_p= fn, unsigned long nr_pages, struct vmem_altmap *altmap) @@ -684,8 +681,8 @@ void __ref move_pfn_range_to_zone(struct zone *zone, un= signed long start_pfn, /* * TODO now we have a visible range of pages which are not associated * with their zone properly. Not nice but set_pfnblock_flags_mask - * expects the zone spans the pfn range. All the pages in the range - * are reserved so nobody should be touching them so we should be safe + * expects the zone spans the pfn range. The sections are not yet + * marked online so nobody should be touching the memmap. */ memmap_init_zone(nr_pages, nid, zone_idx(zone), start_pfn, MEMMAP_HOTPLUG, altmap); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f9488efff680..aa6ecac27b68 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5927,8 +5927,6 @@ void __meminit memmap_init_zone(unsigned long size, i= nt nid, unsigned long zone, =20 page =3D pfn_to_page(pfn); __init_single_page(page, pfn, zone, nid); - if (context =3D=3D MEMMAP_HOTPLUG) - __SetPageReserved(page); =20 /* * Mark the block movable so that blocks are reserved for @@ -5980,15 +5978,6 @@ void __ref memmap_init_zone_device(struct zone *zone, =20 __init_single_page(page, pfn, zone_idx, nid); =20 - /* - * Mark page reserved as it will need to wait for onlining - * phase for it to be fully associated with a zone. - * - * We can use the non-atomic __set_bit operation for setting - * the flag as we are still initializing the pages. - */ - __SetPageReserved(page); - /* * ZONE_DEVICE pages union ->lru with a ->pgmap back pointer * and zone_device_data. It is a bug if a ZONE_DEVICE page is --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 06:53:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1571919336; cv=none; d=zoho.com; s=zohoarc; b=PiuUqQN6zn5YTbwrkPiSIOSrMK3yBjJwz0H65NvG+HHBq/eERO+/iU/R6dRIeItNLJGaMs0GFUCijoziQgmob+oK+4cPBzj+kZcDpX7af/WY/PmhZ7qEcnG5ZP1rsyvd7V+kCuLbRf+hjHDUu2EN7AHvdOOBPiSprmfASiyD49o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919336; 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=JNbpjHxA/zzBzbThMkK3m5jQqRIXmnxjai1tiHio3OU=; b=FXsGm3IgS9y4eR4P3Ly2ch4ZX370vu4X3xnD3GX+IcZ5hBKPqR8YwJbKzGpl/2qxypwez+GfIXTh8QxsbiY2j/gF67Rez3/XUgIelWF++XZ6PxiX29FVJ6PG8QJGxHGiNiDL4JG6B+k5rU6OM3UxNvpd2bUrISQ9uaKxwj4rWIY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1571919336520718.6670129264376; Thu, 24 Oct 2019 05:15:36 -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 1iNc0a-0005gc-82; Thu, 24 Oct 2019 12:14:28 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNc0Z-0005gH-EM for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 12:14:27 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.61]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id d0f2c718-f657-11e9-949f-12813bfff9fa; Thu, 24 Oct 2019 12:14:24 +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-18-37WSCG0IOc2aalj4O1vt1g-1; Thu, 24 Oct 2019 08:14:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D798B800D49; Thu, 24 Oct 2019 12:14:16 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F37C196B2; Thu, 24 Oct 2019 12:13:57 +0000 (UTC) X-Inumbo-ID: d0f2c718-f657-11e9-949f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571919263; 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=1YxG8LTmp2DdNmR96mx6EPMKm57sikpokfCgsqoqhbU=; b=Rfmec48jCcWV7+GY49SOXEBc6DNBXOvXSnbZwRzbqkwCsodsJafWLlRB/k6eGKCDuCcrkg VQCBo+I9ACRnOSaAyGY5byukiM6W7n5TEe1cU7IpGAFNfRqqd0D3vnvDhsUCJkEwu5iryB VdZXS8Q6d8x/UqEnLm6B2ra7Uy1OZK4= From: David Hildenbrand To: linux-kernel@vger.kernel.org Date: Thu, 24 Oct 2019 14:09:38 +0200 Message-Id: <20191024120938.11237-11-david@redhat.com> In-Reply-To: <20191024120938.11237-1-david@redhat.com> References: <20191024120938.11237-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 37WSCG0IOc2aalj4O1vt1g-1 X-Mimecast-Spam-Score: 0 Subject: [Xen-devel] [PATCH v1 10/10] mm/usercopy.c: Update comment in check_page_span() regarding ZONE_DEVICE 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: 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" , Dan Williams , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , "Matthew Wilcox \(Oracle\)" , Mike Rapoport , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Anthony Yznaga , Oscar Salvador , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , Sasha Levin , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Christophe Leroy , Mel Gorman , Cornelia Huck , Pavel Tatashin , Sean Christopherson , 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) ZONE_DEVICE (a.k.a. device memory) is no longer marked PG_reserved. Update the comment. While at it, make it match what the code is acutally doing (reject vs. accept). Cc: Kees Cook Cc: Andrew Morton Cc: "Isaac J. Manjarres" Cc: "Matthew Wilcox (Oracle)" Cc: Qian Cai Cc: Thomas Gleixner Signed-off-by: David Hildenbrand --- mm/usercopy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/usercopy.c b/mm/usercopy.c index 660717a1ea5c..80f254024c97 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -199,9 +199,9 @@ static inline void check_page_span(const void *ptr, uns= igned long n, return; =20 /* - * Reject if range is entirely either Reserved (i.e. special or - * device memory), or CMA. Otherwise, reject since the object spans - * several independently allocated pages. + * Accept if the range is entirely either Reserved ("special") or + * CMA. Otherwise, reject since the object spans several independently + * allocated pages. */ is_reserved =3D PageReserved(page); is_cma =3D is_migrate_cma_page(page); --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel