arch/powerpc/kvm/book3s_hv_builtin.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kvm/book3s_hv_builtin.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kvm/book3s_hv_builtin.c- Extension
.c- Size
- 16111 bytes
- Lines
- 630
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- 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/cpu.hlinux/kvm_host.hlinux/preempt.hlinux/export.hlinux/sched.hlinux/spinlock.hlinux/init.hlinux/memblock.hlinux/sizes.hlinux/cma.hlinux/bitops.hasm/cputable.hasm/interrupt.hasm/kvm_ppc.hasm/kvm_book3s.hasm/machdep.hasm/xics.hasm/xive.hasm/dbell.hasm/cputhreads.hasm/io.hasm/opal.hasm/smp.hbook3s_xics.hbook3s_xive.hbook3s_hv.h
Detected Declarations
function early_parse_kvm_cma_resvfunction kvm_free_hpt_cmafunction kvm_cma_reservefunction kvmppc_rm_h_conferfunction kvm_hv_vm_activatedfunction kvm_hv_vm_deactivatedfunction kvm_hv_mode_activefunction kvmppc_hcall_impl_hv_realmodefunction kvmppc_hwrng_presentfunction kvmppc_rm_h_randomfunction kvmhv_rm_send_ipifunction cpu_first_thread_siblingfunction kvmhv_interrupt_vcorefunction kvmhv_commence_exitfunction kvmppc_check_passthrufunction kvmppc_check_passthrufunction kvmppc_read_intrfunction kvmppc_read_one_intrfunction kvmppc_end_cedefunction kvmppc_set_msr_hvfunction inject_interruptfunction kvmppc_inject_interrupt_hvfunction guestfunction flush_guest_tlbfunction kvmppc_check_need_tlb_flushexport kvm_alloc_hpt_cmaexport kvm_free_hpt_cmaexport kvm_hv_vm_activatedexport kvm_hv_vm_deactivatedexport kvmppc_hcall_impl_hv_realmodeexport kvmppc_hwrng_presentexport kvmppc_host_rm_ops_hvexport kvmppc_set_msr_hvexport kvmppc_inject_interrupt_hvexport kvmppc_check_need_tlb_flush
Annotated Snippet
if ((threads_ceded | threads_conferring) == threads_running) {
rv = H_TOO_HARD; /* => do yield */
break;
}
}
clear_bit(ptid, &vc->conferring_threads);
return rv;
}
/*
* When running HV mode KVM we need to block certain operations while KVM VMs
* exist in the system. We use a counter of VMs to track this.
*
* One of the operations we need to block is onlining of secondaries, so we
* protect hv_vm_count with cpus_read_lock/unlock().
*/
static atomic_t hv_vm_count;
void kvm_hv_vm_activated(void)
{
cpus_read_lock();
atomic_inc(&hv_vm_count);
cpus_read_unlock();
}
EXPORT_SYMBOL_GPL(kvm_hv_vm_activated);
void kvm_hv_vm_deactivated(void)
{
cpus_read_lock();
atomic_dec(&hv_vm_count);
cpus_read_unlock();
}
EXPORT_SYMBOL_GPL(kvm_hv_vm_deactivated);
bool kvm_hv_mode_active(void)
{
return atomic_read(&hv_vm_count) != 0;
}
extern int hcall_real_table[], hcall_real_table_end[];
int kvmppc_hcall_impl_hv_realmode(unsigned long cmd)
{
cmd /= 4;
if (cmd < hcall_real_table_end - hcall_real_table &&
hcall_real_table[cmd])
return 1;
return 0;
}
EXPORT_SYMBOL_GPL(kvmppc_hcall_impl_hv_realmode);
int kvmppc_hwrng_present(void)
{
return ppc_md.get_random_seed != NULL;
}
EXPORT_SYMBOL_GPL(kvmppc_hwrng_present);
long kvmppc_rm_h_random(struct kvm_vcpu *vcpu)
{
unsigned long rand;
if (ppc_md.get_random_seed &&
ppc_md.get_random_seed(&rand)) {
kvmppc_set_gpr(vcpu, 4, rand);
return H_SUCCESS;
}
return H_HARDWARE;
}
/*
* Send an interrupt or message to another CPU.
* The caller needs to include any barrier needed to order writes
* to memory vs. the IPI/message.
*/
void kvmhv_rm_send_ipi(int cpu)
{
void __iomem *xics_phys;
unsigned long msg = PPC_DBELL_TYPE(PPC_DBELL_SERVER);
/* On POWER9 we can use msgsnd for any destination cpu. */
if (cpu_has_feature(CPU_FTR_ARCH_300)) {
msg |= get_hard_smp_processor_id(cpu);
__asm__ __volatile__ (PPC_MSGSND(%0) : : "r" (msg));
return;
}
/* On POWER8 for IPIs to threads in the same core, use msgsnd. */
if (cpu_has_feature(CPU_FTR_ARCH_207S) &&
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/kvm_host.h`, `linux/preempt.h`, `linux/export.h`, `linux/sched.h`, `linux/spinlock.h`, `linux/init.h`, `linux/memblock.h`.
- Detected declarations: `function early_parse_kvm_cma_resv`, `function kvm_free_hpt_cma`, `function kvm_cma_reserve`, `function kvmppc_rm_h_confer`, `function kvm_hv_vm_activated`, `function kvm_hv_vm_deactivated`, `function kvm_hv_mode_active`, `function kvmppc_hcall_impl_hv_realmode`, `function kvmppc_hwrng_present`, `function kvmppc_rm_h_random`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration 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.