1 #include <machine/asm.h>
3 IMPORT(remaining_invocations)
7 #define JUNK 0xCC0FFEE0
9 #define COPY(dest, offset) \
11 mov 4*offset(%esp), %ebx ; \
12 mov %ebx, 4*offset(%ebp) ;
14 /* Copy the result of a pusha to dest. */
16 COPY(dest, 0); COPY(dest, 1); COPY(dest, 2); COPY(dest, 3); \
17 COPY(dest, 4); COPY(dest, 5); COPY(dest, 6); COPY(dest, 7);
19 /* void check_context_loop() */
20 ENTRY(check_context_loop)
21 /* Save original context so we can restore it. */
24 /* Put some junk in the registers.
25 * We want to junk the state, and junk it differently per reg,
26 * so it's likelier corruption is actually detected. We can't
27 * touch %esp but we can verify that it doesn't change from its
38 /* Save the junked state so we can compare it. */
41 /* Check if we're done. */
42 cmpl $0, (_C_LABEL(remaining_invocations))
51 /* Save the junked, but should be unmodified state
55 COPYA(_C_LABEL(newstate));
58 /* copy and restore junked state */
59 COPYA(_C_LABEL(origstate));
62 /* restore original state and return */