xref: /openbmc/linux/arch/x86/kvm/vmx/vmcs_shadow_fields.h (revision 8dd06ef34b6e2f41b29fbf5fc1663780f2524285)
1e2174295SSean Christopherson #if !defined(SHADOW_FIELD_RO) && !defined(SHADOW_FIELD_RW)
2e2174295SSean Christopherson BUILD_BUG_ON(1)
3e2174295SSean Christopherson #endif
4e2174295SSean Christopherson 
5e0123119SSean Christopherson #ifndef SHADOW_FIELD_RO
61c6f0b47SSean Christopherson #define SHADOW_FIELD_RO(x, y)
7e0123119SSean Christopherson #endif
8e0123119SSean Christopherson #ifndef SHADOW_FIELD_RW
91c6f0b47SSean Christopherson #define SHADOW_FIELD_RW(x, y)
10e0123119SSean Christopherson #endif
11e0123119SSean Christopherson 
12e0123119SSean Christopherson /*
13e0123119SSean Christopherson  * We do NOT shadow fields that are modified when L0
14e0123119SSean Christopherson  * traps and emulates any vmx instruction (e.g. VMPTRLD,
15e0123119SSean Christopherson  * VMXON...) executed by L1.
16e0123119SSean Christopherson  * For example, VM_INSTRUCTION_ERROR is read
17e0123119SSean Christopherson  * by L1 if a vmx instruction fails (part of the error path).
18e0123119SSean Christopherson  * Note the code assumes this logic. If for some reason
19e0123119SSean Christopherson  * we start shadowing these fields then we need to
20e0123119SSean Christopherson  * force a shadow sync when L0 emulates vmx instructions
21e0123119SSean Christopherson  * (e.g. force a sync if VM_INSTRUCTION_ERROR is modified
22e0123119SSean Christopherson  * by nested_vmx_failValid)
23e0123119SSean Christopherson  *
24e0123119SSean Christopherson  * When adding or removing fields here, note that shadowed
25e0123119SSean Christopherson  * fields must always be synced by prepare_vmcs02, not just
26*4d516fe7SMiaohe Lin  * prepare_vmcs02_rare.
27e0123119SSean Christopherson  */
28e0123119SSean Christopherson 
29e0123119SSean Christopherson /*
30e0123119SSean Christopherson  * Keeping the fields ordered by size is an attempt at improving
31668effb6SMiaohe Lin  * branch prediction in vmcs12_read_any and vmcs12_write_any.
32e0123119SSean Christopherson  */
33e0123119SSean Christopherson 
34e0123119SSean Christopherson /* 16-bits */
351c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_INTR_STATUS, guest_intr_status)
361c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_PML_INDEX, guest_pml_index)
371c6f0b47SSean Christopherson SHADOW_FIELD_RW(HOST_FS_SELECTOR, host_fs_selector)
381c6f0b47SSean Christopherson SHADOW_FIELD_RW(HOST_GS_SELECTOR, host_gs_selector)
39e0123119SSean Christopherson 
40e0123119SSean Christopherson /* 32-bits */
411c6f0b47SSean Christopherson SHADOW_FIELD_RO(VM_EXIT_REASON, vm_exit_reason)
421c6f0b47SSean Christopherson SHADOW_FIELD_RO(VM_EXIT_INTR_INFO, vm_exit_intr_info)
431c6f0b47SSean Christopherson SHADOW_FIELD_RO(VM_EXIT_INSTRUCTION_LEN, vm_exit_instruction_len)
441c6f0b47SSean Christopherson SHADOW_FIELD_RO(IDT_VECTORING_INFO_FIELD, idt_vectoring_info_field)
451c6f0b47SSean Christopherson SHADOW_FIELD_RO(IDT_VECTORING_ERROR_CODE, idt_vectoring_error_code)
461c6f0b47SSean Christopherson SHADOW_FIELD_RO(VM_EXIT_INTR_ERROR_CODE, vm_exit_intr_error_code)
471c6f0b47SSean Christopherson SHADOW_FIELD_RO(GUEST_CS_AR_BYTES, guest_cs_ar_bytes)
481c6f0b47SSean Christopherson SHADOW_FIELD_RO(GUEST_SS_AR_BYTES, guest_ss_ar_bytes)
491c6f0b47SSean Christopherson SHADOW_FIELD_RW(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control)
50eceb9973SPaolo Bonzini SHADOW_FIELD_RW(PIN_BASED_VM_EXEC_CONTROL, pin_based_vm_exec_control)
511c6f0b47SSean Christopherson SHADOW_FIELD_RW(EXCEPTION_BITMAP, exception_bitmap)
521c6f0b47SSean Christopherson SHADOW_FIELD_RW(VM_ENTRY_EXCEPTION_ERROR_CODE, vm_entry_exception_error_code)
531c6f0b47SSean Christopherson SHADOW_FIELD_RW(VM_ENTRY_INTR_INFO_FIELD, vm_entry_intr_info_field)
541c6f0b47SSean Christopherson SHADOW_FIELD_RW(VM_ENTRY_INSTRUCTION_LEN, vm_entry_instruction_len)
551c6f0b47SSean Christopherson SHADOW_FIELD_RW(TPR_THRESHOLD, tpr_threshold)
561c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_INTERRUPTIBILITY_INFO, guest_interruptibility_info)
571c6f0b47SSean Christopherson SHADOW_FIELD_RW(VMX_PREEMPTION_TIMER_VALUE, vmx_preemption_timer_value)
58e0123119SSean Christopherson 
59e0123119SSean Christopherson /* Natural width */
601c6f0b47SSean Christopherson SHADOW_FIELD_RO(EXIT_QUALIFICATION, exit_qualification)
611c6f0b47SSean Christopherson SHADOW_FIELD_RO(GUEST_LINEAR_ADDRESS, guest_linear_address)
621c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_RIP, guest_rip)
631c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_RSP, guest_rsp)
641c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_CR0, guest_cr0)
651c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_CR3, guest_cr3)
661c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_CR4, guest_cr4)
671c6f0b47SSean Christopherson SHADOW_FIELD_RW(GUEST_RFLAGS, guest_rflags)
681c6f0b47SSean Christopherson SHADOW_FIELD_RW(CR0_GUEST_HOST_MASK, cr0_guest_host_mask)
691c6f0b47SSean Christopherson SHADOW_FIELD_RW(CR0_READ_SHADOW, cr0_read_shadow)
701c6f0b47SSean Christopherson SHADOW_FIELD_RW(CR4_READ_SHADOW, cr4_read_shadow)
711c6f0b47SSean Christopherson SHADOW_FIELD_RW(HOST_FS_BASE, host_fs_base)
721c6f0b47SSean Christopherson SHADOW_FIELD_RW(HOST_GS_BASE, host_gs_base)
73e0123119SSean Christopherson 
74e0123119SSean Christopherson /* 64-bit */
751c6f0b47SSean Christopherson SHADOW_FIELD_RO(GUEST_PHYSICAL_ADDRESS, guest_physical_address)
761c6f0b47SSean Christopherson SHADOW_FIELD_RO(GUEST_PHYSICAL_ADDRESS_HIGH, guest_physical_address)
77e0123119SSean Christopherson 
78e0123119SSean Christopherson #undef SHADOW_FIELD_RO
79e0123119SSean Christopherson #undef SHADOW_FIELD_RW
80