arch/powerpc/kvm/book3s_mmu_hpte.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kvm/book3s_mmu_hpte.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kvm/book3s_mmu_hpte.c- Extension
.c- Size
- 9282 bytes
- Lines
- 381
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.hlinux/hash.hlinux/slab.hlinux/rculist.hasm/kvm_ppc.hasm/kvm_book3s.hasm/machdep.hasm/mmu_context.hasm/hw_irq.htrace_pr.h
Detected Declarations
function kvmppc_mmu_hash_ptefunction kvmppc_mmu_hash_pte_longfunction kvmppc_mmu_hash_vptefunction kvmppc_mmu_hash_vpte_longfunction kvmppc_mmu_hash_vpte_64kfunction kvmppc_mmu_hpte_cache_mapfunction invalidate_ptefunction kvmppc_mmu_pte_flush_allfunction kvmppc_mmu_pte_flush_pagefunction kvmppc_mmu_pte_flush_longfunction kvmppc_mmu_pte_flushfunction kvmppc_mmu_pte_vflush_shortfunction kvmppc_mmu_pte_vflush_64kfunction kvmppc_mmu_pte_vflush_longfunction kvmppc_mmu_pte_vflushfunction kvmppc_mmu_pte_pflushfunction kvmppc_mmu_hpte_cache_freefunction kvmppc_mmu_hpte_destroyfunction kvmppc_mmu_hpte_init_hashfunction kvmppc_mmu_hpte_initfunction kvmppc_mmu_hpte_sysinitfunction kvmppc_mmu_hpte_sysexit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2010 SUSE Linux Products GmbH. All rights reserved.
*
* Authors:
* Alexander Graf <agraf@suse.de>
*/
#include <linux/kvm_host.h>
#include <linux/hash.h>
#include <linux/slab.h>
#include <linux/rculist.h>
#include <asm/kvm_ppc.h>
#include <asm/kvm_book3s.h>
#include <asm/machdep.h>
#include <asm/mmu_context.h>
#include <asm/hw_irq.h>
#include "trace_pr.h"
#define PTE_SIZE 12
static struct kmem_cache *hpte_cache;
static inline u64 kvmppc_mmu_hash_pte(u64 eaddr)
{
return hash_64(eaddr >> PTE_SIZE, HPTEG_HASH_BITS_PTE);
}
static inline u64 kvmppc_mmu_hash_pte_long(u64 eaddr)
{
return hash_64((eaddr & 0x0ffff000) >> PTE_SIZE,
HPTEG_HASH_BITS_PTE_LONG);
}
static inline u64 kvmppc_mmu_hash_vpte(u64 vpage)
{
return hash_64(vpage & 0xfffffffffULL, HPTEG_HASH_BITS_VPTE);
}
static inline u64 kvmppc_mmu_hash_vpte_long(u64 vpage)
{
return hash_64((vpage & 0xffffff000ULL) >> 12,
HPTEG_HASH_BITS_VPTE_LONG);
}
#ifdef CONFIG_PPC_BOOK3S_64
static inline u64 kvmppc_mmu_hash_vpte_64k(u64 vpage)
{
return hash_64((vpage & 0xffffffff0ULL) >> 4,
HPTEG_HASH_BITS_VPTE_64K);
}
#endif
void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte)
{
u64 index;
struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
trace_kvm_book3s_mmu_map(pte);
spin_lock(&vcpu3s->mmu_lock);
/* Add to ePTE list */
index = kvmppc_mmu_hash_pte(pte->pte.eaddr);
hlist_add_head_rcu(&pte->list_pte, &vcpu3s->hpte_hash_pte[index]);
/* Add to ePTE_long list */
index = kvmppc_mmu_hash_pte_long(pte->pte.eaddr);
hlist_add_head_rcu(&pte->list_pte_long,
&vcpu3s->hpte_hash_pte_long[index]);
/* Add to vPTE list */
index = kvmppc_mmu_hash_vpte(pte->pte.vpage);
hlist_add_head_rcu(&pte->list_vpte, &vcpu3s->hpte_hash_vpte[index]);
/* Add to vPTE_long list */
index = kvmppc_mmu_hash_vpte_long(pte->pte.vpage);
hlist_add_head_rcu(&pte->list_vpte_long,
&vcpu3s->hpte_hash_vpte_long[index]);
#ifdef CONFIG_PPC_BOOK3S_64
/* Add to vPTE_64k list */
index = kvmppc_mmu_hash_vpte_64k(pte->pte.vpage);
hlist_add_head_rcu(&pte->list_vpte_64k,
&vcpu3s->hpte_hash_vpte_64k[index]);
#endif
vcpu3s->hpte_cache_count++;
Annotation
- Immediate include surface: `linux/kvm_host.h`, `linux/hash.h`, `linux/slab.h`, `linux/rculist.h`, `asm/kvm_ppc.h`, `asm/kvm_book3s.h`, `asm/machdep.h`, `asm/mmu_context.h`.
- Detected declarations: `function kvmppc_mmu_hash_pte`, `function kvmppc_mmu_hash_pte_long`, `function kvmppc_mmu_hash_vpte`, `function kvmppc_mmu_hash_vpte_long`, `function kvmppc_mmu_hash_vpte_64k`, `function kvmppc_mmu_hpte_cache_map`, `function invalidate_pte`, `function kvmppc_mmu_pte_flush_all`, `function kvmppc_mmu_pte_flush_page`, `function kvmppc_mmu_pte_flush_long`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.