xref: /linux/arch/x86/kvm/vmx/vmcs_shadow_fields.h (revision a4eb44a6435d6d8f9e642407a4a06f65eb90ca04)
1 #if !defined(SHADOW_FIELD_RO) && !defined(SHADOW_FIELD_RW)
2 BUILD_BUG_ON(1)
3 #endif
4 
5 #ifndef SHADOW_FIELD_RO
6 #define SHADOW_FIELD_RO(x, y)
7 #endif
8 #ifndef SHADOW_FIELD_RW
9 #define SHADOW_FIELD_RW(x, y)
10 #endif
11 
12 /*
13  * We do NOT shadow fields that are modified when L0
14  * traps and emulates any vmx instruction (e.g. VMPTRLD,
15  * VMXON...) executed by L1.
16  * For example, VM_INSTRUCTION_ERROR is read
17  * by L1 if a vmx instruction fails (part of the error path).
18  * Note the code assumes this logic. If for some reason
19  * we start shadowing these fields then we need to
20  * force a shadow sync when L0 emulates vmx instructions
21  * (e.g. force a sync if VM_INSTRUCTION_ERROR is modified
22  * by nested_vmx_failValid)
23  *
24  * When adding or removing fields here, note that shadowed
25  * fields must always be synced by prepare_vmcs02, not just
26  * prepare_vmcs02_rare.
27  */
28 
29 /*
30  * Keeping the fields ordered by size is an attempt at improving
31  * branch prediction in vmcs12_read_any and vmcs12_write_any.
32  */
33 
34 /* 16-bits */
35 SHADOW_FIELD_RW(GUEST_INTR_STATUS, guest_intr_status)
36 SHADOW_FIELD_RW(GUEST_PML_INDEX, guest_pml_index)
37 SHADOW_FIELD_RW(HOST_FS_SELECTOR, host_fs_selector)
38 SHADOW_FIELD_RW(HOST_GS_SELECTOR, host_gs_selector)
39 
40 /* 32-bits */
41 SHADOW_FIELD_RO(VM_EXIT_REASON, vm_exit_reason)
42 SHADOW_FIELD_RO(VM_EXIT_INTR_INFO, vm_exit_intr_info)
43 SHADOW_FIELD_RO(VM_EXIT_INSTRUCTION_LEN, vm_exit_instruction_len)
44 SHADOW_FIELD_RO(IDT_VECTORING_INFO_FIELD, idt_vectoring_info_field)
45 SHADOW_FIELD_RO(IDT_VECTORING_ERROR_CODE, idt_vectoring_error_code)
46 SHADOW_FIELD_RO(VM_EXIT_INTR_ERROR_CODE, vm_exit_intr_error_code)
47 SHADOW_FIELD_RO(GUEST_CS_AR_BYTES, guest_cs_ar_bytes)
48 SHADOW_FIELD_RO(GUEST_SS_AR_BYTES, guest_ss_ar_bytes)
49 SHADOW_FIELD_RW(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control)
50 SHADOW_FIELD_RW(PIN_BASED_VM_EXEC_CONTROL, pin_based_vm_exec_control)
51 SHADOW_FIELD_RW(EXCEPTION_BITMAP, exception_bitmap)
52 SHADOW_FIELD_RW(VM_ENTRY_EXCEPTION_ERROR_CODE, vm_entry_exception_error_code)
53 SHADOW_FIELD_RW(VM_ENTRY_INTR_INFO_FIELD, vm_entry_intr_info_field)
54 SHADOW_FIELD_RW(VM_ENTRY_INSTRUCTION_LEN, vm_entry_instruction_len)
55 SHADOW_FIELD_RW(TPR_THRESHOLD, tpr_threshold)
56 SHADOW_FIELD_RW(GUEST_INTERRUPTIBILITY_INFO, guest_interruptibility_info)
57 SHADOW_FIELD_RW(VMX_PREEMPTION_TIMER_VALUE, vmx_preemption_timer_value)
58 
59 /* Natural width */
60 SHADOW_FIELD_RO(EXIT_QUALIFICATION, exit_qualification)
61 SHADOW_FIELD_RO(GUEST_LINEAR_ADDRESS, guest_linear_address)
62 SHADOW_FIELD_RW(GUEST_RIP, guest_rip)
63 SHADOW_FIELD_RW(GUEST_RSP, guest_rsp)
64 SHADOW_FIELD_RW(GUEST_CR0, guest_cr0)
65 SHADOW_FIELD_RW(GUEST_CR3, guest_cr3)
66 SHADOW_FIELD_RW(GUEST_CR4, guest_cr4)
67 SHADOW_FIELD_RW(GUEST_RFLAGS, guest_rflags)
68 SHADOW_FIELD_RW(CR0_GUEST_HOST_MASK, cr0_guest_host_mask)
69 SHADOW_FIELD_RW(CR0_READ_SHADOW, cr0_read_shadow)
70 SHADOW_FIELD_RW(CR4_READ_SHADOW, cr4_read_shadow)
71 SHADOW_FIELD_RW(HOST_FS_BASE, host_fs_base)
72 SHADOW_FIELD_RW(HOST_GS_BASE, host_gs_base)
73 
74 /* 64-bit */
75 SHADOW_FIELD_RO(GUEST_PHYSICAL_ADDRESS, guest_physical_address)
76 SHADOW_FIELD_RO(GUEST_PHYSICAL_ADDRESS_HIGH, guest_physical_address)
77 
78 #undef SHADOW_FIELD_RO
79 #undef SHADOW_FIELD_RW
80