Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796173768; b=OKV/JVUS5gciIHwaiMDchrfZ8nYkwuXXUYpv/3nl4SwKLES4PEwK19AUSQ2Nm03IUXSj 2DWOexCUGDE1iswynLz2agg8QMiuP4K7xhVVWE171VgsYs6QmHHl66EX3dp+bNC8YVmi9 I7N1Xj0/omaVDzqCAgKAsKhwOFl+9nwje4EnYxNSc+hOfZYuOm5RUS5BOIbC4aFBeiFxd 7CY0xMo9df6XnbK/aWDVdEulV730nvvUDbu70OTk2cjmmIo3vty/RnTik6lkZtr5Mypm2 JXlZwkPJ5D90XhZrkoi3f2IWh7f62EC+bDIDh0glhPNlfG0ewC0E3exITjWBgybqj8w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796173768; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=g/kWKb9oZusK72C6OJcw0UM4QUThZkRWvvE3svgxpso=; b=cp/4aUKScWGqJkKowmY3Xanf6nlkygrFUXb7VmzxawN+Wx8Dno8OZiGfT/y6RUj56iVt hCKpWat0G/zKY9YmrhiD1hz1u+XDV6Iaf7gyX0YtfxYWE8cs/A1PlmYSFv1+8OlUbJck2 /rg8/LRhudt5OfishGk0SSYZvD+HBxoMMVQkmg4Nrg5D21RlmKqa8dL4wdejehs9U/R+E cEumMbC3NjezWT9jzeG/npL/cxnSP1k/DL7PVOPsOwAmYAKyR9uOz29RL4wfm4w6WUsBZ 2lljxu0ldKdSMRozH1yrGLDxF0aTRqC/bsb45wHlOdsOcvf9X+ET0D4UoB5apnTUB4w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=gir2pd12; arc=none smtp.remote-ip=209.85.210.200 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 865C8606A31A for ; Wed, 2 Dec 2026 01:09:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 865C8606A31A 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.a=rsa-sha256 header.s=20260707 header.b=gir2pd12 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-8bb1a7b0e52so8300098b3a.1 for ; Tue, 01 Dec 2026 17:09:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796173768; x=1796778568; 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=g/kWKb9oZusK72C6OJcw0UM4QUThZkRWvvE3svgxpso=; b=gir2pd12HKELAMtGFZVVN+NUGdIJVeVjEkTkxhvs38qu6giT+Lcbmc0Yz2GhiLNlAu eXX64cOrKW97lsDF3h9TKh2+EWf4dLX7VgF/v2Dv9P1FDgcId2E/ggIb1G8PvL2p2Knb q3gwee2BD51BhoqxvVxZCDtCakt1TtPITSF3cbzLLhJO9+U0IVxiIYPMaObD3hEZmLms w4v/UOABUW9v1A8CpmjvRzhOCu38XGZ/sd/FZj7LfALcVZlJ/jE1SIVWkBxlaX7+769D CE67r4gvNIjEZF6oIdJEWazmw1ARULl7SgdpYioFA42VQog6HkdxO93hjhyx+GLOBcaF zvXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796173768; x=1796778568; 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=g/kWKb9oZusK72C6OJcw0UM4QUThZkRWvvE3svgxpso=; b=jQNdmhi7X+87EvK/GqoWetok02rYVxqRTI7TqcmmTS8DzK21Wx1cvydeRij7d9oilE 2YW0UT2yuWF8CNXJQbLbU/+emLAW/HepDeyRK4sAG8j5TU0LBmZ+MagdNspYUyb3BuYw lWK7wkZD9Aw1ck9EnJvrF+3TZi42T6ZvPa2MSngYQa8u8AdLlgx2wRAvWfjmsMo+ZTAS ykfs5vCLDnbsKDbLKF12GrkNypr8jmrWHCOGSL/YIbtGY7OiKW9hLiq0CYubOI2drjZW L/iqAx/QGsMXdY10fBKDOb37ydHIgz3MKkNjgGaZ9k94ENvfJb6EiX/TfZyvv0/ZBFN/ hfyQ== X-Forwarded-Encrypted: i=1; AL+hErH/kFOBWzINSZ6wVTjOG5sfSgUp0v9fvtL4llBbcj1OHpsDLLGc1WcqJ3xqMkgXzjsxxIA=@vger.kernel.org X-Gm-Message-State: APuU4Z80vQnYm+/ruRY3OvGeKO7VrkRpbx8VIzEfoMSnzgBsSBRPo+0E /FZD436cmJ6YBLlrxuZIJHs+rEG6tujXR1Ay9UqqT4QcZPtvp95bIS5s63Zodg5NtUx5NvNVci0 CRBvXjQ== X-Received: from pfbks11.prod.google.com ([2002:a05:6a00:4b8b:b0:8b5:fe4e:af1c]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:1acd:b0:881:be70:448e with SMTP id d2e1a72fcca58-8c87d220cffmr39054990b3a.53.1796173767569; Tue, 01 Dec 2026 17:09:27 -0800 (PST) Date: Tue, 1 Dec 2026 17:09:26 -0800 In-Reply-To: <3a3c5681-ff1e-47b6-b942-2d5ce64a8d6d@arm.com> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 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> <120ad525-efa5-4129-9d97-fa6fa5db747f@arm.com> <3a3c5681-ff1e-47b6-b942-2d5ce64a8d6d@arm.com> Message-ID: Subject: Re: [PATCH v3 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot From: Sean Christopherson To: Suzuki K Poulose Cc: Steven Price , Fuad Tabba , Ackerley Tng , 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 Content-Type: text/plain; charset="us-ascii" On Mon, Nov 23, 2026, Suzuki K Poulose wrote: > On 19/11/2026 14:54, Sean Christopherson wrote: > > On Thu, Nov 19, 2026, Suzuki K Poulose wrote: > > > 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 > > > > It's only an error if (a) the userspace address in the memslot points at the > > gmem fd and > > I don't understand this part. With inplace conversion, we mark the slot > as GMEM_ONLY and always resolve shared faults from the gmem (on arm64 > as described by the API). So, isn't it a usage error from the VMM if it > plans to use GUEST_MEMFD_FLAG_MMAP=false with inplace conversion ? Sure, but KVM isn't the usage police. Critically, KVM can't know what the VMM *intends*, KVM only knows what the VMM has actually done. > In other words, do you mean to say, passing a non-gmem fd userspace address > is fine with GUEST_MEMFD_FLAG_MMAP=false ? Yes. arm64 is relatively unique in that it does VMA lookups when handling faults, most other architectures don't care. E.g. x86 cares only what's mapped into the userspace page tables, and doesn't try to enforce anything at a VMA level. > But the API documentation I don't see any contradiction. The blurb you quote above specifically talks about guest faults, and KVM *does* go straight to gmem for those. KVM accesses to guest memory aren't guest faults, so that above blurb doesn't apply. > and the GMEM_ONLY flags contradict the usage. GMEM_ONLY is a KVM-internal thing, and is slightly misnamed. It's really KVM_MMU_CAN_GET_PFNS_FROM_GMEM or something like that. > Now, should we reject that in KVM or not is the secondary question. No, because we risk disallowing legitimate (if unusual) setups that KVM can handle just fine.