tools/testing/selftests/kvm/x86/monitor_mwait_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/monitor_mwait_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/x86/monitor_mwait_test.c- Extension
.c- Size
- 3728 bytes
- Lines
- 137
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fcntl.hstdio.hstdlib.hstring.hsys/ioctl.hkvm_util.hprocessor.hkselftest.h
Detected Declarations
enum monitor_mwait_testcasesfunction guest_monitor_waitfunction main
Annotated Snippet
if (testcase & MWAIT_QUIRK_DISABLED) {
disabled_quirks |= KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS;
strcpy(test, "MWAIT can fault");
} else {
strcpy(test, "MWAIT never faults");
}
if (testcase & MISC_ENABLES_QUIRK_DISABLED) {
disabled_quirks |= KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT;
strcat(test, ", MISC_ENABLE updates CPUID");
} else {
strcat(test, ", no CPUID updates");
}
vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, disabled_quirks);
if (!(testcase & MISC_ENABLES_QUIRK_DISABLED) &&
(!!(testcase & CPUID_DISABLED) ^ !!(testcase & MWAIT_DISABLED)))
continue;
if (testcase & CPUID_DISABLED) {
strcat(test, ", CPUID clear");
vcpu_clear_cpuid_feature(vcpu, X86_FEATURE_MWAIT);
} else {
strcat(test, ", CPUID set");
vcpu_set_cpuid_feature(vcpu, X86_FEATURE_MWAIT);
}
if (testcase & MWAIT_DISABLED)
strcat(test, ", MWAIT disabled");
vcpu_run(vcpu);
TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_IO);
switch (get_ucall(vcpu, &uc)) {
case UCALL_ABORT:
/* Detected in vcpu_run */
break;
case UCALL_DONE:
ksft_test_result_pass("%s\n", test);
break;
default:
TEST_FAIL("Unknown ucall %lu", uc.cmd);
break;
}
kvm_vm_free(vm);
}
ksft_finished();
return 0;
}
Annotation
- Immediate include surface: `fcntl.h`, `stdio.h`, `stdlib.h`, `string.h`, `sys/ioctl.h`, `kvm_util.h`, `processor.h`, `kselftest.h`.
- Detected declarations: `enum monitor_mwait_testcases`, `function guest_monitor_wait`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.