switch (aarch32_check_condition(instr, regs->pstate)) { case ARM_OPCODE_CONDTEST_PASS: break; case ARM_OPCODE_CONDTEST_FAIL: /* Condition failed - return to next instruction */ goto ret; case ARM_OPCODE_CONDTEST_UNCOND: /* If unconditional encoding - not a SWP, undef */ return -EFAULT; default: return -EINVAL;
}
address = (u32)regs->user_regs.regs[rn];
data = (u32)regs->user_regs.regs[rt2];
destreg = aarch32_insn_extract_reg_num(instr, A32_RT_OFFSET);
pr_debug("addr in r%d->0x%08x, dest is r%d, source in r%d->0x%08x)\n",
rn, address, destreg,
aarch32_insn_extract_reg_num(instr, A32_RT2_OFFSET), data);
/* Check access in reasonable access range for both SWP and SWPB */
user_ptr = (constvoid __user *)(unsignedlong)(address & ~3); if (!access_ok(user_ptr, 4)) {
pr_debug("SWP{B} emulation: access to 0x%08x not allowed!\n",
address); goto fault;
}
res = emulate_swpX(address, &data, type); if (res == -EFAULT) goto fault; elseif (res == 0)
regs->user_regs.regs[destreg] = data;
ret: if (type == TYPE_SWPB)
trace_instruction_emulation("swpb", regs->pc); else
trace_instruction_emulation("swp", regs->pc);
staticbool try_emulate_swp(struct pt_regs *regs, u32 insn)
{ /* SWP{B} only exists in ARM state and does not exist in Thumb */ if (!compat_user_mode(regs) || compat_thumb_mode(regs)) returnfalse;
if ((insn & 0x0fb00ff0) != 0x01000090) returnfalse;
switch (aarch32_check_condition(instr, regs->pstate)) { case ARM_OPCODE_CONDTEST_PASS: break; case ARM_OPCODE_CONDTEST_FAIL: /* Condition failed - return to next instruction */ goto ret; case ARM_OPCODE_CONDTEST_UNCOND: /* If unconditional encoding - not a barrier instruction */ return -EFAULT; default: return -EINVAL;
}
/* *DisableIRQstoserializeagainstanIPIfrom *run_all_cpu_set_hw_mode(),ensuringtheHWisprogrammedtothemost *recentenablementstateifthetworacewithoneanother.
*/
local_irq_save(flags); for (int i = 0; i < ARRAY_SIZE(insn_emulations); i++) { struct insn_emulation *insn = insn_emulations[i]; bool enable = READ_ONCE(insn->current_mode) == INSN_HW; if (insn->status == INSN_UNAVAILABLE) continue;
if (insn->set_hw_mode && insn->set_hw_mode(enable)) {
pr_warn("CPU[%u] cannot support the emulation of %s",
cpu, insn->name);
rc = -EINVAL;
}
}
local_irq_restore(flags);
return rc;
}
staticint update_insn_emulation_mode(struct insn_emulation *insn, enum insn_emulation_mode prev)
{ int ret = 0;
switch (prev) { case INSN_UNDEF: /* Nothing to be done */ break; case INSN_EMULATE: break; case INSN_HW: if (!run_all_cpu_set_hw_mode(insn, false))
pr_notice("Disabled %s support\n", insn->name); break;
}
switch (insn->current_mode) { case INSN_UNDEF: break; case INSN_EMULATE: break; case INSN_HW:
ret = run_all_cpu_set_hw_mode(insn, true); if (!ret)
pr_notice("Enabled %s support\n", insn->name); break;
}
return ret;
}
staticint emulation_proc_handler(conststruct ctl_table *table, int write, void *buffer, size_t *lenp,
loff_t *ppos)
{ int ret = 0; struct insn_emulation *insn = container_of(table->data, struct insn_emulation, current_mode); enum insn_emulation_mode prev_mode = insn->current_mode;
mutex_lock(&insn_emulation_mutex);
ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (ret || !write || prev_mode == insn->current_mode) goto ret;
ret = update_insn_emulation_mode(insn, prev_mode); if (ret) { /* Mode change failed, revert to previous mode. */
WRITE_ONCE(insn->current_mode, prev_mode);
update_insn_emulation_mode(insn, INSN_UNDEF);
}
ret:
mutex_unlock(&insn_emulation_mutex); return ret;
}
switch (insn->status) { case INSN_DEPRECATED:
insn->current_mode = INSN_EMULATE; /* Disable the HW mode if it was turned on at early boot time */
run_all_cpu_set_hw_mode(insn, false);
insn->max = INSN_HW; break; case INSN_OBSOLETE:
insn->current_mode = INSN_UNDEF;
insn->max = INSN_EMULATE; break; case INSN_UNAVAILABLE:
insn->current_mode = INSN_UNDEF;
insn->max = INSN_UNDEF; break;
}
/* Program the HW if required */
update_insn_emulation_mode(insn, INSN_UNDEF);
if (insn->status != INSN_UNAVAILABLE) {
sysctl = &insn->sysctl;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.