Discussion:
Valgrind: r16224 - in /trunk: NEWS coregrind/m_syswrap/syswrap-solaris.c include/vki/vki-scnums-solaris.h include/vki/vki-solaris.h memcheck/tests/solaris/scalar.c memcheck/tests/solaris/scalar.stderr.exp
(too old to reply)
s***@valgrind.org
2017-02-14 10:35:20 UTC
Permalink
Raw Message
Author: iraisr
Date: Tue Feb 14 10:35:20 2017
New Revision: 16224

Log:
Solaris: Add syscall wrapper for lgrpsys(180)
Fixes BZ#376455.

Modified:
trunk/NEWS
trunk/coregrind/m_syswrap/syswrap-solaris.c
trunk/include/vki/vki-scnums-solaris.h
trunk/include/vki/vki-solaris.h
trunk/memcheck/tests/solaris/scalar.c
trunk/memcheck/tests/solaris/scalar.stderr.exp

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Tue Feb 14 10:35:20 2017
@@ -114,6 +114,7 @@
375772 +1 error in get_elf_symbol_info() when computing value of 'hi' address
for ML_(find_rx_mapping)()
375806 Test helgrind/tests/tc22_exit_w_lock fails with glibc 2.24
+376455 Solaris: unhandled syscall lgrpsys(180)

Release 3.12.0 (20 October 2016)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Modified: trunk/coregrind/m_syswrap/syswrap-solaris.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-solaris.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-solaris.c Tue Feb 14 10:35:20 2017
@@ -1025,6 +1025,7 @@
DECL_TEMPLATE(solaris, sys_lwp_cond_broadcast);
DECL_TEMPLATE(solaris, sys_pread);
DECL_TEMPLATE(solaris, sys_pwrite);
+DECL_TEMPLATE(solaris, sys_lgrpsys);
DECL_TEMPLATE(solaris, sys_rusagesys);
DECL_TEMPLATE(solaris, sys_port);
DECL_TEMPLATE(solaris, sys_pollsys);
@@ -7494,6 +7495,53 @@
POST_MEM_WRITE(ARG2, RES * sizeof(vki_size_t));
}

