From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7E6B2EEE85; Wed, 2 Sep 2026 03:27:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788319642; cv=none; b=qc8NUeOw46Uj3ZY1Uum1w5wJqU1lxp9RaKpqvHl3Nyyp6MNzGOH7mVkl6Yl9SsXqUxz/mYZ6Y6mPrW+WqQlj/kiNHDi85saKFkno9yPpybLwMn5l+RfEbUuWFBxuQibI8F7BSRdQLNCueG/qN8c0rOKeiqlhTTQkEYj+erRKp1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788319642; c=relaxed/simple; bh=TUJHEOBl3U7XWWW3kQmwva+BBRdNdtlcHkUtD6k5bq4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tmY/s50iCpOHooqBs24AzP20p7qnaZbqKsmjTlaEAwA7xO1Gdg+UKbb/zHVryAezEqw/iGRUeQBtBBQ5EwXFYQXwWdibQ3WslkWOs6Lt6oa2gZN1BGAGNQdxsL+lF82nIWEJUbiR5YIXvXCEi8A2EnMjIl9D05wjCocNqyNTng8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kZI5kPyk; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kZI5kPyk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1788319639; x=1819855639; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=TUJHEOBl3U7XWWW3kQmwva+BBRdNdtlcHkUtD6k5bq4=; b=kZI5kPykEsGy+8P0A11yINzZeuTaSxSbdA05TOKIpaxOjFm88AcZGhpl l6fk3bm7CmSGZkpVoirtkuj76quEcQ8nN51PvAwX++Camdzl3N1qPO6gT K+GL1zdZe8sqA3CIJn6XSFwiBV9ZGE/u2pHGgSkqcCKnMIhxMIPzBv/Iv Bof4S+dQNH1xdP1iRZhFCudsV0AkA7Prrh0mva0v9qtvqC8Cr3G3kJxrH mEIPRpN7gPUHUgECJ2iL0Ub4QJKhrjoU7YWof7B04HK54ZiiJLzz36Xnx zSPUnW8KdMUi+IILNKiCg2Na9fXqEUM3lRgu5RExYUC8wTRhXGJj9DBJQ w==; X-CSE-ConnectionGUID: wumDXX6mS8Sjvs7B83xmjg== X-CSE-MsgGUID: bv3I+bh7TR2cjqySbuPb6Q== X-IronPort-AV: E=McAfee;i="6800,10657,11893"; a="76317666" X-IronPort-AV: E=Sophos;i="6.25,257,1779174000"; d="scan'208";a="76317666" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2026 20:27:17 -0700 X-CSE-ConnectionGUID: AGeB1hPEQT+hgLB03500lw== X-CSE-MsgGUID: TM+113I7RAS5hRz8VK5CNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,257,1779174000"; d="scan'208";a="266677621" Received: from unknown (HELO [10.238.2.33]) ([10.238.2.33]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2026 20:27:03 -0700 Message-ID: Date: Wed, 2 Sep 2026 11:27:00 +0800 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v12 11/45] KVM: guest_memfd: Invalidate both SHARED and PRIVATE mappings for in-place conversions To: ackerleytng@google.com Cc: aik@amd.com, andrew.jones@linux.dev, brauner@kernel.org, chao.p.peng@linux.intel.com, david@kernel.org, jmattson@google.com, jthoughton@google.com, michael.roth@amd.com, oupton@kernel.org, pankaj.gupta@amd.com, qperret@google.com, rick.p.edgecombe@intel.com, rientjes@google.com, shivankg@amd.com, steven.price@arm.com, willy@infradead.org, wyihan@google.com, yan.y.zhao@intel.com, forkloop@google.com, pratyush@kernel.org, suzuki.poulose@arm.com, aneesh.kumar@kernel.org, liam@infradead.org, Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Shuah Khan , Shuah Khan , Vishal Annapurve , Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Youngjun Park , Qi Zheng , Shakeel Butt , Kiryl Shutsemau , Baoquan He , Jason Gunthorpe , John Hubbard , Peter Xu , tarunsahu@google.com, Randy Dunlap , Lorenzo Stoakes , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Fuad Tabba , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev References: <20260830-gmem-inplace-conversion-v12-0-85e5fd25252a@google.com> <20260830-gmem-inplace-conversion-v12-11-85e5fd25252a@google.com> Content-Language: en-US From: Binbin Wu In-Reply-To: <20260830-gmem-inplace-conversion-v12-11-85e5fd25252a@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 8/31/2026 8:25 AM, Ackerley Tng via B4 Relay wrote: > From: Sean Christopherson > > When removing one or more folios from a guest_memfd instance, invalidate > both SHARED and PRIVATE mappings if in-place conversion is enabled, because > stating the obvious, KVM needs to ensure that all mappings to the folio(s) > are dropped. > > Opportunistically rename the helper to capture that it returns a filter for > all gfns in anticipation of zapping only the previous mapping types on > conversion. I.e. when doing in-place conversion to PRIVATE, only SHARED > mappings need to be zapped (ignoring that KVM would ideally not invalidate > ranges whose attributes aren't changing in the first place). > > Note, precisely zapping only the possible mapping types when in-place > conversion is disabled is important for functional correctness, not just > for performance. Specifically, if KVM zaps both when SHARED vs. PRIVATE is > tracked per-VM, then a PUNCH_HOLE operation on a PRIVATE guest_memfd will > incorrectly zap SHARED mappings that have nothing to do with that gmem > instance (because they're mapped via a VMA, not a gmem fd). > > The incorrect over-zapping of SHARED memory that doesn't belong to the gmem > fd requesting the zapping will be resolved in a later patch, where, if > in-place conversion is enabled, KVM will use both shared and private memory > from the guest_memfd. If both shared and private memory are from the > guest_memfd, invalidation will only zap memory belonging to the given gmem > instance. > > Signed-off-by: Sean Christopherson > Signed-off-by: Ackerley Tng Reviewed-by: Binbin Wu