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=-12.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 AE3EFC49EA7 for ; Thu, 24 Jun 2021 15:35:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B4BC60234 for ; Thu, 24 Jun 2021 15:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232350AbhFXPhv (ORCPT ); Thu, 24 Jun 2021 11:37:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57344 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232109AbhFXPhu (ORCPT ); Thu, 24 Jun 2021 11:37:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624548930; 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=f6k4ykVaPXFxqKCeveqsqgjZTsHJh+2Hx0FU9Hu8Shk=; b=CzWgx2D41CtewkNoKfSXlHNvHr4JzTaydpUFctZ4grhohiyPOOiZM03jcOk+BqcQY9PARI ND/EiZ7OUbRRvzed7FFSGmmjCFYZnkRwlObmggnrscauZJ4LXoRq8lHxJhyJVtNv037ugs MALhEc0j8q3/V50B+B5aP17iCj4dO/Y= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-VXI788-YP1Ck1TJRwRnGtA-1; Thu, 24 Jun 2021 11:35:29 -0400 X-MC-Unique: VXI788-YP1Ck1TJRwRnGtA-1 Received: by mail-wr1-f72.google.com with SMTP id d8-20020adfef880000b029011a9391927aso2317801wro.22 for ; Thu, 24 Jun 2021 08:35:28 -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=f6k4ykVaPXFxqKCeveqsqgjZTsHJh+2Hx0FU9Hu8Shk=; b=TuhbXlZrZA0DWosS5lyhdRUDXmlwJ9plmrn/8fxpc9k9MliF5lrGopv+2tPTXyxctU atwclaVesHMNnBPUDKi4GsNot0ml0D1NX3jctQeAz3qrdanR5DlYQkFZ2g+3sziPn9sn /cOqSWSYe9hPasTv9n+XGs4KUjIZ0rKAGj4L+U2AI2JU5Vz2a197CZlQvf8k0cVe9+25 jDTRwLWPoxzf/3G2znxPsi2GFYIkrPJkxQ/S8tQeqIxMN7nDl4pA3tMN/JCR+nprN6h+ Cb1QqNIfh3eHjQMVZkF76mpTxyjJcAwiA3QGypBLOQC0ixWzpu3xjyV3LoD4/j3AyZ63 6JQg== X-Gm-Message-State: AOAM5309RXw8lbQV+XDERE+nzZGG2y9ppYnPurHY8qIRLqCE2BaCsXXC 7Mo+FYPAc2CubyAWbp7g20mNHY3++x7oDbUSs8D83WbyLdzYKngU/57s6IMGPpGRxYZ4kiBhaFN OaZlfLw/qQg2x X-Received: by 2002:a05:6000:1251:: with SMTP id j17mr5373890wrx.122.1624548927956; Thu, 24 Jun 2021 08:35:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBnDqu4vf3bAIylFJkD7JiEEmgRW9T3VoP4swdNx5pmdzHboAZtCJNJi7bVPTY8V2i+hs/AQ== X-Received: by 2002:a05:6000:1251:: with SMTP id j17mr5373864wrx.122.1624548927675; Thu, 24 Jun 2021 08:35:27 -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 v18sm4013288wrv.24.2021.06.24.08.35.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Jun 2021 08:35:27 -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> <0d3a699a-15eb-9f1b-0735-79d14736f38c@redhat.com> <1624539354.6zggpdrdbw.astroid@bobo.none> From: Paolo Bonzini Subject: Re: [PATCH 0/6] KVM: Remove uses of struct page from x86 and arm64 MMU Message-ID: <81d99029-ec40-19c5-5647-20607d78dab0@redhat.com> Date: Thu, 24 Jun 2021 17:35:25 +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: <1624539354.6zggpdrdbw.astroid@bobo.none> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 24/06/21 14:57, Nicholas Piggin wrote: > KVM: Fix page ref underflow for regions with valid but non-refcounted pages It doesn't really fix the underflow, it disallows mapping them in the first place. Since in principle things can break, I'd rather be explicit, so let's go with "KVM: do not allow mapping valid but non-reference-counted pages". > It's possible to create a region which maps valid but non-refcounted > pages (e.g., tail pages of non-compound higher order allocations). These > host pages can then be returned by gfn_to_page, gfn_to_pfn, etc., family > of APIs, which take a reference to the page, which takes it from 0 to 1. > When the reference is dropped, this will free the page incorrectly. > > Fix this by only taking a reference on the page if it was non-zero, s/on the page/on valid pages/ (makes clear that invalid pages are fine without refcounting). Thank you *so* much, I'm awful at Linux mm. Paolo > which indicates it is participating in normal refcounting (and can be > released with put_page). > > Signed-off-by: Nicholas Piggin