From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7A584766A7 for ; Wed, 19 Aug 2026 14:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787149685; cv=none; b=hu5+OFE8eg9hXR7V1oV1ROAQjSmtLRFcjowjHEYJT7sClK/KyeM0ngJ/8Hrls0QipE7JAtF4jYT88UGDBKvKg3NR8ai6xJYBbS9uSOzopwy9kGuhr6/Vmau6QfDRluh+GbrmfgQ4OkQ1ixLjG5vsO7DNTNcc/CXaovgzH0Kzhas= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787149685; c=relaxed/simple; bh=HeVS9XsCAoIM35TlkEqB62UzYjPlpdl4VrCCpvJjbC0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WxWjNxDyMlTObzyx6c0udGEkXA25imacg+6jupd0C9D37a0DgOtnbMvZhOfD6if+skT6EmNdJs9tr0ZxwNTaify/sLdn36e4rJdo70ula9DDwAsmM07F3Gi3JMXI16oReBb1hNtLejsGWR4xnzv4zOftPzM1wEZUlH4yyjPac60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=i1dEBH1V; arc=none smtp.client-ip=209.85.214.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="i1dEBH1V" Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2cf6acd760cso13471095ad.3 for ; Wed, 19 Aug 2026 07:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787149671; x=1787754471; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NVWozadQO7xAVs0CxEChlrBPcTWGOFFwMoQqLAdxyTc=; b=i1dEBH1Vu2tmvfiGgKfbaMRuuG4hnJzAX7c/OBC6zh9r/PLZYit3NqaMcuhn/ZkpQ3 PM+MfVSrmQOZw5ugXRok23WkxBCooOsRJphHrMnEa9AYiR7C4610zhZiekDZ6ad63CcI Mp2EbpkcvI4xYcLM9mgY/i0PwzN4Uq/D/GnaoRdA7LhW56GzNnA7gBE2kER19CNlMEGP U6kQKvGX4OqxXfady66TOU2CD8OVsB+9bgAij/2Y7iyiCmhWBwHeNqSRhJ2II6Xs753h IcAkLe2a6S6QNtSJ1uJPWZc8YEeoGBcNMF22IhOpVTA0l2MrZp2N1XH/IdzlMxr8AEBM godQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787149671; x=1787754471; h=content-type: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:content-type; bh=NVWozadQO7xAVs0CxEChlrBPcTWGOFFwMoQqLAdxyTc=; b=epTDhCqsY6jnRRcsSjkXzaXLWDPm+T/GrrQQ+15N8XYXo8E4nI6Ewr+g+h+XIaYeNx SLv8cWmd454WnrYKeA08gQQVDp9N/NfIlcaeo9m2bL7VfbxGIwwFtaLPI1pONwjCF5qw fJA1c8C2QunqqcJBMzgNDsyEfwBjBVFxXi3VQuhIMAf5MUi7kCIVhP5ntK4XTQCGPawo 14AlPLS5FmWNhs0EGK2aFssRbAyYAFLDvRA42TzsKV/3PnmEpa3pzIBQfzMRRV+OGW7V al7Wl/PnH+pTDjvksjLPW9VTy4SKrLlILs1wNf9I6FqoeWwGxYzr+IhpOUPBPdmF3yDH ccjw== X-Forwarded-Encrypted: i=1; AHgh+Rp1G8uQgJJW1MZAPCZsJO+hd8yeS5K5B+H+Cz5VBMkksc5r+0VOkZ410FKLg2DViX3h8Um17qaj3du4koM=@vger.kernel.org X-Gm-Message-State: AOJu0YzVYGfwrQcfAgUTtfXZU8kkZiWiil4l/RQMukn6YWTOxjCRZfLi iINYdiMvQ9SkyJ4Mw+TeECMJkmG5iA9RaArbUxqxlSWRF9YsF/TILBheVLqhIkwBi8oFUy8MFxq Ngm6hIg== X-Received: from plos6.prod.google.com ([2002:a17:903:1ac6:b0:2ca:ddbd:a19c]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f792:b0:2d3:6fac:d67c with SMTP id d9443c01a7336-2d5ff7c849dmr91033865ad.10.1787149671281; Wed, 19 Aug 2026 07:27:51 -0700 (PDT) Date: Wed, 19 Aug 2026 07:27:50 -0700 In-Reply-To: <7c368424-80f9-4491-8578-d26ccc7dc835@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260818-gmem-no-return-page-v2-0-5298f42d49bb@google.com> <807b4b9f-b1ca-4b5c-bc9e-22bf0637ba33@kernel.org> <7c368424-80f9-4491-8578-d26ccc7dc835@kernel.org> Message-ID: Subject: Re: [PATCH v2 0/4] Stop returning struct page from guest_memfd PFN lookup From: Sean Christopherson To: "David Hildenbrand (Arm)" , g@google.com Cc: Ackerley Tng , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ashish Kalra , Michael Roth , Brijesh Singh , Marc Zyngier , Oliver Upton , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Fuad Tabba , Yan Zhao , Rick P Edgecombe , Vishal Annapurve , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Content-Type: text/plain; charset="us-ascii" On Wed, Aug 19, 2026, David Hildenbrand (Arm) wrote: > On 8/18/26 21:55, Sean Christopherson wrote: > > On Tue, Aug 18, 2026, David Hildenbrand (Arm) wrote: > >> On 8/18/26 11:15, Ackerley Tng wrote: > >>> KVM currently expects kvm_gmem_get_pfn() to return a refcounted struct > >>> page. Callers (such as x86 TDP MMU, arm64 Stage-2 fault handler, and SEV-SNP > >>> VMSA / RMP handlers) hold this refcount across page fault handling. > >>> > >>> Holding a page refcount across fault handling is problematic for guest_memfd. > >>> In-place memory conversions between confidential computing shared and private > >>> states inspect folio refcounts to ensure exclusive ownership by guest_memfd. A > >>> concurrent guest page fault taking a reference on the folio causes conversions > >>> to fail due to an elevated refcount. > >> > >> Right. Won't we still, at least temporarily, grab a reference while looking up > >> the folio in the page cache, or will we be preventing that concurrent race with > >> locking? > > > > The latter. What I want to aim for is that if the relevant guest_memfd range > > has never been mmap()'d and there are no memory failures, then conversion is > > guaranteed to not fail due to elevated refcounts. > > > > Or to put it a different way, I want KVM's ABI to be that pausing vCPU is *NOT* > > required to perform an in-place conversion. > > Having the VM access a page that is currently under conversion (triggered by the > VM) should not be the common case, no? Except, prefaulting, of course. "not be the common case" is likely an understatement. In practice, I don't it will happen outside of guest bugs and KVM testcases. It's the testcases that I want to "unblock" though. If we commit to never having to pause vCPUs, even if the guest is misbehaving, then that gives us deterministic behavior we can validate, i.e. a way to detect similar regressions in the future. I don't expect any regressions would be super problematic, but being able to treat any failed conversion as a KVM bug (for the curated setup) mitigates the risk of death by a thousand cuts, i.e. reduces the risk of gradually degrading conversion performance because more and more transient references being taken by KVM.