I would do it this way:
struct svm_nested_state {
...
/* cached fields from the vmcb12 */
struct vmcb_control_area_cached ctl;
struct vmcb_save_area_cached save;
...
};
The only thing that requires a little bit of additional work when
applying this is svm_get_nested_state() (and theoretically
svm_set_nested_state(), in option 2). In this function, nested.ctl is
copied in user_vmcb->control. But now nested.ctl is not anymore a
vmcb_control_area, so the sizes differ.
There are 2 options here:
1) copy nested.ctl into a full vmcb_control_area, and copy it to user
space without modifying the API. The advantage is that the API is left
intact, but an additional copy is required.
2) modify KVM_GET_NESTED_STATE and KVM_SET_NESTED_STATE to handle
vmcb_control_area_cached. Advantage is that there is a lightweight copy
+ the benefits explained by you in the previous email (no unset field).
I am not sure which one is the preferred way here.
Thank you,
Emanuele