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.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 7B91DC49EA6 for ; Thu, 24 Jun 2021 15:36:06 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 BE11660234 for ; Thu, 24 Jun 2021 15:36:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE11660234 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4G9kkD4zDCz3bnl for ; Fri, 25 Jun 2021 01:36:04 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CzWgx2D4; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZBx2tblY; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=216.205.24.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=pbonzini@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CzWgx2D4; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZBx2tblY; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4G9kjj3fq0z300T for ; Fri, 25 Jun 2021 01:35:34 +1000 (AEST) 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= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624548931; 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=ZBx2tblYKfmR4+9rG4NOwghzYxEOd7Mmx5Gn0vYSog7hKciWxWX4+Pdl6FZR1XLdZPc2pO MW7CiIwm6uEl/1E/Q9j53Du43FZmbal+Xi4KZCJAIE1hSQ1DFwIHgnXIXWc3YZ9vgMErJq wu2hpoiNvzSUm94KYiwFUKDyPBSRb5U= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-QZNPaVDqOZKjtIf0Jis2pA-1; Thu, 24 Jun 2021 11:35:29 -0400 X-MC-Unique: QZNPaVDqOZKjtIf0Jis2pA-1 Received: by mail-wr1-f70.google.com with SMTP id x5-20020adff0c50000b029011a7be832b7so2328206wro.18 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=KoXQXZDBARSD8OrmCPFo6Ijc1llv7tX6e6HZYPGTGOeEBHpaigyHw/UVII+SLg+kYM ZjJ91tXlPiKWZIG/oiy+Hq7CLyxBrue6cpd80nW84S3M7/9llZIDQnf1bQhaPao42hJn N7X+Oj3u6Qlyy88sKUpsWVPIp06+wTxCwKptWfrim8LTSxeBJKtp4LTmWpqxW8JAOpoj xJgMrUWBcWsoArc4Tb1sBh8+9SF7cBiZhggnC5nGOp4g2ya7g6feGJBp1PJ0ibSZkGgG kCiAwYbPnCr34uHnHk0s3Lyip9THJQ+7EP8MtjejLtw6hby4LdOLyFxnAGMcGdl7Z3s9 e7Sw== X-Gm-Message-State: AOAM530Y8FFeoLde+8xOkNc0cwLhgmm+I1foacdTcp7irMTnTd1CuZwd pjWsh01Hy6c4NKb8ctJaPky46rPjGaVmaQudVk7XTs4C2F4HbGCkf+c+6n7QKi5/yu3Za8tbQWU nhyPK/QR5Ny0jd8yCbWsQ1gK+rw== X-Received: by 2002:a05:6000:1251:: with SMTP id j17mr5373898wrx.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 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> 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-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wanpeng Li , kvm@vger.kernel.org, David Stevens , Alexandru Elisei , intel-gfx@lists.freedesktop.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, kvmarm@lists.cs.columbia.edu, Will Deacon , Suzuki K Poulose , James Morse , kvm-ppc@vger.kernel.org, Sean Christopherson , Vitaly Kuznetsov , linux-mips@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Jim Mattson Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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