arch/powerpc/kvm/book3s_emulate.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kvm/book3s_emulate.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kvm/book3s_emulate.c- Extension
.c- Size
- 25225 bytes
- Lines
- 1073
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/kvm_ppc.hasm/disassemble.hasm/kvm_book3s.hasm/reg.hasm/switch_to.hasm/time.hasm/tm.hbook3s.hasm/asm-prototypes.h
Detected Declarations
enum priv_levelfunction spr_allowedfunction kvmppc_copyto_vcpu_tmfunction kvmppc_copyfrom_vcpu_tmfunction kvmppc_emulate_treclaimfunction kvmppc_emulate_trchkptfunction kvmppc_emulate_tabortfunction MSR_TM_ACTIVEfunction kvmppc_core_emulate_op_prfunction kvmppc_set_batfunction kvmppc_core_emulate_mtspr_prfunction kvmppc_core_emulate_mfspr_prfunction kvmppc_alignment_dsisrfunction kvmppc_alignment_dar
Annotated Snippet
MSR_TM_ACTIVE(guest_msr)) {
vcpu->arch.texasr &= ~(TEXASR_PR | TEXASR_HV);
if (guest_msr & MSR_PR)
vcpu->arch.texasr |= TEXASR_PR;
if (guest_msr & MSR_HV)
vcpu->arch.texasr |= TEXASR_HV;
vcpu->arch.tfiar = kvmppc_get_pc(vcpu);
}
tm_disable();
preempt_enable();
}
#endif
int kvmppc_core_emulate_op_pr(struct kvm_vcpu *vcpu,
unsigned int inst, int *advance)
{
int emulated = EMULATE_DONE;
int rt = get_rt(inst);
int rs = get_rs(inst);
int ra = get_ra(inst);
int rb = get_rb(inst);
u32 inst_sc = 0x44000002;
switch (get_op(inst)) {
case 0:
emulated = EMULATE_FAIL;
if ((kvmppc_get_msr(vcpu) & MSR_LE) &&
(inst == swab32(inst_sc))) {
/*
* This is the byte reversed syscall instruction of our
* hypercall handler. Early versions of LE Linux didn't
* swap the instructions correctly and ended up in
* illegal instructions.
* Just always fail hypercalls on these broken systems.
*/
kvmppc_set_gpr(vcpu, 3, EV_UNIMPLEMENTED);
kvmppc_set_pc(vcpu, kvmppc_get_pc(vcpu) + 4);
emulated = EMULATE_DONE;
}
break;
case 19:
switch (get_xop(inst)) {
case OP_19_XOP_RFID:
case OP_19_XOP_RFI: {
unsigned long srr1 = kvmppc_get_srr1(vcpu);
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
unsigned long cur_msr = kvmppc_get_msr(vcpu);
/*
* add rules to fit in ISA specification regarding TM
* state transition in TM disable/Suspended state,
* and target TM state is TM inactive(00) state. (the
* change should be suppressed).
*/
if (((cur_msr & MSR_TM) == 0) &&
((srr1 & MSR_TM) == 0) &&
MSR_TM_SUSPENDED(cur_msr) &&
!MSR_TM_ACTIVE(srr1))
srr1 |= MSR_TS_S;
#endif
kvmppc_set_pc(vcpu, kvmppc_get_srr0(vcpu));
kvmppc_set_msr(vcpu, srr1);
*advance = 0;
break;
}
default:
emulated = EMULATE_FAIL;
break;
}
break;
case 31:
switch (get_xop(inst)) {
case OP_31_XOP_MFMSR:
kvmppc_set_gpr(vcpu, rt, kvmppc_get_msr(vcpu));
break;
case OP_31_XOP_MTMSRD:
{
ulong rs_val = kvmppc_get_gpr(vcpu, rs);
if (inst & 0x10000) {
ulong new_msr = kvmppc_get_msr(vcpu);
new_msr &= ~(MSR_RI | MSR_EE);
new_msr |= rs_val & (MSR_RI | MSR_EE);
kvmppc_set_msr_fast(vcpu, new_msr);
} else
kvmppc_set_msr(vcpu, rs_val);
break;
Annotation
- Immediate include surface: `asm/kvm_ppc.h`, `asm/disassemble.h`, `asm/kvm_book3s.h`, `asm/reg.h`, `asm/switch_to.h`, `asm/time.h`, `asm/tm.h`, `book3s.h`.
- Detected declarations: `enum priv_level`, `function spr_allowed`, `function kvmppc_copyto_vcpu_tm`, `function kvmppc_copyfrom_vcpu_tm`, `function kvmppc_emulate_treclaim`, `function kvmppc_emulate_trchkpt`, `function kvmppc_emulate_tabort`, `function MSR_TM_ACTIVE`, `function kvmppc_core_emulate_op_pr`, `function kvmppc_set_bat`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
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.