From owner-p4-projects@FreeBSD.ORG Fri Aug 21 23:07:10 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 002B8106568F; Fri, 21 Aug 2009 23:07:09 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8E7E106568C for ; Fri, 21 Aug 2009 23:07:09 +0000 (UTC) (envelope-from stas@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 8DF3F8FC0C for ; Fri, 21 Aug 2009 23:07:09 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n7LN79ud006629 for ; Fri, 21 Aug 2009 23:07:09 GMT (envelope-from stas@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n7LN79n6006627 for perforce@freebsd.org; Fri, 21 Aug 2009 23:07:09 GMT (envelope-from stas@freebsd.org) Date: Fri, 21 Aug 2009 23:07:09 GMT Message-Id: <200908212307.n7LN79n6006627@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to stas@freebsd.org using -f From: Stanislav Sedov To: Perforce Change Reviews Cc: Subject: PERFORCE change 167595 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Aug 2009 23:07:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=167595 Change 167595 by stas@stas_orion on 2009/08/21 23:06:20 - Add a basic ioctl handler. With this chane the basic vlagrind on amd64 should be mostly functional. Affected files ... .. //depot/projects/valgrind/coregrind/m_syswrap/priv_syswrap-freebsd.h#18 edit .. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#37 edit Differences ... ==== //depot/projects/valgrind/coregrind/m_syswrap/priv_syswrap-freebsd.h#18 (text+ko) ==== @@ -261,6 +261,8 @@ DECL_TEMPLATE(freebsd, sys_thr_new); DECL_TEMPLATE(freebsd, sys_thr_kill); DECL_TEMPLATE(freebsd, sys_thr_kill2); +DECL_TEMPLATE(freebsd, sys_fcntl); +DECL_TEMPLATE(freebsd, sys_ioctl); #endif // __PRIV_SYSWRAP_FREEBSD_H /*--------------------------------------------------------------------*/ ==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#37 (text+ko) ==== @@ -3102,6 +3102,58 @@ } } +PRE(sys_ioctl) +{ + UInt dir = _VKI_IOC_DIR(ARG2); + UInt size = _VKI_IOC_SIZE(ARG2); + *flags |= SfMayBlock; + PRINT("sys_ioctl ( %ld, 0x%lx, %#lx )",ARG1,ARG2,ARG3); + PRE_REG_READ3(long, "ioctl", + unsigned int, fd, unsigned int, request, unsigned long, arg); + +/* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder */ + if (VG_(strstr)(VG_(clo_sim_hints), "lax-ioctls") != NULL) { + /* + * Be very lax about ioctl handling; the only + * assumption is that the size is correct. Doesn't + * require the full buffer to be initialized when + * writing. Without this, using some device + * drivers with a large number of strange ioctl + * commands becomes very tiresome. + */ + } else if (/* size == 0 || */ dir == _VKI_IOC_NONE) { + static Int moans = 3; + if (moans > 0 && !VG_(clo_xml)) { + moans--; + VG_(message)(Vg_UserMsg, + "Warning: noted but unhandled ioctl 0x%lx" + " with no size/direction hints", + ARG2); + VG_(message)(Vg_UserMsg, + " This could cause spurious value errors" + " to appear."); + VG_(message)(Vg_UserMsg, + " See README_MISSING_SYSCALL_OR_IOCTL for " + "guidance on writing a proper wrapper." ); + } + } else { + if ((dir & _VKI_IOC_WRITE) && size > 0) + PRE_MEM_READ( "ioctl(generic)", ARG3, size); + if ((dir & _VKI_IOC_READ) && size > 0) + PRE_MEM_WRITE( "ioctl(generic)", ARG3, size); + } +} + +POST(sys_ioctl) +{ + UInt dir = _VKI_IOC_DIR(ARG2); + UInt size = _VKI_IOC_SIZE(ARG2); + vg_assert(SUCCESS); + if (size > 0 && (dir & _VKI_IOC_READ) + && RES == 0 && ARG3 != (Addr)NULL) + POST_MEM_WRITE(ARG3, size); +} + #undef PRE #undef POST @@ -3173,7 +3225,7 @@ // 4.3 sigpending 52 GENXY(__NR_sigaltstack, sys_sigaltstack), // 53 -// GENXY(__NR_ioctl, sys_ioctl), // 54 + BSDXY(__NR_ioctl, sys_ioctl), // 54 // BSDX_(__NR_reboot, sys_reboot), // 55 BSDX_(__NR_revoke, sys_revoke), // 56