On 09.04.2018 06:21, Jidong Xiao wrote: > Hi, > > The Intel SDM says: > > "The launch state of a VMCS determines which VM-entry instruction > should be used with that VMCS: the > VMLAUNCH instruction requires a VMCS whose launch state is “clear”; > the VMRESUME instruction requires a VMCS > whose launch state is “launched”. A logical processor maintains a > VMCS’s launch state in the corresponding VMCS > region." > > "There are no other ways to modify the launch state of a VMCS (it > cannot be modified using VMWRITE) and there > is no direct way to discover it (it cannot be read using VMREAD).' > > According to the above description, the launch state is stored in the > VMCS region, but it seems the SDM doesn't say where exactly the launch > state is stored in the VMCS. For example, the VMCS data is organized > into six logic groups: Guest-state area, Host-state area, VM-execution > control fields, VM-exit control fields, VM-entry control fields, > VM-exit information fields. However, I can't find the "launch state" > in any of these fields. > > If it's in the VMCS region, then why can't I find it? and why it can't > be discovered by VMREAD? Why do you assume the launch state has to be stored inside the VMCS region? It is just being stated that you cannot detect/modify it via VMWRITE/VMREAD. Which is perfectly true if the launch state is stored outside of the VMCS region. What the SDM states here simply is that the caller has to remember if a VMCS has already been launched. This is what we do with the "launched" variable. And this is also what we use for emulation of VMLAUNCH/VMRESUME in nested_vmx_run(). > > I saw in the kvm source code a variable called launched is defined, > which enables kvm to trace the launch state of the VMCS, but is this > launch state really existing in the VMCS region? If so, where exactly > is it? Nope, not in the region, it's glued to struct loaded_vmcs. > > -Jidong > -- Thanks, David / dhildenb