tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c- Extension
.c- Size
- 6088 bytes
- Lines
- 246
- 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.htest_util.hkvm_util.hprocessor.hvmx.h
Detected Declarations
function l2_guest_codefunction l1_guest_codefunction guest_codefunction main
Annotated Snippet
switch (get_ucall(vcpu, &uc)) {
case UCALL_ABORT:
REPORT_GUEST_ASSERT(uc);
/* NOT REACHED */
case UCALL_SYNC:
break;
case UCALL_DONE:
goto done;
default:
TEST_FAIL("Unknown ucall %lu", uc.cmd);
}
/* UCALL_SYNC is handled here. */
TEST_ASSERT(!strcmp((const char *)uc.args[0], "hello") &&
uc.args[1] == stage, "Stage %d: Unexpected register values vmexit, got %lx",
stage, (ulong)uc.args[1]);
/*
* If this stage 2 then we should verify the vmx pt expiry
* is as expected.
* From L1's perspective verify Preemption timer hasn't
* expired too early.
* From L2's perspective verify Preemption timer hasn't
* expired too late.
*/
if (stage == 2) {
pr_info("Stage %d: L1 PT expiry TSC (%lu) , L1 TSC deadline (%lu)\n",
stage, uc.args[2], uc.args[3]);
pr_info("Stage %d: L2 PT expiry TSC (%lu) , L2 TSC deadline (%lu)\n",
stage, uc.args[4], uc.args[5]);
TEST_ASSERT(uc.args[2] >= uc.args[3],
"Stage %d: L1 PT expiry TSC (%lu) < L1 TSC deadline (%lu)",
stage, uc.args[2], uc.args[3]);
TEST_ASSERT(uc.args[4] < uc.args[5],
"Stage %d: L2 PT expiry TSC (%lu) > L2 TSC deadline (%lu)",
stage, uc.args[4], uc.args[5]);
}
state = vcpu_save_state(vcpu);
memset(®s1, 0, sizeof(regs1));
vcpu_regs_get(vcpu, ®s1);
kvm_vm_release(vm);
/* Restore state in a new VM. */
vcpu = vm_recreate_with_one_vcpu(vm);
vcpu_load_state(vcpu, state);
kvm_x86_state_cleanup(state);
memset(®s2, 0, sizeof(regs2));
vcpu_regs_get(vcpu, ®s2);
TEST_ASSERT(!memcmp(®s1, ®s2, sizeof(regs2)),
"Unexpected register values after vcpu_load_state; rdi: %lx rsi: %lx",
(ulong) regs2.rdi, (ulong) regs2.rsi);
}
done:
kvm_vm_free(vm);
}
Annotation
- Immediate include surface: `fcntl.h`, `stdio.h`, `stdlib.h`, `string.h`, `sys/ioctl.h`, `test_util.h`, `kvm_util.h`, `processor.h`.
- Detected declarations: `function l2_guest_code`, `function l1_guest_code`, `function guest_code`, `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.