Lines Matching full:state
28 void test_nested_state(struct kvm_vcpu *vcpu, struct kvm_nested_state *state) in test_nested_state() argument
30 vcpu_nested_state_set(vcpu, state); in test_nested_state()
34 struct kvm_nested_state *state, in test_nested_state_expect_errno() argument
39 rv = __vcpu_nested_state_set(vcpu, state); in test_nested_state_expect_errno()
47 struct kvm_nested_state *state) in test_nested_state_expect_einval() argument
49 test_nested_state_expect_errno(vcpu, state, EINVAL); in test_nested_state_expect_einval()
53 struct kvm_nested_state *state) in test_nested_state_expect_efault() argument
55 test_nested_state_expect_errno(vcpu, state, EFAULT); in test_nested_state_expect_efault()
58 void set_revision_id_for_vmcs12(struct kvm_nested_state *state, in set_revision_id_for_vmcs12() argument
62 memcpy(&state->data, &vmcs12_revision, sizeof(u32)); in set_revision_id_for_vmcs12()
65 void set_default_state(struct kvm_nested_state *state) in set_default_state() argument
67 memset(state, 0, sizeof(*state)); in set_default_state()
68 state->flags = KVM_STATE_NESTED_RUN_PENDING | in set_default_state()
70 state->format = 0; in set_default_state()
71 state->size = sizeof(*state); in set_default_state()
74 void set_default_vmx_state(struct kvm_nested_state *state, int size) in set_default_vmx_state() argument
76 memset(state, 0, size); in set_default_vmx_state()
78 state->flags = KVM_STATE_NESTED_EVMCS; in set_default_vmx_state()
79 state->format = 0; in set_default_vmx_state()
80 state->size = size; in set_default_vmx_state()
81 state->hdr.vmx.vmxon_pa = 0x1000; in set_default_vmx_state()
82 state->hdr.vmx.vmcs12_pa = 0x2000; in set_default_vmx_state()
83 state->hdr.vmx.smm.flags = 0; in set_default_vmx_state()
84 set_revision_id_for_vmcs12(state, VMCS12_REVISION); in set_default_vmx_state()
91 struct kvm_nested_state *state = in test_vmx_nested_state() local
95 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
96 state->format = 1; in test_vmx_nested_state()
97 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
103 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
104 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
111 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
112 state->hdr.vmx.vmxon_pa = -1ull; in test_vmx_nested_state()
113 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
115 state->hdr.vmx.vmcs12_pa = -1ull; in test_vmx_nested_state()
116 state->flags = KVM_STATE_NESTED_EVMCS; in test_vmx_nested_state()
117 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
119 state->flags = 0; in test_vmx_nested_state()
120 test_nested_state(vcpu, state); in test_vmx_nested_state()
127 * setting the nested state. When the eVMCS flag is not set, the in test_vmx_nested_state()
130 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
131 state->flags = 0; in test_vmx_nested_state()
132 state->hdr.vmx.vmxon_pa = -1ull; in test_vmx_nested_state()
133 state->hdr.vmx.vmcs12_pa = -1ull; in test_vmx_nested_state()
134 test_nested_state(vcpu, state); in test_vmx_nested_state()
141 state->flags = KVM_STATE_NESTED_EVMCS; in test_vmx_nested_state()
142 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
144 test_nested_state(vcpu, state); in test_vmx_nested_state()
148 state->hdr.vmx.smm.flags = 1; in test_vmx_nested_state()
149 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
152 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
153 state->hdr.vmx.flags = ~0; in test_vmx_nested_state()
154 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
157 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
158 state->hdr.vmx.vmxon_pa = -1ull; in test_vmx_nested_state()
159 state->flags = 0; in test_vmx_nested_state()
160 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
163 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
164 state->hdr.vmx.vmxon_pa = 1; in test_vmx_nested_state()
165 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
171 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
172 state->flags = KVM_STATE_NESTED_GUEST_MODE | in test_vmx_nested_state()
174 state->hdr.vmx.smm.flags = KVM_STATE_NESTED_SMM_GUEST_MODE; in test_vmx_nested_state()
175 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
182 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
183 state->hdr.vmx.smm.flags = ~(KVM_STATE_NESTED_SMM_GUEST_MODE | in test_vmx_nested_state()
185 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
188 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
189 state->flags = 0; in test_vmx_nested_state()
190 state->hdr.vmx.smm.flags = KVM_STATE_NESTED_SMM_GUEST_MODE; in test_vmx_nested_state()
191 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
197 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
198 state->size = sizeof(*state); in test_vmx_nested_state()
199 state->flags = 0; in test_vmx_nested_state()
200 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
202 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
203 state->size = sizeof(*state); in test_vmx_nested_state()
204 state->flags = 0; in test_vmx_nested_state()
205 state->hdr.vmx.vmcs12_pa = -1; in test_vmx_nested_state()
206 test_nested_state(vcpu, state); in test_vmx_nested_state()
212 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
213 state->flags = 0; in test_vmx_nested_state()
214 test_nested_state(vcpu, state); in test_vmx_nested_state()
217 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
218 state->size = sizeof(*state); in test_vmx_nested_state()
219 state->flags = 0; in test_vmx_nested_state()
220 state->hdr.vmx.vmcs12_pa = -1; in test_vmx_nested_state()
221 state->hdr.vmx.flags = ~0; in test_vmx_nested_state()
222 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
225 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
226 state->hdr.vmx.vmxon_pa = 0; in test_vmx_nested_state()
227 state->hdr.vmx.vmcs12_pa = 0; in test_vmx_nested_state()
228 test_nested_state_expect_einval(vcpu, state); in test_vmx_nested_state()
231 * Test that if we leave nesting the state reflects that when we get in test_vmx_nested_state()
234 set_default_vmx_state(state, state_sz); in test_vmx_nested_state()
235 state->hdr.vmx.vmxon_pa = -1ull; in test_vmx_nested_state()
236 state->hdr.vmx.vmcs12_pa = -1ull; in test_vmx_nested_state()
237 state->flags = 0; in test_vmx_nested_state()
238 test_nested_state(vcpu, state); in test_vmx_nested_state()
239 vcpu_nested_state_get(vcpu, state); in test_vmx_nested_state()
240 TEST_ASSERT(state->size >= sizeof(*state) && state->size <= state_sz, in test_vmx_nested_state()
242 sizeof(*state), state_sz, state->size); in test_vmx_nested_state()
244 TEST_ASSERT_EQ(state->hdr.vmx.vmxon_pa, -1ull); in test_vmx_nested_state()
245 TEST_ASSERT_EQ(state->hdr.vmx.vmcs12_pa, -1ull); in test_vmx_nested_state()
246 TEST_ASSERT_EQ(state->flags, 0); in test_vmx_nested_state()
248 free(state); in test_vmx_nested_state()
265 void set_default_svm_state(struct kvm_nested_state *state, int size) in set_default_svm_state() argument
267 memset(state, 0, size); in set_default_svm_state()
268 state->format = 1; in set_default_svm_state()
269 state->size = size; in set_default_svm_state()
270 state->hdr.svm.vmcb_pa = 0x3000; in set_default_svm_state()
277 struct kvm_nested_state *state = in test_svm_nested_state() local
283 set_default_svm_state(state, state_sz); in test_svm_nested_state()
284 state->format = 0; in test_svm_nested_state()
285 test_nested_state_expect_einval(vcpu, state); in test_svm_nested_state()
288 set_default_svm_state(state, state_sz); in test_svm_nested_state()
289 state->flags = KVM_STATE_NESTED_EVMCS; in test_svm_nested_state()
290 test_nested_state_expect_einval(vcpu, state); in test_svm_nested_state()
298 set_default_svm_state(state, state_sz); in test_svm_nested_state()
299 state->flags = KVM_STATE_NESTED_GUEST_MODE; in test_svm_nested_state()
300 test_nested_state_expect_einval(vcpu, state); in test_svm_nested_state()
302 state->flags = 0; in test_svm_nested_state()
303 test_nested_state(vcpu, state); in test_svm_nested_state()
305 state->flags = KVM_STATE_NESTED_GIF_SET; in test_svm_nested_state()
306 test_nested_state(vcpu, state); in test_svm_nested_state()
312 set_default_svm_state(state, state_sz); in test_svm_nested_state()
313 state->hdr.svm.vmcb_pa = -1ull; in test_svm_nested_state()
314 state->flags = 0; in test_svm_nested_state()
315 test_nested_state(vcpu, state); in test_svm_nested_state()
316 state->flags = KVM_STATE_NESTED_GUEST_MODE; in test_svm_nested_state()
317 test_nested_state_expect_einval(vcpu, state); in test_svm_nested_state()
323 set_default_svm_state(state, state_sz/2); in test_svm_nested_state()
324 state->flags = 0; in test_svm_nested_state()
325 test_nested_state(vcpu, state); in test_svm_nested_state()
326 state->flags = KVM_STATE_NESTED_GUEST_MODE; in test_svm_nested_state()
327 test_nested_state_expect_einval(vcpu, state); in test_svm_nested_state()
330 * Test that if we leave nesting the state reflects that when we get it in test_svm_nested_state()
334 set_default_svm_state(state, state_sz); in test_svm_nested_state()
335 state->hdr.svm.vmcb_pa = -1ull; in test_svm_nested_state()
336 state->flags = KVM_STATE_NESTED_GIF_SET; in test_svm_nested_state()
337 test_nested_state(vcpu, state); in test_svm_nested_state()
338 vcpu_nested_state_get(vcpu, state); in test_svm_nested_state()
339 TEST_ASSERT(state->size >= sizeof(*state) && state->size <= state_sz, in test_svm_nested_state()
341 sizeof(*state), state_sz, state->size); in test_svm_nested_state()
343 TEST_ASSERT_EQ(state->hdr.svm.vmcb_pa, 0); in test_svm_nested_state()
344 TEST_ASSERT_EQ(state->flags, KVM_STATE_NESTED_GIF_SET); in test_svm_nested_state()
346 free(state); in test_svm_nested_state()
352 struct kvm_nested_state state; in main() local
376 set_default_state(&state); in main()
377 state.size = 0; in main()
378 test_nested_state_expect_einval(vcpu, &state); in main()
387 set_default_state(&state); in main()
388 state.flags = 0xf; in main()
389 test_nested_state_expect_einval(vcpu, &state); in main()
395 set_default_state(&state); in main()
396 state.flags = KVM_STATE_NESTED_RUN_PENDING; in main()
397 test_nested_state_expect_einval(vcpu, &state); in main()