+
+ /*
+ * Test that:
+ *
+ * - "syscall" in a FRED system doesn't clobber %rcx and %r11.
+ * - "syscall" in a non-FRED system sets %rcx=%rip and %r11=%rflags.
+ */
+ ret = check_regs_result(r11, rcx, rbx);
+ assert(ret != REGS_ERROR);
+
+ /*
+ * Test that we don't get a mix of REGS_SAVED and REGS_SYSRET.
+ * It needs at least calling do_syscall() twice to assert.
+ */
+ if (regs_ok_state == REGS_UNDEFINED) {
+ /*
+ * First time calling do_syscall().
+ */
+ regs_ok_state = ret;
+ } else {
+ assert(regs_ok_state == ret);
+ }
+
+ ret = check_regs_result(ctx->uc_mcontext.gregs[REG_R11],
+ ctx->uc_mcontext.gregs[REG_RCX],
+ ctx->uc_mcontext.gregs[REG_RBX]);
+
+ assert(ret != REGS_ERROR);
+
/* Set IP and CX to match so that SYSRET can happen. */
ctx->uc_mcontext.gregs[REG_RIP] = rip;
ctx->uc_mcontext.gregs[REG_RCX] = rip;