From d092793872848b83dfb8973640ce71dc2522a8f3 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Thu, 17 Sep 2009 20:22:14 +0300 Subject: [PATCH 1/7] implementations of dup3 and fallocate that are good enough to fool LTP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updated fallocate check to new configure, added dup3 check as suggested by Jan-Simon Möller. Riku: updated to apply to current git. Signed-off-by: Ulrich Hecht Signed-off-by: Riku Voipio --- configure | 36 ++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 10 ++++++++++ 2 files changed, 46 insertions(+) diff --git a/configure b/configure index ca6d45c612..3df9d07f4a 100755 --- a/configure +++ b/configure @@ -1569,6 +1569,36 @@ if compile_prog "" "" ; then eventfd=yes fi +# check for fallocate +fallocate=no +cat > $TMPC << EOF +#include + +int main(void) +{ + fallocate(0, 0, 0, 0); + return 0; +} +EOF +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + fallocate=yes +fi + +# check for dup3 +dup3=no +cat > $TMPC << EOF +#include + +int main(void) +{ + dup3(0, 0, 0); + return 0; +} +EOF +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + dup3=yes +fi + # Check if tools are available to build documentation. if test "$docs" != "no" ; then if test -x "`which texi2html 2>/dev/null`" -a \ @@ -1950,6 +1980,12 @@ fi if test "$eventfd" = "yes" ; then echo "CONFIG_EVENTFD=y" >> $config_host_mak fi +if test "$fallocate" = "yes" ; then + echo "CONFIG_FALLOCATE=y" >> $config_host_mak +fi +if test "$dup3" = "yes" ; then + echo "CONFIG_DUP3=y" >> $config_host_mak +fi if test "$inotify" = "yes" ; then echo "CONFIG_INOTIFY=y" >> $config_host_mak fi diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bf06d14fc7..d07c381f02 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4746,6 +4746,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_dup2: ret = get_errno(dup2(arg1, arg2)); break; +#if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3) + case TARGET_NR_dup3: + ret = get_errno(dup3(arg1, arg2, arg3)); + break; +#endif #ifdef TARGET_NR_getppid /* not on alpha */ case TARGET_NR_getppid: ret = get_errno(getppid()); @@ -7013,6 +7018,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #endif #endif /* CONFIG_EVENTFD */ +#if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) + case TARGET_NR_fallocate: + ret = get_errno(fallocate(arg1, arg2, arg3, arg4)); + break; +#endif default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); From 691372066ca89e4669b41fc55cab6a061d88af6c Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Thu, 17 Sep 2009 21:08:37 +0300 Subject: [PATCH 2/7] linux-user: getpriority errno fix getpriority returned wrong errno; fixes LTP test getpriority02. Signed-off-by: Ulrich Hecht Signed-off-by: Riku Voipio --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d07c381f02..baf00e0bf9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5311,7 +5311,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, /* libc does special remapping of the return value of * sys_getpriority() so it's just easiest to call * sys_getpriority() directly rather than through libc. */ - ret = sys_getpriority(arg1, arg2); + ret = get_errno(sys_getpriority(arg1, arg2)); break; case TARGET_NR_setpriority: ret = get_errno(setpriority(arg1, arg2, arg3)); From 61322e91a177b7b79ac2df5a540fe67db2d9e2dd Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Tue, 1 Sep 2009 23:27:47 +0400 Subject: [PATCH 3/7] linux-user: fix ppc target_stat64 st_blocks layout Swap __pad1 and st_blocks fields location to maintain proper alignment. This fixes incorrect 'du' and 'stat' report on ppc guest. Signed-off-by: Max Filippov Signed-off-by: Riku Voipio --- linux-user/syscall_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index c018165bf3..dce36b2457 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1187,8 +1187,8 @@ struct __attribute__((__packed__)) target_stat64 { unsigned long long __pad0; long long st_size; int st_blksize; - long long st_blocks; /* Number 512-byte blocks allocated. */ unsigned int __pad1; + long long st_blocks; /* Number 512-byte blocks allocated. */ int target_st_atime; unsigned int target_st_atime_nsec; int target_st_mtime; From e2cc3f6ebe65f98171e07c6097c0bfa9171f6f0e Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Fri, 2 Oct 2009 14:10:04 +0200 Subject: [PATCH 4/7] linux-user: don't zero a buffer twice prepare_binprm() zeroes bprm->buf. That buffer is already zeroed in main() and hasn't been touched since so that is not necessary. Signed-off-by: Paul Bolle Signed-off-by: Riku Voipio --- linux-user/linuxload.c | 1 - 1 file changed, 1 deletion(-) diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 4091bdcccc..2d778a2ced 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -96,7 +96,6 @@ static int prepare_binprm(struct linux_binprm *bprm) } } - memset(bprm->buf, 0, sizeof(bprm->buf)); retval = lseek(bprm->fd, 0L, SEEK_SET); if(retval >= 0) { retval = read(bprm->fd, bprm->buf, 128); From cf6de34aecd7817050de46ff85c57423c9444285 Mon Sep 17 00:00:00 2001 From: Riku Voipio Date: Wed, 30 Sep 2009 11:44:34 +0300 Subject: [PATCH 5/7] linux-user: Update ARM hwcaps Update ARM hwcaps to match Linux kernel 2.6.31 state Signed-off-by: Riku Voipio --- linux-user/elfload.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 62a3f2ac2c..682a813981 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -330,11 +330,18 @@ enum ARM_HWCAP_ARM_FPA = 1 << 5, ARM_HWCAP_ARM_VFP = 1 << 6, ARM_HWCAP_ARM_EDSP = 1 << 7, + ARM_HWCAP_ARM_JAVA = 1 << 8, + ARM_HWCAP_ARM_IWMMXT = 1 << 9, + ARM_HWCAP_ARM_THUMBEE = 1 << 10, + ARM_HWCAP_ARM_NEON = 1 << 11, + ARM_HWCAP_ARM_VFPv3 = 1 << 12, + ARM_HWCAP_ARM_VFPv3D16 = 1 << 13, }; #define ELF_HWCAP (ARM_HWCAP_ARM_SWP | ARM_HWCAP_ARM_HALF \ | ARM_HWCAP_ARM_THUMB | ARM_HWCAP_ARM_FAST_MULT \ - | ARM_HWCAP_ARM_FPA | ARM_HWCAP_ARM_VFP) + | ARM_HWCAP_ARM_FPA | ARM_HWCAP_ARM_VFP \ + | ARM_HWCAP_ARM_NEON | ARM_HWCAP_ARM_VFPv3 ) #endif From f7680a5593032d0c4f699144666605a4f8b044b9 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Fri, 16 Oct 2009 17:00:44 +0200 Subject: [PATCH 6/7] linux-user: KD/VT/FB ioctls everything needed to run SDL on a framebuffer device in the userspace emulator Signed-off-by: Ulrich Hecht Signed-off-by: Riku Voipio --- linux-user/ioctls.h | 14 +++++++++++ linux-user/syscall.c | 2 ++ linux-user/syscall_defs.h | 16 ++++++++++++ linux-user/syscall_types.h | 51 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 685cc71310..769e1bcb81 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -53,7 +53,10 @@ IOCTL(KIOCSOUND, 0, TYPE_INT) IOCTL(KDMKTONE, 0, TYPE_INT) + IOCTL(KDSETMODE, 0, TYPE_INT) IOCTL(KDGKBTYPE, IOC_R, MK_PTR(TYPE_CHAR)) + IOCTL(KDGKBMODE, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(KDSKBMODE, 0, TYPE_INT) IOCTL(KDGKBENT, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_kbentry))) IOCTL(KDGKBSENT, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_kbsentry))) @@ -314,3 +317,14 @@ IOCTL(MTIOCTOP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_mtop))) IOCTL(MTIOCGET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_mtget))) IOCTL(MTIOCPOS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_mtpos))) + + IOCTL(FBIOGET_FSCREENINFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_fb_fix_screeninfo))) + IOCTL(FBIOGET_VSCREENINFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_fb_var_screeninfo))) + IOCTL(FBIOPUT_VSCREENINFO, IOC_W, MK_PTR(MK_STRUCT(STRUCT_fb_var_screeninfo))) + + IOCTL(VT_OPENQRY, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(VT_GETSTATE, IOC_R, MK_PTR(MK_STRUCT(STRUCT_vt_stat))) + IOCTL(VT_ACTIVATE, 0, TYPE_INT) + IOCTL(VT_WAITACTIVE, 0, TYPE_INT) + IOCTL(VT_LOCKSWITCH, 0, TYPE_INT) + IOCTL(VT_UNLOCKSWITCH, 0, TYPE_INT) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index baf00e0bf9..31dfcb75c2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -79,6 +79,8 @@ #include #include #include +#include +#include #include "linux_loop.h" #include "qemu.h" diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index dce36b2457..2d45753dd9 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -660,6 +660,9 @@ struct target_pollfd { #define TARGET_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */ #define TARGET_KDMKTONE 0x4B30 /* generate tone */ #define TARGET_KDGKBTYPE 0x4b33 +#define TARGET_KDSETMODE 0x4b3a +#define TARGET_KDGKBMODE 0x4b44 +#define TARGET_KDSKBMODE 0x4b45 #define TARGET_KDGKBENT 0x4B46 /* gets one entry in translation table */ #define TARGET_KDGKBSENT 0x4B48 /* gets one function key string entry */ @@ -874,6 +877,19 @@ struct target_pollfd { #define TARGET_LOOP_GET_STATUS64 0x4C05 #define TARGET_LOOP_CHANGE_FD 0x4C06 +/* fb ioctls */ +#define TARGET_FBIOGET_VSCREENINFO 0x4600 +#define TARGET_FBIOPUT_VSCREENINFO 0x4601 +#define TARGET_FBIOGET_FSCREENINFO 0x4602 + +/* vt ioctls */ +#define TARGET_VT_OPENQRY 0x5600 +#define TARGET_VT_GETSTATE 0x5603 +#define TARGET_VT_ACTIVATE 0x5606 +#define TARGET_VT_WAITACTIVE 0x5607 +#define TARGET_VT_LOCKSWITCH 0x560b +#define TARGET_VT_UNLOCKSWITCH 0x560c + /* from asm/termbits.h */ #define TARGET_NCC 8 diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index d3f3df91a3..340dbd367f 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -114,3 +114,54 @@ STRUCT(mtop, TYPE_SHORT, TYPE_INT) STRUCT(mtget, TYPE_LONG, TYPE_LONG, TYPE_LONG, TYPE_LONG, TYPE_LONG, TYPE_INT, TYPE_INT) STRUCT(mtpos, TYPE_LONG) + +STRUCT(fb_fix_screeninfo, + MK_ARRAY(TYPE_CHAR, 16), /* id */ + TYPE_ULONG, /* smem_start */ + TYPE_INT, /* smem_len */ + TYPE_INT, /* type */ + TYPE_INT, /* type_aux */ + TYPE_INT, /* visual */ + TYPE_SHORT, /* xpanstep */ + TYPE_SHORT, /* ypanstep */ + TYPE_SHORT, /* ywrapstep */ + TYPE_INT, /* line_length */ + TYPE_ULONG, /* mmio_start */ + TYPE_INT, /* mmio_len */ + TYPE_INT, /* accel */ + MK_ARRAY(TYPE_CHAR, 3)) /* reserved */ + +STRUCT(fb_var_screeninfo, + TYPE_INT, /* xres */ + TYPE_INT, /* yres */ + TYPE_INT, /* xres_virtual */ + TYPE_INT, /* yres_virtual */ + TYPE_INT, /* xoffset */ + TYPE_INT, /* yoffset */ + TYPE_INT, /* bits_per_pixel */ + TYPE_INT, /* grayscale */ + MK_ARRAY(TYPE_INT, 3), /* red */ + MK_ARRAY(TYPE_INT, 3), /* green */ + MK_ARRAY(TYPE_INT, 3), /* blue */ + MK_ARRAY(TYPE_INT, 3), /* transp */ + TYPE_INT, /* nonstd */ + TYPE_INT, /* activate */ + TYPE_INT, /* height */ + TYPE_INT, /* width */ + TYPE_INT, /* accel_flags */ + TYPE_INT, /* pixclock */ + TYPE_INT, /* left_margin */ + TYPE_INT, /* right_margin */ + TYPE_INT, /* upper_margin */ + TYPE_INT, /* lower_margin */ + TYPE_INT, /* hsync_len */ + TYPE_INT, /* vsync_len */ + TYPE_INT, /* sync */ + TYPE_INT, /* vmode */ + TYPE_INT, /* rotate */ + MK_ARRAY(TYPE_INT, 5)) /* reserved */ + +STRUCT(vt_stat, + TYPE_SHORT, /* v_active */ + TYPE_SHORT, /* v_signal */ + TYPE_SHORT) /* v_state */ From dab46405d964a17f8df7df14cca5804537c3f590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= Date: Sat, 17 Oct 2009 21:52:43 +0300 Subject: [PATCH 7/7] Re: linux-user/syscall.c - don't add GUEST_BASE to NULL pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes the mount call. GUEST_BASE shouldn't be added to a NULL pointer on arg5 . failing call: mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) = -1 EFAULT (Bad address) correct call: mount("rootfs", "/", 0x37ab0, MS_MGC_VAL|MS_REMOUNT, NULL) = 0 Signed-off-by:  Jan-Simon Möller   Signed-off-by: Riku Voipio --- linux-user/syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 31dfcb75c2..0254226a42 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4463,12 +4463,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, p3 = lock_user_string(arg3); if (!p || !p2 || !p3) ret = -TARGET_EFAULT; - else + else { /* FIXME - arg5 should be locked, but it isn't clear how to * do that since it's not guaranteed to be a NULL-terminated * string. */ - ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5))); + if ( ! arg5 ) + ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL)); + else + ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5))); + } unlock_user(p, arg1, 0); unlock_user(p2, arg2, 0); unlock_user(p3, arg3, 0);