mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Steven Price <steven.price@arm.com>,
	Fuad Tabba <tabba@google.com>,
	 Ackerley Tng <ackerleytng@google.com>,
	kvm@vger.kernel.org, kvmarm@lists.linux.dev,
	 Catalin Marinas <catalin.marinas@arm.com>,
	Marc Zyngier <maz@kernel.org>, Will Deacon <will@kernel.org>,
	 James Morse <james.morse@arm.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	 Zenghui Yu <yuzenghui@huawei.com>,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org, Joey Gouly <joey.gouly@arm.com>,
	 Alexandru Elisei <alexandru.elisei@arm.com>,
	Christoffer Dall <christoffer.dall@arm.com>,
	 linux-coco@lists.linux.dev,
	 Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>,
	Gavin Shan <gshan@redhat.com>,
	 Shanker Donthineni <sdonthineni@nvidia.com>,
	Alper Gun <alpergun@google.com>,
	 "Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
	Emi Kisanuki <fj0570is@fujitsu.com>,
	 Vishal Annapurve <vannapurve@google.com>,
	WeiLin.Chang@arm.com,  Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Kohei Enju <enju.kohei@fujitsu.com>
Subject: Re: [PATCH v3 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot
Date: Tue, 1 Dec 2026 17:09:26 -0800	[thread overview]
Message-ID: <aw9vxq0UuNZLuMyP@seanjc-mac.roam.internal> (raw)
In-Reply-To: <3a3c5681-ff1e-47b6-b942-2d5ce64a8d6d@arm.com>

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.

  reply	other threads:[~2026-12-02  1:09 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 16:43 [PATCH v3 00/11] KVM: arm64: CCA: Prepare Realm memory management Steven Price
2026-11-16 16:43 ` [PATCH v3 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot Steven Price
2026-11-17 14:05   ` Fuad Tabba
2026-11-18 10:34     ` Suzuki K Poulose
2026-11-18 11:14       ` Steven Price
2026-11-18 12:04         ` Suzuki K Poulose
2026-11-18 15:18           ` Steven Price
2026-11-19 10:10             ` Suzuki K Poulose
2026-11-19 14:54               ` Sean Christopherson
2026-11-23 11:13                 ` Suzuki K Poulose
2026-12-02  1:09                   ` Sean Christopherson [this message]
2026-11-16 16:43 ` [PATCH v3 02/11] KVM: arm64: CCA: Introduce Realms Steven Price
2026-11-17 14:07   ` Fuad Tabba
2026-11-18 16:12     ` Steven Price
2026-11-16 16:43 ` [PATCH v3 03/11] KVM: arm64: Handle attributes in stage2_unmap_range Steven Price
2026-11-17 14:16   ` Fuad Tabba
2026-11-18 16:12     ` Steven Price
2026-11-16 16:43 ` [PATCH v3 04/11] KVM: arm64: CCA: Add basic infrastructure for creating a realm Steven Price
2026-11-16 16:43 ` [PATCH v3 05/11] KVM: arm64: CCA: Tear down RTTs Steven Price
2026-11-19  3:39   ` Wei-Lin Chang
2026-11-19 14:27     ` Steven Price
2026-11-16 16:43 ` [PATCH v3 06/11] KVM: arm64: CCA: Add Realm RTT mapping and invalidation helpers Steven Price
2026-11-16 16:43 ` [PATCH v3 07/11] KVM: Allow architectures to reject memslot changes before invalidation Steven Price
2026-11-17 14:31   ` Fuad Tabba
2026-11-18 16:44     ` Steven Price
2026-11-16 16:43 ` [PATCH v3 08/11] KVM: arm64: CCA: Prevent memslot modifications after Realm creation Steven Price
2026-11-17 14:42   ` Fuad Tabba
2026-11-18 16:49     ` Steven Price
2026-11-16 16:43 ` [PATCH v3 09/11] KVM: arm64: CCA: Support runtime faulting of memory Steven Price
2026-11-19  7:48   ` Wei-Lin Chang
2026-11-19 17:01     ` Steven Price
2026-11-20 13:18       ` Suzuki K Poulose
2026-11-16 16:43 ` [PATCH v3 10/11] KVM: arm64: Dispatch stage-2 destruction by VM flavor Steven Price
2026-11-17 15:02   ` Fuad Tabba
2026-11-18 17:04     ` Steven Price
2026-11-16 16:43 ` [PATCH v3 11/11] KVM: arm64: CCA: Add Realm stage-2 MMU operations Steven Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aw9vxq0UuNZLuMyP@seanjc-mac.roam.internal \
    --to=seanjc@google.com \
    --cc=WeiLin.Chang@arm.com \
    --cc=ackerleytng@google.com \
    --cc=alexandru.elisei@arm.com \
    --cc=alpergun@google.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@arm.com \
    --cc=enju.kohei@fujitsu.com \
    --cc=fj0570is@fujitsu.com \
    --cc=gankulkarni@os.amperecomputing.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=sdonthineni@nvidia.com \
    --cc=steven.price@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@google.com \
    --cc=vannapurve@google.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®