+PRE(sys_lgrpsys)
+{
+ /* Kernel: int lgrpsys(int subcode, long ia, void *ap); */
+ switch (ARG1 /*subcode*/) {
+ case VKI_LGRP_SYS_MEMINFO:
+ PRINT("sys_lgrpsys ( %ld, %ld, %#lx )", SARG1, SARG2, ARG3);
+ PRE_REG_READ3(long, SC2("lgrpsys", "meminfo"), int, subcode,
+ int, addr_count, vki_meminfo_t *, minfo);
+ PRE_MEM_READ("lgrpsys(minfo)", ARG3, sizeof(vki_meminfo_t));
+
+ if (ML_(safe_to_deref)((vki_meminfo_t *) ARG3, sizeof(vki_meminfo_t))) {
+ vki_meminfo_t *minfo = (vki_meminfo_t *) ARG3;
+ PRE_MEM_READ("lgrpsys(minfo->mi_inaddr)",
+ (Addr) minfo->mi_inaddr, SARG2 * sizeof(vki_uint64_t));
+ PRE_MEM_READ("lgrpsys(minfo->mi_info_req)", (Addr) minfo->mi_info_req,
+ minfo->mi_info_count * sizeof(vki_uint_t));
+ PRE_MEM_WRITE("lgrpsys(minfo->mi_outdata)", (Addr) minfo->mi_outdata,
+ SARG2 * minfo->mi_info_count * sizeof(vki_uint64_t));
+ PRE_MEM_WRITE("lgrpsys(minfo->mi_validity)",
+ (Addr) minfo->mi_validity, SARG2 * sizeof(vki_uint_t));
+ }
+ break;
+ default:
+ VG_(unimplemented)("Syswrap of the lgrpsys call with subcode %ld.",
+ SARG1);
+ /*NOTREACHED*/
+ break;
+ }
+}
+
+POST(sys_lgrpsys)
+{
+ switch (ARG1 /*subcode*/) {
+ case VKI_LGRP_SYS_MEMINFO:
+ {
+ vki_meminfo_t *minfo = (vki_meminfo_t *) ARG3;
+ POST_MEM_WRITE((Addr) minfo->mi_outdata,
+ SARG2 * minfo->mi_info_count * sizeof(vki_uint64_t));
+ POST_MEM_WRITE((Addr) minfo->mi_validity, SARG2 * sizeof(vki_uint_t));
+ }
+ break;
+ default:
+ vg_assert(0);
+ break;
+ }
+}
+
PRE(sys_rusagesys)
{
/* Kernel: int rusagesys(int code, void *arg1, void *arg2,
@@ -7554,7 +7602,6 @@
vg_assert(0);
break;
}
-
}

PRE(sys_port)
@@ -10864,6 +10911,7 @@
#if defined(VGP_x86_solaris)
PLAX_(__NR_llseek, sys_llseek32), /* 175 */
#endif /* VGP_x86_solaris */
+ SOLXY(__NR_lgrpsys, sys_lgrpsys), /* 180 */
SOLXY(__NR_rusagesys, sys_rusagesys), /* 181 */
SOLXY(__NR_port, sys_port), /* 182 */
SOLXY(__NR_pollsys, sys_pollsys), /* 183 */

Modified: trunk/include/vki/vki-scnums-solaris.h
==============================================================================
--- trunk/include/vki/vki-scnums-solaris.h (original)
+++ trunk/include/vki/vki-scnums-solaris.h Tue Feb 14 10:35:20 2017
@@ -237,8 +237,7 @@
//#define __NR_brand SYS_brand
//#define __NR_kaio SYS_kaio
//#define __NR_cpc SYS_cpc
-//#define __NR_lgrpsys SYS_lgrpsys
-//#define __NR_meminfosys SYS_meminfosys /* = SYS_lgrpsys */
+#define __NR_lgrpsys SYS_lgrpsys
#define __NR_rusagesys SYS_rusagesys
#define __NR_port SYS_port
#define __NR_pollsys SYS_pollsys

Modified: trunk/include/vki/vki-solaris.h
==============================================================================
--- trunk/include/vki/vki-solaris.h (original)
+++ trunk/include/vki/vki-solaris.h Tue Feb 14 10:35:20 2017
@@ -604,6 +604,21 @@
#define vki_semid64_ds semid_ds64


+#include <sys/lgrp_user_impl.h>
+#define VKI_LGRP_SYS_MEMINFO LGRP_SYS_MEMINFO
+#define VKI_LGRP_SYS_GENERATION LGRP_SYS_GENERATION
+#define VKI_LGRP_SYS_VERSION LGRP_SYS_VERSION
+#define VKI_LGRP_SYS_SNAPSHOT LGRP_SYS_SNAPSHOT
+#define VKI_LGRP_SYS_AFFINITY_GET LGRP_SYS_AFFINITY_GET
+#define VKI_LGRP_SYS_AFFINITY_SET LGRP_SYS_AFFINITY_SET
+#define VKI_LGRP_SYS_LATENCY LGRP_SYS_LATENCY
+#define VKI_LGRP_SYS_HOME LGRP_SYS_HOME
+#define VKI_LGRP_SYS_AFF_INHERIT_GET LGRP_SYS_AFF_INHERIT_GET
+#define VKI_LGRP_SYS_AFF_INHERIT_SET LGRP_SYS_AFF_INHERIT_SET
+#define VKI_LGRP_SYS_DEVICE_LGRPS LGRP_SYS_DEVICE_LGRPS
+#define VKI_LGRP_SYS_MAXSOCKETS_GET LGRP_SYS_MAXSOCKETS_GET
+
+
#include <sys/loadavg.h>
#define VKI_LOADAVG_NSTATS LOADAVG_NSTATS

@@ -643,6 +658,8 @@
#define VKI_MC_UNLOCKAS MC_UNLOCKAS
#define VKI_MC_HAT_ADVISE MC_HAT_ADVISE

+#define vki_meminfo_t meminfo_t
+

#include <sys/mntio.h>
#define VKI_MNTIOC_GETEXTMNTENT MNTIOC_GETEXTMNTENT

Modified: trunk/memcheck/tests/solaris/scalar.c
==============================================================================
--- trunk/memcheck/tests/solaris/scalar.c (original)
+++ trunk/memcheck/tests/solaris/scalar.c Tue Feb 14 10:35:20 2017
@@ -9,6 +9,7 @@
#include <sys/door.h>
#include <sys/fcntl.h>
#include <sys/fstyp.h>
+#include <sys/lgrp_user_impl.h>
#include <sys/mman.h>
#include <sys/modctl.h>
#include <sys/mount.h>
@@ -701,6 +702,34 @@
}

