tools/testing/selftests/kvm/lib/arm64/processor.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/lib/arm64/processor.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/lib/arm64/processor.c- Extension
.c- Size
- 18848 bytes
- Lines
- 729
- 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/compiler.hassert.hguest_modes.hkvm_util.hprocessor.hucall_common.hvgic.hlinux/bitfield.hlinux/sizes.h
Detected Declarations
struct handlersfunction pgd_indexfunction pud_indexfunction pmd_indexfunction pte_indexfunction use_lpa2_pte_formatfunction addr_ptefunction pte_addrfunction ptrs_per_pgdfunction ptrs_per_ptefunction virt_arch_pgd_allocfunction _virt_pg_mapfunction virt_arch_pg_mapfunction addr_arch_gva2gpafunction pte_dumpfunction virt_arch_dumpfunction vm_supports_el2function kvm_get_default_vcpu_targetfunction aarch64_vcpu_setupfunction vcpu_arch_dumpfunction vcpu_arch_set_entry_pointfunction vcpu_args_setfunction kvm_exit_unexpected_exceptionfunction assert_on_unhandled_exceptionfunction vcpu_init_descriptor_tablesfunction route_exceptionfunction vm_init_descriptor_tablesfunction vm_install_sync_handlerfunction vm_install_exception_handlerfunction guest_get_vcpuidfunction max_ipa_for_page_sizefunction aarch64_get_supported_page_sizesfunction volatilefunction smccc_smcfunction kvm_selftest_arch_initfunction vm_populate_gva_bitmapfunction wfifunction test_wants_mtefunction test_disable_default_vgicfunction kvm_arch_vm_post_createfunction kvm_arch_vm_finalize_vcpusfunction kvm_arch_vm_releasefunction kvm_arch_has_default_irqchip
Annotated Snippet
struct handlers {
handler_fn exception_handlers[VECTOR_NUM][ESR_ELx_EC_MAX + 1];
};
void vcpu_init_descriptor_tables(struct kvm_vcpu *vcpu)
{
extern char vectors;
vcpu_set_reg(vcpu, ctxt_reg_alias(vcpu, SYS_VBAR_EL1), (u64)&vectors);
}
void route_exception(struct ex_regs *regs, int vector)
{
struct handlers *handlers = (struct handlers *)exception_handlers;
bool valid_ec;
int ec = 0;
switch (vector) {
case VECTOR_SYNC_CURRENT:
case VECTOR_SYNC_LOWER_64:
ec = ESR_ELx_EC(read_sysreg(esr_el1));
valid_ec = true;
break;
case VECTOR_IRQ_CURRENT:
case VECTOR_IRQ_LOWER_64:
case VECTOR_FIQ_CURRENT:
case VECTOR_FIQ_LOWER_64:
case VECTOR_ERROR_CURRENT:
case VECTOR_ERROR_LOWER_64:
ec = 0;
valid_ec = false;
break;
default:
valid_ec = false;
goto unexpected_exception;
}
if (handlers && handlers->exception_handlers[vector][ec])
return handlers->exception_handlers[vector][ec](regs);
unexpected_exception:
kvm_exit_unexpected_exception(vector, ec, valid_ec);
}
void vm_init_descriptor_tables(struct kvm_vm *vm)
{
vm->handlers = __vm_alloc(vm, sizeof(struct handlers), vm->page_size,
MEM_REGION_DATA);
*(gva_t *)addr_gva2hva(vm, (gva_t)(&exception_handlers)) = vm->handlers;
}
void vm_install_sync_handler(struct kvm_vm *vm, int vector, int ec,
void (*handler)(struct ex_regs *))
{
struct handlers *handlers = addr_gva2hva(vm, vm->handlers);
assert(VECTOR_IS_SYNC(vector));
assert(vector < VECTOR_NUM);
assert(ec <= ESR_ELx_EC_MAX);
handlers->exception_handlers[vector][ec] = handler;
}
void vm_install_exception_handler(struct kvm_vm *vm, int vector,
void (*handler)(struct ex_regs *))
{
struct handlers *handlers = addr_gva2hva(vm, vm->handlers);
assert(!VECTOR_IS_SYNC(vector));
assert(vector < VECTOR_NUM);
handlers->exception_handlers[vector][0] = handler;
}
u32 guest_get_vcpuid(void)
{
return read_sysreg(tpidr_el1);
}
static u32 max_ipa_for_page_size(u32 vm_ipa, u32 gran,
u32 not_sup_val, u32 ipa52_min_val)
{
if (gran == not_sup_val)
return 0;
else if (gran >= ipa52_min_val && vm_ipa >= 52)
return 52;
else
return min(vm_ipa, 48U);
}
void aarch64_get_supported_page_sizes(u32 ipa, u32 *ipa4k,
Annotation
- Immediate include surface: `linux/compiler.h`, `assert.h`, `guest_modes.h`, `kvm_util.h`, `processor.h`, `ucall_common.h`, `vgic.h`, `linux/bitfield.h`.
- Detected declarations: `struct handlers`, `function pgd_index`, `function pud_index`, `function pmd_index`, `function pte_index`, `function use_lpa2_pte_format`, `function addr_pte`, `function pte_addr`, `function ptrs_per_pgd`, `function ptrs_per_pte`.
- 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.