From patchwork Fri Feb 13 10:02:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Alrae X-Patchwork-Id: 439461 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 621C11400DE for ; Fri, 13 Feb 2015 21:08:42 +1100 (AEDT) Received: from localhost ([::1]:54211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDAu-0005Mr-GQ for incoming@patchwork.ozlabs.org; Fri, 13 Feb 2015 05:08:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMD5l-0004YG-2H for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:03:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMD5k-0007ea-1I for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:03:20 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:40796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMD5j-0007eW-Qs for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:03:19 -0500 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id EB19074A9EFD9 for ; Fri, 13 Feb 2015 10:03:16 +0000 (GMT) Received: from lalrae-linux.kl.imgtec.org (192.168.14.163) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 13 Feb 2015 10:03:18 +0000 From: Leon Alrae To: Date: Fri, 13 Feb 2015 10:02:12 +0000 Message-ID: <1423821732-22542-15-git-send-email-leon.alrae@imgtec.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1423821732-22542-1-git-send-email-leon.alrae@imgtec.com> References: <1423821732-22542-1-git-send-email-leon.alrae@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.14.163] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.59.15.196 Subject: [Qemu-devel] [PULL 14/14] linux-user: correct stat structure in MIPS N32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Simple "hello world" MIPS N32 userland program crashes with segfault due to incorrectly defined stat structure in QEMU. Correct "target_stat" definition to match kernel's "stat64" as in MIPS N32 there are only plain "stat" syscalls using 64-bit structure. Reported-by: Daniel Sanders Signed-off-by: Leon Alrae Tested-by: Daniel Sanders Reviewed-by: James Hogan --- linux-user/syscall_defs.h | 86 +++++++++++------------------------------------ 1 file changed, 19 insertions(+), 67 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 9ed6de8..edd5f3c 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1607,73 +1607,25 @@ struct target_stat { #elif defined(TARGET_ABI_MIPSN32) struct target_stat { - unsigned st_dev; - int st_pad1[3]; /* Reserved for network id */ - unsigned int st_ino; - unsigned int st_mode; - unsigned int st_nlink; - int st_uid; - int st_gid; - unsigned st_rdev; - unsigned int st_pad2[2]; - unsigned int st_size; - unsigned int st_pad3; - /* - * Actually this should be timestruc_t st_atime, st_mtime and st_ctime - * but we don't have it under Linux. - */ - unsigned int target_st_atime; - unsigned int target_st_atime_nsec; - unsigned int target_st_mtime; - unsigned int target_st_mtime_nsec; - unsigned int target_st_ctime; - unsigned int target_st_ctime_nsec; - unsigned int st_blksize; - unsigned int st_blocks; - unsigned int st_pad4[14]; -}; - -/* - * This matches struct stat64 in glibc2.1, hence the absolutely insane - * amounts of padding around dev_t's. The memory layout is the same as of - * struct stat of the 64-bit kernel. - */ - -#define TARGET_HAS_STRUCT_STAT64 -struct target_stat64 { - unsigned int st_dev; - unsigned int st_pad0[3]; /* Reserved for st_dev expansion */ - - target_ulong st_ino; - - unsigned int st_mode; - unsigned int st_nlink; - - int st_uid; - int st_gid; - - unsigned int st_rdev; - unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */ - - int st_size; - - /* - * Actually this should be timestruc_t st_atime, st_mtime and st_ctime - * but we don't have it under Linux. - */ - int target_st_atime; - unsigned int target_st_atime_nsec; /* Reserved for st_atime expansion */ - - int target_st_mtime; - unsigned int target_st_mtime_nsec; /* Reserved for st_mtime expansion */ - - int target_st_ctime; - unsigned int target_st_ctime_nsec; /* Reserved for st_ctime expansion */ - - unsigned int st_blksize; - unsigned int st_pad2; - - int st_blocks; + abi_ulong st_dev; + abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */ + uint64_t st_ino; + unsigned int st_mode; + unsigned int st_nlink; + int st_uid; + int st_gid; + abi_ulong st_rdev; + abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */ + int64_t st_size; + abi_long target_st_atime; + abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */ + abi_long target_st_mtime; + abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */ + abi_long target_st_ctime; + abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */ + abi_ulong st_blksize; + abi_ulong st_pad2; + int64_t st_blocks; }; #elif defined(TARGET_ABI_MIPSO32)