Re: [PATCH 1/5] kvm: add exit_to_guest_mode() and enter_from_guest_mode()

From: Sean Christopherson
Date: Thu Jan 13 2022 - 15:32:29 EST


On Tue, Jan 11, 2022, Mark Rutland wrote:
> Atop this, new exit_to_guest_mode() and enter_from_guest_mode() helpers
> are added to handle the ordering of lockdep, tracing, and RCU manageent.
> These are named to align with exit_to_user_mode() and
> enter_from_user_mode().
>
> Subsequent patches will migrate architectures over to the new helpers,
> following a sequence:
>
> guest_timing_enter_irqoff();
>
> exit_to_guest_mode();

I'm not a fan of this nomenclature. First and foremost, virtualization refers to
transfers to guest mode as VM-Enter, and transfers from guest mode as VM-Exit.
It's really, really confusing to read this code from a virtualization perspective.
The functions themselves are contradictory as the "enter" helper calls functions
with "exit" in their name, and vice versa.

We settled on xfer_to_guest_mode_work() for a similar conundrum in the past, though
I don't love using xfer_to/from_guest_mode() as that makes it sound like those
helpers handle the actual transition into guest mode, i.e. runs the vCPU.

To avoid too much bikeshedding, what about reusing the names we all compromised
on when we did this for x86 and call them kvm_guest_enter/exit_irqoff()? If x86
is converted in the first patch then we could even avoid temporary #ifdefs.

> < run the vcpu >
> enter_from_guest_mode();
> < take any pending IRQs >
>
> guest_timing_exit_irqoff();