Lines Matching +full:write +full:- +full:only
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Tests for Hyper-V features enablement
18 * but to activate the feature it is sufficient to set it to a non-zero
27 bool write; member
47 GUEST_ASSERT(msr->idx); in guest_msr()
49 if (msr->write) in guest_msr()
50 vector = wrmsr_safe(msr->idx, msr->write_val); in guest_msr()
52 if (!vector && (!msr->write || !is_write_only_msr(msr->idx))) in guest_msr()
53 vector = rdmsr_safe(msr->idx, &msr_val); in guest_msr()
55 if (msr->fault_expected) in guest_msr()
58 msr->write ? "WR" : "RD", msr->idx, vector); in guest_msr()
62 msr->write ? "WR" : "RD", msr->idx, vector); in guest_msr()
64 if (vector || is_write_only_msr(msr->idx)) in guest_msr()
67 if (msr->write) in guest_msr()
70 msr->idx, msr->write_val, msr_val); in guest_msr()
73 if (msr->idx == HV_X64_MSR_TSC_INVARIANT_CONTROL) { in guest_msr()
90 GUEST_ASSERT_NE(hcall->control, 0); in guest_hcall()
95 if (!(hcall->control & HV_HYPERCALL_FAST_BIT)) { in guest_hcall()
102 vector = __hyperv_hypercall(hcall->control, input, output, &res); in guest_hcall()
103 if (hcall->ud_expected) { in guest_hcall()
106 hcall->control, vector); in guest_hcall()
110 hcall->control, vector); in guest_hcall()
111 GUEST_ASSERT_EQ(res, hcall->expect); in guest_hcall()
120 * Enable all supported Hyper-V features, then clear the leafs holding in vcpu_reset_hv_cpuid()
154 prev_cpuid = allocate_kvm_cpuid2(vcpu->cpuid->nent); in guest_test_msrs_access()
166 * Only available when Hyper-V identification is set in guest_test_msrs_access()
168 msr->idx = HV_X64_MSR_GUEST_OS_ID; in guest_test_msrs_access()
169 msr->write = false; in guest_test_msrs_access()
170 msr->fault_expected = true; in guest_test_msrs_access()
173 msr->idx = HV_X64_MSR_HYPERCALL; in guest_test_msrs_access()
174 msr->write = false; in guest_test_msrs_access()
175 msr->fault_expected = true; in guest_test_msrs_access()
183 msr->idx = HV_X64_MSR_GUEST_OS_ID; in guest_test_msrs_access()
184 msr->write = true; in guest_test_msrs_access()
185 msr->write_val = HYPERV_LINUX_OS_ID; in guest_test_msrs_access()
186 msr->fault_expected = false; in guest_test_msrs_access()
189 msr->idx = HV_X64_MSR_GUEST_OS_ID; in guest_test_msrs_access()
190 msr->write = false; in guest_test_msrs_access()
191 msr->fault_expected = false; in guest_test_msrs_access()
194 msr->idx = HV_X64_MSR_HYPERCALL; in guest_test_msrs_access()
195 msr->write = false; in guest_test_msrs_access()
196 msr->fault_expected = false; in guest_test_msrs_access()
200 msr->idx = HV_X64_MSR_VP_RUNTIME; in guest_test_msrs_access()
201 msr->write = false; in guest_test_msrs_access()
202 msr->fault_expected = true; in guest_test_msrs_access()
206 msr->idx = HV_X64_MSR_VP_RUNTIME; in guest_test_msrs_access()
207 msr->write = false; in guest_test_msrs_access()
208 msr->fault_expected = false; in guest_test_msrs_access()
211 /* Read only */ in guest_test_msrs_access()
212 msr->idx = HV_X64_MSR_VP_RUNTIME; in guest_test_msrs_access()
213 msr->write = true; in guest_test_msrs_access()
214 msr->write_val = 1; in guest_test_msrs_access()
215 msr->fault_expected = true; in guest_test_msrs_access()
219 msr->idx = HV_X64_MSR_TIME_REF_COUNT; in guest_test_msrs_access()
220 msr->write = false; in guest_test_msrs_access()
221 msr->fault_expected = true; in guest_test_msrs_access()
225 msr->idx = HV_X64_MSR_TIME_REF_COUNT; in guest_test_msrs_access()
226 msr->write = false; in guest_test_msrs_access()
227 msr->fault_expected = false; in guest_test_msrs_access()
230 /* Read only */ in guest_test_msrs_access()
231 msr->idx = HV_X64_MSR_TIME_REF_COUNT; in guest_test_msrs_access()
232 msr->write = true; in guest_test_msrs_access()
233 msr->write_val = 1; in guest_test_msrs_access()
234 msr->fault_expected = true; in guest_test_msrs_access()
238 msr->idx = HV_X64_MSR_VP_INDEX; in guest_test_msrs_access()
239 msr->write = false; in guest_test_msrs_access()
240 msr->fault_expected = true; in guest_test_msrs_access()
244 msr->idx = HV_X64_MSR_VP_INDEX; in guest_test_msrs_access()
245 msr->write = false; in guest_test_msrs_access()
246 msr->fault_expected = false; in guest_test_msrs_access()
249 /* Read only */ in guest_test_msrs_access()
250 msr->idx = HV_X64_MSR_VP_INDEX; in guest_test_msrs_access()
251 msr->write = true; in guest_test_msrs_access()
252 msr->write_val = 1; in guest_test_msrs_access()
253 msr->fault_expected = true; in guest_test_msrs_access()
257 msr->idx = HV_X64_MSR_RESET; in guest_test_msrs_access()
258 msr->write = false; in guest_test_msrs_access()
259 msr->fault_expected = true; in guest_test_msrs_access()
263 msr->idx = HV_X64_MSR_RESET; in guest_test_msrs_access()
264 msr->write = false; in guest_test_msrs_access()
265 msr->fault_expected = false; in guest_test_msrs_access()
268 msr->idx = HV_X64_MSR_RESET; in guest_test_msrs_access()
269 msr->write = true; in guest_test_msrs_access()
271 * TODO: the test only writes '0' to HV_X64_MSR_RESET in guest_test_msrs_access()
276 msr->write_val = 0; in guest_test_msrs_access()
277 msr->fault_expected = false; in guest_test_msrs_access()
281 msr->idx = HV_X64_MSR_REFERENCE_TSC; in guest_test_msrs_access()
282 msr->write = false; in guest_test_msrs_access()
283 msr->fault_expected = true; in guest_test_msrs_access()
287 msr->idx = HV_X64_MSR_REFERENCE_TSC; in guest_test_msrs_access()
288 msr->write = false; in guest_test_msrs_access()
289 msr->fault_expected = false; in guest_test_msrs_access()
292 msr->idx = HV_X64_MSR_REFERENCE_TSC; in guest_test_msrs_access()
293 msr->write = true; in guest_test_msrs_access()
294 msr->write_val = 0; in guest_test_msrs_access()
295 msr->fault_expected = false; in guest_test_msrs_access()
299 msr->idx = HV_X64_MSR_EOM; in guest_test_msrs_access()
300 msr->write = false; in guest_test_msrs_access()
301 msr->fault_expected = true; in guest_test_msrs_access()
308 msr->idx = HV_X64_MSR_EOM; in guest_test_msrs_access()
309 msr->write = false; in guest_test_msrs_access()
310 msr->fault_expected = true; in guest_test_msrs_access()
314 msr->idx = HV_X64_MSR_EOM; in guest_test_msrs_access()
315 msr->write = false; in guest_test_msrs_access()
316 msr->fault_expected = false; in guest_test_msrs_access()
319 msr->idx = HV_X64_MSR_EOM; in guest_test_msrs_access()
320 msr->write = true; in guest_test_msrs_access()
321 msr->write_val = 0; in guest_test_msrs_access()
322 msr->fault_expected = false; in guest_test_msrs_access()
326 msr->idx = HV_X64_MSR_STIMER0_CONFIG; in guest_test_msrs_access()
327 msr->write = false; in guest_test_msrs_access()
328 msr->fault_expected = true; in guest_test_msrs_access()
332 msr->idx = HV_X64_MSR_STIMER0_CONFIG; in guest_test_msrs_access()
333 msr->write = false; in guest_test_msrs_access()
334 msr->fault_expected = false; in guest_test_msrs_access()
337 msr->idx = HV_X64_MSR_STIMER0_CONFIG; in guest_test_msrs_access()
338 msr->write = true; in guest_test_msrs_access()
339 msr->write_val = 0; in guest_test_msrs_access()
340 msr->fault_expected = false; in guest_test_msrs_access()
344 msr->idx = HV_X64_MSR_STIMER0_CONFIG; in guest_test_msrs_access()
345 msr->write = true; in guest_test_msrs_access()
346 msr->write_val = 1 << 12; in guest_test_msrs_access()
347 msr->fault_expected = true; in guest_test_msrs_access()
351 msr->idx = HV_X64_MSR_STIMER0_CONFIG; in guest_test_msrs_access()
352 msr->write = true; in guest_test_msrs_access()
353 msr->write_val = 1 << 12; in guest_test_msrs_access()
354 msr->fault_expected = false; in guest_test_msrs_access()
358 msr->idx = HV_X64_MSR_EOI; in guest_test_msrs_access()
359 msr->write = false; in guest_test_msrs_access()
360 msr->fault_expected = true; in guest_test_msrs_access()
364 msr->idx = HV_X64_MSR_EOI; in guest_test_msrs_access()
365 msr->write = true; in guest_test_msrs_access()
366 msr->write_val = 1; in guest_test_msrs_access()
367 msr->fault_expected = false; in guest_test_msrs_access()
371 msr->idx = HV_X64_MSR_TSC_FREQUENCY; in guest_test_msrs_access()
372 msr->write = false; in guest_test_msrs_access()
373 msr->fault_expected = true; in guest_test_msrs_access()
377 msr->idx = HV_X64_MSR_TSC_FREQUENCY; in guest_test_msrs_access()
378 msr->write = false; in guest_test_msrs_access()
379 msr->fault_expected = false; in guest_test_msrs_access()
382 /* Read only */ in guest_test_msrs_access()
383 msr->idx = HV_X64_MSR_TSC_FREQUENCY; in guest_test_msrs_access()
384 msr->write = true; in guest_test_msrs_access()
385 msr->write_val = 1; in guest_test_msrs_access()
386 msr->fault_expected = true; in guest_test_msrs_access()
390 msr->idx = HV_X64_MSR_REENLIGHTENMENT_CONTROL; in guest_test_msrs_access()
391 msr->write = false; in guest_test_msrs_access()
392 msr->fault_expected = true; in guest_test_msrs_access()
396 msr->idx = HV_X64_MSR_REENLIGHTENMENT_CONTROL; in guest_test_msrs_access()
397 msr->write = false; in guest_test_msrs_access()
398 msr->fault_expected = false; in guest_test_msrs_access()
401 msr->idx = HV_X64_MSR_REENLIGHTENMENT_CONTROL; in guest_test_msrs_access()
402 msr->write = true; in guest_test_msrs_access()
403 msr->write_val = 1; in guest_test_msrs_access()
404 msr->fault_expected = false; in guest_test_msrs_access()
407 /* Can only write '0' */ in guest_test_msrs_access()
408 msr->idx = HV_X64_MSR_TSC_EMULATION_STATUS; in guest_test_msrs_access()
409 msr->write = true; in guest_test_msrs_access()
410 msr->write_val = 1; in guest_test_msrs_access()
411 msr->fault_expected = true; in guest_test_msrs_access()
415 msr->idx = HV_X64_MSR_CRASH_P0; in guest_test_msrs_access()
416 msr->write = false; in guest_test_msrs_access()
417 msr->fault_expected = true; in guest_test_msrs_access()
421 msr->idx = HV_X64_MSR_CRASH_P0; in guest_test_msrs_access()
422 msr->write = false; in guest_test_msrs_access()
423 msr->fault_expected = false; in guest_test_msrs_access()
426 msr->idx = HV_X64_MSR_CRASH_P0; in guest_test_msrs_access()
427 msr->write = true; in guest_test_msrs_access()
428 msr->write_val = 1; in guest_test_msrs_access()
429 msr->fault_expected = false; in guest_test_msrs_access()
433 msr->idx = HV_X64_MSR_SYNDBG_STATUS; in guest_test_msrs_access()
434 msr->write = false; in guest_test_msrs_access()
435 msr->fault_expected = true; in guest_test_msrs_access()
440 msr->idx = HV_X64_MSR_SYNDBG_STATUS; in guest_test_msrs_access()
441 msr->write = false; in guest_test_msrs_access()
442 msr->fault_expected = false; in guest_test_msrs_access()
445 msr->idx = HV_X64_MSR_SYNDBG_STATUS; in guest_test_msrs_access()
446 msr->write = true; in guest_test_msrs_access()
447 msr->write_val = 0; in guest_test_msrs_access()
448 msr->fault_expected = false; in guest_test_msrs_access()
455 msr->idx = HV_X64_MSR_TSC_INVARIANT_CONTROL; in guest_test_msrs_access()
456 msr->write = false; in guest_test_msrs_access()
457 msr->fault_expected = true; in guest_test_msrs_access()
464 msr->idx = HV_X64_MSR_TSC_INVARIANT_CONTROL; in guest_test_msrs_access()
465 msr->write = false; in guest_test_msrs_access()
466 msr->fault_expected = false; in guest_test_msrs_access()
472 msr->idx = HV_X64_MSR_TSC_INVARIANT_CONTROL; in guest_test_msrs_access()
473 msr->write = true; in guest_test_msrs_access()
474 msr->write_val = 0xdeadbeef; in guest_test_msrs_access()
475 msr->fault_expected = true; in guest_test_msrs_access()
481 msr->idx = HV_X64_MSR_TSC_INVARIANT_CONTROL; in guest_test_msrs_access()
482 msr->write = true; in guest_test_msrs_access()
483 msr->write_val = 1; in guest_test_msrs_access()
484 msr->fault_expected = false; in guest_test_msrs_access()
494 memcpy(prev_cpuid, vcpu->cpuid, kvm_cpuid2_size(vcpu->cpuid->nent)); in guest_test_msrs_access()
497 msr->idx, msr->write ? "write" : "read"); in guest_test_msrs_access()
546 prev_cpuid = allocate_kvm_cpuid2(vcpu->cpuid->nent); in guest_test_hcalls_access()
554 hcall->control = 0xbeef; in guest_test_hcalls_access()
555 hcall->expect = HV_STATUS_INVALID_HYPERCALL_CODE; in guest_test_hcalls_access()
559 hcall->control = HVCALL_POST_MESSAGE; in guest_test_hcalls_access()
560 hcall->expect = HV_STATUS_ACCESS_DENIED; in guest_test_hcalls_access()
564 hcall->control = HVCALL_POST_MESSAGE; in guest_test_hcalls_access()
565 hcall->expect = HV_STATUS_INVALID_HYPERCALL_INPUT; in guest_test_hcalls_access()
569 hcall->control = HVCALL_SIGNAL_EVENT; in guest_test_hcalls_access()
570 hcall->expect = HV_STATUS_ACCESS_DENIED; in guest_test_hcalls_access()
574 hcall->control = HVCALL_SIGNAL_EVENT; in guest_test_hcalls_access()
575 hcall->expect = HV_STATUS_INVALID_HYPERCALL_INPUT; in guest_test_hcalls_access()
579 hcall->control = HVCALL_RESET_DEBUG_SESSION; in guest_test_hcalls_access()
580 hcall->expect = HV_STATUS_INVALID_HYPERCALL_CODE; in guest_test_hcalls_access()
584 hcall->control = HVCALL_RESET_DEBUG_SESSION; in guest_test_hcalls_access()
585 hcall->expect = HV_STATUS_ACCESS_DENIED; in guest_test_hcalls_access()
589 hcall->control = HVCALL_RESET_DEBUG_SESSION; in guest_test_hcalls_access()
590 hcall->expect = HV_STATUS_OPERATION_DENIED; in guest_test_hcalls_access()
594 hcall->control = HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE; in guest_test_hcalls_access()
595 hcall->expect = HV_STATUS_ACCESS_DENIED; in guest_test_hcalls_access()
599 hcall->control = HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE; in guest_test_hcalls_access()
600 hcall->expect = HV_STATUS_SUCCESS; in guest_test_hcalls_access()
603 hcall->control = HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX; in guest_test_hcalls_access()
604 hcall->expect = HV_STATUS_ACCESS_DENIED; in guest_test_hcalls_access()
608 hcall->control = HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX; in guest_test_hcalls_access()
609 hcall->expect = HV_STATUS_SUCCESS; in guest_test_hcalls_access()
613 hcall->control = HVCALL_SEND_IPI; in guest_test_hcalls_access()
614 hcall->expect = HV_STATUS_ACCESS_DENIED; in guest_test_hcalls_access()
618 hcall->control = HVCALL_SEND_IPI; in guest_test_hcalls_access()
619 hcall->expect = HV_STATUS_INVALID_HYPERCALL_INPUT; in guest_test_hcalls_access()
622 /* Nothing in 'sparse banks' -> success */ in guest_test_hcalls_access()
623 hcall->control = HVCALL_SEND_IPI_EX; in guest_test_hcalls_access()
624 hcall->expect = HV_STATUS_SUCCESS; in guest_test_hcalls_access()
628 hcall->control = HVCALL_NOTIFY_LONG_SPIN_WAIT; in guest_test_hcalls_access()
629 hcall->expect = HV_STATUS_ACCESS_DENIED; in guest_test_hcalls_access()
633 hcall->control = HVCALL_NOTIFY_LONG_SPIN_WAIT; in guest_test_hcalls_access()
634 hcall->expect = HV_STATUS_SUCCESS; in guest_test_hcalls_access()
638 hcall->control = HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE | HV_HYPERCALL_FAST_BIT; in guest_test_hcalls_access()
639 hcall->ud_expected = true; in guest_test_hcalls_access()
643 hcall->control = HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE | HV_HYPERCALL_FAST_BIT; in guest_test_hcalls_access()
644 hcall->ud_expected = false; in guest_test_hcalls_access()
645 hcall->expect = HV_STATUS_SUCCESS; in guest_test_hcalls_access()
648 hcall->control = HV_EXT_CALL_QUERY_CAPABILITIES; in guest_test_hcalls_access()
649 hcall->expect = HV_STATUS_ACCESS_DENIED; in guest_test_hcalls_access()
653 hcall->control = HV_EXT_CALL_QUERY_CAPABILITIES | HV_HYPERCALL_FAST_BIT; in guest_test_hcalls_access()
654 hcall->expect = HV_STATUS_INVALID_PARAMETER; in guest_test_hcalls_access()
663 memcpy(prev_cpuid, vcpu->cpuid, kvm_cpuid2_size(vcpu->cpuid->nent)); in guest_test_hcalls_access()
665 pr_debug("Stage %d: testing hcall: 0x%lx\n", stage, hcall->control); in guest_test_hcalls_access()
690 pr_info("Testing access to Hyper-V specific MSRs\n"); in main()
693 pr_info("Testing access to Hyper-V hypercalls\n"); in main()