arch/arm64/kvm/at.c
Source file repositories/reference/linux-study-clean/arch/arm64/kvm/at.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kvm/at.c- Extension
.c- Size
- 43221 bytes
- Lines
- 1884
- 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.
- 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/kvm_host.hasm/esr.hasm/kvm_hyp.hasm/kvm_mmu.hasm/lsui.h
Detected Declarations
struct mmu_configstruct desc_matchfunction Copyrightfunction get_ia_sizefunction check_output_sizefunction has_52bit_pafunction desc_to_oafunction compute_translation_regimefunction effective_tcr2function s1pie_enabledfunction compute_s1poefunction has_tgranfunction tcr_to_tg0_pgshiftfunction tcr_to_tg1_pgshiftfunction fallback_tgran_shiftfunction tcr_tg_pgshiftfunction setup_s1_walkfunction kvm_read_s1_descfunction kvm_swap_s1_descfunction walk_s1function __mmu_config_savefunction __mmu_config_restorefunction at_s1e1p_fastfunction s2_memattr_to_attrfunction combine_s1_s2_attrfunction compute_final_shfunction compute_s1_shfunction combine_shfunction compute_par_s12function compute_par_s1function pan3_enabledfunction compute_s1_direct_permissionsfunction compute_s1_hierarchical_permissionsfunction compute_s1_indirect_permissionsfunction compute_s1_overlay_permissionsfunction compute_s1_permissionsfunction handle_at_slowfunction __kvm_at_s1e01_fastfunction par_check_s1_perm_faultfunction par_check_s1_access_faultfunction __kvm_at_s1e01function __kvm_at_s1e2function __kvm_at_s12function __kvm_translate_vafunction match_s1_descfunction __kvm_find_s1_desc_levelfunction __lsui_swap_descfunction __lse_swap_desc
Annotated Snippet
struct mmu_config {
u64 ttbr0;
u64 ttbr1;
u64 tcr;
u64 mair;
u64 tcr2;
u64 pir;
u64 pire0;
u64 por_el0;
u64 por_el1;
u64 sctlr;
u64 vttbr;
u64 vtcr;
};
static void __mmu_config_save(struct mmu_config *config)
{
config->ttbr0 = read_sysreg_el1(SYS_TTBR0);
config->ttbr1 = read_sysreg_el1(SYS_TTBR1);
config->tcr = read_sysreg_el1(SYS_TCR);
config->mair = read_sysreg_el1(SYS_MAIR);
if (cpus_have_final_cap(ARM64_HAS_TCR2)) {
config->tcr2 = read_sysreg_el1(SYS_TCR2);
if (cpus_have_final_cap(ARM64_HAS_S1PIE)) {
config->pir = read_sysreg_el1(SYS_PIR);
config->pire0 = read_sysreg_el1(SYS_PIRE0);
}
if (system_supports_poe()) {
config->por_el1 = read_sysreg_el1(SYS_POR);
config->por_el0 = read_sysreg_s(SYS_POR_EL0);
}
}
config->sctlr = read_sysreg_el1(SYS_SCTLR);
config->vttbr = read_sysreg(vttbr_el2);
config->vtcr = read_sysreg(vtcr_el2);
}
static void __mmu_config_restore(struct mmu_config *config)
{
/*
* ARM errata 1165522 and 1530923 require TGE to be 1 before
* we update the guest state.
*/
asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT));
write_sysreg_el1(config->ttbr0, SYS_TTBR0);
write_sysreg_el1(config->ttbr1, SYS_TTBR1);
write_sysreg_el1(config->tcr, SYS_TCR);
write_sysreg_el1(config->mair, SYS_MAIR);
if (cpus_have_final_cap(ARM64_HAS_TCR2)) {
write_sysreg_el1(config->tcr2, SYS_TCR2);
if (cpus_have_final_cap(ARM64_HAS_S1PIE)) {
write_sysreg_el1(config->pir, SYS_PIR);
write_sysreg_el1(config->pire0, SYS_PIRE0);
}
if (system_supports_poe()) {
write_sysreg_el1(config->por_el1, SYS_POR);
write_sysreg_s(config->por_el0, SYS_POR_EL0);
}
}
write_sysreg_el1(config->sctlr, SYS_SCTLR);
write_sysreg(config->vttbr, vttbr_el2);
write_sysreg(config->vtcr, vtcr_el2);
}
static bool at_s1e1p_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
{
u64 host_pan;
bool fail;
host_pan = read_sysreg_s(SYS_PSTATE_PAN);
write_sysreg_s(*vcpu_cpsr(vcpu) & PSTATE_PAN, SYS_PSTATE_PAN);
switch (op) {
case OP_AT_S1E1RP:
fail = __kvm_at(OP_AT_S1E1RP, vaddr);
break;
case OP_AT_S1E1WP:
fail = __kvm_at(OP_AT_S1E1WP, vaddr);
break;
}
write_sysreg_s(host_pan, SYS_PSTATE_PAN);
return fail;
}
#define MEMATTR(ic, oc) (MEMATTR_##oc << 4 | MEMATTR_##ic)
#define MEMATTR_NC 0b0100
#define MEMATTR_Wt 0b1000
Annotation
- Immediate include surface: `linux/kvm_host.h`, `asm/esr.h`, `asm/kvm_hyp.h`, `asm/kvm_mmu.h`, `asm/lsui.h`.
- Detected declarations: `struct mmu_config`, `struct desc_match`, `function Copyright`, `function get_ia_size`, `function check_output_size`, `function has_52bit_pa`, `function desc_to_oa`, `function compute_translation_regime`, `function effective_tcr2`, `function s1pie_enabled`.
- Atlas domain: Architecture Layer / arch/arm64.
- 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.