Hmm, and there's no indication on success that the previous entry was assigned?
Adding a tracepoint in rmpupdate() to allow tracking transitions is probably a
good idea, otherwise debugging RMP violations and/or unexpected #VC is going to
be painful.
And/or if the kernel/KVM behavior is to never reassign directly and reading an RMP
entry isn't prohibitively expensive, then we could add a sanity check that the RMP
is unassigned and reject rmpupdate() if the page is already assigned. Probably
not worth it if the overhead is noticeable, but it could be nice to have if things
go sideways.
To be clear, it's not just an optimization. Pages that haven't yet been touched
may be already owned by a different VM (or even this VM). I.e. "reverting" those
pages would actually result in a form of corruption. It's somewhat of a moot point
because assigning a single page to multiple guests is going to be fatal anyways,
but potentially making a bug worse by introducing even more noise/confusion is not
good.