On Wed, May 15, 2024 at 10:38 PM Julian Stecklina <julian.stecklina@xxxxxxxxxxxxxxxxxxxxx> wrote: > > On Wed, 15 May 2024 13:08:39 +0200 Paolo wrote: > > On 5/15/24 10:06, Liang Chen wrote: > >> In a nested VM environment, a vCPU can run either an L1 or L2 VM. If the > >> L0 VMM tries to configure L1 VM registers via the KVM_SET_REGS ioctl while > >> the vCPU is running an L2 VM, it may inadvertently modify the L2 VM's > >> registers, corrupting the L2 VM. To avoid this error, registers should be > >> treated as read-only when the vCPU is actively running an L2 VM. > > > > No, this is intentional. The L0 hypervisor has full control on the CPU > > registers, no matter if the VM is in guest mode or not. > > We have a very similar issue and we already discussed it in these two > threads [1, 2]. Our proposed solution is to introduce a flag in > kvm_run to make userspace aware of exits with L2 state. > Thank you for the information. That should be sufficient for userspace to determine if the vCPU is in guest mode. Thanks, Liang > Julian > > > [1] https://lore.kernel.org/kvm/20240416123558.212040-1-julian.stecklina@xxxxxxxxxxxxxxxxxxxxx/T/#m2eebd2ab30a86622aea3732112150851ac0768fe > [2] https://lore.kernel.org/kvm/20240508132502.184428-1-julian.stecklina@xxxxxxxxxxxxxxxxxxxxx/T/#u >