tools/testing/selftests/kvm/lib/x86/processor.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/lib/x86/processor.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/lib/x86/processor.c- Extension
.c- Size
- 39495 bytes
- Lines
- 1472
- 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
linux/bitmap.htest_util.hkvm_util.hpmu.hprocessor.hsmm.hsvm_util.hsev.hvmx.h
Detected Declarations
function regs_dumpfunction segment_dumpfunction dtable_dumpfunction sregs_dumpfunction kvm_is_tdp_enabledfunction virt_mmu_initfunction virt_arch_pgd_allocfunction tdp_mmu_initfunction __virt_pg_mapfunction virt_arch_pg_mapfunction virt_map_levelfunction vm_is_target_ptefunction virt_arch_dumpfunction vm_enable_tdpfunction kvm_cpu_has_tdpfunction __tdp_mapfunction tdp_mapfunction tdp_identity_map_default_memslotsfunction tdp_identity_map_1gfunction kvm_seg_set_unusablefunction kvm_seg_fill_gdt_64bitfunction kvm_seg_set_kernel_code_64bitfunction kvm_seg_set_kernel_data_64bitfunction addr_arch_gva2gpafunction kvm_seg_set_tss_64bitfunction vcpu_init_sregsfunction vcpu_init_xcrsfunction set_idt_entryfunction kvm_fixup_exceptionfunction route_exceptionfunction vm_init_descriptor_tablesfunction vm_install_exception_handlerfunction assert_on_unhandled_exceptionfunction kvm_arch_vm_post_createfunction vcpu_arch_set_entry_pointfunction vcpu_arch_freefunction __kvm_cpu_hasfunction kvm_cpuid_hasfunction kvm_cpuid_propertyfunction kvm_get_feature_msrfunction __vm_xsave_require_permissionfunction vcpu_init_cpuidfunction vcpu_set_cpuid_propertyfunction vcpu_clear_cpuid_entryfunction vcpu_set_or_clear_cpuid_featurefunction vcpu_get_msrfunction _vcpu_set_msrfunction vcpu_args_set
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2018, Google LLC.
*/
#include "linux/bitmap.h"
#include "test_util.h"
#include "kvm_util.h"
#include "pmu.h"
#include "processor.h"
#include "smm.h"
#include "svm_util.h"
#include "sev.h"
#include "vmx.h"
#ifndef NUM_INTERRUPTS
#define NUM_INTERRUPTS 256
#endif
#define KERNEL_CS 0x8
#define KERNEL_DS 0x10
#define KERNEL_TSS 0x18
gva_t exception_handlers;
bool host_cpu_is_amd;
bool host_cpu_is_intel;
bool host_cpu_is_hygon;
bool host_cpu_is_amd_compatible;
bool is_forced_emulation_enabled;
u64 guest_tsc_khz;
const char *ex_str(int vector)
{
switch (vector) {
#define VEC_STR(v) case v##_VECTOR: return "#" #v
case DE_VECTOR: return "no exception";
case KVM_MAGIC_DE_VECTOR: return "#DE";
VEC_STR(DB);
VEC_STR(NMI);
VEC_STR(BP);
VEC_STR(OF);
VEC_STR(BR);
VEC_STR(UD);
VEC_STR(NM);
VEC_STR(DF);
VEC_STR(TS);
VEC_STR(NP);
VEC_STR(SS);
VEC_STR(GP);
VEC_STR(PF);
VEC_STR(MF);
VEC_STR(AC);
VEC_STR(MC);
VEC_STR(XM);
VEC_STR(VE);
VEC_STR(CP);
VEC_STR(HV);
VEC_STR(VC);
VEC_STR(SX);
default: return "#??";
#undef VEC_STR
}
}
static void regs_dump(FILE *stream, struct kvm_regs *regs, u8 indent)
{
fprintf(stream, "%*srax: 0x%.16llx rbx: 0x%.16llx "
"rcx: 0x%.16llx rdx: 0x%.16llx\n",
indent, "",
regs->rax, regs->rbx, regs->rcx, regs->rdx);
fprintf(stream, "%*srsi: 0x%.16llx rdi: 0x%.16llx "
"rsp: 0x%.16llx rbp: 0x%.16llx\n",
indent, "",
regs->rsi, regs->rdi, regs->rsp, regs->rbp);
fprintf(stream, "%*sr8: 0x%.16llx r9: 0x%.16llx "
"r10: 0x%.16llx r11: 0x%.16llx\n",
indent, "",
regs->r8, regs->r9, regs->r10, regs->r11);
fprintf(stream, "%*sr12: 0x%.16llx r13: 0x%.16llx "
"r14: 0x%.16llx r15: 0x%.16llx\n",
indent, "",
regs->r12, regs->r13, regs->r14, regs->r15);
fprintf(stream, "%*srip: 0x%.16llx rfl: 0x%.16llx\n",
indent, "",
regs->rip, regs->rflags);
}
static void segment_dump(FILE *stream, struct kvm_segment *segment,
u8 indent)
{
Annotation
- Immediate include surface: `linux/bitmap.h`, `test_util.h`, `kvm_util.h`, `pmu.h`, `processor.h`, `smm.h`, `svm_util.h`, `sev.h`.
- Detected declarations: `function regs_dump`, `function segment_dump`, `function dtable_dump`, `function sregs_dump`, `function kvm_is_tdp_enabled`, `function virt_mmu_init`, `function virt_arch_pgd_alloc`, `function tdp_mmu_init`, `function __virt_pg_map`, `function virt_arch_pg_map`.
- 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.