From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 A1148246770 for ; Wed, 26 Aug 2026 02:29:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787711355; cv=none; b=GLTE6zbChz9Vq8wQDQCOjfOaA+yuKJEa8+zrX6VuIpZeuWXqPr3DueYCvJPLzqFbB+UHvLj7cJcnqkY5tZIZ3wYuxcS94C7VLSOVSSlBQ4Un/bKFNgHbYEeGaJdaEdK0/KZwOErqEw5moiSXkVmIzr+JZ35PvrKK+JuQVJkdvTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787711355; c=relaxed/simple; bh=jytyOnxKug/0HATBzAcgvdrubIDuZNK62vbz3KdkDXw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=n8/KQ0C6f0bojtF2wqbprfuOUqCHMCyNtt4GKysFlqvqbxajsqKJxqyAp4ApKFPidZRebsG8eh/LHTSdRW/OLTmd/gNxJQKzPGVUpNI9Y9QV+DHylF4PVgRnqCMGrlb8/S9HdJsoiUbz231GG6tBtHXdecYgqF+V1IHM2XIumtg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kvbNCQa4; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kvbNCQa4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787711353; x=1819247353; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=jytyOnxKug/0HATBzAcgvdrubIDuZNK62vbz3KdkDXw=; b=kvbNCQa46tLQa61t+kmcpeTJntNBaXqwediHd8WUGoaa7acWVVu0expW /GPsowCiT+C7HbiB4TB9TX8xjmTmXBQAeCa2LjpOn4jIfK1ycRbQTq+91 jn29ch9hCbcIeFSf4Qalzix4NPG3BBaVMfDQAJHiExxpyz7XlHg7NZpcl w9681d6kPjksJz5NGXtrzaHeijgLEhyzUYjSzRvdcz8WOXRipN/ZPvgHD p0qASdUeaJBLkS3Z+cRFMandyImkJcVB5vUWX+dtRPY4Bl+ZbLltBaDS1 do1rh8Yvk/N46y3UsDJVqJWjMWg9QFUDGb8EIjkN7gOLyL0H51Pp1wNAl g==; X-CSE-ConnectionGUID: h+UV+oiBT12gf3ocdtX7iA== X-CSE-MsgGUID: wGm6a377TMqzilKQgQX58g== X-IronPort-AV: E=McAfee;i="6800,10657,11886"; a="98522506" X-IronPort-AV: E=Sophos;i="6.25,243,1779174000"; d="scan'208";a="98522506" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2026 19:29:13 -0700 X-CSE-ConnectionGUID: Kq9+eMnnQVKhBINXbsGToA== X-CSE-MsgGUID: f17Ncq3BQG6gkWw4k95B4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,243,1779174000"; d="scan'208";a="266865838" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.124.240.119]) ([10.124.240.119]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2026 19:28:59 -0700 Message-ID: Date: Wed, 26 Aug 2026 10:28:56 +0800 Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v10 09/41] KVM: guest_memfd: Filter both shared and private when invalidating To: Sean Christopherson , Michael Roth Cc: Ackerley Tng , Suzuki K Poulose , "David Hildenbrand (Arm)" , aik@amd.com, andrew.jones@linux.dev, binbin.wu@linux.intel.com, brauner@kernel.org, chao.p.peng@linux.intel.com, jmattson@google.com, jthoughton@google.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, tabba@google.com, willy@infradead.org, wyihan@google.com, yan.y.zhao@intel.com, forkloop@google.com, pratyush@kernel.org, aneesh.kumar@kernel.org, liam@infradead.org, Paolo Bonzini , 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, Vlastimil Babka , 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: <20260807-gmem-inplace-conversion-v10-0-2fc18ee6d3ba@google.com> <20260807-gmem-inplace-conversion-v10-9-2fc18ee6d3ba@google.com> <13ca60c6-e154-4397-8092-09f861e90fe0@kernel.org> <7eba513d-cdae-4832-abac-038dcdd88517@intel.com> Content-Language: en-US From: Xiaoyao Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/26/2026 2:55 AM, Sean Christopherson wrote: > On Tue, Aug 25, 2026, Michael Roth wrote: >> On Wed, Aug 26, 2026 at 12:13:47AM +0800, Xiaoyao Li wrote: >>> On 8/20/2026 9:32 AM, Sean Christopherson wrote: >>>> And vice versa, a PUNCH_HOLE on a SHARED gmem (if userspace is >>>> using an INIT_SHARED gmem for the shared branch of a memslot) could invalidate the >>>> PRIVATE mappings (of a different gmem instance). >>> >>> I'm wondering now how this could happen. >>> >>> the requirement for PUNCH_HOLE on gmem to trigger mapping invalidation is >>> the gmem is bound with the memslot. But how can a memslot bound with two >>> gmem instances? >> >> I think this is for when userspace uses an mmap'able guest_memfd instance >> to handle shared memory, and a 'normal' guest_memfd instance for private >> memory. Each instance is bound to the same memslot/GPA range, and >> KVM_SET_MEMORY_ATTRIBUTES handles switching between the 2. What I didn't figure out is exactly how the two gmem instances are bound to the same memslot. The case I can imagine is 1. create gmem1 with GUEST_MEMFD_FLAG_MMAP and GUEST_MEMFD_FLAG_INIT_SHARED, and get fd1. mmap the returned fd1 to get a hva. 2. create gmem2 to get a fd2. 3. call KVM_SET_USER_MEMORY_REGION2 with KVM_MEM_GUEST_MEMFD flag. Pass the @hva from 1) to 'userspace_addr' field and pass the gmem fd2 to 'guest_memfd' field. However, with this case, only gmem2 is bound to the memslot while gmem1 is not. Following PUNCH_HOLE on gmem1 doesn't invalidate any mappings because the f->bindings of it is empty. Do I miss anything?