[RFC PATCH v5 02/38] KVM: arm64: Add lock/unlock memslot user API
Alexandru Elisei
alexandru.elisei at arm.com
Tue Feb 15 04:13:23 PST 2022
Hi,
On Tue, Feb 15, 2022 at 12:02:26PM +0000, Marc Zyngier wrote:
> On Tue, 15 Feb 2022 11:03:59 +0000,
> Alexandru Elisei <alexandru.elisei at arm.com> wrote:
> >
> > > If a memslot with read/write permission is locked with read only,
> > > and then unlocked, can userspace expect stage 2 mapping for the
> > > memslot to be updated with read/write ?
> >
> > Locking a memslot with the read flag would map the memory described by the
> > memslot with read permissions at stage 2. When the memslot is unlocked, KVM
> > won't touch the stage 2 entries.
> >
> > When the memslot is unlocked, the pages (as in, struct page) backing the VM
> > memory as described by the memslot are unpinned. Then the host's MM subsystem
> > can treat the memory like any other pages (make them old, new, unmap them, do
> > nothing, etc), and the MMU notifier will take care of updating the stage 2
> > entries as necessary.
> >
> > I guess I should have been more precise in the description. I'll
> > change "causes the memory pinned when locking the memslot specified
> > in args[0] to be unpinned" to something that clearly states that the
> > memory in the host that backs the memslot is unpinned.
> >
> > > Can userspace delete the memslot that is locked (without unlocking) ?
> >
> > No, it cannot.
> >
> > > If so, userspace can expect the corresponding range to be implicitly
> > > unlocked, correct ?
> >
> > Userspace must explicitely unlock the memslot before deleting it. I want
> > userspace to be explicit in its intent.
>
> Does it get in the way of making this robust wrt userspace being
> killed (or terminating without unlock first)?
Patch #8 ("KVM: arm64: Unlock memslots after stage 2 tables are freed")
teaches kvm_arch_flush_shadow_all() to unlock all locked memslots.
Thanks,
Alex
>
> M.
>
> --
> Without deviation from the norm, progress is not possible.
More information about the linux-arm-kernel
mailing list