tools/testing/selftests/kvm/x86/userspace_msr_exit_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/userspace_msr_exit_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/x86/userspace_msr_exit_test.c- Extension
.c- Size
- 19891 bytes
- Lines
- 778
- 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
sys/ioctl.hkvm_test_harness.htest_util.hkvm_util.hvmx.h
Detected Declarations
function deny_msrfunction prepare_bitmapsfunction test_rdmsrfunction test_wrmsrfunction test_em_rdmsrfunction test_em_wrmsrfunction guest_code_filter_allowfunction guest_msr_callsfunction guest_code_filter_denyfunction guest_code_permission_bitmapfunction __guest_gp_handlerfunction guest_gp_handlerfunction guest_fep_gp_handlerfunction check_for_guest_assertfunction process_rdmsrfunction process_wrmsrfunction process_ucall_donefunction process_ucallfunction run_guest_then_process_rdmsrfunction run_guest_then_process_wrmsrfunction run_guest_then_process_ucallfunction run_guest_then_process_ucall_donefunction handle_ucallfunction handle_rdmsrfunction handle_wrmsrfunction run_user_space_msr_flag_testfunction run_msr_filter_flag_testfunction main
Annotated Snippet
get_ucall(vcpu, &uc) == UCALL_ABORT) {
REPORT_GUEST_ASSERT(uc);
}
}
static void process_rdmsr(struct kvm_vcpu *vcpu, u32 msr_index)
{
struct kvm_run *run = vcpu->run;
check_for_guest_assert(vcpu);
TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_X86_RDMSR);
TEST_ASSERT(run->msr.index == msr_index,
"Unexpected msr (0x%04x), expected 0x%04x",
run->msr.index, msr_index);
switch (run->msr.index) {
case MSR_IA32_XSS:
run->msr.data = 0;
break;
case MSR_IA32_FLUSH_CMD:
run->msr.error = 1;
break;
case MSR_NON_EXISTENT:
run->msr.data = msr_non_existent_data;
break;
case MSR_FS_BASE:
run->msr.data = MSR_FS_BASE;
break;
case MSR_GS_BASE:
run->msr.data = MSR_GS_BASE;
break;
default:
TEST_ASSERT(false, "Unexpected MSR: 0x%04x", run->msr.index);
}
}
static void process_wrmsr(struct kvm_vcpu *vcpu, u32 msr_index)
{
struct kvm_run *run = vcpu->run;
check_for_guest_assert(vcpu);
TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_X86_WRMSR);
TEST_ASSERT(run->msr.index == msr_index,
"Unexpected msr (0x%04x), expected 0x%04x",
run->msr.index, msr_index);
switch (run->msr.index) {
case MSR_IA32_XSS:
if (run->msr.data != 0)
run->msr.error = 1;
break;
case MSR_IA32_FLUSH_CMD:
if (run->msr.data != 1)
run->msr.error = 1;
break;
case MSR_NON_EXISTENT:
msr_non_existent_data = run->msr.data;
break;
default:
TEST_ASSERT(false, "Unexpected MSR: 0x%04x", run->msr.index);
}
}
static void process_ucall_done(struct kvm_vcpu *vcpu)
{
struct ucall uc;
check_for_guest_assert(vcpu);
TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_IO);
TEST_ASSERT(get_ucall(vcpu, &uc) == UCALL_DONE,
"Unexpected ucall command: %lu, expected UCALL_DONE (%d)",
uc.cmd, UCALL_DONE);
}
static u64 process_ucall(struct kvm_vcpu *vcpu)
{
struct ucall uc = {};
check_for_guest_assert(vcpu);
TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_IO);
switch (get_ucall(vcpu, &uc)) {
case UCALL_SYNC:
break;
case UCALL_ABORT:
Annotation
- Immediate include surface: `sys/ioctl.h`, `kvm_test_harness.h`, `test_util.h`, `kvm_util.h`, `vmx.h`.
- Detected declarations: `function deny_msr`, `function prepare_bitmaps`, `function test_rdmsr`, `function test_wrmsr`, `function test_em_rdmsr`, `function test_em_wrmsr`, `function guest_code_filter_allow`, `function guest_msr_calls`, `function guest_code_filter_deny`, `function guest_code_permission_bitmap`.
- 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.