arch/powerpc/mm/book3s64/hash_native.c
Source file repositories/reference/linux-study-clean/arch/powerpc/mm/book3s64/hash_native.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/mm/book3s64/hash_native.c- Extension
.c- Size
- 22911 bytes
- Lines
- 876
- 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/spinlock.hlinux/bitops.hlinux/of.hlinux/processor.hlinux/threads.hlinux/smp.hlinux/pgtable.hasm/machdep.hasm/mmu.hasm/mmu_context.hasm/trace.hasm/tlb.hasm/cputable.hasm/udbg.hasm/kexec.hasm/ppc-opcode.hasm/feature-fixups.h
Detected Declarations
function acquire_hpte_lockfunction release_hpte_lockfunction acquire_hpte_lockfunction fixup_tlbie_vpnfunction __tlbiefunction __tlbielfunction tlbiefunction native_lock_hptefunction native_unlock_hptefunction native_hpte_insertfunction native_hpte_removefunction native_hpte_updateppfunction __native_hpte_findfunction native_hpte_findfunction native_hpte_updateboltedppfunction native_hpte_removeboltedfunction native_hpte_invalidatefunction native_hugepage_invalidatefunction native_hugepage_invalidatefunction hpte_decodefunction native_hpte_clearfunction __tlbiefunction native_flush_hash_rangefunction pte_iterate_hashed_subpagesfunction pte_iterate_hashed_subpagesfunction pte_iterate_hashed_subpagesfunction hpte_init_native
Annotated Snippet
if (! (be64_to_cpu(hptep->v) & HPTE_V_VALID)) {
/* retry with lock held */
native_lock_hpte(hptep);
if (! (be64_to_cpu(hptep->v) & HPTE_V_VALID))
break;
native_unlock_hpte(hptep);
}
hptep++;
}
if (i == HPTES_PER_GROUP) {
local_irq_restore(flags);
return -1;
}
hpte_v = hpte_encode_v(vpn, psize, apsize, ssize) | vflags | HPTE_V_VALID;
hpte_r = hpte_encode_r(pa, psize, apsize) | rflags;
if (!(vflags & HPTE_V_BOLTED)) {
DBG_LOW(" i=%x hpte_v=%016lx, hpte_r=%016lx\n",
i, hpte_v, hpte_r);
}
if (cpu_has_feature(CPU_FTR_ARCH_300)) {
hpte_r = hpte_old_to_new_r(hpte_v, hpte_r);
hpte_v = hpte_old_to_new_v(hpte_v);
}
hptep->r = cpu_to_be64(hpte_r);
/* Guarantee the second dword is visible before the valid bit */
eieio();
/*
* Now set the first dword including the valid bit
* NOTE: this also unlocks the hpte
*/
release_hpte_lock();
hptep->v = cpu_to_be64(hpte_v);
__asm__ __volatile__ ("ptesync" : : : "memory");
local_irq_restore(flags);
return i | (!!(vflags & HPTE_V_SECONDARY) << 3);
}
static long native_hpte_remove(unsigned long hpte_group)
{
unsigned long hpte_v, flags;
struct hash_pte *hptep;
int i;
int slot_offset;
local_irq_save(flags);
DBG_LOW(" remove(group=%lx)\n", hpte_group);
/* pick a random entry to start at */
slot_offset = mftb() & 0x7;
for (i = 0; i < HPTES_PER_GROUP; i++) {
hptep = htab_address + hpte_group + slot_offset;
hpte_v = be64_to_cpu(hptep->v);
if ((hpte_v & HPTE_V_VALID) && !(hpte_v & HPTE_V_BOLTED)) {
/* retry with lock held */
native_lock_hpte(hptep);
hpte_v = be64_to_cpu(hptep->v);
if ((hpte_v & HPTE_V_VALID)
&& !(hpte_v & HPTE_V_BOLTED))
break;
native_unlock_hpte(hptep);
}
slot_offset++;
slot_offset &= 0x7;
}
if (i == HPTES_PER_GROUP) {
i = -1;
goto out;
}
/* Invalidate the hpte. NOTE: this also unlocks it */
release_hpte_lock();
hptep->v = 0;
out:
local_irq_restore(flags);
return i;
}
Annotation
- Immediate include surface: `linux/spinlock.h`, `linux/bitops.h`, `linux/of.h`, `linux/processor.h`, `linux/threads.h`, `linux/smp.h`, `linux/pgtable.h`, `asm/machdep.h`.
- Detected declarations: `function acquire_hpte_lock`, `function release_hpte_lock`, `function acquire_hpte_lock`, `function fixup_tlbie_vpn`, `function __tlbie`, `function __tlbiel`, `function tlbie`, `function native_lock_hpte`, `function native_unlock_hpte`, `function native_hpte_insert`.
- 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.