Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp82557pxv; Thu, 24 Jun 2021 03:22:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymxECKVtn46oILeJmzii2W+Wz8j6UKU09EPp+pFbQT/qNq2gsS1/QCYOcRSu3bRdw+G/zg X-Received: by 2002:a17:906:c799:: with SMTP id cw25mr4492542ejb.173.1624530148370; Thu, 24 Jun 2021 03:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624530148; cv=none; d=google.com; s=arc-20160816; b=NPRRQoJTaioNQ+GMG2Q58xM6Vv0w/GMmmyFPD7Gr54yq/jCWTycZ30GbtEWpUo12Am qAAOOM4VSaSkf1OEFm3VbLRgZOBwa/lwItsDE7jAEXSoRcrxQbIcWhYXA866fvY/h3Iv XG9KJPWsytYrRxbKd9EHa2HFVsBeUm88KDb991pR5yAFXBuQcgQ142jFG8oM/HBXEZHt PT9m31DQlI7Z/OR307ZJKFbcg3AW0MkYdWepLpOqnfP62EZ0yQ3j0rHUeXxrCn5bxuyI 7duy/BJl9T4PMSWIdm+QSFYjP5XXcz7Qpfvxuy5Wz3zp4WM5rOg4nd9FDYQAqj5wk6RO txaw== 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:from:references :cc:to:subject:dkim-signature; bh=oKXkBJKG47HF5zZ+T34yALxUp2DCGSnnk7HiRaaGJBk=; b=XjQzjrdrwCSKHDd2Fs6I16oXTUbGqOJEYns3sjhBGKuaf2Bpy/7ttoaQDdxLioe4th Tv3uzXSu4ld+X63kUs2h6etUq1fEnJBSIaP8BBmNmuQK5msRxE4u+LvMkEXRt07QV+Nn B7WrixIDA9UqPqeX76exhizxXA4GNVmRMJ6J1nWjthVX9UshaT7ZqZByL+ZrYKtQ2Ff2 8x5EGGG5giazboxfjeBGDybPmtXhHIN4nmDOPdAVoqk6hC2slOUTaDsSas1viIcZzgKw iLPAeHW2JX0NcQnr9SsPES8yUfSIHvyMjGAGfF9MItPUXCTBoR6LRz5fRWNEwDLNBYWH CQiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OyOYIhkF; 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 s26si2408552ejm.748.2021.06.24.03.22.04; Thu, 24 Jun 2021 03:22:28 -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=OyOYIhkF; 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 S232111AbhFXKX2 (ORCPT + 99 others); Thu, 24 Jun 2021 06:23:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54055 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbhFXKX0 (ORCPT ); Thu, 24 Jun 2021 06:23:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624530067; 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=oKXkBJKG47HF5zZ+T34yALxUp2DCGSnnk7HiRaaGJBk=; b=OyOYIhkFlD72RXa4ApycBznJ8h/A4rxQkZYFz4zqo5MtkH1geetKyPWMfBX0ch0jh7q3Lg qnz7zGgvlyQUIzPbypEimxNaD0+gpIcj0/R+UxQuP9AGOacLVchr1yQsGXdxC66zyvRmgz DHDojJLPq7Dlhzp9U4RjDK0rp/NxRo4= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-500-t3N2-tNlOdqsRDkUTqFnIg-1; Thu, 24 Jun 2021 06:21:05 -0400 X-MC-Unique: t3N2-tNlOdqsRDkUTqFnIg-1 Received: by mail-ej1-f69.google.com with SMTP id z6-20020a17090665c6b02903700252d1ccso1825894ejn.10 for ; Thu, 24 Jun 2021 03:21:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oKXkBJKG47HF5zZ+T34yALxUp2DCGSnnk7HiRaaGJBk=; b=hych8KnTmprct82ROgDQ8EBmHG9KbL2Pujm10QyxRCQcxFigWUcnNnBevvKb4N7aY0 NqtZd7O5b05RW81HGKgFpwGqcbL1fETcSeK6GZvsmzl4ovMpcGbmHO2yIYq722LCvddH YrPx3CAhCnqeKbXk2/wt0QZy+hix8cznZ2iUAI0pOxToLmk/898apuNcAdwWjG4DCK1U SzR3fsfjPP+y/5yaW088UiHxpmkbOLLg3sltcszuLoectBCawmt5gc0o4xsYnmZVicFX eTyi2/kdQHCS4f6Avp4okmjTXGsRAA8/hDcvTfrywpkYaYn0vczXAtn10oknalsREl2Q J7Ig== X-Gm-Message-State: AOAM533VswjTNFGMOQkMa559OD+J4GjHShqn4IfdrRdN46vnDS9Q//td fh0ZOMuOVb3FJpz3Yi7UCjzuwzNX4O+GiS26ZpIYk2mb7l8JnO56347WgPcdc29GFS7Xlm9e8Ol WXxsvAhnFOS/AxBEHOEsr15D4 X-Received: by 2002:a05:6402:220d:: with SMTP id cq13mr6001637edb.214.1624530064585; Thu, 24 Jun 2021 03:21:04 -0700 (PDT) X-Received: by 2002:a05:6402:220d:: with SMTP id cq13mr6001609edb.214.1624530064420; Thu, 24 Jun 2021 03:21:04 -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 e7sm493571ejm.93.2021.06.24.03.21.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Jun 2021 03:21:03 -0700 (PDT) Subject: Re: [PATCH 2/6] KVM: mmu: also return page from gfn_to_pfn 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 , Suzuki K Poulose , Vitaly Kuznetsov , Wanpeng Li , Will Deacon References: <20210624035749.4054934-1-stevensd@google.com> <20210624035749.4054934-3-stevensd@google.com> <1624524331.zsin3qejl9.astroid@bobo.none> <201b68a7-10ea-d656-0c1e-5511b1f22674@redhat.com> <1624528342.s2ezcyp90x.astroid@bobo.none> <1624529635.75a1ann91v.astroid@bobo.none> From: Paolo Bonzini Message-ID: Date: Thu, 24 Jun 2021 12:21:01 +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: <1624529635.75a1ann91v.astroid@bobo.none> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/06/21 12:17, Nicholas Piggin wrote: >> If all callers were updated that is one thing, but from the changelog >> it sounds like that would not happen and there would be some gfn_to_pfn >> users left over. >> >> But yes in the end you would either need to make gfn_to_pfn never return >> a page found via follow_pte, or change all callers to the new way. If >> the plan is for the latter then I guess that's fine. > > Actually in that case anyway I don't see the need -- the existence of > gfn_to_pfn is enough to know it might be buggy. It can just as easily > be grepped for as kvm_pfn_page_unwrap. Sure, but that would leave us with longer function names (gfn_to_pfn_page* instead of gfn_to_pfn*). So the "safe" use is the one that looks worse and the unsafe use is the one that looks safe. > And are gfn_to_page cases also > vulernable to the same issue? No, they're just broken for the VM_IO|VM_PFNMAP case. Paolo > So I think it could be marked deprecated or something if not everything > will be converted in the one series, and don't need to touch all that > arch code with this patch.