arch/arm64/kvm/handle_exit.c
Source file repositories/reference/linux-study-clean/arch/arm64/kvm/handle_exit.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kvm/handle_exit.c- Extension
.c- Size
- 16149 bytes
- Lines
- 581
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kvm.hlinux/kvm_host.hlinux/ubsan.hasm/esr.hasm/exception.hasm/kvm_asm.hasm/kvm_emulate.hasm/kvm_mmu.hasm/kvm_nested.hasm/debug-monitors.hasm/stacktrace/nvhe.hasm/traps.hkvm/arm_hypercalls.htrace_handle_exit.h
Detected Declarations
function kvm_handle_guest_serrorfunction handle_hvcfunction handle_smcfunction fixup_guest_exitfunction kvm_handle_wfxfunction kvm_handle_guest_debugfunction kvm_handle_unknown_ecfunction handle_svefunction bugfunction kvm_handle_eretfunction handle_svcfunction kvm_handle_gcsfunction handle_otherfunction kvm_get_exit_handlerfunction handle_trap_exceptionsfunction handle_exitfunction handle_exit_earlyfunction print_nvhe_hyp_panicfunction kvm_nvhe_report_cfi_failurefunction nvhe_hyp_panic_handlerfunction esr_brk_commentfunction ESR_ELx_EC
Annotated Snippet
if (esr & ESR_ELx_WFx_ISS_RV) {
u64 val, now;
now = kvm_phys_timer_read();
if (is_hyp_ctxt(vcpu) && vcpu_el2_e2h_is_set(vcpu))
now -= timer_get_offset(vcpu_hvtimer(vcpu));
else
now -= timer_get_offset(vcpu_vtimer(vcpu));
val = vcpu_get_reg(vcpu, kvm_vcpu_sys_get_rt(vcpu));
if (now >= val)
goto out;
} else {
/* Treat WFxT as WFx if RN is invalid */
esr &= ~ESR_ELx_WFx_ISS_WFxT;
}
}
if (esr & ESR_ELx_WFx_ISS_WFE) {
kvm_vcpu_on_spin(vcpu, vcpu_mode_priv(vcpu));
} else {
if (esr & ESR_ELx_WFx_ISS_WFxT)
vcpu_set_flag(vcpu, IN_WFIT);
kvm_vcpu_wfi(vcpu);
}
out:
kvm_incr_pc(vcpu);
return 1;
}
/**
* kvm_handle_guest_debug - handle a debug exception instruction
*
* @vcpu: the vcpu pointer
*
* We route all debug exceptions through the same handler. If both the
* guest and host are using the same debug facilities it will be up to
* userspace to re-inject the correct exception for guest delivery.
*
* @return: 0 (while setting vcpu->run->exit_reason)
*/
static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu)
{
struct kvm_run *run = vcpu->run;
u64 esr = kvm_vcpu_get_esr(vcpu);
if (!vcpu->guest_debug && forward_debug_exception(vcpu))
return 1;
run->exit_reason = KVM_EXIT_DEBUG;
run->debug.arch.hsr = lower_32_bits(esr);
run->debug.arch.hsr_high = upper_32_bits(esr);
run->flags = KVM_DEBUG_ARCH_HSR_HIGH_VALID;
switch (ESR_ELx_EC(esr)) {
case ESR_ELx_EC_WATCHPT_LOW:
run->debug.arch.far = vcpu->arch.fault.far_el2;
break;
case ESR_ELx_EC_SOFTSTP_LOW:
*vcpu_cpsr(vcpu) |= DBG_SPSR_SS;
break;
}
return 0;
}
static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu)
{
u64 esr = kvm_vcpu_get_esr(vcpu);
kvm_pr_unimpl("Unknown exception class: esr: %#016llx -- %s\n",
esr, esr_get_class_string(esr));
kvm_inject_undefined(vcpu);
return 1;
}
/*
* Guest access to SVE registers should be routed to this handler only
* when the system doesn't support SVE.
*/
static int handle_sve(struct kvm_vcpu *vcpu)
{
if (guest_hyp_sve_traps_enabled(vcpu))
return kvm_inject_nested_sync(vcpu, kvm_vcpu_get_esr(vcpu));
kvm_inject_undefined(vcpu);
Annotation
- Immediate include surface: `linux/kvm.h`, `linux/kvm_host.h`, `linux/ubsan.h`, `asm/esr.h`, `asm/exception.h`, `asm/kvm_asm.h`, `asm/kvm_emulate.h`, `asm/kvm_mmu.h`.
- Detected declarations: `function kvm_handle_guest_serror`, `function handle_hvc`, `function handle_smc`, `function fixup_guest_exit`, `function kvm_handle_wfx`, `function kvm_handle_guest_debug`, `function kvm_handle_unknown_ec`, `function handle_sve`, `function bug`, `function kvm_handle_eret`.
- Atlas domain: Architecture Layer / arch/arm64.
- 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.