On 09/06/21 12:23, Marc Zyngier wrote:
Implement initial support for KVM_{GET,SET}_SYSTEM_COUNTER_STATE ioctls
to migrate the value of CNTVOFF_EL2. These ioctls yield precise control
of the virtual counter-timers to userspace, allowing it to define its
own heuristics for managing vCPU offsets.
I'm not really in favour of inventing a completely new API, for
multiple reasons:
- CNTVOFF is an EL2 concept. I'd rather not expose it as such as it
becomes really confusing with NV (which does expose its own CNTVOFF
via the ONE_REG interface)
- You seem to allow each vcpu to get its own offset. I don't think
that's right. The architecture defines that all PEs have the same
view of the counters, and an EL1 guest should be given that
illusion.
- by having a parallel save/restore interface, you make it harder to
reason about what happens with concurrent calls to both interfaces
- the userspace API is already horribly bloated, and I'm not overly
keen on adding more if we can avoid it.
I'd rather you extend the current ONE_REG interface and make it modal,
either allowing the restore of an absolute value or an offset for
CNTVCT_EL0. This would also keep a consistent behaviour when restoring
vcpus. The same logic would apply to the physical offset.
What about using KVM_GET/SET_DEVICE_ATTR? It makes sense that the guest
value for nested virt goes through ONE_REG, while the host value goes
through DEVICE_ATTR.
Paolo