From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95B13C49EAB for ; Thu, 24 Jun 2021 12:02:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6ACEA613DA for ; Thu, 24 Jun 2021 12:02:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ACEA613DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:Subject: From:References:Cc:To:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fcQXIfiRJug2xFR/GWygvjOwavFa0yyjIgH0ihoa7J4=; b=DK4tZV6deIus1lZ9zL8NKOi+Y8 RwDvjq6+V3lcfwCQEFRoYYQvVjQivjH6fQPkx8d66qsKAootw7HX/8ScIqcAqdAGMxgZQ5P+Vaoy7 iUSbe8+Qzt1YTSDPI6teL+KPiY5xSPjG3O/vpOjjH1z3OHkcW2nvzRdM2hv/+0LMiZpBR42SgLHI9 pKTvrRFvQCEKmBOXvuKotTtWwzylf7gT1PLML/iT1p7ADjQPKUQUhvuo3Ky9eWraDeLgvqF3WFjUf KRcMDcZD1jXVzWcd/ZlrfWsnkFvMldN7xQTFHLAc5lK7NldcXVZ9twsx81Zk8EQzN3okr4Cavzx4V NO0IWsFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwO2B-00EUKa-BM; Thu, 24 Jun 2021 12:00:39 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwO27-00EUJR-Be for linux-arm-kernel@lists.infradead.org; Thu, 24 Jun 2021 12:00:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624536032; 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=avGojGcO92NTULuhKarR1IMbTxAu/KipAq8BEw7I0Ko=; b=NwH7B5NWjpeo7xHuBdxiGRVZh4xvFr+1lFCIJJITHPUdkX1qQF6HaOwh7QLG0Nd8FkYAvF xESavrCoW3oJDHBQuPpw3tbG2YBsPxiC6jO70F5rBsHr1BY5umW0PjAB5zZ5EoQX6wnH1p zktQA9JdpEloy+r80cSPmHzIxlXLtTM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-S_KYk56VMIOZIFQy6bYFgg-1; Thu, 24 Jun 2021 08:00:31 -0400 X-MC-Unique: S_KYk56VMIOZIFQy6bYFgg-1 Received: by mail-wr1-f69.google.com with SMTP id v8-20020a5d43c80000b029011a94e052f2so2132251wrr.2 for ; Thu, 24 Jun 2021 05:00:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=avGojGcO92NTULuhKarR1IMbTxAu/KipAq8BEw7I0Ko=; b=ALDbIGfg3gFw7xHVAH0RaJIkq8Prpex2m0h0HpKkTdTgfKWKfsgKvtkGwipwM7jCMO eUBWMCE9/hXod3+TXmkD9kEYMbMy4KvYRhADxaVpyLD5uSDmBJqT4FRVGdTepx2gZiVe TWnfsf65ugiRMXntEnxZdIPzfU/nySG+D/y16nYOkyCp06WftBBP5XcZenX+tlK82Yc+ 4N+XegNvg8a52L5TKGBLxibpMxFSL4bfedHQrbHSQ53zCcKf0pRo+l0ygxdsjit1P1nh VCSI3odKSC4TFvO5F7Ydx3heQa2eakoB8TCdQ6jsd+65o9mqdaXFgUnQg7yTXoVIslR7 GS5g== X-Gm-Message-State: AOAM5307/inKOw1mm8J4VnHbutzEq65rWV7FPjIsW4HJRrpF6pFjqH7L t4NuOAbZAANP3z0wnIO/twVAquODf5+hy+26v/N6GQp6/rsMCqFWL8BhXk6gkfUO4KEgueAKT5h lsoB1rDIlwZFlUbUn81n1674mkOjXNBnDBC8= X-Received: by 2002:a1c:f215:: with SMTP id s21mr3879317wmc.179.1624536030029; Thu, 24 Jun 2021 05:00:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXFCnAp+BCIAB50GwF3Py3d9h4g0enz3/eZSVNkNtDC1Z07h1ecnwnq+OHmfePVB6B9P4IuQ== X-Received: by 2002:a1c:f215:: with SMTP id s21mr3879281wmc.179.1624536029808; Thu, 24 Jun 2021 05:00:29 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o2sm3074141wrp.53.2021.06.24.05.00.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Jun 2021 05:00:29 -0700 (PDT) To: Nicholas Piggin , Aleksandar Markovic , Huacai Chen , Marc Zyngier , Paul Mackerras , David Stevens , Zhenyu Wang , Zhi Wang Cc: Alexandru Elisei , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, James Morse , Jim Mattson , Joerg Roedel , kvmarm@lists.cs.columbia.edu, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Sean Christopherson , David Stevens , Suzuki K Poulose , Vitaly Kuznetsov , Wanpeng Li , Will Deacon References: <20210624035749.4054934-1-stevensd@google.com> <1624530624.8jff1f4u11.astroid@bobo.none> <1624534759.nj0ylor2eh.astroid@bobo.none> From: Paolo Bonzini Subject: Re: [PATCH 0/6] KVM: Remove uses of struct page from x86 and arm64 MMU Message-ID: Date: Thu, 24 Jun 2021 14:00:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <1624534759.nj0ylor2eh.astroid@bobo.none> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_050035_516252_24C82506 X-CRM114-Status: GOOD ( 15.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 24/06/21 13:42, Nicholas Piggin wrote: > +static int kvm_try_get_pfn(kvm_pfn_t pfn) > +{ > + if (kvm_is_reserved_pfn(pfn)) > + return 1; So !pfn_valid would always return true. Yeah, this should work and is certainly appealing! Paolo > + return get_page_unless_zero(pfn_to_page(pfn)); > +} > + > static int hva_to_pfn_remapped(struct vm_area_struct *vma, > unsigned long addr, bool *async, > bool write_fault, bool *writable, > @@ -2104,13 +2111,21 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma, > * Whoever called remap_pfn_range is also going to call e.g. > * unmap_mapping_range before the underlying pages are freed, > * causing a call to our MMU notifier. > + * > + * Certain IO or PFNMAP mappings can be backed with valid > + * struct pages, but be allocated without refcounting e.g., > + * tail pages of non-compound higher order allocations, which > + * would then underflow the refcount when the caller does the > + * required put_page. Don't allow those pages here. > */ > - kvm_get_pfn(pfn); > + if (!kvm_try_get_pfn(pfn)) > + r = -EFAULT; > > out: > pte_unmap_unlock(ptep, ptl); > *p_pfn = pfn; > - return 0; > + > + return r; > } > > /* > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel