/* * Allocate a new stack frame with enough space to hold the register * states in an in-memory pt_regs and also create the back chain to * the caller's stack frame.
*/
stdu r1, -INT_FRAME_SIZE(r1)
/* * Save non-volatile GPRs on stack. This includes TOC pointer (GPR2) * and local variables (GPR14 to GPR31). The register for the pt_regs * parameter (GPR3) is saved additionally to ensure that the resulting * register state can still be saved even if GPR3 gets overwritten * when loading the initial register state for the test instruction. * The stack pointer (GPR1) and the thread pointer (GPR13) are not * saved as these should not be modified anyway.
*/
SAVE_GPRS(2, 3, r1)
SAVE_NVGPRS(r1)
/* * Save LR on stack to ensure that the return address is available * even if it gets overwritten by the test instruction.
*/
mflr r0
std r0, _LINK(r1)
/* * Save CR on stack. For simplicity, the entire register is saved * even though only fields 2 to 4 are non-volatile.
*/
mfcr r0
std r0, _CCR(r1)
/* * Load register state for the test instruction without touching the * critical non-volatile registers. The register state is passed as a * pointer to a pt_regs instance.
*/
subi r31, r3, GPR0
/* Load LR from pt_regs */ ld r0, _LINK(r31)
mtlr r0
/* Placeholder for the test instruction */
.balign 64
1: nop
nop
patch_site 1b patch__exec_instr
/* * Since GPR3 is overwritten, temporarily restore it back to its * original state, i.e. the pointer to pt_regs, to ensure that the * resulting register state can be saved. Before doing this, a copy * of it is created in the scratch space which is used later on to * save it to pt_regs.
*/
std r3, 8(r1)
REST_GPR(3, r1)
/* Save resulting GPR state to pt_regs */
subi r3, r3, GPR0
SAVE_GPR(0, r3)
SAVE_GPR(2, r3)
SAVE_GPRS(4, 12, r3)
SAVE_NVGPRS(r3)
/* Save resulting LR to pt_regs */
mflr r0
std r0, _LINK(r3)
/* Save resulting CR to pt_regs */
mfcr r0
std r0, _CCR(r3)
/* Save resulting XER to pt_regs */
mfxer r0
std r0, _XER(r3)
/* Restore resulting GPR3 from scratch space and save it to pt_regs */ ld r0, 8(r1)
std r0, GPR3(r3)
/* Set return value to denote execution success */
li r3, 0
/* Continue */
b 3f
/* Set return value to denote execution failure */
2: li r3, -EFAULT
/* Restore the non-volatile GPRs from stack */
3: REST_GPR(2, r1)
REST_NVGPRS(r1)
/* Restore LR from stack to be able to return */ ld r0, _LINK(r1)
mtlr r0
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.