syscall_mask, &saved, sizeof(vki_sigset_t)
);
# elif defined(VGO_freebsd)
- Word real_syscallno;
UChar cflag;
VG_(sigemptyset)(&saved);
- if (tst->arch.vex.guest_SC_CLASS == VG_FREEBSD_SYSCALL0)
- real_syscallno = __NR_syscall;
- else if (tst->arch.vex.guest_SC_CLASS == VG_FREEBSD_SYSCALL198)
- real_syscallno = __NR___syscall;
- else
- real_syscallno = syscallno;
err = ML_(do_syscall_for_client_WRK)(
- real_syscallno, &tst->arch.vex,
+ syscallno, &tst->arch.vex,
syscall_mask, &saved, sizeof(vki_sigset_t),
&cflag
);
static
Bool eq_SyscallArgs ( SyscallArgs* a1, SyscallArgs* a2 )
{
- return a1->sysno == a2->sysno
+ return a1->canonical_sysno == a2->canonical_sysno
+#if defined(VGO_freebsd)
+ && a1->original_sysno == a2->original_sysno
+#endif
&& a1->arg1 == a2->arg1
&& a1->arg2 == a2->arg2
&& a1->arg3 == a2->arg3
{
#if defined(VGP_x86_linux)
VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla;
- canonical->sysno = gst->guest_EAX;
+ canonical->canonical_sysno = gst->guest_EAX;
canonical->arg1 = gst->guest_EBX;
canonical->arg2 = gst->guest_ECX;
canonical->arg3 = gst->guest_EDX;
#elif defined(VGP_amd64_linux)
VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;
- canonical->sysno = gst->guest_RAX;
+ canonical->canonical_sysno = gst->guest_RAX;
canonical->arg1 = gst->guest_RDI;
canonical->arg2 = gst->guest_RSI;
canonical->arg3 = gst->guest_RDX;
#elif defined(VGP_ppc32_linux)
VexGuestPPC32State* gst = (VexGuestPPC32State*)gst_vanilla;
- canonical->sysno = gst->guest_GPR0;
+ canonical->canonical_sysno = gst->guest_GPR0;
canonical->arg1 = gst->guest_GPR3;
canonical->arg2 = gst->guest_GPR4;
canonical->arg3 = gst->guest_GPR5;
#elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
VexGuestPPC64State* gst = (VexGuestPPC64State*)gst_vanilla;
- canonical->sysno = gst->guest_GPR0;
+ canonical->canonical_sysno = gst->guest_GPR0;
canonical->arg1 = gst->guest_GPR3;
canonical->arg2 = gst->guest_GPR4;
canonical->arg3 = gst->guest_GPR5;
// FreeBSD supports different calling conventions
switch (gst->guest_EAX) {
case __NR_syscall:
- canonical->klass = VG_FREEBSD_SYSCALL0;
- canonical->sysno = stack[1];
+ canonical->canonical_sysno = stack[1];
stack += 1;
break;
case __NR___syscall:
- canonical->klass = VG_FREEBSD_SYSCALL198;
- canonical->sysno = stack[1];
+ canonical->canonical_sysno = stack[1];
stack += 2;
break;
default:
- canonical->klass = 0;
- canonical->sysno = gst->guest_EAX;
+ canonical->canonical_sysno = gst->guest_EAX;
break;
}
+
+ canonical->original_sysno = gst->guest_EAX;
+
// stack[0] is a (fake) return address
canonical->arg1 = stack[1];
canonical->arg2 = stack[2];
VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;
UWord *stack = (UWord *)gst->guest_RSP;
- // FreeBSD supports different calling conventions
- // @todo PJF this all seems over complicated to me
- // SYSCALL_STD is OK but for the other
- // two here we overwrite canonical->sysno with
- // the final syscall number but then in do_syscall_for_client
- // we switch real_syscallno back to __NR_syscall or __NR___syscall
switch (gst->guest_RAX) {
case __NR_syscall:
- canonical->klass = VG_FREEBSD_SYSCALL0;
- canonical->sysno = gst->guest_RDI;
+ canonical->canonical_sysno = gst->guest_RDI;
break;
case __NR___syscall:
- canonical->klass = VG_FREEBSD_SYSCALL198;
- canonical->sysno = gst->guest_RDI;
+ canonical->canonical_sysno = gst->guest_RDI;
break;
default:
- canonical->klass = VG_FREEBSD_SYSCALL_STD;
- canonical->sysno = gst->guest_RAX;
+ canonical->canonical_sysno = gst->guest_RAX;
break;
}
+ canonical->original_sysno = gst->guest_RAX;
+
// stack[0] is a (fake) return address
- if (canonical->klass == VG_FREEBSD_SYSCALL0 || canonical->klass == VG_FREEBSD_SYSCALL198) {
+ if (gst->guest_RAX == __NR_syscall || gst->guest_RAX == __NR___syscall) {
// stack[0] is return address
canonical->arg1 = gst->guest_RSI;
canonical->arg2 = gst->guest_RDX;
VexGuestARM64State* gst = (VexGuestARM64State*)gst_vanilla;
switch (gst->guest_X8) {
case __NR_syscall:
- canonical->klass = VG_FREEBSD_SYSCALL0;
- canonical->sysno = gst->guest_X0;
+ canonical->canonical_sysno = gst->guest_X0;
break;
case __NR___syscall:
- canonical->klass = VG_FREEBSD_SYSCALL198;
- canonical->sysno = gst->guest_X0;
+ canonical->canonical_sysno = gst->guest_X0;
break;
default:
- canonical->klass = 0;
- canonical->sysno = gst->guest_X8;
+ canonical->canonical_sysno = gst->guest_X8;
break;
}
- if (canonical->klass == VG_FREEBSD_SYSCALL0 || canonical->klass == VG_FREEBSD_SYSCALL198) {
+
+ canonical->original_sysno = gst->guest_X8;
+
+ if (gst->guest_X8 == __NR_syscall ||
+ gst->guest_X8 == __NR___syscall) {
canonical->arg1 = gst->guest_X1;
canonical->arg2 = gst->guest_X2;
canonical->arg3 = gst->guest_X3;
#elif defined(VGP_arm_linux)
VexGuestARMState* gst = (VexGuestARMState*)gst_vanilla;
- canonical->sysno = gst->guest_R7;
+ canonical->canonical_sysno = gst->guest_R7;
canonical->arg1 = gst->guest_R0;
canonical->arg2 = gst->guest_R1;
canonical->arg3 = gst->guest_R2;
#elif defined(VGP_arm64_linux)
VexGuestARM64State* gst = (VexGuestARM64State*)gst_vanilla;
- canonical->sysno = gst->guest_X8;
+ canonical->canonical_sysno = gst->guest_X8;
canonical->arg1 = gst->guest_X0;
canonical->arg2 = gst->guest_X1;
canonical->arg3 = gst->guest_X2;
#elif defined(VGP_mips32_linux)
VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla;
- canonical->sysno = gst->guest_r2; // v0
- if (canonical->sysno == __NR_exit) {
+ canonical->canonical_sysno = gst->guest_r2; // v0
+ if (canonical->canonical_sysno == __NR_exit) {
canonical->arg1 = gst->guest_r4; // a0
canonical->arg2 = 0;
canonical->arg3 = 0;
canonical->arg5 = 0;
canonical->arg6 = 0;
canonical->arg8 = 0;
- } else if (canonical->sysno != __NR_syscall) {
+ } else if (canonical->canonical_sysno != __NR_syscall) {
canonical->arg1 = gst->guest_r4; // a0
canonical->arg2 = gst->guest_r5; // a1
canonical->arg3 = gst->guest_r6; // a2
canonical->arg8 = 0;
} else {
// Fixme hack handle syscall()
- canonical->sysno = gst->guest_r4; // a0
+ canonical->canonical_sysno = gst->guest_r4; // a0
canonical->arg1 = gst->guest_r5; // a1
canonical->arg2 = gst->guest_r6; // a2
canonical->arg3 = gst->guest_r7; // a3
#elif defined(VGP_mips64_linux)
VexGuestMIPS64State* gst = (VexGuestMIPS64State*)gst_vanilla;
- canonical->sysno = gst->guest_r2; // v0
+ canonical->canonical_sysno = gst->guest_r2; // v0
canonical->arg1 = gst->guest_r4; // a0
canonical->arg2 = gst->guest_r5; // a1
canonical->arg3 = gst->guest_r6; // a2
#elif defined(VGP_nanomips_linux)
VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla;
- canonical->sysno = gst->guest_r2; // t4
+ canonical->canonical_sysno = gst->guest_r2; // t4
canonical->arg1 = gst->guest_r4; // a0
canonical->arg2 = gst->guest_r5; // a1
canonical->arg3 = gst->guest_r6; // a2
VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla;
UWord *stack = (UWord *)gst->guest_ESP;
// GrP fixme hope syscalls aren't called with really shallow stacks...
- canonical->sysno = gst->guest_EAX;
- if (canonical->sysno != 0) {
+ canonical->canonical_sysno = gst->guest_EAX;
+ if (canonical->canonical_sysno != 0) {
// stack[0] is return address
canonical->arg1 = stack[1];
canonical->arg2 = stack[2];
// DDD: the tool can't see that the params have been shifted! Can
// lead to incorrect checking, I think, because the PRRAn/PSARn
// macros will mention the pre-shifted args.
- canonical->sysno = stack[1];
- vg_assert(canonical->sysno != 0);
+ canonical->canonical_sysno = stack[1];
+ vg_assert(canonical->canonical_sysno != 0);
canonical->arg1 = stack[2];
canonical->arg2 = stack[3];
canonical->arg3 = stack[4];
PRINT("SYSCALL[%d,?](0) syscall(%s, ...); please stand by...\n",
VG_(getpid)(), /*tid,*/
- VG_SYSNUM_STRING(canonical->sysno));
+ VG_SYSNUM_STRING(canonical->canonical_sysno));
}
// Here we determine what kind of syscall it was by looking at the
switch (trc) {
case VEX_TRC_JMP_SYS_INT128:
// int $0x80 = Unix, 64-bit result
- vg_assert(canonical->sysno >= 0);
- canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(canonical->sysno);
+ vg_assert(canonical->canonical_sysno >= 0);
+ canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(canonical->canonical_sysno);
break;
case VEX_TRC_JMP_SYS_SYSENTER:
// syscall = Unix, 32-bit result
// OR Mach, 32-bit result
- if (canonical->sysno >= 0) {
+ if (canonical->canonical_sysno >= 0) {
// GrP fixme hack: 0xffff == I386_SYSCALL_NUMBER_MASK
- canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(canonical->sysno
+ canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(canonical->canonical_sysno
& 0xffff);
} else {
- canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MACH(-canonical->sysno);
+ canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MACH(-canonical->canonical_sysno);
}
break;
case VEX_TRC_JMP_SYS_INT129:
// int $0x81 = Mach, 32-bit result
- vg_assert(canonical->sysno < 0);
- canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MACH(-canonical->sysno);
+ vg_assert(canonical->canonical_sysno < 0);
+ canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MACH(-canonical->canonical_sysno);
break;
case VEX_TRC_JMP_SYS_INT130:
// int $0x82 = mdep, 32-bit result
- vg_assert(canonical->sysno >= 0);
- canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(canonical->sysno);
+ vg_assert(canonical->canonical_sysno >= 0);
+ canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(canonical->canonical_sysno);
break;
default:
vg_assert(0);
vg_assert(trc == VEX_TRC_JMP_SYS_SYSCALL);
// GrP fixme hope syscalls aren't called with really shallow stacks...
- canonical->sysno = gst->guest_RAX;
- if (canonical->sysno != __NR_syscall) {
+ canonical->canonical_sysno = gst->guest_RAX;
+ if (canonical->canonical_sysno != __NR_syscall) {
// stack[0] is return address
canonical->arg1 = gst->guest_RDI;
canonical->arg2 = gst->guest_RSI;
// DDD: the tool can't see that the params have been shifted! Can
// lead to incorrect checking, I think, because the PRRAn/PSARn
// macros will mention the pre-shifted args.
- canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(gst->guest_RDI);
- vg_assert(canonical->sysno != __NR_syscall);
+ canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(gst->guest_RDI);
+ vg_assert(canonical->canonical_sysno != __NR_syscall);
canonical->arg1 = gst->guest_RSI;
canonical->arg2 = gst->guest_RDX;
canonical->arg3 = gst->guest_R10; // not rcx with syscall insn
PRINT("SYSCALL[%d,?](0) syscall(%s, ...); please stand by...\n",
VG_(getpid)(), /*tid,*/
- VG_SYSNUM_STRING(canonical->sysno));
+ VG_SYSNUM_STRING(canonical->canonical_sysno));
}
- // no canonical->sysno adjustment needed
+ // no canonical->canonical_sysno adjustment needed
#elif defined(VGP_s390x_linux)
VexGuestS390XState* gst = (VexGuestS390XState*)gst_vanilla;
- canonical->sysno = gst->guest_SYSNO;
+ canonical->canonical_sysno = gst->guest_SYSNO;
canonical->arg1 = gst->guest_r2;
canonical->arg2 = gst->guest_r3;
canonical->arg3 = gst->guest_r4;
#elif defined(VGP_riscv64_linux)
VexGuestRISCV64State* gst = (VexGuestRISCV64State*)gst_vanilla;
- canonical->sysno = gst->guest_x17; /* a7 */
+ canonical->canonical_sysno = gst->guest_x17; /* a7 */
canonical->arg1 = gst->guest_x10; /* a0 */
canonical->arg2 = gst->guest_x11; /* a1 */
canonical->arg3 = gst->guest_x12; /* a2 */
#elif defined(VGP_x86_solaris)
VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla;
UWord *stack = (UWord *)gst->guest_ESP;
- canonical->sysno = gst->guest_EAX;
+ canonical->canonical_sysno = gst->guest_EAX;
/* stack[0] is a return address. */
canonical->arg1 = stack[1];
canonical->arg2 = stack[2];
break;
case VEX_TRC_JMP_SYS_INT210:
/* int $0xD2 = fasttrap */
- canonical->sysno
- = VG_SOLARIS_SYSCALL_CONSTRUCT_FASTTRAP(canonical->sysno);
+ canonical->canonical_sysno
+ = VG_SOLARIS_SYSCALL_CONSTRUCT_FASTTRAP(canonical->canonical_sysno);
break;
default:
vg_assert(0);
#elif defined(VGP_amd64_solaris)
VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;
UWord *stack = (UWord *)gst->guest_RSP;
- canonical->sysno = gst->guest_RAX;
+ canonical->canonical_sysno = gst->guest_RAX;
/* stack[0] is a return address. */
canonical->arg1 = gst->guest_RDI;
canonical->arg2 = gst->guest_RSI;
break;
case VEX_TRC_JMP_SYS_INT210:
/* int $0xD2 = fasttrap */
- canonical->sysno
- = VG_SOLARIS_SYSCALL_CONSTRUCT_FASTTRAP(canonical->sysno);
+ canonical->canonical_sysno
+ = VG_SOLARIS_SYSCALL_CONSTRUCT_FASTTRAP(canonical->canonical_sysno);
break;
default:
vg_assert(0);
{
#if defined(VGP_x86_linux)
VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla;
- gst->guest_EAX = canonical->sysno;
+ gst->guest_EAX = canonical->canonical_sysno;
gst->guest_EBX = canonical->arg1;
gst->guest_ECX = canonical->arg2;
gst->guest_EDX = canonical->arg3;
#elif defined(VGP_amd64_linux)
VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;
- gst->guest_RAX = canonical->sysno;
+ gst->guest_RAX = canonical->canonical_sysno;
gst->guest_RDI = canonical->arg1;
gst->guest_RSI = canonical->arg2;
gst->guest_RDX = canonical->arg3;
#elif defined(VGP_ppc32_linux)
VexGuestPPC32State* gst = (VexGuestPPC32State*)gst_vanilla;
- gst->guest_GPR0 = canonical->sysno;
+ gst->guest_GPR0 = canonical->canonical_sysno;
gst->guest_GPR3 = canonical->arg1;
gst->guest_GPR4 = canonical->arg2;
gst->guest_GPR5 = canonical->arg3;
#elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
VexGuestPPC64State* gst = (VexGuestPPC64State*)gst_vanilla;
- gst->guest_GPR0 = canonical->sysno;
+ gst->guest_GPR0 = canonical->canonical_sysno;
gst->guest_GPR3 = canonical->arg1;
gst->guest_GPR4 = canonical->arg2;
gst->guest_GPR5 = canonical->arg3;
UWord *stack = (UWord *)gst->guest_ESP;
// stack[0] is a (fake) return address
- switch (canonical->klass) {
- case VG_FREEBSD_SYSCALL0:
- gst->guest_EAX = __NR_syscall;
- stack[1] = canonical->sysno;
+ switch (canonical->original_sysno) {
+ case __NR_syscall:
+ stack[1] = canonical->canonical_sysno;
stack++;
break;
- case VG_FREEBSD_SYSCALL198:
- gst->guest_EAX = __NR___syscall;
- stack[1] = canonical->sysno;
+ case __NR___syscall:
+ stack[1] = canonical->canonical_sysno;
stack += 2;
break;
default:
- gst->guest_EAX = canonical->sysno;
break;
}
+ gst->guest_EAX = canonical->original_sysno;
+
stack[1] = canonical->arg1;
stack[2] = canonical->arg2;
stack[3] = canonical->arg3;
VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;
UWord *stack = (UWord *)gst->guest_RSP;
- // stack[0] is a (fake) return address
- switch (canonical->klass) {
- case VG_FREEBSD_SYSCALL0:
- gst->guest_RAX = __NR_syscall;
- break;
- case VG_FREEBSD_SYSCALL198:
- gst->guest_RAX = __NR___syscall;
- break;
- default:
- gst->guest_RAX = canonical->sysno;
- break;
- }
-
- if (canonical->klass == VG_FREEBSD_SYSCALL0 || canonical->klass == VG_FREEBSD_SYSCALL198) {
- gst->guest_RDI = canonical->sysno;
+ if (canonical->original_sysno == __NR_syscall ||
+ canonical->original_sysno == __NR___syscall) {
+ gst->guest_RDI = canonical->canonical_sysno;
gst->guest_RSI = canonical->arg1;
gst->guest_RDX = canonical->arg2;
gst->guest_R10 = canonical->arg3;
stack[2] = canonical->arg8;
}
+ gst->guest_RAX = canonical->original_sysno;
+
#elif defined(VGP_arm64_freebsd)
VexGuestARM64State* gst = (VexGuestARM64State*)gst_vanilla;
- switch (canonical->klass) {
- case VG_FREEBSD_SYSCALL0:
- gst->guest_X8 = __NR_syscall;
- break;
- case VG_FREEBSD_SYSCALL198:
- gst->guest_X8 = __NR___syscall;
- break;
- default:
- gst->guest_X8 = canonical->sysno;
- break;
- }
- if (canonical->klass == VG_FREEBSD_SYSCALL0 || canonical->klass == VG_FREEBSD_SYSCALL198) {
- gst->guest_X0 = canonical->sysno;
+
+ if (canonical->original_sysno == __NR_syscall ||
+ canonical->original_sysno == __NR___syscall) {
+ gst->guest_X0 = canonical->canonical_sysno;
gst->guest_X1 = canonical->arg1;
gst->guest_X2 = canonical->arg2;
gst->guest_X3 = canonical->arg3;
gst->guest_X6 = canonical->arg7;
}
+ gst->guest_X8 = canonical->original_sysno;
+
#elif defined(VGP_arm_linux)
VexGuestARMState* gst = (VexGuestARMState*)gst_vanilla;
- gst->guest_R7 = canonical->sysno;
+ gst->guest_R7 = canonical->canonical_sysno;
gst->guest_R0 = canonical->arg1;
gst->guest_R1 = canonical->arg2;
gst->guest_R2 = canonical->arg3;
#elif defined(VGP_arm64_linux)
VexGuestARM64State* gst = (VexGuestARM64State*)gst_vanilla;
- gst->guest_X8 = canonical->sysno;
+ gst->guest_X8 = canonical->canonical_sysno;
gst->guest_X0 = canonical->arg1;
gst->guest_X1 = canonical->arg2;
gst->guest_X2 = canonical->arg3;
VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla;
UWord *stack = (UWord *)gst->guest_ESP;
- gst->guest_EAX = VG_DARWIN_SYSNO_FOR_KERNEL(canonical->sysno);
+ gst->guest_EAX = VG_DARWIN_SYSNO_FOR_KERNEL(canonical->canonical_sysno);
// GrP fixme? gst->guest_TEMP_EFLAG_C = 0;
// stack[0] is return address
VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;
UWord *stack = (UWord *)gst->guest_RSP;
- gst->guest_RAX = VG_DARWIN_SYSNO_FOR_KERNEL(canonical->sysno);
+ gst->guest_RAX = VG_DARWIN_SYSNO_FOR_KERNEL(canonical->canonical_sysno);
// GrP fixme? gst->guest_TEMP_EFLAG_C = 0;
// stack[0] is return address
#elif defined(VGP_s390x_linux)
VexGuestS390XState* gst = (VexGuestS390XState*)gst_vanilla;
- gst->guest_SYSNO = canonical->sysno;
+ gst->guest_SYSNO = canonical->canonical_sysno;
gst->guest_r2 = canonical->arg1;
gst->guest_r3 = canonical->arg2;
gst->guest_r4 = canonical->arg3;
#elif defined(VGP_mips32_linux)
VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla;
if (canonical->arg8 != __NR_syscall) {
- gst->guest_r2 = canonical->sysno;
+ gst->guest_r2 = canonical->canonical_sysno;
gst->guest_r4 = canonical->arg1;
gst->guest_r5 = canonical->arg2;
gst->guest_r6 = canonical->arg3;
} else {
canonical->arg8 = 0;
gst->guest_r2 = __NR_syscall;
- gst->guest_r4 = canonical->sysno;
+ gst->guest_r4 = canonical->canonical_sysno;
gst->guest_r5 = canonical->arg1;
gst->guest_r6 = canonical->arg2;
gst->guest_r7 = canonical->arg3;
#elif defined(VGP_nanomips_linux)
VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla;
- gst->guest_r2 = canonical->sysno;
+ gst->guest_r2 = canonical->canonical_sysno;
gst->guest_r4 = canonical->arg1;
gst->guest_r5 = canonical->arg2;
gst->guest_r6 = canonical->arg3;
gst->guest_r11 = canonical->arg8;
#elif defined(VGP_mips64_linux)
VexGuestMIPS64State* gst = (VexGuestMIPS64State*)gst_vanilla;
- gst->guest_r2 = canonical->sysno;
+ gst->guest_r2 = canonical->canonical_sysno;
gst->guest_r4 = canonical->arg1;
gst->guest_r5 = canonical->arg2;
gst->guest_r6 = canonical->arg3;
#elif defined(VGP_riscv64_linux)
VexGuestRISCV64State* gst = (VexGuestRISCV64State*)gst_vanilla;
- gst->guest_x17 = canonical->sysno; /* a7 */
+ gst->guest_x17 = canonical->canonical_sysno; /* a7 */
gst->guest_x10 = canonical->arg1; /* a0 */
gst->guest_x11 = canonical->arg2; /* a1 */
gst->guest_x12 = canonical->arg3; /* a2 */
UWord *stack = (UWord *)gst->guest_ESP;
/* Fasttraps or anything else cannot go through this way. */
- vg_assert(VG_SOLARIS_SYSNO_CLASS(canonical->sysno)
+ vg_assert(VG_SOLARIS_SYSNO_CLASS(canonical->canonical_sysno)
== VG_SOLARIS_SYSCALL_CLASS_CLASSIC);
- gst->guest_EAX = canonical->sysno;
+ gst->guest_EAX = canonical->canonical_sysno;
/* stack[0] is a return address. */
stack[1] = canonical->arg1;
stack[2] = canonical->arg2;
UWord *stack = (UWord *)gst->guest_RSP;
/* Fasttraps or anything else cannot go through this way. */
- vg_assert(VG_SOLARIS_SYSNO_CLASS(canonical->sysno)
+ vg_assert(VG_SOLARIS_SYSNO_CLASS(canonical->canonical_sysno)
== VG_SOLARIS_SYSCALL_CLASS_CLASSIC);
- gst->guest_RAX = canonical->sysno;
+ gst->guest_RAX = canonical->canonical_sysno;
/* stack[0] is a return address. */
gst->guest_RDI = canonical->arg1;
gst->guest_RSI = canonical->arg2;
/*OUT*/UWord* flags )
{
VG_(dmsg)("WARNING: unhandled %s syscall: %s\n",
- VG_PLATFORM, VG_SYSNUM_STRING(args->sysno));
+ VG_PLATFORM, VG_SYSNUM_STRING(args->canonical_sysno));
if (VG_(clo_verbosity) > 1) {
VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
}
Word VG_(is_in_syscall_no) (ThreadId tid )
{
vg_assert(tid < VG_N_THREADS);
- return syscallInfo[tid].orig_args.sysno;
+ return syscallInfo[tid].orig_args.canonical_sysno;
}
static void ensure_initialised ( void )
void VG_(client_syscall) ( ThreadId tid, UInt trc )
{
- Word sysno;
+ Word canonical_sysno;
+ Word original_sysno;
ThreadState* tst;
const SyscallTableEntry* ent;
SyscallArgLayout layout;
/* Save the syscall number in the thread state in case the syscall
is interrupted by a signal. */
- sysno = sci->orig_args.sysno;
+ canonical_sysno = sci->orig_args.canonical_sysno;
+#if defined(VGO_freebsd)
+ original_sysno = sci->orig_args.original_sysno;
+#else
+ /*
+ * When there is no "syscall syycall" the original
+ * and canonical sysno values are the same
+ */
+ original_sysno = sci->orig_args.canonical_sysno;
+#endif
+
-# if defined(VGO_freebsd)
- tst->arch.vex.guest_SC_CLASS = sci->orig_args.klass;
-# endif
/* It's sometimes useful, as a crude debugging hack, to get a
stack trace at each (or selected) syscalls. */
- if (0 && sysno == __NR_ioctl) {
+ if (0 && canonical_sysno == __NR_ioctl) {
VG_(umsg)("\nioctl:\n");
VG_(get_and_pp_StackTrace)(tid, 10);
VG_(umsg)("\n");
because it only has a single syscall return convention and so
there is no ambiguity involved in converting the post-signal
machine state into a SysRes. */
- tst->arch.vex.guest_SC_CLASS = VG_DARWIN_SYSNO_CLASS(sysno);
+ tst->arch.vex.guest_SC_CLASS = VG_DARWIN_SYSNO_CLASS(canonical_sysno);
# endif
/* The default what-to-do-next thing is hand the syscall to the
/* Fetch the syscall's handlers. If no handlers exist for this
syscall, we are given dummy handlers which force an immediate
return with ENOSYS. */
- ent = get_syscall_entry(sysno);
+ ent = get_syscall_entry(canonical_sysno);
/* Fetch the layout information, which tells us where in the guest
state the syscall args reside. This is a platform-dependent
checks (PRE_REG_READ calls) know which bits of the guest state
they need to inspect. */
#if defined(VGP_amd64_freebsd) || defined (VGP_arm64_freebsd)
- if (sci->orig_args.klass == VG_FREEBSD_SYSCALL0 || sci->orig_args.klass == VG_FREEBSD_SYSCALL198) {
+ if (original_sysno == __NR_syscall ||
+ original_sysno == __NR___syscall) {
syscall_syscall = True;
}
#endif
*/
PRINT("SYSCALL[%d,%u](%s) ",
- VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno));
+ VG_(getpid)(), tid, VG_SYSNUM_STRING(canonical_sysno));
/* Do any pre-syscall actions */
if (VG_(needs).syscall_wrapper) {
tmpv[5] = sci->orig_args.arg6;
tmpv[6] = sci->orig_args.arg7;
tmpv[7] = sci->orig_args.arg8;
- VG_TDICT_CALL(tool_pre_syscall, tid, sysno,
+ VG_TDICT_CALL(tool_pre_syscall, tid, canonical_sysno,
&tmpv[0], sizeof(tmpv)/sizeof(tmpv[0]));
}
&sci->args, &sci->status, &sci->flags );
/* If needed, gdbserver will report syscall entry to GDB */
- VG_(gdbserver_report_syscall)(True, sysno, tid);
+ VG_(gdbserver_report_syscall)(True, canonical_sysno, tid);
/* The pre-handler may have modified:
sci->args
/* Now we proceed according to what the pre-handler decided. */
vg_assert(sci->status.what == SsHandToKernel
|| sci->status.what == SsComplete);
- vg_assert(sci->args.sysno == sci->orig_args.sysno);
+ vg_assert(sci->args.canonical_sysno == sci->orig_args.canonical_sysno);
if (sci->status.what == SsComplete && !sr_isError(sci->status.sres)) {
/* The pre-handler completed the syscall itself, declaring
/* Do the call, which operates directly on the guest state,
not on our abstracted copies of the args/result. */
- do_syscall_for_client(sysno, tst, &mask);
+ do_syscall_for_client(original_sysno, tst, &mask);
/* do_syscall_for_client may not return if the syscall was
interrupted by a signal. In that case, flow of control is
/* Be decorative, if required. */
if (VG_(clo_trace_syscalls)) {
PRINT("SYSCALL[%d,%u](%s) ... [async] --> %s",
- VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno),
+ VG_(getpid)(), tid, VG_SYSNUM_STRING(canonical_sysno),
VG_(sr_as_string)(sci->status.sres));
}
guest state. Indeed doing so could be construed as
incorrect. */
SysRes sres
- = VG_(do_syscall)(sysno, sci->args.arg1, sci->args.arg2,
+ = VG_(do_syscall)(canonical_sysno, sci->args.arg1, sci->args.arg2,
sci->args.arg3, sci->args.arg4,
sci->args.arg5, sci->args.arg6,
sci->args.arg7, sci->args.arg8 );
putSyscallStatusIntoGuestState( tid, &sci->status, &tst->arch.vex );
/* If needed, gdbserver will report syscall return to GDB */
- VG_(gdbserver_report_syscall)(False, sysno, tid);
+ VG_(gdbserver_report_syscall)(False, canonical_sysno, tid);
/* Situation now:
- the guest state is now correctly modified following the syscall
const SyscallTableEntry* ent;
SyscallStatus test_status;
ThreadState* tst;
- Word sysno;
+ Word canonical_sysno;
/* Preliminaries */
vg_assert(VG_(is_valid_tid)(tid));
/* Get the system call number. Because the pre-handler isn't
allowed to mess with it, it should be the same for both the
original and potentially-modified args. */
- vg_assert(sci->args.sysno == sci->orig_args.sysno);
- sysno = sci->args.sysno;
+ vg_assert(sci->args.canonical_sysno == sci->orig_args.canonical_sysno);
+ canonical_sysno = sci->args.canonical_sysno;
getSyscallStatusFromGuestState( &test_status, &tst->arch.vex );
if (!(sci->flags & SfNoWriteResult)) {
- vg_assert(eq_SyscallStatus( sysno, &sci->status, &test_status ));
+ vg_assert(eq_SyscallStatus( canonical_sysno, &sci->status, &test_status ));
}
/* Failure of the above assertion on Darwin can indicate a problem
in the syscall wrappers that pre-fail or pre-succeed the
- it exists, and
- Success or (Failure and PostOnFail is set)
*/
- ent = get_syscall_entry(sysno);
+ ent = get_syscall_entry(canonical_sysno);
if (ent->after
&& ((!sr_isError(sci->status.sres))
|| (sr_isError(sci->status.sres)
tmpv[6] = sci->orig_args.arg7;
tmpv[7] = sci->orig_args.arg8;
VG_TDICT_CALL(tool_post_syscall, tid,
- sysno,
+ canonical_sysno,
&tmpv[0], sizeof(tmpv)/sizeof(tmpv[0]),
sci->status.sres);
}