From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796173768; b=WY9UGq0N4aJhXYhdVUw4umJVjgzcygwZGaHVohYKc+qmB7rNmJa/vhhBDiNRpu2dp8R+ SyjFXLEAJysaT8DBc0yGgCbFHtidFXv6B2lfytS+tk2ma3upCqE1np+m1UuHEyfq5Li/z n6TNyvfCc9F7f4cZsnLY4Skx6UagMi0dMmnpam90gC6lT6ZFP7C4Aolg5fin8hDzwI8zk 5yHh5b7eCwOSvmBWkA+7Z++RUJfTSDKNo/IWgi6yhuo1XKSOKOJpFBXmOMl8+zMx3aS3X fZ8Ia5OJI4jagDeVNYoNZM7IAW3EHwcRrfWaGNzet3z7rxaEFroV0tRGeISwVGl4boQ== 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=KSuE2+BS18iHTek7cbY1ejalPj5RwFRiSsY1hHD0+LO/lFqv77S0a/FHXOwh6Xt550dC 2P0gM2XXf7ju0B8vN4JJC2AnWRCdyBJ2KEiuVxsdRvpq2aijGGOnJX8J5pR3seC+zwKqk xYadjShYNokPMFcr1cPAU8SwSrrz6y6aNPPK2U7/ftqlNRqHqbPz8ZsKz7TSBMJzRakPu 91jig2PntO28bb2aNtacS6yZKX/uwL6jVgTmf9BeF0+dKWOrKQpKWN0659vWIke4TowWg 3ZjjGi8maK9ahEJVd5OOuRwQYNHUX3Saa9NK1+b6QCCbkanydSwIMpLzh7rjPzWwYQQ== 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.197 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (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 8C332606A322 for ; Wed, 2 Dec 2026 01:09:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8C332606A322 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-f197.google.com with SMTP id d2e1a72fcca58-8aa185840bdso9253156b3a.3 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=r1gB3lHDcE6L5hGTfTAtAD5IP3Y/fGezzqQR5JVxhJnRSAmNvTdlyD/jGqT2xFcCu5 j9hJqGXnBp2rXkGXJr7bYLx1Vbjy5epY+j1yCcSLYXNX3UU/Ab7hyTJl6AlYfB9/Xaiw a8LcnunN2ThsaIvQT/x1Ve/vGjELgXVpeizEV7FPhcpajKDmr6gG5bT7wFEIADs+wwC1 JOObb8PKzsikUqEpXsn3jeS7XvnwXWOD1XTEm4KvNCeS6MbLA1kMRsWjMyqjroksI6u8 wqBPniyGU3oXvmv/AeuaBUXD4EtVO2lbs2hfrfAlBi41JsAUHMK6LtaLqOGhYU7F5cv3 rYSw== X-Forwarded-Encrypted: i=1; AL+hErF9vFi0l2C7MxZiHN39PniwnFue3eLst+wlGfp54a3hMlSQkI7l7UenL3VnjKyNgQPd9nofzs4wh5hh9hY=@vger.kernel.org X-Gm-Message-State: APuU4Z8nLAbkCOLsu3Mx/KGCk3RGieOery37+EipBU0o+yAaxtS48jOd D0S1KZulC7xqddQU07M5bPZq4E37SO3BbkSxLVUAGISgr1sbRcEDra3Y6sy3Aa4EKvg5DkEn3Cb pNZbMlw== 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: linux-kernel@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.