arch/powerpc/kvm/powerpc.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kvm/powerpc.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kvm/powerpc.c- Extension
.c- Size
- 58892 bytes
- Lines
- 2526
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/err.hlinux/kvm_host.hlinux/vmalloc.hlinux/hrtimer.hlinux/sched/signal.hlinux/fs.hlinux/slab.hlinux/file.hlinux/module.hlinux/irqbypass.hlinux/kvm_irqfd.hlinux/of.hasm/cputable.hlinux/uaccess.hasm/kvm_ppc.hasm/cputhreads.hasm/irqflags.hasm/iommu.hasm/switch_to.hasm/xive.hasm/hvcall.hasm/plpar_wrappers.hasm/ultravisor.hasm/setup.htiming.h../mm/mmu_decl.htrace.h
Detected Declarations
function kvm_arch_vcpu_runnablefunction kvm_arch_dy_runnablefunction kvm_arch_vcpu_in_kernelfunction kvm_arch_vcpu_should_kickfunction kvmppc_prepare_to_enterfunction kvmppc_swab_sharedfunction kvmppc_kvm_pvfunction kvmppc_sanity_checkfunction kvmppc_emulate_mmiofunction kvmppc_stfunction kvmppc_ldfunction kvm_arch_init_vmfunction kvm_arch_destroy_vmfunction kvm_vm_ioctl_check_extensionfunction kvm_arch_dev_ioctlfunction kvm_arch_free_memslotfunction kvm_arch_prepare_memory_regionfunction kvm_arch_commit_memory_regionfunction kvm_arch_flush_shadow_memslotfunction kvm_arch_vcpu_precreatefunction kvmppc_decrementer_wakeupfunction kvm_arch_vcpu_createfunction kvm_arch_vcpu_postcreatefunction kvm_cpu_has_pending_timerfunction kvm_arch_vcpu_loadfunction kvm_arch_vcpu_putfunction kvm_arch_has_irq_bypassfunction kvm_arch_irq_bypass_add_producerfunction kvm_arch_irq_bypass_del_producerfunction kvmppc_get_vsr_dword_offsetfunction kvmppc_get_vsr_word_offsetfunction kvmppc_set_vsr_dwordfunction kvmppc_set_vsr_dword_dumpfunction kvmppc_set_vsr_word_dumpfunction kvmppc_set_vsr_wordfunction kvmppc_get_vmx_offset_genericfunction kvmppc_get_vmx_dword_offsetfunction kvmppc_get_vmx_word_offsetfunction kvmppc_get_vmx_hword_offsetfunction kvmppc_get_vmx_byte_offsetfunction kvmppc_set_vmx_dwordfunction kvmppc_set_vmx_wordfunction kvmppc_set_vmx_hwordfunction kvmppc_set_vmx_bytefunction sp_to_dpfunction dp_to_spfunction kvmppc_complete_mmio_loadfunction __kvmppc_handle_load
Annotated Snippet
if (need_resched()) {
local_irq_enable();
cond_resched();
hard_irq_disable();
continue;
}
if (signal_pending(current)) {
kvmppc_account_exit(vcpu, SIGNAL_EXITS);
vcpu->run->exit_reason = KVM_EXIT_INTR;
r = -EINTR;
break;
}
vcpu->mode = IN_GUEST_MODE;
/*
* Reading vcpu->requests must happen after setting vcpu->mode,
* so we don't miss a request because the requester sees
* OUTSIDE_GUEST_MODE and assumes we'll be checking requests
* before next entering the guest (and thus doesn't IPI).
* This also orders the write to mode from any reads
* to the page tables done while the VCPU is running.
* Please see the comment in kvm_flush_remote_tlbs.
*/
smp_mb();
if (kvm_request_pending(vcpu)) {
/* Make sure we process requests preemptable */
local_irq_enable();
trace_kvm_check_requests(vcpu);
r = kvmppc_core_check_requests(vcpu);
hard_irq_disable();
if (r > 0)
continue;
break;
}
if (kvmppc_core_prepare_to_enter(vcpu)) {
/* interrupts got enabled in between, so we
are back at square 1 */
continue;
}
guest_enter_irqoff();
return 1;
}
/* return to host */
local_irq_enable();
return r;
}
EXPORT_SYMBOL_GPL(kvmppc_prepare_to_enter);
#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE)
static void kvmppc_swab_shared(struct kvm_vcpu *vcpu)
{
struct kvm_vcpu_arch_shared *shared = vcpu->arch.shared;
int i;
shared->sprg0 = swab64(shared->sprg0);
shared->sprg1 = swab64(shared->sprg1);
shared->sprg2 = swab64(shared->sprg2);
shared->sprg3 = swab64(shared->sprg3);
shared->srr0 = swab64(shared->srr0);
shared->srr1 = swab64(shared->srr1);
shared->dar = swab64(shared->dar);
shared->msr = swab64(shared->msr);
shared->dsisr = swab32(shared->dsisr);
shared->int_pending = swab32(shared->int_pending);
for (i = 0; i < ARRAY_SIZE(shared->sr); i++)
shared->sr[i] = swab32(shared->sr[i]);
}
#endif
int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
{
int nr = kvmppc_get_gpr(vcpu, 11);
int r;
unsigned long __maybe_unused param1 = kvmppc_get_gpr(vcpu, 3);
unsigned long __maybe_unused param2 = kvmppc_get_gpr(vcpu, 4);
unsigned long __maybe_unused param3 = kvmppc_get_gpr(vcpu, 5);
unsigned long __maybe_unused param4 = kvmppc_get_gpr(vcpu, 6);
unsigned long r2 = 0;
if (!(kvmppc_get_msr(vcpu) & MSR_SF)) {
/* 32 bit mode */
param1 &= 0xffffffff;
param2 &= 0xffffffff;
param3 &= 0xffffffff;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/err.h`, `linux/kvm_host.h`, `linux/vmalloc.h`, `linux/hrtimer.h`, `linux/sched/signal.h`, `linux/fs.h`, `linux/slab.h`.
- Detected declarations: `function kvm_arch_vcpu_runnable`, `function kvm_arch_dy_runnable`, `function kvm_arch_vcpu_in_kernel`, `function kvm_arch_vcpu_should_kick`, `function kvmppc_prepare_to_enter`, `function kvmppc_swab_shared`, `function kvmppc_kvm_pv`, `function kvmppc_sanity_check`, `function kvmppc_emulate_mmio`, `function kvmppc_st`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.