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 1AABAC49EAB for ; Thu, 24 Jun 2021 15:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0488C613DA for ; Thu, 24 Jun 2021 15:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232109AbhFXPhv (ORCPT ); Thu, 24 Jun 2021 11:37:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33017 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbhFXPhu (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-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-LvDdVF0fM5m-veF00-b02g-1; Thu, 24 Jun 2021 11:35:29 -0400 X-MC-Unique: LvDdVF0fM5m-veF00-b02g-1 Received: by mail-wm1-f69.google.com with SMTP id o3-20020a05600c5103b02901aeb7a4ac06so3214412wms.5 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=Ai6k9fwRpxUeGW4Xhg2qpLGq5uw/49li74ow2pPZXQPLAfygI0K4NdEkxOCWli8JBp 5lob9K0pcPzVsaezSlGLyxQj0RBWJxdQmw8m3M+yv+lqwcrC8vIJ+C9vSV+xYted7guQ BYmFxl09QSxcMEMEY+3WZbREJLueoH2bdy8noo/HlL3APUmm8bPLqvbz7WdIx5n7YTnw NTIuBVT5+OSAms77C9hOZnNMlvNBzLNBJoVwGqqgs9QDEAcU+VfRlvzr0Ipnpj8JY3Lt Qu6bhf3SpTRBe9kKBSyeT/FK2c7rU1Ty6F4F+cDjlaE9fH/jJ4Xf/QZ+iXc7CMPcG2ww 6KKw== X-Gm-Message-State: AOAM533oByTUYCgUEvA8f8zVZXZ3DsX7u4hJYhAyeydMayxWU6RZEgr1 KiaK6QlT6LpGC4rIweWowlgoUNIRkUD+zRrbyAjfvjRPG4IIUcfr1i3PZfOljRpioLvU9kvVTml BcPqlZJ8iq7UYVP2jOaboii1E X-Received: by 2002:a05:6000:1251:: with SMTP id j17mr5373906wrx.122.1624548927957; 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: linux-kernel@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