Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp97256pxv; Thu, 24 Jun 2021 03:45:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcMrVcnu3tIGe7XbvZXD6pgbReDdCkUvjZ2Ny1diMCHfTrEDuON/GQ/XBvyO1X125/1RE4 X-Received: by 2002:a17:906:744:: with SMTP id z4mr4682476ejb.347.1624531534636; Thu, 24 Jun 2021 03:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624531534; cv=none; d=google.com; s=arc-20160816; b=Dbgjb+b10mwRIhV6qDcOrn69p46ftgYgr2+3/UkbL9TCflrEl8VkydyHGVcc46oryz ql3F6l/m1V7DTX6kX7lopWX4g2Q5hRXOnuELXC+rh/MdbqchF802rcC0I9yLlqmFxr3D M5jQzL5ooIG51QYkZ8G04D9ahMthyJ2KwQm3251Omo0BARz9rlbfjSOdiBrj/u5d+jzQ JqXWsB6rTXozztyjMmSaixnvYZS2lKJfk3uU/xXI2cX0NgH25nux3wfkzR1PdsRB7t4Q L6vd8Uor70L6ZJPH0casqZsUJrMutZr8/wiypTHmX74fx6/nblCewLAqf2/xkX0ybY/a pDSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id :mime-version:in-reply-to:references:cc:to:subject:from:date :dkim-signature; bh=NfjdhOW72m4TGpvzWGEQF11KzSsneVbaVBvFK0bGPzo=; b=X8QBeeZvqcb81i9cw0cHF75N895a/96sNoj5nRu87Pqs/KH1FPm2q0NVa41MzcmuwF I+i+sgCSljMTZG2dfOAJvsFUjk13s/GOpmMHKk+HbY4rLz9JyU4BextFCfvG21jWCfVZ 0SCLU5lGBi9O2xD2XPXwC0elkNyaIo5qQV+ZUocrB+jl82pVerudcFEpe/Sn3w2p5WsK dN0ok5GG5xP1dUSOjj3I5oob2Zofn4R4oLdC61jS7p0kyWGom552GFaPhgWf2a54gt7o tCc4Rr4P0UlHacvc6T2BUezbCZ/U1w/UZkq6D2G+z3h/VMpxJY9Rx1u7lkR4Kgh5nyrJ Zn7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kt+9hz5Z; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si2435066ejj.647.2021.06.24.03.45.09; Thu, 24 Jun 2021 03:45:34 -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=@gmail.com header.s=20161025 header.b=Kt+9hz5Z; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbhFXKog (ORCPT + 99 others); Thu, 24 Jun 2021 06:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbhFXKof (ORCPT ); Thu, 24 Jun 2021 06:44:35 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07C19C061574; Thu, 24 Jun 2021 03:42:15 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id v7so4395729pgl.2; Thu, 24 Jun 2021 03:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=NfjdhOW72m4TGpvzWGEQF11KzSsneVbaVBvFK0bGPzo=; b=Kt+9hz5Z8hf17MTaP2NEbCNsixEB/2vtcneDIWMxInZE3wFpBTCY4arVW85yk4tRHF qWXnzq5TbY8JfmQrKqxmZnou8HmT8i1seCjd1BlC3DaEQNjDAwV+HQjRqrh2wSC5wL59 gRrb2rxjfZldQEn+6eMb0tmL7unUZmTBjbxFxwf6fUug4isZHK1CcpQ0getq8GAd87FC 3RcDqKD/Mv0yWnn2UAF2jMZ1K/PXC5Gqwy+wDcve3LXPzWTqm+dcHR3tVukvmCrbGHtj N0va4eRcYEBOnrKc/XVLBME0xL1myho/N5KENcJl2Jx0DUZHv582U2/2wqKp+nzNi87p llKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=NfjdhOW72m4TGpvzWGEQF11KzSsneVbaVBvFK0bGPzo=; b=EKM9Hoz1AkYt7M5Z8lb96YYyA8+ChZoTU3UvnS28Ve0OHmzOAGr5v6nmUUxx5d4k/C A2rixeFSTZ2Ogos1U17EGbCwRGslN0y/n7IbXBTDUHIgYGjppLHFyLJQBBSZRpOcOoyL OC6hmX6XZ+FW9VgxolIgj38mbp94pFIZxMdpGBJQ1/+W8u/6560BOY6MiYAwbeWlkTEM 4iFjxyo1oj1ItoDcVyH6LoZwH5ceFIV5HmgUs7Gf1uScUZP+Yr/GRDlYYNSLP3PFWiY5 SFenRUUJV17Et/DP0Idohjsc4gHD3fuhR5EZw51dNRb59av/vJjrg91mS0eH95D01ycm atzA== X-Gm-Message-State: AOAM533y2vDZ/uDrjEl52nQ0ExR1bqpZlwUZpZoBve0t9NTP5OvWE6qJ M7P+jzPzjuLEb086POtGg9I= X-Received: by 2002:a63:586:: with SMTP id 128mr4140080pgf.366.1624531334522; Thu, 24 Jun 2021 03:42:14 -0700 (PDT) Received: from localhost (60-242-147-73.tpgi.com.au. [60.242.147.73]) by smtp.gmail.com with ESMTPSA id i8sm2522609pfq.165.2021.06.24.03.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 03:42:14 -0700 (PDT) Date: Thu, 24 Jun 2021 20:42:08 +1000 From: Nicholas Piggin Subject: Re: [PATCH 2/6] KVM: mmu: also return page from gfn_to_pfn To: Aleksandar Markovic , Huacai Chen , Marc Zyngier , Paul Mackerras , Paolo Bonzini , 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> In-Reply-To: MIME-Version: 1.0 Message-Id: <1624531085.fax3fcqpgc.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Excerpts from Paolo Bonzini's message of June 24, 2021 8:21 pm: > 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 retur= n >>> 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. >=20 > Sure, but that would leave us with longer function names=20 > (gfn_to_pfn_page* instead of gfn_to_pfn*). So the "safe" use is the one=20 > that looks worse and the unsafe use is the one that looks safe. The churn isn't justified because of function name length. Choose g2pp()=20 if you want a non-descriptive but short name. The existing name isn't good anyway because it not only looks up a pfn=20 but also a page, and more importantly it gets a ref on the page. The name should be changed if you introduce a new API. >> And are gfn_to_page cases also >> vulernable to the same issue? >=20 > No, they're just broken for the VM_IO|VM_PFNMAP case. No they aren't vulnerable, or they are vunlerable but also broken in=20 other cases? Thanks, Nick