arch/powerpc/include/asm/kvm_book3s_64.h
Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/kvm_book3s_64.h
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/include/asm/kvm_book3s_64.h- Extension
.h- Size
- 19233 bytes
- Lines
- 701
- 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/string.hasm/bitops.hasm/book3s/64/mmu-hash.hasm/cpu_has_feature.hasm/ppc-opcode.hasm/pte-walk.h
Detected Declarations
struct kvm_nested_gueststruct rmap_nestedfunction for_each_nest_rmap_safefunction ___PPC_Rfunction svcpu_putfunction kvm_is_radixfunction kvmhv_vcpu_is_radixfunction try_lock_hptefunction unlock_hptefunction __unlock_hptefunction LPfunction kvmppc_hpte_base_page_shiftfunction kvmppc_hpte_actual_page_shiftfunction kvmppc_actual_pgszfunction kvmppc_pgsize_lp_encodingfunction compute_tlbie_rbfunction hpte_rpnfunction hpte_is_writablefunction hpte_make_readonlyfunction hpte_cache_flags_okfunction kvmppc_read_update_linux_ptefunction hpte_read_permissionfunction hpte_write_permissionfunction hpte_get_skey_permfunction lock_rmapfunction unlock_rmapfunction slot_is_alignedfunction slb_pgsize_encodingfunction is_vrma_hptefunction note_hpte_modificationfunction kvm_memslotsfunction kvmppc_hpt_nptefunction kvmppc_hpt_maskfunction set_dirty_bitsfunction set_dirty_bits_atomicfunction sanitize_msrfunction copy_from_checkpointfunction copy_to_checkpointfunction find_kvm_secondary_pte_unlocked
Annotated Snippet
struct kvm_nested_guest {
struct kvm *l1_host; /* L1 VM that owns this nested guest */
int l1_lpid; /* lpid L1 guest thinks this guest is */
int shadow_lpid; /* real lpid of this nested guest */
pgd_t *shadow_pgtable; /* our page table for this guest */
u64 l1_gr_to_hr; /* L1's addr of part'n-scoped table */
u64 process_table; /* process table entry for this guest */
long refcnt; /* number of pointers to this struct */
struct mutex tlb_lock; /* serialize page faults and tlbies */
struct kvm_nested_guest *next;
cpumask_t need_tlb_flush;
short prev_cpu[NR_CPUS];
u8 radix; /* is this nested guest radix */
};
/*
* We define a nested rmap entry as a single 64-bit quantity
* 0xFFF0000000000000 12-bit lpid field
* 0x000FFFFFFFFFF000 40-bit guest 4k page frame number
* 0x0000000000000001 1-bit single entry flag
*/
#define RMAP_NESTED_LPID_MASK 0xFFF0000000000000UL
#define RMAP_NESTED_LPID_SHIFT (52)
#define RMAP_NESTED_GPA_MASK 0x000FFFFFFFFFF000UL
#define RMAP_NESTED_IS_SINGLE_ENTRY 0x0000000000000001UL
/* Structure for a nested guest rmap entry */
struct rmap_nested {
struct llist_node list;
u64 rmap;
};
/*
* for_each_nest_rmap_safe - iterate over the list of nested rmap entries
* safe against removal of the list entry or NULL list
* @pos: a (struct rmap_nested *) to use as a loop cursor
* @node: pointer to the first entry
* NOTE: this can be NULL
* @rmapp: an (unsigned long *) in which to return the rmap entries on each
* iteration
* NOTE: this must point to already allocated memory
*
* The nested_rmap is a llist of (struct rmap_nested) entries pointed to by the
* rmap entry in the memslot. The list is always terminated by a "single entry"
* stored in the list element of the final entry of the llist. If there is ONLY
* a single entry then this is itself in the rmap entry of the memslot, not a
* llist head pointer.
*
* Note that the iterator below assumes that a nested rmap entry is always
* non-zero. This is true for our usage because the LPID field is always
* non-zero (zero is reserved for the host).
*
* This should be used to iterate over the list of rmap_nested entries with
* processing done on the u64 rmap value given by each iteration. This is safe
* against removal of list entries and it is always safe to call free on (pos).
*
* e.g.
* struct rmap_nested *cursor;
* struct llist_node *first;
* unsigned long rmap;
* for_each_nest_rmap_safe(cursor, first, &rmap) {
* do_something(rmap);
* free(cursor);
* }
*/
#define for_each_nest_rmap_safe(pos, node, rmapp) \
for ((pos) = llist_entry((node), typeof(*(pos)), list); \
(node) && \
(*(rmapp) = ((RMAP_NESTED_IS_SINGLE_ENTRY & ((u64) (node))) ? \
((u64) (node)) : ((pos)->rmap))) && \
(((node) = ((RMAP_NESTED_IS_SINGLE_ENTRY & ((u64) (node))) ? \
((struct llist_node *) ((pos) = NULL)) : \
(pos)->list.next)), true); \
(pos) = llist_entry((node), typeof(*(pos)), list))
struct kvm_nested_guest *kvmhv_get_nested(struct kvm *kvm, int l1_lpid,
bool create);
void kvmhv_put_nested(struct kvm_nested_guest *gp);
int kvmhv_nested_next_lpid(struct kvm *kvm, int lpid);
/* Encoding of first parameter for H_TLB_INVALIDATE */
#define H_TLBIE_P1_ENC(ric, prs, r) (___PPC_RIC(ric) | ___PPC_PRS(prs) | \
___PPC_R(r))
/* Power architecture requires HPT is at least 256kiB, at most 64TiB */
#define PPC_MIN_HPT_ORDER 18
#define PPC_MAX_HPT_ORDER 46
#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
static inline struct kvmppc_book3s_shadow_vcpu *svcpu_get(struct kvm_vcpu *vcpu)
Annotation
- Immediate include surface: `linux/string.h`, `asm/bitops.h`, `asm/book3s/64/mmu-hash.h`, `asm/cpu_has_feature.h`, `asm/ppc-opcode.h`, `asm/pte-walk.h`.
- Detected declarations: `struct kvm_nested_guest`, `struct rmap_nested`, `function for_each_nest_rmap_safe`, `function ___PPC_R`, `function svcpu_put`, `function kvm_is_radix`, `function kvmhv_vcpu_is_radix`, `function try_lock_hpte`, `function unlock_hpte`, `function __unlock_hpte`.
- 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.