Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3473808rdh; Mon, 27 Nov 2023 15:36:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNP124t6fI5no3BmG6gyX90v/27dSZ2TB65lx/Iwux0p5HLsoCVpl1LzLgghp7BOsWiQ65 X-Received: by 2002:a17:902:bd46:b0:1cf:896f:d6c5 with SMTP id b6-20020a170902bd4600b001cf896fd6c5mr12739536plx.41.1701128181326; Mon, 27 Nov 2023 15:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701128181; cv=none; d=google.com; s=arc-20160816; b=D3916mIQtAy9sTUdNv/Dx6UFAp6v6GN3YVnJExfgGYiAMM0agbLd4ubAh/mY3YUQQD m9Q+t6n6rmchkDm+j6eJO1xbTvKJVkz/gQR8+CntR50uCF7ayn7hIuv8j0HzCAdqwHwA T7gnf+L9AJvP1OSKc7wuA7G1ySaEUoCiqZe12X2NHYbIkVe4/RZk+OCC2eyCSrexDMSq 5a0qKbYKIW98xboqlohiyhkYuXLtvVAgjw3vM8H5ekmyIzeScXRv5Xp1X8m1zMzpLNVG W+L6wOmRU3jcCOvNP8UoYYOVpQ1mrxMyV97al2WBePeVHtdyUoYNzWA7/kFyCQJu58mi S4IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=l2m9WeXChb3IZcdkKWz2g1bAMA6uELaN8nkmuyBZmHQ=; fh=u0GXVbvFBkfkZJWtNNusiS2pWbJHl8vZp2yIVPEetlE=; b=dPhcadE7PyZhjSMjTEixn105fXZ34d+nMZ0oriev6ohPx4D54fBPpMM2b/O1azXOs+ XCIiYnvnsiDqOiQTf3EloQ75LP3II0rTVQiiO2I4IgPeiZHpn6oQe5183eGmB2biN+tn 6phMiYdWLGykEBymqm/jnYDoddnGXAfyREX2kSfoMaj1sKf88uC6MApmsSlIqow7jHOh bANZIMnfha/PgMWBHz6X/O/Zm7qnart2qRurEyvyxNIx1duOgQjyysxKH1I4KpIikkaM U+zXPOOWTw3Dkp1SZTVgAchqgc1nTbya1s+FCU3lQlDNrpeTipQRKIqRCYlFRtTqPK54 vnig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JJ51m+5w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i1-20020a170902cf0100b001cf50e0508bsi11598043plg.506.2023.11.27.15.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 15:36:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JJ51m+5w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D92448090FA3; Mon, 27 Nov 2023 15:36:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233644AbjK0XgG (ORCPT + 99 others); Mon, 27 Nov 2023 18:36:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbjK0XgD (ORCPT ); Mon, 27 Nov 2023 18:36:03 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 984D61B5 for ; Mon, 27 Nov 2023 15:36:09 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-285d331c6f7so2002361a91.0 for ; Mon, 27 Nov 2023 15:36:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701128169; x=1701732969; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=l2m9WeXChb3IZcdkKWz2g1bAMA6uELaN8nkmuyBZmHQ=; b=JJ51m+5wRnTP7vn03VCHFIfTvAw0xvgRojQ6u5JK931ViOOx9HO8zWPrCjvp1Ou7t6 hc6vBHZ8Ob95+Tx49Yoxrx43E+duJ1T45hzXkEY4laEQfreEoDvJZSTdhtGL2bUlw2nx ZIqcfGRr5rDdBdJJB1q4akp2y4t9ZVkfadWwVDODx8BBFWXXCFWPz2UW20exsOG1HmtN 7Op7jaJGXIzgL+yIcnruHcNn2jy+BISi1if2XFnTbaxj593IZ1PT5H8alRSVpoG+UwF2 YnICVbQ5CsDms0b5RGUzqbvqaq1ixWv4vjooSsZxJqMrDNygV1jMuoc50hnan9p53kFr 7ZOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701128169; x=1701732969; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l2m9WeXChb3IZcdkKWz2g1bAMA6uELaN8nkmuyBZmHQ=; b=lt8YfPmSGj73vyMFyIZncG9orSDH7ny8gMoFBXqN1ZuWOzns3tc6Dys/BcvZ6aSuW8 caDSAo6wx4KNRNMMGdrNIg1OOgLoPh/9YWUb1O/NZavdAehnJcBdf53/GbK3CYBoGBgT zJ0jTFs4S2PMF+UGJGVD0IsfH0xho1ZcTUEaZSD0AqZijPpqY3Woy1WfEShTOyNvAIMV HG3vBc1PC4N+Ob8VRBJFej3GiOFpQCnxmIPvpankZR0NVM9n/y8r6vRSy+3dxh3S9NoB aTgPmDRiihf9OuakhVeykk/jo2t8KIalHhSqNYlAL2vXZie0XAyeiZOsAC1AGrDWReg9 gRRA== X-Gm-Message-State: AOJu0Yxx4vxPYiTpPcrL+DE/pRDkK231Qz4A/L+Kp2L5uRbKV5B6FKFK tI2twzYsRKNaCMgQHPaOCyGiQIcftaI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:88:b0:285:860c:3359 with SMTP id bb8-20020a17090b008800b00285860c3359mr2734111pjb.4.1701128169103; Mon, 27 Nov 2023 15:36:09 -0800 (PST) Date: Mon, 27 Nov 2023 15:36:07 -0800 In-Reply-To: Mime-Version: 1.0 References: <20231121180223.12484-1-paul@xen.org> <20231121180223.12484-6-paul@xen.org> Message-ID: Subject: Re: [PATCH v8 05/15] KVM: pfncache: remove KVM_GUEST_USES_PFN usage From: Sean Christopherson To: David Woodhouse Cc: Paul Durrant , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 27 Nov 2023 15:36:20 -0800 (PST) On Tue, Nov 21, 2023, David Woodhouse wrote: > On Tue, 2023-11-21 at 18:02 +0000, Paul Durrant wrote: > > From: Paul Durrant > > > > As noted in [1] the KVM_GUEST_USES_PFN usage flag is never set by any > > callers of kvm_gpc_init(), which also makes the 'vcpu' argument redundant. > > Moreover, all existing callers specify KVM_HOST_USES_PFN so the usage > > check in hva_to_pfn_retry() and hence the 'usage' argument to > > kvm_gpc_init() are also redundant. > > Remove the pfn_cache_usage enumeration and remove the redundant arguments, > > fields of struct gfn_to_hva_cache, and all the related code. > > > > [1] https://lore.kernel.org/all/ZQiR8IpqOZrOpzHC@google.com/ > > > > Signed-off-by: Paul Durrant > > I think it's https://lore.kernel.org/all/ZBEEQtmtNPaEqU1i@google.com/ Yeah, that's the more important link. > which is the key reference. I'm not sure I'm 100% on board, but I never > got round to replying to Sean's email because it was one of those "put > up or shut up situations" and I didn't have the bandwidth to actually > write the code to prove my point. > > I think it *is* important to support non-pinned pages. There's a reason > we even made the vapic page migratable. We want to support memory > hotplug, we want to cope with machine checks telling us to move certain > pages (which I suppose is memory hotplug). See commit 38b9917350cb > ("kvm: vmx: Implement set_apic_access_page_addr") for example. The vAPIC page is slightly different in that it effectively never opened a window for page migration, i.e. once a vCPU was created that page was stuck. For nested virtualization pages, the probability of being able to migrate a page at any given time might be relatively low, but it's extremely unlikely for a page to be pinned for the entire lifetime of a (L1) VM. > I agree that in the first round of the nVMX code there were bugs. And > sure, of *course* it isn't sufficient to wire up the invalidation > without either a KVM_REQ_SOMETHIMG to put it back, or just a *check* on > the corresponding gpc on the way back into the guest. We'd have worked > that out. Maybe. I spent most of a day, maybe longer, hacking at the nVMX code and was unable to get line of sight to an end result that I felt would be worth pursuing. I'm definitely not saying it's impossible, and I'm not dead set against re-introducing KVM_GUEST_USES_PFN or similar, but a complete solution crosses the threshold where it's unreasonable to ask/expect someone to pick up the work in order to get their code/series merged. Which is effectively what you said below, I just wanted to explain why I'm pushing to remove KVM_GUEST_USES_PFN, and to say that if you or someone else were to write the code it wouldn't be an automatic nak. > And yes, the gpc has had bugs as we implemented it, but the point was > that we got to something which *is* working, and forms a usable > building block. > > So I'm not really sold on the idea of ditching KVM_GUEST_USES_PFN. I > think we could get it working, and I think it's worth it. But my > opinion is worth very little unless I express it in 'diff -up' form > instead of prose, and reverting this particular patch is the least of > my barriers to doing so, so reluctantly...