* [Qemu-devel] [PATCH] linux-user: correct stat structure in MIPS N32
@ 2015-01-30 15:08 Leon Alrae
2015-02-09 12:06 ` James Hogan
0 siblings, 1 reply; 2+ messages in thread
From: Leon Alrae @ 2015-01-30 15:08 UTC (permalink / raw)
To: qemu-devel; +Cc: riku.voipio, aurelien
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 <daniel.sanders@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Tested-by: Daniel Sanders <daniel.sanders@imgtec.com>
---
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 ebb3be1..0fc4317 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1600,73 +1600,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)
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: correct stat structure in MIPS N32
2015-01-30 15:08 [Qemu-devel] [PATCH] linux-user: correct stat structure in MIPS N32 Leon Alrae
@ 2015-02-09 12:06 ` James Hogan
0 siblings, 0 replies; 2+ messages in thread
From: James Hogan @ 2015-02-09 12:06 UTC (permalink / raw)
To: Leon Alrae, qemu-devel; +Cc: riku.voipio, aurelien
[-- Attachment #1: Type: text/plain, Size: 3933 bytes --]
Hi Leon,
On 30/01/15 15:08, Leon Alrae wrote:
> 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 <daniel.sanders@imgtec.com>
> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
> Tested-by: Daniel Sanders <daniel.sanders@imgtec.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cheers
James
> ---
> 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 ebb3be1..0fc4317 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -1600,73 +1600,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)
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-09 12:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-30 15:08 [Qemu-devel] [PATCH] linux-user: correct stat structure in MIPS N32 Leon Alrae
2015-02-09 12:06 ` James Hogan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.