On 3/28/23 14:31, Tianrui Zhao wrote:
+ case 0xc91: + /* idle GSPR */ + er = _kvm_emu_idle(vcpu); + break;
So this is my last remark. What some other architectures do is change vcpu->arch.mp_state when entering an idle state, and at this point all calls to KVM_RUN would call the equivalent of _kvm_emu_idle(). This requires implementing the KVM_GET_MPSTATE and KVM_SET_MPSTATE ioctls.
This might also be useful if later you want to implement a mechanism where vCPUs can pause or resume, for example for multi-vCPU VMs.
You can implement this on top of what you have, but I highly recommend that you do it in the first version of what is committed to Linux.
Paolo