arch/x86/kvm/mmu/mmu_internal.h
Source file repositories/reference/linux-study-clean/arch/x86/kvm/mmu/mmu_internal.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kvm/mmu/mmu_internal.h- Extension
.h- Size
- 12950 bytes
- Lines
- 415
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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/types.hlinux/kvm_host.hasm/kvm_host.hmmu.h
Detected Declarations
struct kvm_mmu_pagestruct kvm_page_faultfunction kvm_mmu_role_as_idfunction kvm_mmu_page_as_idfunction is_mirror_spfunction kvm_mmu_alloc_external_sptfunction kvm_gfn_root_bitsfunction kvm_mmu_page_ad_need_write_protectfunction gfn_round_for_levelfunction kvm_flush_remote_tlbs_gfnfunction is_nx_huge_page_enabledfunction kvm_mmu_prepare_memory_fault_exitfunction kvm_mmu_do_page_fault
Annotated Snippet
struct kvm_mmu_page {
/*
* Note, "link" through "spt" fit in a single 64 byte cache line on
* 64-bit kernels, keep it that way unless there's a reason not to.
*/
struct list_head link;
struct hlist_node hash_link;
bool tdp_mmu_page;
bool unsync;
union {
u8 mmu_valid_gen;
/* Only accessed under slots_lock. */
bool tdp_mmu_scheduled_root_to_zap;
};
/*
* The shadow page can't be replaced by an equivalent huge page
* because it is being used to map an executable page in the guest
* and the NX huge page mitigation is enabled.
*/
bool nx_huge_page_disallowed;
/*
* The following two entries are used to key the shadow page in the
* hash table.
*/
union kvm_mmu_page_role role;
gfn_t gfn;
u64 *spt;
/*
* Stores the result of the guest translation being shadowed by each
* SPTE. KVM shadows two types of guest translations: nGPA -> GPA
* (shadow EPT/NPT) and GVA -> GPA (traditional shadow paging). In both
* cases the result of the translation is a GPA and a set of access
* constraints.
*
* The GFN is stored in the upper bits (PAGE_SHIFT) and the shadowed
* access permissions are stored in the lower bits. Note, for
* convenience and uniformity across guests, the access permissions are
* stored in KVM format (e.g. ACC_EXEC_MASK) not the raw guest format.
*/
u64 *shadowed_translation;
/* Currently serving as active root */
union {
int root_count;
refcount_t tdp_mmu_root_count;
};
bool has_mapped_host_mmio;
union {
/* These two members aren't used for TDP MMU */
struct {
unsigned int unsync_children;
/*
* Number of writes since the last time traversal
* visited this page.
*/
atomic_t write_flooding_count;
};
/*
* Page table page of external PT.
* Passed to TDX module, not accessed by KVM.
*/
void *external_spt;
};
union {
struct kvm_rmap_head parent_ptes; /* rmap pointers to parent sptes */
tdp_ptep_t ptep;
};
DECLARE_BITMAP(unsync_child_bitmap, 512);
/*
* Tracks shadow pages that, if zapped, would allow KVM to create an NX
* huge page. A shadow page will have nx_huge_page_disallowed set but
* not be on the list if a huge page is disallowed for other reasons,
* e.g. because KVM is shadowing a PTE at the same gfn, the memslot
* isn't properly aligned, etc...
*/
struct list_head possible_nx_huge_page_link;
#ifdef CONFIG_X86_32
/*
* Used out of the mmu-lock to avoid reading spte values while an
* update is in progress; see the comments in __get_spte_lockless().
*/
Annotation
- Immediate include surface: `linux/types.h`, `linux/kvm_host.h`, `asm/kvm_host.h`, `mmu.h`.
- Detected declarations: `struct kvm_mmu_page`, `struct kvm_page_fault`, `function kvm_mmu_role_as_id`, `function kvm_mmu_page_as_id`, `function is_mirror_sp`, `function kvm_mmu_alloc_external_spt`, `function kvm_gfn_root_bits`, `function kvm_mmu_page_ad_need_write_protect`, `function gfn_round_for_level`, `function kvm_flush_remote_tlbs_gfn`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.