Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp322266pxv; Thu, 24 Jun 2021 08:39:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKBtyBVcCOwfteCndwsE9ikV6t7n2Jx0g0bM2Th7o10i9BGxBhAy3G6+8kG8HF11kXBenm X-Received: by 2002:a17:907:2d07:: with SMTP id gs7mr5865232ejc.375.1624549184034; Thu, 24 Jun 2021 08:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624549184; cv=none; d=google.com; s=arc-20160816; b=X4wf1rr/SWj4hDCeX5DkbuNOhSOMdql2+AqgSyLcHxrU7/s+hMR4ZK9/OCIsRwXEUF VzgZZ0qioVTIwBQ9KuTBA2GBzpY1AMVw1eU4jSlN5ZPCGnUyfJSsN+JKwW8EpjdTvIic Hit+TckSokjTsT9YNpC7Bvt5BRcS3uYJXHyn2pP3eYQKJQ4mIOvqMe6tK2DV1BNRMXqp e3YnJCLNPj7o58hPv1NllHYzMJTmq+5JtVgXoDbOMfeQ0zSNxI/Mu7LT/0ZnqLcg6CMQ 1QcTcTttd0lHZYRgjLm+Lyyo57Zmb3Vv4ksCHPSK7M1FyaJbNyc6dJEcVyCQKjON+PlX 5haw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=f6k4ykVaPXFxqKCeveqsqgjZTsHJh+2Hx0FU9Hu8Shk=; b=kAh+jEjXPavbN+zLehowYqTaOV7L2m1kgZwPeZiQyJxPVSBcc9Wad19vzbA/kZ4oqx PLyyZhWpLdSSZWtj/Kgw4TFn1nCiUFtUBDMsT5r17pxyCwGcz/jNeneyvf8QJrLdvtGS heX4k5yeSnkMkSVMvKuiVfdog2ZmuYWzgY2oUGRyT/TIkQhneu+E3y42rezKgXrndUM6 D7FZewQai5jDzw0w57b0aIGcptcs2Nj+adfDxcTDadw8gnSs6v/wAO7PqfdtdRs8tIz8 /LuYX/B3dNaRSye7puv2Mygl7aj90Lu+y7fYh+wTkAScFZ8Ft+NZ3ru7gSkGU3vt4jyG pUZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CzWgx2D4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 18si3103325ejj.476.2021.06.24.08.39.19; Thu, 24 Jun 2021 08:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CzWgx2D4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232324AbhFXPhu (ORCPT + 99 others); Thu, 24 Jun 2021 11:37:50 -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-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