tools/testing/selftests/kvm/x86/kvm_buslock_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/kvm_buslock_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/x86/kvm_buslock_test.c- Extension
.c- Size
- 3376 bytes
- Lines
- 136
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hkvm_util.hprocessor.hsvm_util.hvmx.htest_util.h
Detected Declarations
function guest_generate_buslocksfunction l2_guest_codefunction l1_svm_codefunction l1_vmx_codefunction guest_codefunction main
Annotated Snippet
if (run->exit_reason == KVM_EXIT_IO) {
switch (get_ucall(vcpu, &uc)) {
case UCALL_ABORT:
REPORT_GUEST_ASSERT(uc);
goto done;
case UCALL_SYNC:
continue;
case UCALL_DONE:
goto done;
default:
TEST_FAIL("Unknown ucall 0x%lx.", uc.cmd);
}
}
TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_X86_BUS_LOCK);
/*
* Verify the counter is actually getting incremented, e.g. that
* KVM isn't skipping the instruction. On Intel, the exit is
* trap-like, i.e. the counter should already have been
* incremented. On AMD, it's fault-like, i.e. the counter will
* be incremented when the guest re-executes the instruction.
*/
sync_global_from_guest(vm, *val);
TEST_ASSERT_EQ(atomic_read(val), bus_locks + host_cpu_is_intel);
bus_locks++;
}
TEST_FAIL("Didn't receive UCALL_DONE, took %u bus lock exits\n", bus_locks);
done:
TEST_ASSERT_EQ(i, bus_locks);
kvm_vm_free(vm);
return 0;
}
Annotation
- Immediate include surface: `linux/atomic.h`, `kvm_util.h`, `processor.h`, `svm_util.h`, `vmx.h`, `test_util.h`.
- Detected declarations: `function guest_generate_buslocks`, `function l2_guest_code`, `function l1_svm_code`, `function l1_vmx_code`, `function guest_code`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.