arch/mips/kvm/tlb.c
Source file repositories/reference/linux-study-clean/arch/mips/kvm/tlb.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/kvm/tlb.c- Extension
.c- Size
- 13078 bytes
- Lines
- 526
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched.hlinux/smp.hlinux/mm.hlinux/delay.hlinux/export.hlinux/kvm_host.hlinux/srcu.hasm/cpu.hasm/bootinfo.hasm/mipsregs.hasm/mmu_context.hasm/cacheflush.hasm/tlb.hasm/tlbdebug.hasm/r4kcache.h
Detected Declarations
function kvm_mips_get_root_asidfunction _kvm_mips_host_tlb_invfunction clear_root_gidfunction set_root_gid_to_guest_gidfunction kvm_vz_host_tlb_invfunction kvm_vz_guest_tlb_lookupfunction kvm_vz_local_flush_roottlb_all_guestsfunction kvm_vz_local_flush_guesttlb_allfunction kvm_vz_save_guesttlbfunction kvm_vz_load_guesttlbfunction kvm_loongson_clear_guest_vtlbfunction kvm_loongson_clear_guest_ftlbexport GUESTID_MASKexport GUESTID_FIRST_VERSIONexport GUESTID_VERSION_MASKexport kvm_vz_host_tlb_invexport kvm_vz_guest_tlb_lookupexport kvm_vz_local_flush_roottlb_all_guestsexport kvm_vz_local_flush_guesttlb_allexport kvm_vz_save_guesttlbexport kvm_vz_load_guesttlbexport kvm_loongson_clear_guest_vtlbexport kvm_loongson_clear_guest_ftlb
Annotated Snippet
#include <linux/sched.h>
#include <linux/smp.h>
#include <linux/mm.h>
#include <linux/delay.h>
#include <linux/export.h>
#include <linux/kvm_host.h>
#include <linux/srcu.h>
#include <asm/cpu.h>
#include <asm/bootinfo.h>
#include <asm/mipsregs.h>
#include <asm/mmu_context.h>
#include <asm/cacheflush.h>
#include <asm/tlb.h>
#include <asm/tlbdebug.h>
#undef CONFIG_MIPS_MT
#include <asm/r4kcache.h>
#define CONFIG_MIPS_MT
unsigned long GUESTID_MASK;
EXPORT_SYMBOL_GPL(GUESTID_MASK);
unsigned long GUESTID_FIRST_VERSION;
EXPORT_SYMBOL_GPL(GUESTID_FIRST_VERSION);
unsigned long GUESTID_VERSION_MASK;
EXPORT_SYMBOL_GPL(GUESTID_VERSION_MASK);
static u32 kvm_mips_get_root_asid(struct kvm_vcpu *vcpu)
{
struct mm_struct *gpa_mm = &vcpu->kvm->arch.gpa_mm;
if (cpu_has_guestid)
return 0;
else
return cpu_asid(smp_processor_id(), gpa_mm);
}
static int _kvm_mips_host_tlb_inv(unsigned long entryhi)
{
int idx;
write_c0_entryhi(entryhi);
mtc0_tlbw_hazard();
tlb_probe();
tlb_probe_hazard();
idx = read_c0_index();
BUG_ON(idx >= current_cpu_data.tlbsize);
if (idx >= 0) {
write_c0_entryhi(UNIQUE_ENTRYHI(idx));
write_c0_entrylo0(0);
write_c0_entrylo1(0);
mtc0_tlbw_hazard();
tlb_write_indexed();
tlbw_use_hazard();
}
return idx;
}
/* GuestID management */
/**
* clear_root_gid() - Set GuestCtl1.RID for normal root operation.
*/
static inline void clear_root_gid(void)
{
if (cpu_has_guestid) {
clear_c0_guestctl1(MIPS_GCTL1_RID);
mtc0_tlbw_hazard();
}
}
/**
* set_root_gid_to_guest_gid() - Set GuestCtl1.RID to match GuestCtl1.ID.
*
* Sets the root GuestID to match the current guest GuestID, for TLB operation
* on the GPA->RPA mappings in the root TLB.
*
* The caller must be sure to disable HTW while the root GID is set, and
* possibly longer if TLB registers are modified.
*/
static inline void set_root_gid_to_guest_gid(void)
{
unsigned int guestctl1;
if (cpu_has_guestid) {
Annotation
- Immediate include surface: `linux/sched.h`, `linux/smp.h`, `linux/mm.h`, `linux/delay.h`, `linux/export.h`, `linux/kvm_host.h`, `linux/srcu.h`, `asm/cpu.h`.
- Detected declarations: `function kvm_mips_get_root_asid`, `function _kvm_mips_host_tlb_inv`, `function clear_root_gid`, `function set_root_gid_to_guest_gid`, `function kvm_vz_host_tlb_inv`, `function kvm_vz_guest_tlb_lookup`, `function kvm_vz_local_flush_roottlb_all_guests`, `function kvm_vz_local_flush_guesttlb_all`, `function kvm_vz_save_guesttlb`, `function kvm_vz_load_guesttlb`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: integration 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.