MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ept_init

Function ept_init

freebsd/amd64/vmm/intel/ept.c:80–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78 &ept_pmap_flags, 0, NULL);
79
80int
81ept_init(int ipinum)
82{
83 int use_hw_ad_bits, use_superpages, use_exec_only;
84 uint64_t cap;
85
86 cap = rdmsr(MSR_VMX_EPT_VPID_CAP);
87
88 /*
89 * Verify that:
90 * - page walk length is 4 steps
91 * - extended page tables can be laid out in write-back memory
92 * - invvpid instruction with all possible types is supported
93 * - invept instruction with all possible types is supported
94 */
95 if (!EPT_PWL4(cap) ||
96 !EPT_MEMORY_TYPE_WB(cap) ||
97 !INVVPID_SUPPORTED(cap) ||
98 !INVVPID_ALL_TYPES_SUPPORTED(cap) ||
99 !INVEPT_SUPPORTED(cap) ||
100 !INVEPT_ALL_TYPES_SUPPORTED(cap))
101 return (EINVAL);
102
103 ept_pmap_flags = ipinum & PMAP_NESTED_IPIMASK;
104
105 use_superpages = 1;
106 TUNABLE_INT_FETCH("hw.vmm.ept.use_superpages", &use_superpages);
107 if (use_superpages && EPT_PDE_SUPERPAGE(cap))
108 ept_pmap_flags |= PMAP_PDE_SUPERPAGE; /* 2MB superpage */
109
110 use_hw_ad_bits = 1;
111 TUNABLE_INT_FETCH("hw.vmm.ept.use_hw_ad_bits", &use_hw_ad_bits);
112 if (use_hw_ad_bits && AD_BITS_SUPPORTED(cap))
113 ept_enable_ad_bits = 1;
114 else
115 ept_pmap_flags |= PMAP_EMULATE_AD_BITS;
116
117 use_exec_only = 1;
118 TUNABLE_INT_FETCH("hw.vmm.ept.use_exec_only", &use_exec_only);
119 if (use_exec_only && EPT_SUPPORTS_EXEC_ONLY(cap))
120 ept_pmap_flags |= PMAP_SUPPORTS_EXEC_ONLY;
121
122 return (0);
123}
124
125#if 0
126static void

Callers 1

vmx_modinitFunction · 0.85

Calls 1

rdmsrFunction · 0.50

Tested by

no test coverage detected