arch/powerpc/kvm/mpic.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kvm/mpic.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kvm/mpic.c- Extension
.c- Size
- 42769 bytes
- Lines
- 1853
- 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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/slab.hlinux/mutex.hlinux/kvm_host.hlinux/errno.hlinux/fs.hlinux/anon_inodes.hlinux/uaccess.hasm/mpic.hasm/kvm_para.hasm/kvm_ppc.hkvm/iodev.h
Detected Declarations
struct fsl_mpic_infostruct irq_queuestruct irq_sourcestruct irq_deststruct openpicstruct mem_regenum irq_typefunction get_current_cpufunction mpic_irq_raisefunction mpic_irq_lowerfunction IRQ_setbitfunction IRQ_resetbitfunction IRQ_checkfunction IRQ_get_nextfunction IRQ_local_pipefunction openpic_update_irqfunction openpic_set_irqfunction openpic_resetfunction read_IRQreg_idrfunction read_IRQreg_ilrfunction read_IRQreg_ivprfunction write_IRQreg_idrfunction write_IRQreg_ilrfunction write_IRQreg_ivprfunction openpic_gcr_writefunction openpic_gbl_writefunction openpic_gbl_readfunction openpic_tmr_writefunction openpic_tmr_readfunction openpic_src_writefunction openpic_src_readfunction openpic_msi_writefunction openpic_msi_readfunction openpic_summary_readfunction openpic_summary_writefunction openpic_cpu_write_internalfunction openpic_cpu_writefunction openpic_iackfunction kvmppc_mpic_set_eprfunction openpic_cpu_read_internalfunction openpic_cpu_readfunction add_mmio_regionfunction fsl_common_initfunction kvm_mpic_read_internalfunction kvm_mpic_write_internalfunction kvm_mpic_readfunction hardwarefunction kvm_mpic_write
Annotated Snippet
struct fsl_mpic_info {
int max_ext;
};
static struct fsl_mpic_info fsl_mpic_20 = {
.max_ext = 12,
};
static struct fsl_mpic_info fsl_mpic_42 = {
.max_ext = 12,
};
#define FRR_NIRQ_SHIFT 16
#define FRR_NCPU_SHIFT 8
#define FRR_VID_SHIFT 0
#define VID_REVISION_1_2 2
#define VID_REVISION_1_3 3
#define VIR_GENERIC 0x00000000 /* Generic Vendor ID */
#define GCR_RESET 0x80000000
#define GCR_MODE_PASS 0x00000000
#define GCR_MODE_MIXED 0x20000000
#define GCR_MODE_PROXY 0x60000000
#define TBCR_CI 0x80000000 /* count inhibit */
#define TCCR_TOG 0x80000000 /* toggles when decrement to zero */
#define IDR_EP_SHIFT 31
#define IDR_EP_MASK (1 << IDR_EP_SHIFT)
#define IDR_CI0_SHIFT 30
#define IDR_CI1_SHIFT 29
#define IDR_P1_SHIFT 1
#define IDR_P0_SHIFT 0
#define ILR_INTTGT_MASK 0x000000ff
#define ILR_INTTGT_INT 0x00
#define ILR_INTTGT_CINT 0x01 /* critical */
#define ILR_INTTGT_MCP 0x02 /* machine check */
#define NUM_OUTPUTS 3
#define MSIIR_OFFSET 0x140
#define MSIIR_SRS_SHIFT 29
#define MSIIR_SRS_MASK (0x7 << MSIIR_SRS_SHIFT)
#define MSIIR_IBS_SHIFT 24
#define MSIIR_IBS_MASK (0x1f << MSIIR_IBS_SHIFT)
static int get_current_cpu(void)
{
#if defined(CONFIG_KVM) && defined(CONFIG_BOOKE)
struct kvm_vcpu *vcpu = current->thread.kvm_vcpu;
return vcpu ? vcpu->arch.irq_cpu_id : -1;
#else
/* XXX */
return -1;
#endif
}
static int openpic_cpu_write_internal(void *opaque, gpa_t addr,
u32 val, int idx);
static int openpic_cpu_read_internal(void *opaque, gpa_t addr,
u32 *ptr, int idx);
static inline void write_IRQreg_idr(struct openpic *opp, int n_IRQ,
uint32_t val);
enum irq_type {
IRQ_TYPE_NORMAL = 0,
IRQ_TYPE_FSLINT, /* FSL internal interrupt -- level only */
IRQ_TYPE_FSLSPECIAL, /* FSL timer/IPI interrupt, edge, no polarity */
};
struct irq_queue {
/* Round up to the nearest 64 IRQs so that the queue length
* won't change when moving between 32 and 64 bit hosts.
*/
unsigned long queue[BITS_TO_LONGS((MAX_IRQ + 63) & ~63)];
int next;
int priority;
};
struct irq_source {
uint32_t ivpr; /* IRQ vector/priority register */
uint32_t idr; /* IRQ destination register */
uint32_t destmask; /* bitmap of CPU destinations */
int last_cpu;
int output; /* IRQ level, e.g. ILR_INTTGT_INT */
int pending; /* TRUE if IRQ is pending */
enum irq_type type;
bool level:1; /* level-triggered */
Annotation
- Immediate include surface: `linux/slab.h`, `linux/mutex.h`, `linux/kvm_host.h`, `linux/errno.h`, `linux/fs.h`, `linux/anon_inodes.h`, `linux/uaccess.h`, `asm/mpic.h`.
- Detected declarations: `struct fsl_mpic_info`, `struct irq_queue`, `struct irq_source`, `struct irq_dest`, `struct openpic`, `struct mem_reg`, `enum irq_type`, `function get_current_cpu`, `function mpic_irq_raise`, `function mpic_irq_lower`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.