Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3498877rwd; Mon, 22 May 2023 15:02:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7fOKxWF3Y88M2+69oz8jjjcXgioEPVCrU86g0f8taZTgxEc+waKuJs9MEZHg8uKr29Slyr X-Received: by 2002:a05:6a00:1783:b0:64d:2841:8380 with SMTP id s3-20020a056a00178300b0064d28418380mr15693740pfg.22.1684792977900; Mon, 22 May 2023 15:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684792977; cv=none; d=google.com; s=arc-20160816; b=nYKrF/4o34qLE8XOLYR4mXMimcM2EERlyDOfMibsG3oA72DUroDjCAWR5W9A0y2iVJ yOy8KpK8hyh/EYAPhapgZOkTsym7v8LX7AHKNAtrhpr7I1cpl/5hU30PKz4WaYo5Hh7I SzvTyU3jX2WfS4oj1RgAsPAMK3xf/UdLRWSwwjcToIgr31CgRoYjtoPtB5xk3vvlGCZi wN+222PoXcRczN7xiIHbtwvBKjKtH53TTn9pPmFuueoT5rq93cMBzbB14o4cXDb1SzEl oMFSJcSOrD3tLmzOIVwpDjy2N7qS3EV2XmAD5uPtmJzSQ6cddD/S55XLxr83DUSKrXyB 3JwA== 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=lsrdrfpStLHLCMcnUFm2bSNiOQJ8DFjC7VWw2vxFB9U=; b=E9iiZNcDi2M4/gLZBDXtspj9O2IV9qEg0wCwyi0V7Wf62R8jbbzqy6rvHCnrgJMjfp FeP4KYsGsArY9vxf2dGdwJ9nYhfp8Ytk6FO8r/95rmg67s58W8oOidEmnoDzRkKfcAex EmSiSG3tHi5Ex8KeO8Lpftt4+ckoZvJuKB3mCr+Wz4wDTThCE+y7kbGn2PK+PGhWojCj ypclTpTRSjnPUAzPuZE/b2dKzrPQ9F28ZgYAvfby/rp5hdnC5sH1JSj7apRpNDdU/lnw i8FSBrHsD63C7eUEZ004TxgS7q/dYpnbeScYxzQxVvaPu0GmeWnvDr1Xga520mKJ4eK3 pAuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3tTDxTYN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a637e16000000b0052cc0b8d59dsi5219585pgc.798.2023.05.22.15.02.43; Mon, 22 May 2023 15:02:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3tTDxTYN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234169AbjEVVzJ (ORCPT + 99 others); Mon, 22 May 2023 17:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbjEVVzI (ORCPT ); Mon, 22 May 2023 17:55:08 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54AB8102 for ; Mon, 22 May 2023 14:55:07 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-52855ba7539so3521774a12.3 for ; Mon, 22 May 2023 14:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684792507; x=1687384507; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lsrdrfpStLHLCMcnUFm2bSNiOQJ8DFjC7VWw2vxFB9U=; b=3tTDxTYNGWf9angAoyiEj35tUIWKL6KNh6Tt+rSkge5LajeXEwtweh7tj3xiQTSc38 iv+rkHwLQur/ja0cpDHOZ4HdUpKv1e4ZFNi5BLvyQGW8LXWLxpL0CZ76idAI0vUmIqfO zT1xmizSSaeQnl+nfygCxJLtB7GZ92jHfMSG05m8baSg+6EE8g/xWSFsfAwCfx6dWvIj am6E5D7S3pKxpYKnVaUdxfqmZpzjbAdBttvgQ7IVHZAgClLc2YYIGCNLIGKSUvOX1Asp HZOlJXIqNRWXxIlTOczhsApaxyJJGELiCb7nAWOj/62KnAYg8rOLdWg8YxcGxQ9FlmC0 rc2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684792507; x=1687384507; 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=lsrdrfpStLHLCMcnUFm2bSNiOQJ8DFjC7VWw2vxFB9U=; b=fVB4zGd/c+um9kh7Ws0bpZxsQol+pXkji7uVwGODlPZddOfoF/bZmf68MW3XYvmTB9 0Vc25dia9hZGKBqdD6+bDVB5HvpUW6xpvp3SfXnu1vupUF6S+vnvTGQn5I/Cx1I/82Ae F5stJb4cjISlts4YYWKrE/5KVGYIyDS3oovRAcoYaSKeIQN2AfaUK9xOn+8RINedu5P1 oPClBTJpwg++kymhxEmeh99qiAIi1V2cbUQ3eSiOUrXwHy3m9nvJboSkU4M66ZhebdeT 3tBSJooc+B2CzyqF3GIbjwQ4GwtSlOHYqF7xXRz7eiUYnT7iEj1ugzCjE1pqc2XFT0JW kVsA== X-Gm-Message-State: AC+VfDxI3JFddVk7FYrMSo+BEIIgWI4WvslIF5ihJ2Ut4P/0FjyIhq3d 0Iy8TbbDGSMNOVdzPlaYJ7Q5o2ihcPs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:22c4:b0:1ac:4e96:cd22 with SMTP id y4-20020a17090322c400b001ac4e96cd22mr2951472plg.5.1684792506826; Mon, 22 May 2023 14:55:06 -0700 (PDT) Date: Mon, 22 May 2023 14:55:05 -0700 In-Reply-To: <20230330085802.2414466-5-stevensd@google.com> Mime-Version: 1.0 References: <20230330085802.2414466-1-stevensd@google.com> <20230330085802.2414466-5-stevensd@google.com> Message-ID: Subject: Re: [PATCH v6 4/4] KVM: mmu: remove over-aggressive warnings From: Sean Christopherson To: David Stevens Cc: Marc Zyngier , Oliver Upton , Paolo Bonzini , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham 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 On Thu, Mar 30, 2023, David Stevens wrote: > From: David Stevens > > Remove two warnings that require ref counts for pages to be non-zero, as > mapped pfns from follow_pfn may not have an initialized ref count. This patch needs to be moved earlier, e.g. if just this patch is reverted, these WARNs will fire on a guest with non-refcounted memory. The shortlog and changelog also need to be reworded. The shortlog in particular is misleading, as the the WARNs aren't overly agressive _in the current code base_, but rather are invalidated by KVM allowing non-refcounted struct page memory to be mapped into the guest. Lastly, as I mentioned in previous versions, I would like to keep the sanity check if possible. But this time, I have a concrete idea :-) When installing a SPTE that points at a refcounted page, set a flag stating as much. Then use the flag to assert that the page has an elevate refcount whenever KVM is operating on the page. It'll require some additional plumbing changes, e.g. to tell make_spte() that the pfn is refcounted, but the actual code should be straightforward. Actually, we should make that a requirement to allow an arch to get non-refcounted struct page memory: the arch must be able to keep track which pages are/aren't refcounted. That'll disallow your GPU use case with 32-bit x86 host kernels (we're out of software bits in PAE SPTEs), but I can't imaging anyone cares. Then I believe we can make that support mutually exclusive with kvm_pfn_to_refcounted_page(), because all of the kvm_follow_pfn() users will know (and remember) that the pfn is backed by a refcounted page.