|
From: <sv...@va...> - 2016-10-04 15:19:17
|
Author: petarj
Date: Tue Oct 4 16:19:10 2016
New Revision: 16003
Log:
mips64: support for prctl(GET/SET_FP_MODE) syscalls
Add MIPS specific wrapper for prctl(GET/SET_FP_MODE) syscalls to
support FP32/FP64 mode switch.
Patch by Aleksandar Rikalo.
Related VEX change r3253.
Related bug - BZ #366079.
Modified:
trunk/coregrind/m_syswrap/syswrap-mips64-linux.c
trunk/include/vki/vki-mips64-linux.h
Modified: trunk/coregrind/m_syswrap/syswrap-mips64-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-mips64-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-mips64-linux.c Tue Oct 4 16:19:10 2016
@@ -312,7 +312,7 @@
DECL_TEMPLATE (mips_linux, sys_cacheflush);
DECL_TEMPLATE (mips_linux, sys_sched_rr_get_interval);
DECL_TEMPLATE (mips_linux, sys_unshare);
-DECL_TEMPLATE (mips_linux, sys_arch_prctl);
+DECL_TEMPLATE (mips_linux, sys_prctl);
DECL_TEMPLATE (mips_linux, sys_ptrace);
DECL_TEMPLATE (mips_linux, sys_mmap);
DECL_TEMPLATE (mips_linux, sys_rt_sigreturn);
@@ -616,6 +616,52 @@
}
}
+PRE (sys_prctl)
+{
+ switch (ARG1) {
+ case VKI_PR_SET_FP_MODE:
+ {
+ VexArchInfo vai;
+ VG_(machine_get_VexArchInfo)(NULL, &vai);
+ /* Reject unsupported modes */
+ if ((ARG2 & ~VKI_PR_FP_MODE_FR) ||
+ ((ARG2 & VKI_PR_FP_MODE_FR) &&
+ !VEX_MIPS_HOST_FP_MODE(vai.hwcaps))) {
+ SET_STATUS_Failure(VKI_EOPNOTSUPP);
+ } else {
+ if (!(VG_(threads)[tid].arch.vex.guest_CP0_status &
+ MIPS_CP0_STATUS_FR) != !(ARG2 & VKI_PR_FP_MODE_FR)) {
+ ThreadId t;
+ for (t = 1; t < VG_N_THREADS; t++) {
+ if (VG_(threads)[t].status != VgTs_Empty) {
+ if (ARG2 & VKI_PR_FP_MODE_FR) {
+ VG_(threads)[t].arch.vex.guest_CP0_status |=
+ MIPS_CP0_STATUS_FR;
+ } else {
+ VG_(threads)[t].arch.vex.guest_CP0_status &=
+ ~MIPS_CP0_STATUS_FR;
+ }
+ }
+ }
+ /* Discard all translations */
+ VG_(discard_translations)(0, (ULong)(-1ll), "prctl(PR_SET_FP_MODE)");
+ }
+ SET_STATUS_Success(0);
+ }
+ break;
+ }
+ case VKI_PR_GET_FP_MODE:
+ if (VG_(threads)[tid].arch.vex.guest_CP0_status & MIPS_CP0_STATUS_FR)
+ SET_STATUS_Success(VKI_PR_FP_MODE_FR);
+ else
+ SET_STATUS_Success(0);
+ break;
+ default:
+ WRAPPER_PRE_NAME(linux, sys_prctl)(tid, layout, arrghs, status, flags);
+ break;
+ }
+}
+
#undef PRE
#undef POST
@@ -787,7 +833,7 @@
LINX_ (__NR_vhangup, sys_vhangup),
LINX_ (__NR_pivot_root,sys_pivot_root),
LINXY (__NR__sysctl, sys_sysctl),
- LINXY (__NR_prctl, sys_prctl),
+ PLAX_ (__NR_prctl, sys_prctl),
LINXY (__NR_adjtimex, sys_adjtimex),
GENX_ (__NR_setrlimit, sys_setrlimit),
GENX_ (__NR_chroot, sys_chroot),
Modified: trunk/include/vki/vki-mips64-linux.h
==============================================================================
--- trunk/include/vki/vki-mips64-linux.h (original)
+++ trunk/include/vki/vki-mips64-linux.h Tue Oct 4 16:19:10 2016
@@ -1011,6 +1011,13 @@
#define VKI_ENOSYS 89 /* Function not implemented */
#define VKI_EOVERFLOW 79 /* Value too large for defined data type */
+//----------------------------------------------------------------------
+// From linux-3.7.0/arch/mips/include/uapi/asm/errno.h
+//----------------------------------------------------------------------
+
+#define VKI_EOPNOTSUPP 122 /* Operation not supported on transport
+ endpoint */
+
#endif // __VKI_MIPS64_LINUX_H
/*--------------------------------------------------------------------*/
|