__attribute__((noinline))
+static void sys_lgrpsys(void)
+{
+ GO(SYS_lgrpsys, "(LGRP_SYS_MEMINFO) 3s 1m");
+ SY(SYS_lgrpsys, x0 + LGRP_SYS_MEMINFO, x0 + 0, x0 + 1); FAIL;
+}
+
+__attribute__((noinline))
+static void sys_lgrpsys2(void)
+{
+ GO(SYS_lgrpsys, "(LGRP_SYS_MEMINFO) 3s 1m");
+ SY(SYS_lgrpsys, x0 + LGRP_SYS_MEMINFO, x0 + 1, x0 + 1); FAIL;
+}
+
+__attribute__((noinline))
+static void sys_lgrpsys3(void)
+{
+ meminfo_t minfo;
+ minfo.mi_inaddr = (void *)(x0 + 1);
+ minfo.mi_info_req = (void *)(x0 + 1);
+ minfo.mi_info_count = x0 + 1;
+ minfo.mi_outdata = (void *)(x0 + 1);
+ minfo.mi_validity = (void *)(x0 + 1);
+
+ GO(SYS_lgrpsys, "(LGRP_SYS_MEMINFO) 4s 4m");
+ SY(SYS_lgrpsys, x0 + LGRP_SYS_MEMINFO, x0 + 1, x0 + &minfo); FAIL;
+}
+
+__attribute__((noinline))
static void sys_rusagesys(void)
{
GO(SYS_rusagesys, "(_RUSAGESYS_GETRUSAGE) 2s 1m");
@@ -2185,7 +2214,9 @@
/* XXX Missing wrapper. */

/* SYS_lgrpsys 180 */
- /* XXX Missing wrapper. */
+ sys_lgrpsys();
+ sys_lgrpsys2();
+ sys_lgrpsys3();

/* SYS_rusagesys 181 */
sys_rusagesys();

Modified: trunk/memcheck/tests/solaris/scalar.stderr.exp
==============================================================================
--- trunk/memcheck/tests/solaris/scalar.stderr.exp (original)
+++ trunk/memcheck/tests/solaris/scalar.stderr.exp Tue Feb 14 10:35:20 2017
@@ -2806,6 +2806,70 @@
Address 0x........ is not stack'd, malloc'd or (recently) free'd

---------------------------------------------------------
+180: SYS_lgrpsys (LGRP_SYS_MEMINFO) 3s 1m
+---------------------------------------------------------
+Syscall param lgrpsys_meminfo(subcode) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys_meminfo(addr_count) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys_meminfo(minfo) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys(minfo) points to unaddressable byte(s)
+ ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
+180: SYS_lgrpsys (LGRP_SYS_MEMINFO) 3s 1m
+---------------------------------------------------------
+Syscall param lgrpsys_meminfo(subcode) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys_meminfo(addr_count) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys_meminfo(minfo) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys(minfo) points to unaddressable byte(s)
+ ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
+180: SYS_lgrpsys (LGRP_SYS_MEMINFO) 4s 4m
+---------------------------------------------------------
+Syscall param lgrpsys_meminfo(subcode) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys_meminfo(addr_count) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys_meminfo(minfo) contains uninitialised byte(s)
+ ...
+
+Syscall param lgrpsys(minfo) points to uninitialised byte(s)
+ ...
+ Address 0x........ is on thread 1's stack
+
+Syscall param lgrpsys(minfo->mi_inaddr) points to unaddressable byte(s)
+ ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param lgrpsys(minfo->mi_info_req) points to unaddressable byte(s)
+ ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param lgrpsys(minfo->mi_outdata) points to unaddressable byte(s)
+ ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param lgrpsys(minfo->mi_validity) points to unaddressable byte(s)
+ ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
181: SYS_rusagesys (_RUSAGESYS_GETRUSAGE) 2s 1m
---------------------------------------------------------
Syscall param rusagesys_getrusage(code) contains uninitialised byte(s)
p***@free.fr
2017-02-14 20:33:03 UTC
Permalink
Raw Message
----- Original Message -----
Post by s***@valgrind.org
Author: iraisr
Date: Tue Feb 14 10:35:20 2017
New Revision: 16224
Hi Ivo
Post by s***@valgrind.org
Modified: trunk/include/vki/vki-solaris.h
==============================================================================
--- trunk/include/vki/vki-solaris.h (original)
+++ trunk/include/vki/vki-solaris.h Tue Feb 14 10:35:20 2017
@@ -604,6 +604,21 @@
#define vki_semid64_ds semid_ds64
+#include <sys/lgrp_user_impl.h>
I think that should be
Post by s***@valgrind.org
+#include <sys/lgrp_user.h>
There's no _impl version on Solaris 11.3.

A+
Paul
Ivo Raisr
2017-02-15 14:36:24 UTC
Permalink
Raw Message
Post by p***@free.fr
Post by s***@valgrind.org
+#include <sys/lgrp_user_impl.h>
I think that should be
Post by s***@valgrind.org
+#include <sys/lgrp_user.h>
There's no _impl version on Solaris 11.3.
Yes, indeed. This situation is true in Solaris 11.next (former Solaris 12).
In Solaris 11.3 we still have only lgrp_user.h.
I will fix that shortly. Thank you for reporting this.
I.

Loading...