From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx> Add meaningful bits as VMX_REGS_AVAIL_SET and VMX_REGS_DIRTY_SET. Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx> --- arch/x86/kvm/vmx/vmx.h | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index e7db42e3b0ce..465aa415c3cb 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -437,16 +437,33 @@ BUILD_CONTROLS_SHADOW(secondary_exec, SECONDARY_VM_EXEC_CONTROL) static inline void vmx_register_cache_reset(struct kvm_vcpu *vcpu) { - vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP) - | (1 << VCPU_EXREG_RFLAGS) - | (1 << VCPU_EXREG_PDPTR) - | (1 << VCPU_EXREG_SEGMENTS) - | (1 << VCPU_EXREG_CR0) - | (1 << VCPU_EXREG_CR3) - | (1 << VCPU_EXREG_CR4) - | (1 << VCPU_EXREG_EXIT_INFO_1) - | (1 << VCPU_EXREG_EXIT_INFO_2)); - vcpu->arch.regs_dirty = 0; +/* + * VMX_REGS_AVAIL_SET - The set of registers that will be updated in cache on + * demand. Other registers not listed here are synced to + * the cache immediately after VM-Exit. + * + * VMX_REGS_DIRTY_SET - The set of registers that might be outdated in + * architecture. Other registers not listed here are synced + * to the architecture immediately when modifying. + */ +#define VMX_REGS_AVAIL_SET ((1 << VCPU_REGS_RIP) |\ + (1 << VCPU_REGS_RSP) |\ + (1 << VCPU_EXREG_RFLAGS) |\ + (1 << VCPU_EXREG_PDPTR) |\ + (1 << VCPU_EXREG_SEGMENTS) |\ + (1 << VCPU_EXREG_CR0) |\ + (1 << VCPU_EXREG_CR3) |\ + (1 << VCPU_EXREG_CR4) |\ + (1 << VCPU_EXREG_EXIT_INFO_1) |\ + (1 << VCPU_EXREG_EXIT_INFO_2)) + +#define VMX_REGS_DIRTY_SET ((1 << VCPU_REGS_RIP) |\ + (1 << VCPU_REGS_RSP) |\ + (1 << VCPU_EXREG_PDPTR) |\ + (1 << VCPU_EXREG_CR3)) + + vcpu->arch.regs_avail &= ~VMX_REGS_AVAIL_SET; + vcpu->arch.regs_dirty &= ~VMX_REGS_DIRTY_SET; } static inline struct kvm_vmx *to_kvm_vmx(struct kvm *kvm) -- 2.19.1.6.gb485710b