Paolo Bonzini <pbonzini@xxxxxxxxxx> writes: > On 20/05/20 20:53, Makarand Sonare wrote: >>> >>>> + >>>> + if (get_user(vmx->nested.preemption_timer_deadline, >>>> + &user_vmx_nested_state->preemption_timer_deadline)) { >>> ... tt also seems that we expect user_vmx_nested_state to always have >>> all fields, e.g. here the offset of 'preemption_timer_deadline' is >>> static, we always expect it to be after shadow vmcs. I think we need a >>> way to calculate the offset dynamically and not require everything to be >>> present. >>> >> Would it suffice if I move preemption_timer_deadline field to >> kvm_vmx_nested_state_hdr? >> > > Yes, please do so. The header is exactly for cases like this where we > have small fields that hold non-architectural pieces of state. > This can definitely work here (and I'm not at all against this solution) but going forward it seems we'll inevitably need a convenient way to handle sparse/extensible 'data'. Also, the header is 128 bytes only. I'd suggest we add an u32/u64 bit set to the header (which will be separate for vmx/svm structures) describing what is and what's not in vmx/svm specific 'data', this way we can easily validate the size and get the right offsets. Also, we'll start saving bits in arch neutral 'flags' as we don't have that many :-) -- Vitaly