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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E6A6C4167B for ; Mon, 27 Nov 2023 23:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233711AbjK0XgH (ORCPT ); Mon, 27 Nov 2023 18:36:07 -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-Google-Smtp-Source: AGHT+IEl4S0gbL0JXiTGTFFkSpfut1kGjfX9yALNxNMX7MfX3x5UbA+DNYzB4IO60o0GRmpObK+5rcrVVuk= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...