Re: [PATCH RFC v2 03/29] mm: asi: Introduce ASI core API

From: Borislav Petkov
Date: Wed Mar 19 2025 - 11:28:46 EST


On Tue, Mar 18, 2025 at 03:48:47PM -0700, Junaid Shahid wrote:
> > Oh. Yeah. In my proposal below I had totally forgotten we had
> > asi_exit() in the context_switch() path (it is there in this patch).
> >
> > So we only need the asi_exit() in the KVM code in order to avoid
> > actually hitting e.g. exit_to_user_mode() in the restricted address
> > space.
> >
> > But... we can just put an asi_exit() there explicitly instead of
> > dumping all this weirdness into the "core API" and the KVM codebase.
> >
> > So... I think all we really need is asi_start_critical() and
> > asi_end_critical()? And make everything else happen as part of the
> > normal functioning of the entry and context-switching logic. Am I
> > forgetting something else?
>
> Yes, I think this should work.

Ok, what I read so far makes sense to me. That thing - modulo simplification
but even without it - is kinda clear and straight-forward:

ioctl(KVM_RUN) {
enter_from_user_mode()
asi_start()
while !need_userspace_handling()
asi_start_critical();
vmenter();
asi_end_critical();
}
asi_end()
exit_to_user_mode()
}

Lemme continue through the set.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette