From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795083044; b=mR9XY1EiRUY3Q8t04/4Fa2ulOShYpHW/6ylaSjEy8kdTM8Ih13ELuW82NmBDEdaLhFR+ XtTvG6p7LeUNKHNYSTaJ0oIFWQgGl/ITj4g5nYHD+m1k7nI77ZakVhoxMCC2ullMb045e gU+uG2Vmo5KZ3D0takkwUT4brSH2+Cn88g9IXY8pXzZKoyFN3lvaJmPbqMgrFGxomumBA wjQY6Y7yP+bPxFA63Hp+cX8GStjCrTjSejjpc19DhveQrsfUUHnLiVxtt0//biKCNvdnp Whn+8jB85TZ+Gg/+lk8yrd/1+UFPAlCXIJG0J8V3ZBDWHxKKrssCeeT5E5L094+YsXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795083044; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:Content-Language:To:Cc:References: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=o0xJIki+mFoJUWoYjAhFxPBVjnzW6F1WhyTl0VK8FZs=; b=DHUEsw4rr7qBZ13UaoKZjk6qpi1O3MuWy0f+fE2pUrrbjVAq9CpRGauq+HqQ63JlzR/o rTwafU4m5ml/IyFsy4/Kc+F3IxoNc4XtptMvYJiOJIDaEA3Wt4GxoKncmzjJGTwgSmZ32 93oTAMNmXQGAzqfW1qSr7KkkS1HS/JG4rR9Zt99Rt61h/68wnCPAqhbQe4uvm/q5ONgTU HtzZdausBNakbQYPs9WNHlk/A8Zwmq/hnx8om1MTUn1U/2kG5FMKPIc7OPgXBGO9z3ZBu a2Jg9YmZqkYHmKN7/SxzS+nS07rROMVeqMAdZrz36ooFGpZd/1qJ5DoB2moIWV8/Q6Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=Q5XwbQpl; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7F48606A320; Thu, 19 Nov 2026 10:10:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D7F48606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=Q5XwbQpl Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 021D81575; Thu, 19 Nov 2026 02:10:40 -0800 (PST) Received: from [10.0.129.3] (Suzukis-MBP.cambridge.arm.com [10.0.129.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 90FB23F632; Thu, 19 Nov 2026 02:10:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1795083042; bh=7YWcBLhIPYqKWe2ix2RQNC66Zd0lpOfLCGPkdsJOsBM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Q5XwbQpl4Z1MWetRAjz0CoLEMc7Y0wB+bliAGEGpeV6ErsaD+ydzUiBaPjwO5jKrs LlqFQ54UaiKTsXHzDr16BV58dhQs/9gv5/7o1EOMNLdON/YbPP7A8pIzJRRaCBTSEb pBoo0+42pwwdHFFOu29tYezIaJbmqXPp6sfM/iK0= Message-ID: <120ad525-efa5-4129-9d97-fa6fa5db747f@arm.com> Date: Thu, 19 Nov 2026 10:10:38 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot Content-Language: en-GB To: Steven Price , Fuad Tabba , Ackerley Tng , Sean Christopherson Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve , WeiLin.Chang@arm.com, Lorenzo Pieralisi , Kohei Enju References: <20261116164358.142785-1-steven.price@arm.com> <20261116164358.142785-2-steven.price@arm.com> <6bb490cd-ebbe-41d7-adf3-d6eaf0e53478@arm.com> <8a095a42-662a-416d-a5d7-79e10161201c@arm.com> From: Suzuki K Poulose In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: Ackerley, Sean On 18/11/2026 15:18, Steven Price wrote: > On 18/11/2026 12:04, Suzuki K Poulose wrote: >> On 18/11/2026 11:14, Steven Price wrote: >>> On 18/11/2026 10:34, Suzuki K Poulose wrote: >>>> Hi Steven >>>> >>>> On 17/11/2026 14:05, Fuad Tabba wrote: >>>>> Hi Steven, >>>>> >>>>> On Mon, 16 Nov 2026 16:43:47 +0000, Steven Price >>>>> wrote: >>>>>> Check the guest_memfd backing file when deciding whether an arm64 >>>>>> memslot has mappable memory rather than checking whether the slot is >>>>>> gmem only. A public helper function is added to be able to reuse the >>>>>> static kvm_gmem_supports_mmap() function. >>>>> >>>>> nit: could the message say why this is needed? It's a no-op until >>>>> patch 8 defines kvm_arch_has_private_mem(), which makes every >>>>> guest_memfd slot gmem-only. >>>> >>>> I still don't understand why this is needed. For arm64 we have always >>>> prevented guest_memfd without MMAP, in kvm_arch_prepare_memory_region(). >>> >>> Fuad is correct, this isn't really needed until patch 8. Patch 8 defines >>> kvm_arch_has_private_mem() - that means that gmem_in_place_conversion >>> becomes true (see include/linux/kvm_host.h). That in turn means that >> >>> every guest_memfd slot is KVM_MEMSLOT_GMEM_ONLY including slots backed >>> by a file without mmap support. >> >> But we dont support slots without MMAP anyways even without this series. >>  So, does it really matter for arm64 ? > > So ChatGPT produced the attached test. It creates a non-mappable gmem > and tries to add it to a normal (non-realm/non-pkvm) VM. With v7.4-rc1 > it is rejected. However without this patch it succeeds. > > The issue is that gmem_in_place_conversion changes the behaviour for > normal VMs. I see, thanks Steven. For context: Arm64 currently (without inplace conversion support) only allows GMEM with MMAP flags only and relies on kvm_slot_gmem_only() to detect that the GMEM has MMAP flag. But, when we enable inplace conversion, we can't reliably reject the slots by kvm_slot_gmem_only(), because all GMEM slots are marked GMEM only with inplace conversion. Also, from the API Documentation, "When the KVM MMU performs a PFN lookup to service a guest fault, the fault will always be consumed from guest_memfd, regardless of whether it is a shared or a private fault (unless in-place conversion is disabled and the backing guest_memfd does not have the GUEST_MEMFD_FLAG_MMAP flag set)." So, in effect, with in-place conversion enabled a KVM_CREATE_GUEST_MEMFD without GUEST_MEMFD_FLAG_MMAP is an error and thats what this patch is trying to fix in arm64 KVM. The question is: 1) Should this be fixed ? How does TDX/SNP support older VMMs with inplace conversion ? What was the conclusion on this breakage ? 2) If it should be, then shouldn't it be done in kvm_gmem_create() ? Suzuki > > Thanks, > Steve >