* [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
@ 2008-10-08 18:54 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-08 18:54 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
There are two different syscall names for the same goal.
On systems with sizeof(long) == 64 it calls newfstatat.
On systems with sizeof(long) == 32 it calls fstatat64.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 5b69b5d..6e55a74 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -165,6 +165,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
#define __NR_sys_linkat __NR_linkat
#define __NR_sys_mkdirat __NR_mkdirat
#define __NR_sys_mknodat __NR_mknodat
+#define __NR_sys_newfstatat __NR_newfstatat
#define __NR_sys_openat __NR_openat
#define __NR_sys_readlinkat __NR_readlinkat
#define __NR_sys_renameat __NR_renameat
@@ -205,7 +206,8 @@ _syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
_syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
uid_t,owner,gid_t,group,int,flags)
#endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+ defined(__NR_fstatat64)
_syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname,
struct stat *,buf,int,flags)
#endif
@@ -236,6 +238,11 @@ _syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode)
_syscall4(int,sys_mknodat,int,dirfd,const char *,pathname,
mode_t,mode,dev_t,dev)
#endif
+#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \
+ defined(__NR_newfstatat)
+_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname,
+ struct stat *,buf,int,flags)
+#endif
#if defined(TARGET_NR_openat) && defined(__NR_openat)
_syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode)
#endif
@@ -5645,11 +5652,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+ (defined(__NR_fstatat64) || defined(__NR_newfstatat))
+#ifdef TARGET_NR_fstatat64
+ case TARGET_NR_fstatat64:
+#endif
+#ifdef TARGET_NR_newfstatat
case TARGET_NR_fstatat64:
+#endif
if (!(p = lock_user_string(arg2)))
goto efault;
+#ifdef __NR_fstatat64
ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4));
+#else
+ ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4));
+#endif
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg3, &st);
break;
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Add readahead syscall
@ 2008-10-13 10:10 Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f1f050e..dc7e561 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5761,7 +5761,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
#ifdef TARGET_NR_readahead
case TARGET_NR_readahead:
- goto unimplemented;
+#if TARGET_ABI_BITS == 32
+#ifdef TARGET_ARM
+ if (((CPUARMState *)cpu_env)->eabi)
+ {
+ arg2 = arg3;
+ arg3 = arg4;
+ arg4 = arg5;
+ }
+#endif
+ ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4));
+#else
+ ret = get_errno(readahead(arg1, arg2, arg3));
+#endif
+ break;
#endif
#ifdef TARGET_NR_setxattr
case TARGET_NR_setxattr:
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Fix getdents* syscalls
2008-10-13 10:10 [Qemu-devel] [PATCH] Add readahead syscall Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
2008-10-13 12:48 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Aurelien Jarno
0 siblings, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
glibc's structs dirent and dirent64 is different from in-kernel dirent
and dirent64. Kernel headers doesn't provide structs dirent(64) any
more. So we should add it to qemu headers.
To avoid conflict with glibc it called struct linux_dirent(64).
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 27 +++++++++++++--------------
linux-user/syscall_defs.h | 15 +++++++++++++++
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dc7e561..40e985a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -28,7 +28,6 @@
#include <fcntl.h>
#include <time.h>
#include <limits.h>
-#include <dirent.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
@@ -94,8 +93,8 @@
#endif
//#include <linux/msdos_fs.h>
-#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2])
-#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2])
+#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct linux_dirent [2])
+#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct linux_dirent [2])
#undef _syscall0
@@ -216,10 +215,10 @@ _syscall3(int,sys_futimesat,int,dirfd,const char *,pathname,
#endif
_syscall2(int,sys_getcwd1,char *,buf,size_t,size)
#if TARGET_ABI_BITS == 32
-_syscall3(int, sys_getdents, uint, fd, struct dirent *, dirp, uint, count);
+_syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count);
#endif
#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
-_syscall3(int, sys_getdents64, uint, fd, struct dirent64 *, dirp, uint, count);
+_syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count);
#endif
_syscall2(int, sys_getpriority, int, which, int, who);
#if !defined (__x86_64__)
@@ -4879,7 +4878,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#elif TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
{
struct target_dirent *target_dirp;
- struct dirent *dirp;
+ struct linux_dirent *dirp;
abi_long count = arg3;
dirp = malloc(count);
@@ -4890,7 +4889,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
- struct dirent *de;
+ struct linux_dirent *de;
struct target_dirent *tde;
int len = ret;
int reclen, treclen;
@@ -4912,7 +4911,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
tnamelen = 256;
/* XXX: may not be correct */
strncpy(tde->d_name, de->d_name, tnamelen);
- de = (struct dirent *)((char *)de + reclen);
+ de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
tde = (struct target_dirent *)((char *)tde + treclen);
count1 += treclen;
@@ -4924,14 +4923,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
}
#else
{
- struct dirent *dirp;
+ struct linux_dirent *dirp;
abi_long count = arg3;
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
- struct dirent *de;
+ struct linux_dirent *de;
int len = ret;
int reclen;
de = dirp;
@@ -4942,7 +4941,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
de->d_reclen = tswap16(reclen);
tswapls(&de->d_ino);
tswapls(&de->d_off);
- de = (struct dirent *)((char *)de + reclen);
+ de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
}
}
@@ -4953,13 +4952,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
case TARGET_NR_getdents64:
{
- struct dirent64 *dirp;
+ struct linux_dirent64 *dirp;
abi_long count = arg3;
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
ret = get_errno(sys_getdents64(arg1, dirp, count));
if (!is_error(ret)) {
- struct dirent64 *de;
+ struct linux_dirent64 *de;
int len = ret;
int reclen;
de = dirp;
@@ -4970,7 +4969,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
de->d_reclen = tswap16(reclen);
tswap64s((uint64_t *)&de->d_ino);
tswap64s((uint64_t *)&de->d_off);
- de = (struct dirent64 *)((char *)de + reclen);
+ de = (struct linux_dirent64 *)((char *)de + reclen);
len -= reclen;
}
}
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index c30bb15..5a58010 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1963,6 +1963,21 @@ struct target_sysinfo {
char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
};
+struct linux_dirent {
+ long d_ino;
+ unsigned long d_off;
+ unsigned short d_reclen;
+ char d_name[256]; /* We must not include limits.h! */
+};
+
+struct linux_dirent64 {
+ uint64_t d_ino;
+ int64_t d_off;
+ unsigned short d_reclen;
+ unsigned char d_type;
+ char d_name[256];
+};
+
#include "socket.h"
#include "errno_defs.h"
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
` (2 more replies)
2008-10-13 12:48 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Aurelien Jarno
1 sibling, 3 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 173 ++++++++++++++++++++++++++++++++++----------------
1 files changed, 117 insertions(+), 56 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 40e985a..7e67093 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1611,7 +1611,6 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
}
#endif
-#ifdef TARGET_NR_ipc
#define N_SHM_REGIONS 32
static struct shm_region {
@@ -1845,20 +1844,26 @@ static inline abi_long do_semctl(int first, int second, int third,
struct target_msqid_ds
{
- struct target_ipc_perm msg_perm;
- abi_ulong msg_stime;
- abi_ulong __unused1;
- abi_ulong msg_rtime;
- abi_ulong __unused2;
- abi_ulong msg_ctime;
- abi_ulong __unused3;
- abi_ulong __msg_cbytes;
- abi_ulong msg_qnum;
- abi_ulong msg_qbytes;
- abi_ulong msg_lspid;
- abi_ulong msg_lrpid;
- abi_ulong __unused4;
- abi_ulong __unused5;
+ struct target_ipc_perm msg_perm;
+ abi_ulong msg_stime;
+#if TARGET_ABI_BITS == 32
+ abi_ulong __unused1;
+#endif
+ abi_ulong msg_rtime;
+#if TARGET_ABI_BITS == 32
+ abi_ulong __unused2;
+#endif
+ abi_ulong msg_ctime;
+#if TARGET_ABI_BITS == 32
+ abi_ulong __unused3;
+#endif
+ abi_ulong __msg_cbytes;
+ abi_ulong msg_qnum;
+ abi_ulong msg_qbytes;
+ abi_ulong msg_lspid;
+ abi_ulong msg_lrpid;
+ abi_ulong __unused4;
+ abi_ulong __unused5;
};
static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md,
@@ -1868,7 +1873,8 @@ static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md,
if (!lock_user_struct(VERIFY_READ, target_md, target_addr, 1))
return -TARGET_EFAULT;
- target_to_host_ipc_perm(&(host_md->msg_perm),target_addr);
+ if (target_to_host_ipc_perm(&(host_md->msg_perm),target_addr))
+ return -TARGET_EFAULT;
host_md->msg_stime = tswapl(target_md->msg_stime);
host_md->msg_rtime = tswapl(target_md->msg_rtime);
host_md->msg_ctime = tswapl(target_md->msg_ctime);
@@ -1888,7 +1894,8 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr,
if (!lock_user_struct(VERIFY_WRITE, target_md, target_addr, 0))
return -TARGET_EFAULT;
- host_to_target_ipc_perm(target_addr,&(host_md->msg_perm));
+ if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm)))
+ return -TARGET_EFAULT;
target_md->msg_stime = tswapl(host_md->msg_stime);
target_md->msg_rtime = tswapl(host_md->msg_rtime);
target_md->msg_ctime = tswapl(host_md->msg_ctime);
@@ -1901,26 +1908,69 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr,
return 0;
}
-static inline abi_long do_msgctl(int first, int second, abi_long ptr)
+struct target_msginfo {
+ int msgpool;
+ int msgmap;
+ int msgmax;
+ int msgmnb;
+ int msgmni;
+ int msgssz;
+ int msgtql;
+ unsigned short int msgseg;
+};
+
+static inline abi_long host_to_target_msginfo(abi_ulong target_addr,
+ struct msginfo *host_msginfo)
+{
+ struct target_msginfo *target_msginfo;
+ if (!lock_user_struct(VERIFY_WRITE, target_msginfo, target_addr, 0))
+ return -TARGET_EFAULT;
+ __put_user(host_msginfo->msgpool, &target_msginfo->msgpool);
+ __put_user(host_msginfo->msgmap, &target_msginfo->msgmap);
+ __put_user(host_msginfo->msgmax, &target_msginfo->msgmax);
+ __put_user(host_msginfo->msgmnb, &target_msginfo->msgmnb);
+ __put_user(host_msginfo->msgmni, &target_msginfo->msgmni);
+ __put_user(host_msginfo->msgssz, &target_msginfo->msgssz);
+ __put_user(host_msginfo->msgtql, &target_msginfo->msgtql);
+ __put_user(host_msginfo->msgseg, &target_msginfo->msgseg);
+ unlock_user_struct(target_msginfo, target_addr, 1);
+}
+
+static inline abi_long do_msgctl(int msgid, int cmd, abi_long ptr)
{
struct msqid_ds dsarg;
- int cmd = second&0xff;
- abi_long ret = 0;
- switch( cmd ) {
+ struct msginfo msginfo;
+ abi_long ret = -TARGET_EINVAL;
+
+ cmd &= 0xff;
+
+ switch (cmd) {
case IPC_STAT:
case IPC_SET:
- target_to_host_msqid_ds(&dsarg,ptr);
- ret = get_errno(msgctl(first, cmd, &dsarg));
- host_to_target_msqid_ds(ptr,&dsarg);
- default:
- ret = get_errno(msgctl(first, cmd, &dsarg));
+ case MSG_STAT:
+ if (target_to_host_msqid_ds(&dsarg,ptr))
+ return -TARGET_EFAULT;
+ ret = get_errno(msgctl(msgid, cmd, &dsarg));
+ if (host_to_target_msqid_ds(ptr,&dsarg))
+ return -TARGET_EFAULT;
+ break;
+ case IPC_RMID:
+ ret = get_errno(msgctl(msgid, cmd, NULL));
+ break;
+ case IPC_INFO:
+ case MSG_INFO:
+ ret = get_errno(msgctl(msgid, cmd, (struct msqid_ds *)&msginfo));
+ if (host_to_target_msginfo(ptr, &msginfo))
+ return -TARGET_EFAULT;
+ break;
}
+
return ret;
}
struct target_msgbuf {
- abi_ulong mtype;
- char mtext[1];
+ abi_long mtype;
+ char mtext[1];
};
static inline abi_long do_msgsnd(int msqid, abi_long msgp,
@@ -1933,8 +1983,8 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))
return -TARGET_EFAULT;
host_mb = malloc(msgsz+sizeof(long));
- host_mb->mtype = tswapl(target_mb->mtype);
- memcpy(host_mb->mtext,target_mb->mtext,msgsz);
+ host_mb->mtype = (abi_long) tswapl(target_mb->mtype);
+ memcpy(host_mb->mtext, target_mb->mtext, msgsz);
ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));
free(host_mb);
unlock_user_struct(target_mb, msgp, 0);
@@ -1943,7 +1993,7 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
}
static inline abi_long do_msgrcv(int msqid, abi_long msgp,
- unsigned int msgsz, int msgtype,
+ unsigned int msgsz, abi_long msgtyp,
int msgflg)
{
struct target_msgbuf *target_mb;
@@ -1953,8 +2003,10 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
if (!lock_user_struct(VERIFY_WRITE, target_mb, msgp, 0))
return -TARGET_EFAULT;
+
host_mb = malloc(msgsz+sizeof(long));
- ret = get_errno(msgrcv(msqid, host_mb, msgsz, 1, msgflg));
+ ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapl(msgtyp), msgflg));
+
if (ret > 0) {
abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong);
target_mtext = lock_user(VERIFY_WRITE, target_mtext_addr, ret, 0);
@@ -1962,9 +2014,10 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
ret = -TARGET_EFAULT;
goto end;
}
- memcpy(target_mb->mtext, host_mb->mtext, ret);
+ memcpy(target_mb->mtext, host_mb->mtext, ret);
unlock_user(target_mtext, target_mtext_addr, ret);
}
+
target_mb->mtype = tswapl(host_mb->mtype);
free(host_mb);
@@ -1974,6 +2027,7 @@ end:
return ret;
}
+#ifdef TARGET_NR_ipc
/* ??? This only works with linear mappings. */
/* do_ipc() must return target values and target errnos. */
static abi_long do_ipc(unsigned int call, int first,
@@ -2006,34 +2060,41 @@ static abi_long do_ipc(unsigned int call, int first,
ret = -TARGET_ENOSYS;
break;
- case IPCOP_msgget:
- ret = get_errno(msgget(first, second));
- break;
+ case IPCOP_msgget:
+ ret = get_errno(msgget(first, second));
+ break;
- case IPCOP_msgsnd:
- ret = do_msgsnd(first, ptr, second, third);
- break;
+ case IPCOP_msgsnd:
+ ret = do_msgsnd(first, ptr, second, third);
+ break;
- case IPCOP_msgctl:
- ret = do_msgctl(first, second, ptr);
- break;
+ case IPCOP_msgctl:
+ ret = do_msgctl(first, second, ptr);
+ break;
- case IPCOP_msgrcv:
- {
- /* XXX: this code is not correct */
- struct ipc_kludge
- {
- void *__unbounded msgp;
- long int msgtyp;
- };
+ case IPCOP_msgrcv:
+ switch (version) {
+ case 0:
+ {
+ struct target_ipc_kludge {
+ abi_long msgp;
+ abi_long msgtyp;
+ } *tmp;
- struct ipc_kludge *foo = (struct ipc_kludge *)g2h(ptr);
- struct msgbuf *msgp = (struct msgbuf *) foo->msgp;
+ if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) {
+ ret = -TARGET_EFAULT;
+ break;
+ }
- ret = do_msgrcv(first, (long)msgp, second, 0, third);
+ ret = do_msgrcv(first, tmp->msgp, second, tmp->msgtyp, third);
- }
- break;
+ unlock_user_struct(tmp, ptr, 0);
+ break;
+ }
+ default:
+ ret = do_msgrcv(first, ptr, second, fifth, third);
+ }
+ break;
case IPCOP_shmat:
{
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Implement msg* syscalls
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-10-13 21:09 ` [Qemu-devel] [PATCH] Implement msg* syscalls Aurelien Jarno
2008-10-13 15:53 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Aurelien Jarno
2008-10-13 21:09 ` Aurelien Jarno
2 siblings, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7e67093..cf0834f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4829,6 +4829,27 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
+
+#ifdef TARGET_NR_msgctl
+ case TARGET_NR_msgctl:
+ ret = do_msgctl(arg1, arg2, arg3);
+ break;
+#endif
+#ifdef TARGET_NR_msgget
+ case TARGET_NR_msgget:
+ ret = get_errno(msgget(arg1, arg2));
+ break;
+#endif
+#ifdef TARGET_NR_msgrcv
+ case TARGET_NR_msgrcv:
+ ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);
+ break;
+#endif
+#ifdef TARGET_NR_msgsnd
+ case TARGET_NR_msgsnd:
+ ret = do_msgsnd(arg1, arg2, arg3, arg4);
+ break;
+#endif
case TARGET_NR_fsync:
ret = get_errno(fsync(arg1));
break;
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement sem* syscalls Kirill A. Shutemov
2008-10-24 7:24 ` [Qemu-devel] Re: [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-10-13 21:09 ` [Qemu-devel] [PATCH] Implement msg* syscalls Aurelien Jarno
1 sibling, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 319 +++++++++++++++++++++++++++++++-------------------
1 files changed, 198 insertions(+), 121 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index cf0834f..1852f35 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1635,14 +1635,14 @@ struct target_ipc_perm
struct target_semid_ds
{
- struct target_ipc_perm sem_perm;
- abi_ulong sem_otime;
- abi_ulong __unused1;
- abi_ulong sem_ctime;
- abi_ulong __unused2;
- abi_ulong sem_nsems;
- abi_ulong __unused3;
- abi_ulong __unused4;
+ struct target_ipc_perm sem_perm;
+ abi_ulong sem_otime;
+ abi_ulong __unused1;
+ abi_ulong sem_ctime;
+ abi_ulong __unused2;
+ abi_ulong sem_nsems;
+ abi_ulong __unused3;
+ abi_ulong __unused4;
};
static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip,
@@ -1690,7 +1690,8 @@ static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd,
if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1))
return -TARGET_EFAULT;
- target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr);
+ if (target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr))
+ return -TARGET_EFAULT;
host_sd->sem_nsems = tswapl(target_sd->sem_nsems);
host_sd->sem_otime = tswapl(target_sd->sem_otime);
host_sd->sem_ctime = tswapl(target_sd->sem_ctime);
@@ -1705,7 +1706,8 @@ static inline abi_long host_to_target_semid_ds(abi_ulong target_addr,
if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0))
return -TARGET_EFAULT;
- host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm));
+ if (host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm)))
+ return -TARGET_EFAULT;;
target_sd->sem_nsems = tswapl(host_sd->sem_nsems);
target_sd->sem_otime = tswapl(host_sd->sem_otime);
target_sd->sem_ctime = tswapl(host_sd->sem_ctime);
@@ -1713,135 +1715,215 @@ static inline abi_long host_to_target_semid_ds(abi_ulong target_addr,
return 0;
}
+struct target_seminfo {
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvmx;
+ int semaem;
+};
+
+static inline abi_long host_to_target_seminfo(abi_ulong target_addr,
+ struct seminfo *host_seminfo)
+{
+ struct target_seminfo *target_seminfo;
+ if (!lock_user_struct(VERIFY_WRITE, target_seminfo, target_addr, 0))
+ return -TARGET_EFAULT;
+ __put_user(host_seminfo->semmap, &target_seminfo->semmap);
+ __put_user(host_seminfo->semmni, &target_seminfo->semmni);
+ __put_user(host_seminfo->semmns, &target_seminfo->semmns);
+ __put_user(host_seminfo->semmnu, &target_seminfo->semmnu);
+ __put_user(host_seminfo->semmsl, &target_seminfo->semmsl);
+ __put_user(host_seminfo->semopm, &target_seminfo->semopm);
+ __put_user(host_seminfo->semume, &target_seminfo->semume);
+ __put_user(host_seminfo->semusz, &target_seminfo->semusz);
+ __put_user(host_seminfo->semvmx, &target_seminfo->semvmx);
+ __put_user(host_seminfo->semaem, &target_seminfo->semaem);
+ unlock_user_struct(target_seminfo, target_addr, 1);
+ return 0;
+}
+
union semun {
- int val;
- struct semid_ds *buf;
- unsigned short *array;
+ int val;
+ struct semid_ds *buf;
+ unsigned short *array;
+ struct seminfo *__buf;
};
union target_semun {
- int val;
- abi_long buf;
- unsigned short int *array;
+ int val;
+ abi_ulong buf;
+ abi_ulong array;
+ abi_ulong __buf;
};
-static inline abi_long target_to_host_semun(int cmd,
- union semun *host_su,
- abi_ulong target_addr,
- struct semid_ds *ds)
+static inline abi_long target_to_host_semarray(int semid, unsigned short **host_array,
+ abi_ulong target_addr)
{
- union target_semun *target_su;
-
- switch( cmd ) {
- case IPC_STAT:
- case IPC_SET:
- if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
- return -TARGET_EFAULT;
- target_to_host_semid_ds(ds,target_su->buf);
- host_su->buf = ds;
- unlock_user_struct(target_su, target_addr, 0);
- break;
- case GETVAL:
- case SETVAL:
- if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
- return -TARGET_EFAULT;
- host_su->val = tswapl(target_su->val);
- unlock_user_struct(target_su, target_addr, 0);
- break;
- case GETALL:
- case SETALL:
- if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
- return -TARGET_EFAULT;
- *host_su->array = tswap16(*target_su->array);
- unlock_user_struct(target_su, target_addr, 0);
- break;
- default:
- gemu_log("semun operation not fully supported: %d\n", (int)cmd);
+ int nsems;
+ unsigned short *array;
+ union semun semun;
+ struct semid_ds semid_ds;
+ int i, ret;
+
+ semun.buf = &semid_ds;
+
+ ret = semctl(semid, 0, IPC_STAT, semun);
+ if (ret == -1)
+ return get_errno(ret);
+
+ nsems = semid_ds.sem_nsems;
+
+ *host_array = malloc(nsems*sizeof(unsigned short));
+ array = lock_user(VERIFY_READ, target_addr,
+ nsems*sizeof(unsigned short), 1);
+ if (!array)
+ return -TARGET_EFAULT;
+
+ for(i=0; i<nsems; i++) {
+ __get_user((*host_array)[i], &array[i]);
}
+ unlock_user(array, target_addr, 0);
+
return 0;
}
-static inline abi_long host_to_target_semun(int cmd,
- abi_ulong target_addr,
- union semun *host_su,
- struct semid_ds *ds)
+static inline abi_long host_to_target_semarray(int semid, abi_ulong target_addr,
+ unsigned short **host_array)
{
- union target_semun *target_su;
-
- switch( cmd ) {
- case IPC_STAT:
- case IPC_SET:
- if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
- return -TARGET_EFAULT;
- host_to_target_semid_ds(target_su->buf,ds);
- unlock_user_struct(target_su, target_addr, 1);
- break;
- case GETVAL:
- case SETVAL:
- if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
- return -TARGET_EFAULT;
- target_su->val = tswapl(host_su->val);
- unlock_user_struct(target_su, target_addr, 1);
- break;
- case GETALL:
- case SETALL:
- if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
- return -TARGET_EFAULT;
- *target_su->array = tswap16(*host_su->array);
- unlock_user_struct(target_su, target_addr, 1);
- break;
- default:
- gemu_log("semun operation not fully supported: %d\n", (int)cmd);
+ int nsems;
+ unsigned short *array;
+ union semun semun;
+ struct semid_ds semid_ds;
+ int i, ret;
+
+ semun.buf = &semid_ds;
+
+ ret = semctl(semid, 0, IPC_STAT, semun);
+ if (ret == -1)
+ return get_errno(ret);
+
+ nsems = semid_ds.sem_nsems;
+
+ array = lock_user(VERIFY_WRITE, target_addr,
+ nsems*sizeof(unsigned short), 0);
+ if (!array)
+ return -TARGET_EFAULT;
+
+ for(i=0; i<nsems; i++) {
+ __put_user((*host_array)[i], &array[i]);
}
+ free(*host_array);
+ unlock_user(array, target_addr, 1);
+
return 0;
}
-static inline abi_long do_semctl(int first, int second, int third,
- abi_long ptr)
+static inline abi_long do_semctl(int semid, int semnum, int cmd,
+ union target_semun target_su)
{
union semun arg;
struct semid_ds dsarg;
- int cmd = third&0xff;
- abi_long ret = 0;
+ unsigned short *array;
+ struct seminfo seminfo;
+ abi_long ret = -TARGET_EINVAL;
+ abi_long err;
- switch( cmd ) {
- case GETVAL:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case SETVAL:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case GETALL:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case SETALL:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case IPC_STAT:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case IPC_SET:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- default:
- ret = get_errno(semctl(first, second, cmd, arg));
+ cmd &= 0xff;
+
+ switch (cmd) {
+ case IPC_STAT:
+ case IPC_SET:
+ case SEM_STAT:
+ err = target_to_host_semid_ds(&dsarg, target_su.buf);
+ if (err)
+ return err;
+ arg.buf = &dsarg;
+ ret = get_errno(semctl(semid, semnum, cmd, arg));
+ err = host_to_target_semid_ds(target_su.buf, &dsarg);
+ if (err)
+ return err;
+ break;
+ case GETVAL:
+ case SETVAL:
+ arg.val = tswapl(target_su.val);
+ ret = get_errno(semctl(semid, semnum, cmd, arg));
+ target_su.val = tswapl(arg.val);
+ break;
+ case GETALL:
+ case SETALL:
+ err = target_to_host_semarray(semid, &array, target_su.array);
+ if (err)
+ return err;
+ arg.array = array;
+ ret = get_errno(semctl(semid, semnum, cmd, arg));
+ err = host_to_target_semarray(semid, target_su.array, &array);
+ if (err)
+ return err;
+ break;
+ case IPC_INFO:
+ case SEM_INFO:
+ arg.__buf = &seminfo;
+ ret = get_errno(semctl(semid, semnum, cmd, arg));
+ err = host_to_target_seminfo(target_su.__buf, &seminfo);
+ if (err)
+ return err;
+ break;
+ case IPC_RMID:
+ case GETPID:
+ case GETNCNT:
+ case GETZCNT:
+ ret = get_errno(semctl(semid, semnum, cmd, NULL));
+ break;
}
return ret;
}
+struct target_sembuf {
+ unsigned short sem_num;
+ short sem_op;
+ short sem_flg;
+};
+
+static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf,
+ abi_ulong target_addr,
+ unsigned nsops)
+{
+ struct target_sembuf *target_sembuf;
+ int i;
+
+ target_sembuf = lock_user(VERIFY_READ, target_addr,
+ nsops*sizeof(struct target_sembuf), 1);
+ if (!target_sembuf)
+ return -TARGET_EFAULT;
+
+ for(i=0; i<nsops; i++) {
+ __put_user(target_sembuf[i].sem_num, &host_sembuf[i].sem_num);
+ __put_user(target_sembuf[i].sem_op, &host_sembuf[i].sem_op);
+ __put_user(target_sembuf[i].sem_flg, &host_sembuf[i].sem_flg);
+ }
+
+ unlock_user(target_sembuf, target_addr, 0);
+
+ return 0;
+}
+
+static inline abi_long do_semop(int semid, abi_long ptr, unsigned nsops)
+{
+ struct sembuf sops[nsops];
+
+ if (target_to_host_sembuf(sops, ptr, nsops))
+ return -TARGET_EFAULT;
+
+ return semop(semid, sops, nsops);
+}
+
struct target_msqid_ds
{
struct target_ipc_perm msg_perm;
@@ -2044,7 +2126,7 @@ static abi_long do_ipc(unsigned int call, int first,
switch (call) {
case IPCOP_semop:
- ret = get_errno(semop(first,(struct sembuf *)g2h(ptr), second));
+ ret = do_semop(first, ptr, second);
break;
case IPCOP_semget:
@@ -2052,12 +2134,7 @@ static abi_long do_ipc(unsigned int call, int first,
break;
case IPCOP_semctl:
- ret = do_semctl(first, second, third, ptr);
- break;
-
- case IPCOP_semtimedop:
- gemu_log("Unsupported ipc call: %d (version %d)\n", call, version);
- ret = -TARGET_ENOSYS;
+ ret = do_semctl(first, second, third, (union target_semun)(abi_ulong) ptr);
break;
case IPCOP_msgget:
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Implement sem* syscalls
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling Kirill A. Shutemov
2008-10-24 7:24 ` [Qemu-devel] Re: [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
1 sibling, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1852f35..1a09d90 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4906,7 +4906,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
-
+#ifdef TARGET_NR_semget
+ case TARGET_NR_semget:
+ ret = get_errno(semget(arg1, arg2, arg3));
+ break;
+#endif
+#ifdef TARGET_NR_semop
+ case TARGET_NR_semop:
+ ret = get_errno(do_semop(arg1, arg2, arg3));
+ break;
+#endif
+#ifdef TARGET_NR_semctl
+ case TARGET_NR_semctl:
+ ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);
+ break;
+#endif
#ifdef TARGET_NR_msgctl
case TARGET_NR_msgctl:
ret = do_msgctl(arg1, arg2, arg3);
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement sem* syscalls Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 282 +++++++++++++++++++++++++++++++++++++++----------
1 files changed, 224 insertions(+), 58 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1a09d90..d1fccb4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2109,6 +2109,206 @@ end:
return ret;
}
+struct target_shmid_ds
+{
+ struct target_ipc_perm shm_perm;
+ abi_ulong shm_segsz;
+ abi_ulong shm_atime;
+#if TARGET_ABI_BITS == 32
+ abi_ulong __unused1;
+#endif
+ abi_ulong shm_dtime;
+#if TARGET_ABI_BITS == 32
+ abi_ulong __unused2;
+#endif
+ abi_ulong shm_ctime;
+#if TARGET_ABI_BITS == 32
+ abi_ulong __unused3;
+#endif
+ int shm_cpid;
+ int shm_lpid;
+ abi_ulong shm_nattch;
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+};
+
+static inline abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd,
+ abi_ulong target_addr)
+{
+ struct target_shmid_ds *target_sd;
+
+ if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1))
+ return -TARGET_EFAULT;
+ if (target_to_host_ipc_perm(&(host_sd->shm_perm), target_addr))
+ return -TARGET_EFAULT;
+ __put_user(target_sd->shm_segsz, &host_sd->shm_segsz);
+ __put_user(target_sd->shm_atime, &host_sd->shm_atime);
+ __put_user(target_sd->shm_dtime, &host_sd->shm_dtime);
+ __put_user(target_sd->shm_ctime, &host_sd->shm_ctime);
+ __put_user(target_sd->shm_cpid, &host_sd->shm_cpid);
+ __put_user(target_sd->shm_lpid, &host_sd->shm_lpid);
+ __put_user(target_sd->shm_nattch, &host_sd->shm_nattch);
+ unlock_user_struct(target_sd, target_addr, 0);
+ return 0;
+}
+
+static inline abi_long host_to_target_shmid_ds(abi_ulong target_addr,
+ struct shmid_ds *host_sd)
+{
+ struct target_shmid_ds *target_sd;
+
+ if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0))
+ return -TARGET_EFAULT;
+ if (host_to_target_ipc_perm(target_addr, &(host_sd->shm_perm)))
+ return -TARGET_EFAULT;
+ __put_user(host_sd->shm_segsz, &target_sd->shm_segsz);
+ __put_user(host_sd->shm_atime, &target_sd->shm_atime);
+ __put_user(host_sd->shm_dtime, &target_sd->shm_dtime);
+ __put_user(host_sd->shm_ctime, &target_sd->shm_ctime);
+ __put_user(host_sd->shm_cpid, &target_sd->shm_cpid);
+ __put_user(host_sd->shm_lpid, &target_sd->shm_lpid);
+ __put_user(host_sd->shm_nattch, &target_sd->shm_nattch);
+ unlock_user_struct(target_sd, target_addr, 1);
+ return 0;
+}
+
+struct target_shminfo {
+ abi_ulong shmmax;
+ abi_ulong shmmin;
+ abi_ulong shmmni;
+ abi_ulong shmseg;
+ abi_ulong shmall;
+};
+
+static inline abi_long host_to_target_shminfo(abi_ulong target_addr,
+ struct shminfo *host_shminfo)
+{
+ struct target_shminfo *target_shminfo;
+ if (!lock_user_struct(VERIFY_WRITE, target_shminfo, target_addr, 0))
+ return -TARGET_EFAULT;
+ __put_user(host_shminfo->shmmax, &target_shminfo->shmmax);
+ __put_user(host_shminfo->shmmin, &target_shminfo->shmmin);
+ __put_user(host_shminfo->shmmni, &target_shminfo->shmmni);
+ __put_user(host_shminfo->shmseg, &target_shminfo->shmseg);
+ __put_user(host_shminfo->shmall, &target_shminfo->shmall);
+ unlock_user_struct(target_shminfo, target_addr, 1);
+}
+
+struct target_shm_info {
+ int used_ids;
+ abi_ulong shm_tot;
+ abi_ulong shm_rss;
+ abi_ulong shm_swp;
+ abi_ulong swap_attempts;
+ abi_ulong swap_successes;
+};
+
+static inline abi_long host_to_target_shm_info(abi_ulong target_addr,
+ struct shm_info *host_shm_info)
+{
+ struct target_shm_info *target_shm_info;
+ if (!lock_user_struct(VERIFY_WRITE, target_shm_info, target_addr, 0))
+ return -TARGET_EFAULT;
+ __put_user(host_shm_info->used_ids, &target_shm_info->used_ids);
+ __put_user(host_shm_info->shm_tot, &target_shm_info->shm_tot);
+ __put_user(host_shm_info->shm_rss, &target_shm_info->shm_rss);
+ __put_user(host_shm_info->shm_swp, &target_shm_info->shm_swp);
+ __put_user(host_shm_info->swap_attempts, &target_shm_info->swap_attempts);
+ __put_user(host_shm_info->swap_successes, &target_shm_info->swap_successes);
+ unlock_user_struct(target_shm_info, target_addr, 1);
+}
+
+static inline abi_long do_shmctl(int shmid, int cmd, abi_long buf)
+{
+ struct shmid_ds dsarg;
+ struct shminfo shminfo;
+ struct shm_info shm_info;
+ abi_long ret = -TARGET_EINVAL;
+
+ cmd &= 0xff;
+
+ switch(cmd) {
+ case IPC_STAT:
+ case IPC_SET:
+ case SHM_STAT:
+ if (target_to_host_shmid_ds(&dsarg, buf))
+ return -TARGET_EFAULT;
+ ret = get_errno(shmctl(shmid, cmd, &dsarg));
+ if (host_to_target_shmid_ds(buf, &dsarg))
+ return -TARGET_EFAULT;
+ break;
+ case IPC_INFO:
+ ret = get_errno(shmctl(shmid, cmd, (struct shmid_ds *)&shminfo));
+ if (host_to_target_shminfo(buf, &shminfo))
+ return -TARGET_EFAULT;
+ break;
+ case SHM_INFO:
+ ret = get_errno(shmctl(shmid, cmd, (struct shmid_ds *)&shm_info));
+ if (host_to_target_shm_info(buf, &shm_info))
+ return -TARGET_EFAULT;
+ break;
+ case IPC_RMID:
+ case SHM_LOCK:
+ case SHM_UNLOCK:
+ ret = get_errno(shmctl(shmid, cmd, NULL));
+ break;
+ }
+
+ return ret;
+}
+
+static inline abi_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
+ unsigned long *raddr)
+{
+ abi_long ret;
+ struct shmid_ds shm_info;
+ int i;
+
+ /* SHM_* flags are the same on all linux platforms */
+ *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
+
+ if (*raddr == -1) {
+ return get_errno(*raddr);
+ }
+
+ /* find out the length of the shared memory segment */
+ ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info));
+ if (is_error(ret)) {
+ /* can't get length, bail out */
+ shmdt((void *) *raddr);
+ return get_errno(ret);
+ }
+
+ page_set_flags(h2g(*raddr), h2g(*raddr) + shm_info.shm_segsz,
+ PAGE_VALID | PAGE_READ |
+ ((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
+
+ for (i = 0; i < N_SHM_REGIONS; i++) {
+ if (shm_regions[i].start == 0) {
+ shm_regions[i].start = h2g(*raddr);
+ shm_regions[i].size = shm_info.shm_segsz;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static inline abi_long do_shmdt(abi_ulong shmaddr)
+{
+ int i;
+
+ for (i = 0; i < N_SHM_REGIONS; ++i) {
+ if (shm_regions[i].start == shmaddr) {
+ shm_regions[i].start = 0;
+ page_set_flags(shmaddr, shm_regions[i].size, 0);
+ break;
+ }
+ }
+
+ return get_errno(shmdt(g2h(shmaddr)));
+}
+
#ifdef TARGET_NR_ipc
/* ??? This only works with linear mappings. */
/* do_ipc() must return target values and target errnos. */
@@ -2118,8 +2318,6 @@ static abi_long do_ipc(unsigned int call, int first,
{
int version;
abi_long ret = 0;
- struct shmid_ds shm_info;
- int i;
version = call >> 16;
call &= 0xffff;
@@ -2174,72 +2372,40 @@ static abi_long do_ipc(unsigned int call, int first,
break;
case IPCOP_shmat:
- {
- abi_ulong raddr;
- void *host_addr;
- /* SHM_* flags are the same on all linux platforms */
- host_addr = shmat(first, (void *)g2h(ptr), second);
- if (host_addr == (void *)-1) {
- ret = get_errno((long)host_addr);
- break;
- }
- raddr = h2g((unsigned long)host_addr);
- /* find out the length of the shared memory segment */
-
- ret = get_errno(shmctl(first, IPC_STAT, &shm_info));
- if (is_error(ret)) {
- /* can't get length, bail out */
- shmdt(host_addr);
- break;
- }
- page_set_flags(raddr, raddr + shm_info.shm_segsz,
- PAGE_VALID | PAGE_READ |
- ((second & SHM_RDONLY)? 0: PAGE_WRITE));
- for (i = 0; i < N_SHM_REGIONS; ++i) {
- if (shm_regions[i].start == 0) {
- shm_regions[i].start = raddr;
- shm_regions[i].size = shm_info.shm_segsz;
+ switch (version) {
+ default:
+ {
+ unsigned long raddr;
+
+ ret = do_shmat(first, ptr, second, &raddr);
+ if (ret)
break;
- }
+
+ ret = put_user_ual(raddr, third);
+ break;
}
- if (put_user_ual(raddr, third))
- return -TARGET_EFAULT;
- ret = 0;
+ case 1:
+ ret = -TARGET_EINVAL;
+ break;
}
- break;
+ break;
+
case IPCOP_shmdt:
- for (i = 0; i < N_SHM_REGIONS; ++i) {
- if (shm_regions[i].start == ptr) {
- shm_regions[i].start = 0;
- page_set_flags(ptr, shm_regions[i].size, 0);
- break;
- }
- }
- ret = get_errno(shmdt((void *)g2h(ptr)));
- break;
+ ret = do_shmdt(ptr);
+ break;
case IPCOP_shmget:
- /* IPC_* flag values are the same on all linux platforms */
- ret = get_errno(shmget(first, second, third));
- break;
+ ret = get_errno(shmget(first, second, third));
+ break;
- /* IPC_* and SHM_* command values are the same on all linux platforms */
case IPCOP_shmctl:
- switch(second) {
- case IPC_RMID:
- case SHM_LOCK:
- case SHM_UNLOCK:
- ret = get_errno(shmctl(first, second, NULL));
- break;
- default:
- goto unimplemented;
- }
+ ret = do_shmctl(first, second, third);
break;
+
default:
- unimplemented:
- gemu_log("Unsupported ipc call: %d (version %d)\n", call, version);
- ret = -TARGET_ENOSYS;
- break;
+ gemu_log("Unsupported ipc call: %d (version %d)\n", call, version);
+ ret = -TARGET_ENOSYS;
+ break;
}
return ret;
}
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Implement shm* syscalls
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov
2008-10-16 20:55 ` [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls Martin Mohring
0 siblings, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d1fccb4..c85fea4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5107,6 +5107,32 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = do_msgsnd(arg1, arg2, arg3, arg4);
break;
#endif
+#ifdef TARGET_NR_shmget
+ case TARGET_NR_shmget:
+ ret = get_errno(shmget(arg1, arg2, arg3));
+ break;
+#endif
+#ifdef TARGET_NR_shmctl
+ case TARGET_NR_shmctl:
+ ret = do_shmctl(arg1, arg2, arg3);
+ break;
+#endif
+#ifdef TARGET_NR_shmat
+ case TARGET_NR_shmat:
+ {
+ abi_long err;
+ unsigned long _ret;
+
+ err = do_shmat(arg1, arg2, arg3, &_ret);
+ ret = err ? err : _ret;
+ }
+ break;
+#endif
+#ifdef TARGET_NR_shmdt
+ case TARGET_NR_shmdt:
+ ret = do_shmdt(arg1);
+ break;
+#endif
case TARGET_NR_fsync:
ret = get_errno(fsync(arg1));
break;
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
2008-10-16 20:55 ` [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls Martin Mohring
1 sibling, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
There are two different syscall names for the same goal.
On systems with sizeof(long) == 64 it calls newfstatat.
On systems with sizeof(long) == 32 it calls fstatat64.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c85fea4..3fa205f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -165,6 +165,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
#define __NR_sys_linkat __NR_linkat
#define __NR_sys_mkdirat __NR_mkdirat
#define __NR_sys_mknodat __NR_mknodat
+#define __NR_sys_newfstatat __NR_newfstatat
#define __NR_sys_openat __NR_openat
#define __NR_sys_readlinkat __NR_readlinkat
#define __NR_sys_renameat __NR_renameat
@@ -205,7 +206,8 @@ _syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
_syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
uid_t,owner,gid_t,group,int,flags)
#endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+ defined(__NR_fstatat64)
_syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname,
struct stat *,buf,int,flags)
#endif
@@ -236,6 +238,11 @@ _syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode)
_syscall4(int,sys_mknodat,int,dirfd,const char *,pathname,
mode_t,mode,dev_t,dev)
#endif
+#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \
+ defined(__NR_newfstatat)
+_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname,
+ struct stat *,buf,int,flags)
+#endif
#if defined(TARGET_NR_openat) && defined(__NR_openat)
_syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode)
#endif
@@ -3481,7 +3488,7 @@ static inline abi_long host_to_target_timespec(abi_ulong target_addr,
return 0;
}
-#ifdef TARGET_NR_stat64
+#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat)
static inline abi_long host_to_target_stat64(void *cpu_env,
abi_ulong target_addr,
struct stat *host_st)
@@ -3513,11 +3520,15 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
} else
#endif
{
+#if TARGET_LONG_BITS == 64
+ struct target_stat *target_st;
+#else
struct target_stat64 *target_st;
+#endif
if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0))
return -TARGET_EFAULT;
- memset(target_st, 0, sizeof(struct target_stat64));
+ memset(target_st, 0, sizeof(*target_st));
__put_user(host_st->st_dev, &target_st->st_dev);
__put_user(host_st->st_ino, &target_st->st_ino);
#ifdef TARGET_STAT64_HAS_BROKEN_ST_INO
@@ -5645,11 +5656,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+ (defined(__NR_fstatat64) || defined(__NR_newfstatat))
+#ifdef TARGET_NR_fstatat64
case TARGET_NR_fstatat64:
+#endif
+#ifdef TARGET_NR_newfstatat
+ case TARGET_NR_newfstatat:
+#endif
if (!(p = lock_user_string(arg2)))
goto efault;
+#ifdef __NR_fstatat64
ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4));
+#else
+ ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4));
+#endif
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg3, &st);
break;
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Kirill A. Shutemov
2008-11-01 10:10 ` [Qemu-devel] [PATCH, v2] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
0 siblings, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
It makes qemu compatible with binfmt_misc's flags 'P' and 'O'.
'P' - preserve-argv[0]. Legacy behavior of binfmt_misc is to overwrite the
original argv[0] with the full path to the binary. When this flag is
included, binfmt_misc will add an argument to the argument vector for
this purpose, thus preserving the original argv[0].
'O' - open-binary. Legacy behavior of binfmt_misc is to pass the full path
of the binary to the interpreter as an argument. When this flag is
included, binfmt_misc will open the file for reading and pass its
descriptor as an argument, instead of the full path, thus allowing
the interpreter to execute non-readable binaries.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
configure | 86 ++++++++++++++++++++++++++----------------------
linux-user/linuxload.c | 7 +---
linux-user/main.c | 39 ++++++++++++++++++++-
linux-user/qemu.h | 2 +-
4 files changed, 87 insertions(+), 47 deletions(-)
diff --git a/configure b/configure
index f14739b..0148b72 100755
--- a/configure
+++ b/configure
@@ -113,6 +113,7 @@ aio="yes"
nptl="yes"
mixemu="no"
bluez="yes"
+binfmt_misc="no"
# OS specific
targetos=`uname -s`
@@ -349,6 +350,8 @@ for opt do
;;
--disable-aio) aio="no"
;;
+ --enable-binfmt-misc) binfmt_misc="yes"
+ ;;
*) echo "ERROR: unknown option $opt"; show_help="yes"
;;
esac
@@ -453,6 +456,7 @@ echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
echo " --disable-vde disable support for vde network"
echo " --disable-aio disable AIO support"
+echo " --enable-binfmt-misc makes usermode compatible with binfmt_misc's flags 'P' and 'O'"
echo ""
echo "NOTE: The object files are built at the place where configure is launched"
exit 1
@@ -969,55 +973,56 @@ else
binsuffix="/bin"
fi
-echo "Install prefix $prefix"
-echo "BIOS directory $prefix$datasuffix"
-echo "binary directory $prefix$binsuffix"
+echo "Install prefix $prefix"
+echo "BIOS directory $prefix$datasuffix"
+echo "binary directory $prefix$binsuffix"
if test "$mingw32" = "no" ; then
-echo "Manual directory $prefix$mansuffix"
-echo "ELF interp prefix $interp_prefix"
-fi
-echo "Source path $source_path"
-echo "C compiler $cc"
-echo "Host C compiler $host_cc"
-echo "ARCH_CFLAGS $ARCH_CFLAGS"
-echo "make $make"
-echo "install $install"
-echo "host CPU $cpu"
-echo "host big endian $bigendian"
-echo "target list $target_list"
-echo "gprof enabled $gprof"
-echo "sparse enabled $sparse"
-echo "profiler $profiler"
-echo "static build $static"
-echo "-Werror enabled $werror"
+echo "Manual directory $prefix$mansuffix"
+echo "ELF interp prefix $interp_prefix"
+fi
+echo "Source path $source_path"
+echo "C compiler $cc"
+echo "Host C compiler $host_cc"
+echo "ARCH_CFLAGS $ARCH_CFLAGS"
+echo "make $make"
+echo "install $install"
+echo "host CPU $cpu"
+echo "host big endian $bigendian"
+echo "target list $target_list"
+echo "gprof enabled $gprof"
+echo "sparse enabled $sparse"
+echo "profiler $profiler"
+echo "static build $static"
+echo "-Werror enabled $werror"
if test "$darwin" = "yes" ; then
- echo "Cocoa support $cocoa"
+ echo "Cocoa support $cocoa"
fi
echo "SDL support $sdl"
if test "$sdl" != "no" ; then
- echo "SDL static link $sdl_static"
-fi
-echo "curses support $curses"
-echo "mingw32 support $mingw32"
-echo "Audio drivers $audio_drv_list"
-echo "Extra audio cards $audio_card_list"
-echo "Mixer emulation $mixemu"
-echo "VNC TLS support $vnc_tls"
+ echo "SDL static link $sdl_static"
+fi
+echo "curses support $curses"
+echo "mingw32 support $mingw32"
+echo "Audio drivers $audio_drv_list"
+echo "Extra audio cards $audio_card_list"
+echo "Mixer emulation $mixemu"
+echo "VNC TLS support $vnc_tls"
if test "$vnc_tls" = "yes" ; then
- echo " TLS CFLAGS $vnc_tls_cflags"
- echo " TLS LIBS $vnc_tls_libs"
+ echo " TLS CFLAGS $vnc_tls_cflags"
+ echo " TLS LIBS $vnc_tls_libs"
fi
if test -n "$sparc_cpu"; then
- echo "Target Sparc Arch $sparc_cpu"
+ echo "Target Sparc Arch $sparc_cpu"
fi
-echo "kqemu support $kqemu"
-echo "brlapi support $brlapi"
-echo "Documentation $build_docs"
+echo "kqemu support $kqemu"
+echo "brlapi support $brlapi"
+echo "Documentation $build_docs"
[ ! -z "$uname_release" ] && \
-echo "uname -r $uname_release"
-echo "NPTL support $nptl"
-echo "vde support $vde"
-echo "AIO support $aio"
+echo "uname -r $uname_release"
+echo "NPTL support $nptl"
+echo "vde support $vde"
+echo "AIO support $aio"
+echo "binfmt_misc support $binfmt_misc"
if test $sdl_too_old = "yes"; then
echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1584,6 +1589,9 @@ if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
fi
+if test "$target_user_only" = "yes" -a "$binfmt_misc" = "yes"; then
+ echo "#define BINFMT_MISC 1" >> $config_h
+fi
test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c
index ada7c69..cbd90f7 100644
--- a/linux-user/linuxload.c
+++ b/linux-user/linuxload.c
@@ -154,7 +154,7 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
return sp;
}
-int loader_exec(const char * filename, char ** argv, char ** envp,
+int loader_exec(int fd, const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop)
{
struct linux_binprm bprm;
@@ -164,10 +164,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp,
bprm.p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int);
for (i=0 ; i<MAX_ARG_PAGES ; i++) /* clear page-table */
bprm.page[i] = 0;
- retval = open(filename, O_RDONLY);
- if (retval < 0)
- return retval;
- bprm.fd = retval;
+ bprm.fd = fd;
bprm.filename = (char *)filename;
bprm.argc = count(argv);
bprm.argv = argv;
diff --git a/linux-user/main.c b/linux-user/main.c
index fef4bf7..25b2867 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -26,6 +26,7 @@
#include "qemu.h"
#include "qemu-common.h"
+#include "elf.h"
/* For tb_lock */
#include "exec-all.h"
@@ -2217,9 +2218,10 @@ void init_task_state(TaskState *ts)
ts->sigqueue_table[i].next = NULL;
}
-int main(int argc, char **argv)
+int main(int argc, char **argv, char **envp)
{
const char *filename;
+ int fd = -1;
const char *cpu_model;
struct target_pt_regs regs1, *regs = ®s1;
struct image_info info1, *info = &info1;
@@ -2380,7 +2382,40 @@ int main(int argc, char **argv)
}
*dst = NULL; /* NULL terminate target_environ */
- if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
+#ifdef BINFMT_MISC
+#if HOST_LONG_BITS == 32
+#define Elf_Dyn Elf32_Dyn
+#else
+#define Elf_Dyn Elf64_Dyn
+#endif
+ {
+ Elf_Dyn *auxv;
+
+ optind++; /* Handle binfmt_misc's option 'P' */
+
+ /* Handle binfmt_misc's option 'O' */
+ while(*envp++ != NULL); /* skip envp. we are on auxv now */
+ for(auxv = (Elf_Dyn *)envp; auxv->d_tag != AT_NULL; auxv++) {
+ if( auxv->d_tag == AT_EXECFD) {
+ fd = auxv->d_un.d_val;
+ break;
+ }
+ }
+
+ if (fd < 0) {
+ printf("Cannot find binary file descriptor\n");
+ _exit(1);
+ }
+ }
+#else
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ printf("Cannot open file %s: %s\n", filename, strerror(errno));
+ _exit(1);
+ }
+#endif
+
+ if (loader_exec(fd, filename, argv+optind, target_environ, regs, info) != 0) {
printf("Error loading %s\n", filename);
_exit(1);
}
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index a2abe51..52835ec 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -168,7 +168,7 @@ struct linux_binprm {
void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
abi_ulong stringp, int push_ptr);
-int loader_exec(const char * filename, char ** argv, char ** envp,
+int loader_exec(int fd, const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop);
int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Kirill A. Shutemov
` (2 more replies)
2008-11-01 10:10 ` [Qemu-devel] [PATCH, v2] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
1 sibling, 3 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
qemu's page table can be incomple if /proc/self/maps is unavailable or
host allocating a memory with mmap(), so we can't use it to find free
memory area.
New version mmap_find_vma() uses mmap() without MAP_FIXED to find free
memory.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/mmap.c | 78 ++++++++++++++++++++++++++++------------------------
1 files changed, 42 insertions(+), 36 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index d5f22b8..19434a2 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -255,52 +255,58 @@ static abi_ulong mmap_next_start = 0x40000000;
unsigned long last_brk;
-/* find a free memory area of size 'size'. The search starts at
- 'start'. If 'start' == 0, then a default start address is used.
- Return -1 if error.
-*/
-/* page_init() marks pages used by the host as reserved to be sure not
- to use them. */
-static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
+/*
+ * Find and reserve a free memory area of size 'size'. The search
+ * starts at 'start'.
+ * Return -1 if error.
+ */
+abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
{
- abi_ulong addr, addr1, addr_start;
- int prot;
- unsigned long new_brk;
-
- new_brk = (unsigned long)sbrk(0);
- if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) {
- /* This is a hack to catch the host allocating memory with brk().
- If it uses mmap then we loose.
- FIXME: We really want to avoid the host allocating memory in
- the first place, and maybe leave some slack to avoid switching
- to mmap. */
- page_set_flags(last_brk & TARGET_PAGE_MASK,
- TARGET_PAGE_ALIGN(new_brk),
- PAGE_RESERVED);
- }
- last_brk = new_brk;
+ void *ptr;
+ abi_ulong addr;
size = HOST_PAGE_ALIGN(size);
- start = start & qemu_host_page_mask;
+ start &= qemu_host_page_mask;
+
+ /* If 'start' == 0, then a default start address is used. */
+ if (start == 0)
+ start = mmap_next_start;
+
addr = start;
- if (addr == 0)
- addr = mmap_next_start;
- addr_start = addr;
+
for(;;) {
- prot = 0;
- for(addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) {
- prot |= page_get_flags(addr1);
- }
- if (prot == 0)
+ /*
+ * Reserve needed memory area to avoid a race.
+ * It should be discarded using:
+ * - mmap() with MAP_FIXED flag
+ * - mremap() with MREMAP_FIXED flag
+ * - shmat() with SHM_REMAP flag
+ */
+ ptr = mmap((void *)(unsigned long)addr, size, PROT_NONE,
+ MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
+
+ /* ENOMEM, if host address space has no memory */
+ if (ptr == MAP_FAILED)
+ return (abi_ulong)-1;
+
+ /* If address fits target address space we've found what we need */
+ if ((unsigned long)ptr + size < (abi_ulong)-1)
break;
+
+ /* Unmap and try again with new page */
+ munmap(ptr, size);
addr += qemu_host_page_size;
- /* we found nothing */
- if (addr == addr_start)
+
+ /* ENOMEM if we check whole of target address space */
+ if (addr == start)
return (abi_ulong)-1;
}
+
+ /* Update default start address */
if (start == 0)
- mmap_next_start = addr + size;
- return addr;
+ mmap_next_start = (unsigned long)ptr + size;
+
+ return h2g(ptr);
}
/* NOTE: all the constants are the HOST ones */
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
2008-10-14 4:04 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Vince Weaver
2008-10-26 16:14 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Vince Weaver
2008-10-27 17:49 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2 siblings, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/mmap.c | 35 +++++++++++++++++++++++++++++------
1 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 19434a2..bc20f4b 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -533,19 +533,41 @@ int target_munmap(abi_ulong start, abi_ulong len)
return ret;
}
-/* XXX: currently, we only handle MAP_ANONYMOUS and not MAP_FIXED
- blocks which have been allocated starting on a host page */
abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
abi_ulong new_size, unsigned long flags,
abi_ulong new_addr)
{
int prot;
- unsigned long host_addr;
+ void *host_addr;
mmap_lock();
- /* XXX: use 5 args syscall */
- host_addr = (long)mremap(g2h(old_addr), old_size, new_size, flags);
- if (host_addr == -1) {
+
+ if (flags & MREMAP_FIXED)
+ host_addr = mremap(g2h(old_addr), old_size, new_size,
+ flags, new_addr);
+ else if (flags & MREMAP_MAYMOVE) {
+ abi_ulong mmap_start;
+
+ mmap_start = mmap_find_vma(0, new_size);
+
+ if (mmap_start == -1) {
+ errno = ENOMEM;
+ host_addr = MAP_FAILED;
+ } else
+ host_addr = mremap(g2h(old_addr), old_size, new_size,
+ flags | MREMAP_FIXED, g2h(mmap_start));
+ } else {
+ host_addr = mremap(g2h(old_addr), old_size, new_size, flags);
+ /* Check if address fits target address space */
+ if ((unsigned long)host_addr + new_size > (abi_ulong)-1) {
+ /* Revert mremap() changes */
+ host_addr = mremap(g2h(old_addr), new_size, old_size, flags);
+ errno = ENOMEM;
+ host_addr = MAP_FAILED;
+ }
+ }
+
+ if (host_addr == MAP_FAILED) {
new_addr = -1;
} else {
new_addr = h2g(host_addr);
@@ -553,6 +575,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
page_set_flags(old_addr, old_addr + old_size, 0);
page_set_flags(new_addr, new_addr + new_size, prot | PAGE_VALID);
}
+
mmap_unlock();
return new_addr;
}
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area
2008-10-13 10:10 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Kirill A. Shutemov
@ 2008-10-13 10:10 ` Kirill A. Shutemov
2008-10-17 6:34 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Kirill A. Shutemov
2008-11-10 7:09 ` [Qemu-devel] [PATCH, v3] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
2008-10-14 4:04 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Vince Weaver
1 sibling, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3fa205f..db3538b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2267,25 +2267,37 @@ static inline abi_long do_shmctl(int shmid, int cmd, abi_long buf)
static inline abi_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
unsigned long *raddr)
{
+ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size);
abi_long ret;
struct shmid_ds shm_info;
int i;
- /* SHM_* flags are the same on all linux platforms */
- *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
-
- if (*raddr == -1) {
- return get_errno(*raddr);
- }
-
/* find out the length of the shared memory segment */
ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info));
if (is_error(ret)) {
/* can't get length, bail out */
- shmdt((void *) *raddr);
return get_errno(ret);
}
+ if (shmaddr)
+ *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
+ else {
+ abi_ulong mmap_start;
+
+ mmap_start = mmap_find_vma(0, shm_info.shm_segsz);
+
+ if (mmap_start == -1) {
+ errno = ENOMEM;
+ *raddr = -1;
+ } else
+ *raddr = (unsigned long) shmat(shmid, g2h(mmap_start),
+ shmflg | SHM_REMAP);
+ }
+
+ if (*raddr == -1) {
+ return get_errno(*raddr);
+ }
+
page_set_flags(h2g(*raddr), h2g(*raddr) + shm_info.shm_segsz,
PAGE_VALID | PAGE_READ |
((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix getdents* syscalls
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
@ 2008-10-13 12:48 ` Aurelien Jarno
2008-10-13 12:59 ` Kirill A. Shutemov
1 sibling, 1 reply; 72+ messages in thread
From: Aurelien Jarno @ 2008-10-13 12:48 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel
Are you usingi cron to send those patches?
More seriously this is the third time you send the patch series in two
weeks. We do *not* have any *explanations*, so we don't know if it is a
new version or only a resend. I have some of your patches in my local
tree and I don't feel checking once more if the patches are the same or
not. Too bad if we miss some important changes.
I agree we are not merging patch very fast, but please be patient.
Resending patches too often and without giving any details only annoys
people and won't help to get your patches applied earlier.
Ping (for a big series) or resend (with the appropriate tag in the
subject) are welcome if we forget a patch. But please be patient.
On Mon, Oct 13, 2008 at 01:10:29PM +0300, Kirill A. Shutemov wrote:
> glibc's structs dirent and dirent64 is different from in-kernel dirent
> and dirent64. Kernel headers doesn't provide structs dirent(64) any
> more. So we should add it to qemu headers.
>
> To avoid conflict with glibc it called struct linux_dirent(64).
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
> linux-user/syscall.c | 27 +++++++++++++--------------
> linux-user/syscall_defs.h | 15 +++++++++++++++
> 2 files changed, 28 insertions(+), 14 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index dc7e561..40e985a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -28,7 +28,6 @@
> #include <fcntl.h>
> #include <time.h>
> #include <limits.h>
> -#include <dirent.h>
> #include <sys/types.h>
> #include <sys/ipc.h>
> #include <sys/msg.h>
> @@ -94,8 +93,8 @@
> #endif
>
> //#include <linux/msdos_fs.h>
> -#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2])
> -#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2])
> +#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct linux_dirent [2])
> +#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct linux_dirent [2])
>
>
> #undef _syscall0
> @@ -216,10 +215,10 @@ _syscall3(int,sys_futimesat,int,dirfd,const char *,pathname,
> #endif
> _syscall2(int,sys_getcwd1,char *,buf,size_t,size)
> #if TARGET_ABI_BITS == 32
> -_syscall3(int, sys_getdents, uint, fd, struct dirent *, dirp, uint, count);
> +_syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count);
> #endif
> #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
> -_syscall3(int, sys_getdents64, uint, fd, struct dirent64 *, dirp, uint, count);
> +_syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count);
> #endif
> _syscall2(int, sys_getpriority, int, which, int, who);
> #if !defined (__x86_64__)
> @@ -4879,7 +4878,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> #elif TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
> {
> struct target_dirent *target_dirp;
> - struct dirent *dirp;
> + struct linux_dirent *dirp;
> abi_long count = arg3;
>
> dirp = malloc(count);
> @@ -4890,7 +4889,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>
> ret = get_errno(sys_getdents(arg1, dirp, count));
> if (!is_error(ret)) {
> - struct dirent *de;
> + struct linux_dirent *de;
> struct target_dirent *tde;
> int len = ret;
> int reclen, treclen;
> @@ -4912,7 +4911,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> tnamelen = 256;
> /* XXX: may not be correct */
> strncpy(tde->d_name, de->d_name, tnamelen);
> - de = (struct dirent *)((char *)de + reclen);
> + de = (struct linux_dirent *)((char *)de + reclen);
> len -= reclen;
> tde = (struct target_dirent *)((char *)tde + treclen);
> count1 += treclen;
> @@ -4924,14 +4923,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> }
> #else
> {
> - struct dirent *dirp;
> + struct linux_dirent *dirp;
> abi_long count = arg3;
>
> if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
> goto efault;
> ret = get_errno(sys_getdents(arg1, dirp, count));
> if (!is_error(ret)) {
> - struct dirent *de;
> + struct linux_dirent *de;
> int len = ret;
> int reclen;
> de = dirp;
> @@ -4942,7 +4941,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> de->d_reclen = tswap16(reclen);
> tswapls(&de->d_ino);
> tswapls(&de->d_off);
> - de = (struct dirent *)((char *)de + reclen);
> + de = (struct linux_dirent *)((char *)de + reclen);
> len -= reclen;
> }
> }
> @@ -4953,13 +4952,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
> case TARGET_NR_getdents64:
> {
> - struct dirent64 *dirp;
> + struct linux_dirent64 *dirp;
> abi_long count = arg3;
> if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
> goto efault;
> ret = get_errno(sys_getdents64(arg1, dirp, count));
> if (!is_error(ret)) {
> - struct dirent64 *de;
> + struct linux_dirent64 *de;
> int len = ret;
> int reclen;
> de = dirp;
> @@ -4970,7 +4969,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> de->d_reclen = tswap16(reclen);
> tswap64s((uint64_t *)&de->d_ino);
> tswap64s((uint64_t *)&de->d_off);
> - de = (struct dirent64 *)((char *)de + reclen);
> + de = (struct linux_dirent64 *)((char *)de + reclen);
> len -= reclen;
> }
> }
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index c30bb15..5a58010 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -1963,6 +1963,21 @@ struct target_sysinfo {
> char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
> };
>
> +struct linux_dirent {
> + long d_ino;
> + unsigned long d_off;
> + unsigned short d_reclen;
> + char d_name[256]; /* We must not include limits.h! */
> +};
> +
> +struct linux_dirent64 {
> + uint64_t d_ino;
> + int64_t d_off;
> + unsigned short d_reclen;
> + unsigned char d_type;
> + char d_name[256];
> +};
> +
> #include "socket.h"
>
> #include "errno_defs.h"
> --
> 1.5.6.5.GIT
>
>
>
>
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix getdents* syscalls
2008-10-13 12:48 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Aurelien Jarno
@ 2008-10-13 12:59 ` Kirill A. Shutemov
2008-10-13 13:10 ` Aurelien Jarno
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 12:59 UTC (permalink / raw)
To: Aurelien Jarno; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]
On Mon, Oct 13, 2008 at 02:48:25PM +0200, Aurelien Jarno wrote:
> Are you usingi cron to send those patches?
>
> More seriously this is the third time you send the patch series in two
> weeks. We do *not* have any *explanations*, so we don't know if it is a
> new version or only a resend.
I have add several patches this. One of them depends on previous.
> I have some of your patches in my local
> tree and I don't feel checking once more if the patches are the same or
> not. Too bad if we miss some important changes.
Can you send a message when you merge a patch to you local tree?
> I agree we are not merging patch very fast, but please be patient.
> Resending patches too often and without giving any details only annoys
> people and won't help to get your patches applied earlier.
Sorry, for annoying.
> Ping (for a big series) or resend (with the appropriate tag in the
> subject) are welcome if we forget a patch. But please be patient.
Ok. I just want to know if somebody notice the patch. Sorry, once again.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix getdents* syscalls
2008-10-13 12:59 ` Kirill A. Shutemov
@ 2008-10-13 13:10 ` Aurelien Jarno
0 siblings, 0 replies; 72+ messages in thread
From: Aurelien Jarno @ 2008-10-13 13:10 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel
On Mon, Oct 13, 2008 at 03:59:24PM +0300, Kirill A. Shutemov wrote:
> On Mon, Oct 13, 2008 at 02:48:25PM +0200, Aurelien Jarno wrote:
> > Are you usingi cron to send those patches?
> >
> > More seriously this is the third time you send the patch series in two
> > weeks. We do *not* have any *explanations*, so we don't know if it is a
> > new version or only a resend.
>
> I have add several patches this. One of them depends on previous.
Then you can only resend the new ones. Not all of them.
> > I have some of your patches in my local
> > tree and I don't feel checking once more if the patches are the same or
> > not. Too bad if we miss some important changes.
>
> Can you send a message when you merge a patch to you local tree?
I can send one, but in any case, in the way I work it only means the patch
looks ok and that it compiles. I may refuse it later if testing fails.
Also you may receive the mail at the same time I actually do the commit,
given that I am not always online (I usually have more time to work on
qemu when I am offline...).
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
@ 2008-10-13 15:53 ` Aurelien Jarno
2008-10-13 18:48 ` Kirill A. Shutemov
2008-10-13 21:09 ` Aurelien Jarno
2 siblings, 1 reply; 72+ messages in thread
From: Aurelien Jarno @ 2008-10-13 15:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
On Mon, Oct 13, 2008 at 01:10:30PM +0300, Kirill A. Shutemov wrote:
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
> linux-user/syscall.c | 173 ++++++++++++++++++++++++++++++++++----------------
> 1 files changed, 117 insertions(+), 56 deletions(-)
Please find my comments below. In general, please avoid mixing
indentation changes with code changes. This only makes the code more
difficult to review.
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 40e985a..7e67093 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1611,7 +1611,6 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
> }
> #endif
>
> -#ifdef TARGET_NR_ipc
> #define N_SHM_REGIONS 32
>
> static struct shm_region {
> @@ -1845,20 +1844,26 @@ static inline abi_long do_semctl(int first, int second, int third,
>
> struct target_msqid_ds
> {
> - struct target_ipc_perm msg_perm;
> - abi_ulong msg_stime;
> - abi_ulong __unused1;
> - abi_ulong msg_rtime;
> - abi_ulong __unused2;
> - abi_ulong msg_ctime;
> - abi_ulong __unused3;
> - abi_ulong __msg_cbytes;
> - abi_ulong msg_qnum;
> - abi_ulong msg_qbytes;
> - abi_ulong msg_lspid;
> - abi_ulong msg_lrpid;
> - abi_ulong __unused4;
> - abi_ulong __unused5;
> + struct target_ipc_perm msg_perm;
> + abi_ulong msg_stime;
> +#if TARGET_ABI_BITS == 32
> + abi_ulong __unused1;
> +#endif
> + abi_ulong msg_rtime;
> +#if TARGET_ABI_BITS == 32
> + abi_ulong __unused2;
> +#endif
> + abi_ulong msg_ctime;
> +#if TARGET_ABI_BITS == 32
> + abi_ulong __unused3;
> +#endif
Could you explain me why those __unused* are only present with
TARGET_ABI_BITS? This is not consistent with the kernel interface
defined in the glibc.
> + abi_ulong __msg_cbytes;
> + abi_ulong msg_qnum;
> + abi_ulong msg_qbytes;
> + abi_ulong msg_lspid;
> + abi_ulong msg_lrpid;
> + abi_ulong __unused4;
> + abi_ulong __unused5;
> };
>
> static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md,
> @@ -1868,7 +1873,8 @@ static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md,
>
> if (!lock_user_struct(VERIFY_READ, target_md, target_addr, 1))
> return -TARGET_EFAULT;
> - target_to_host_ipc_perm(&(host_md->msg_perm),target_addr);
> + if (target_to_host_ipc_perm(&(host_md->msg_perm),target_addr))
> + return -TARGET_EFAULT;
> host_md->msg_stime = tswapl(target_md->msg_stime);
> host_md->msg_rtime = tswapl(target_md->msg_rtime);
> host_md->msg_ctime = tswapl(target_md->msg_ctime);
> @@ -1888,7 +1894,8 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr,
>
> if (!lock_user_struct(VERIFY_WRITE, target_md, target_addr, 0))
> return -TARGET_EFAULT;
> - host_to_target_ipc_perm(target_addr,&(host_md->msg_perm));
> + if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm)))
> + return -TARGET_EFAULT;
> target_md->msg_stime = tswapl(host_md->msg_stime);
> target_md->msg_rtime = tswapl(host_md->msg_rtime);
> target_md->msg_ctime = tswapl(host_md->msg_ctime);
> @@ -1901,26 +1908,69 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr,
> return 0;
> }
>
> -static inline abi_long do_msgctl(int first, int second, abi_long ptr)
> +struct target_msginfo {
> + int msgpool;
> + int msgmap;
> + int msgmax;
> + int msgmnb;
> + int msgmni;
> + int msgssz;
> + int msgtql;
> + unsigned short int msgseg;
> +};
> +
> +static inline abi_long host_to_target_msginfo(abi_ulong target_addr,
> + struct msginfo *host_msginfo)
> +{
> + struct target_msginfo *target_msginfo;
> + if (!lock_user_struct(VERIFY_WRITE, target_msginfo, target_addr, 0))
> + return -TARGET_EFAULT;
> + __put_user(host_msginfo->msgpool, &target_msginfo->msgpool);
> + __put_user(host_msginfo->msgmap, &target_msginfo->msgmap);
> + __put_user(host_msginfo->msgmax, &target_msginfo->msgmax);
> + __put_user(host_msginfo->msgmnb, &target_msginfo->msgmnb);
> + __put_user(host_msginfo->msgmni, &target_msginfo->msgmni);
> + __put_user(host_msginfo->msgssz, &target_msginfo->msgssz);
> + __put_user(host_msginfo->msgtql, &target_msginfo->msgtql);
> + __put_user(host_msginfo->msgseg, &target_msginfo->msgseg);
> + unlock_user_struct(target_msginfo, target_addr, 1);
> +}
> +
> +static inline abi_long do_msgctl(int msgid, int cmd, abi_long ptr)
> {
> struct msqid_ds dsarg;
> - int cmd = second&0xff;
> - abi_long ret = 0;
> - switch( cmd ) {
> + struct msginfo msginfo;
> + abi_long ret = -TARGET_EINVAL;
> +
> + cmd &= 0xff;
> +
> + switch (cmd) {
> case IPC_STAT:
> case IPC_SET:
> - target_to_host_msqid_ds(&dsarg,ptr);
> - ret = get_errno(msgctl(first, cmd, &dsarg));
> - host_to_target_msqid_ds(ptr,&dsarg);
> - default:
> - ret = get_errno(msgctl(first, cmd, &dsarg));
How is default handled now?
> + case MSG_STAT:
> + if (target_to_host_msqid_ds(&dsarg,ptr))
> + return -TARGET_EFAULT;
> + ret = get_errno(msgctl(msgid, cmd, &dsarg));
> + if (host_to_target_msqid_ds(ptr,&dsarg))
> + return -TARGET_EFAULT;
> + break;
> + case IPC_RMID:
> + ret = get_errno(msgctl(msgid, cmd, NULL));
> + break;
> + case IPC_INFO:
> + case MSG_INFO:
> + ret = get_errno(msgctl(msgid, cmd, (struct msqid_ds *)&msginfo));
> + if (host_to_target_msginfo(ptr, &msginfo))
> + return -TARGET_EFAULT;
> + break;
> }
> +
> return ret;
> }
>
> struct target_msgbuf {
> - abi_ulong mtype;
> - char mtext[1];
> + abi_long mtype;
> + char mtext[1];
> };
>
> static inline abi_long do_msgsnd(int msqid, abi_long msgp,
> @@ -1933,8 +1983,8 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
> if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))
> return -TARGET_EFAULT;
> host_mb = malloc(msgsz+sizeof(long));
> - host_mb->mtype = tswapl(target_mb->mtype);
> - memcpy(host_mb->mtext,target_mb->mtext,msgsz);
> + host_mb->mtype = (abi_long) tswapl(target_mb->mtype);
> + memcpy(host_mb->mtext, target_mb->mtext, msgsz);
> ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));
> free(host_mb);
> unlock_user_struct(target_mb, msgp, 0);
> @@ -1943,7 +1993,7 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
> }
>
> static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> - unsigned int msgsz, int msgtype,
> + unsigned int msgsz, abi_long msgtyp,
> int msgflg)
> {
> struct target_msgbuf *target_mb;
> @@ -1953,8 +2003,10 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
>
> if (!lock_user_struct(VERIFY_WRITE, target_mb, msgp, 0))
> return -TARGET_EFAULT;
> +
> host_mb = malloc(msgsz+sizeof(long));
> - ret = get_errno(msgrcv(msqid, host_mb, msgsz, 1, msgflg));
> + ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapl(msgtyp), msgflg));
> +
> if (ret > 0) {
> abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong);
> target_mtext = lock_user(VERIFY_WRITE, target_mtext_addr, ret, 0);
> @@ -1962,9 +2014,10 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> ret = -TARGET_EFAULT;
> goto end;
> }
> - memcpy(target_mb->mtext, host_mb->mtext, ret);
> + memcpy(target_mb->mtext, host_mb->mtext, ret);
> unlock_user(target_mtext, target_mtext_addr, ret);
> }
> +
> target_mb->mtype = tswapl(host_mb->mtype);
> free(host_mb);
>
> @@ -1974,6 +2027,7 @@ end:
> return ret;
> }
>
> +#ifdef TARGET_NR_ipc
> /* ??? This only works with linear mappings. */
> /* do_ipc() must return target values and target errnos. */
> static abi_long do_ipc(unsigned int call, int first,
> @@ -2006,34 +2060,41 @@ static abi_long do_ipc(unsigned int call, int first,
> ret = -TARGET_ENOSYS;
> break;
>
> - case IPCOP_msgget:
> - ret = get_errno(msgget(first, second));
> - break;
> + case IPCOP_msgget:
> + ret = get_errno(msgget(first, second));
> + break;
>
> - case IPCOP_msgsnd:
> - ret = do_msgsnd(first, ptr, second, third);
> - break;
> + case IPCOP_msgsnd:
> + ret = do_msgsnd(first, ptr, second, third);
> + break;
>
> - case IPCOP_msgctl:
> - ret = do_msgctl(first, second, ptr);
> - break;
> + case IPCOP_msgctl:
> + ret = do_msgctl(first, second, ptr);
> + break;
>
> - case IPCOP_msgrcv:
> - {
> - /* XXX: this code is not correct */
> - struct ipc_kludge
> - {
> - void *__unbounded msgp;
> - long int msgtyp;
> - };
> + case IPCOP_msgrcv:
> + switch (version) {
> + case 0:
> + {
> + struct target_ipc_kludge {
> + abi_long msgp;
> + abi_long msgtyp;
> + } *tmp;
>
> - struct ipc_kludge *foo = (struct ipc_kludge *)g2h(ptr);
> - struct msgbuf *msgp = (struct msgbuf *) foo->msgp;
> + if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) {
> + ret = -TARGET_EFAULT;
> + break;
> + }
>
> - ret = do_msgrcv(first, (long)msgp, second, 0, third);
> + ret = do_msgrcv(first, tmp->msgp, second, tmp->msgtyp, third);
>
> - }
> - break;
> + unlock_user_struct(tmp, ptr, 0);
> + break;
> + }
> + default:
> + ret = do_msgrcv(first, ptr, second, fifth, third);
> + }
> + break;
>
> case IPCOP_shmat:
> {
> --
> 1.5.6.5.GIT
>
>
>
>
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling
2008-10-13 15:53 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Aurelien Jarno
@ 2008-10-13 18:48 ` Kirill A. Shutemov
2008-10-13 20:52 ` Aurelien Jarno
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-13 18:48 UTC (permalink / raw)
To: Aurelien Jarno; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 4343 bytes --]
On Mon, Oct 13, 2008 at 05:53:11PM +0200, Aurelien Jarno wrote:
> On Mon, Oct 13, 2008 at 01:10:30PM +0300, Kirill A. Shutemov wrote:
> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> > ---
> > linux-user/syscall.c | 173 ++++++++++++++++++++++++++++++++++----------------
> > 1 files changed, 117 insertions(+), 56 deletions(-)
>
> Please find my comments below. In general, please avoid mixing
> indentation changes with code changes. This only makes the code more
> difficult to review.
Ok.
By the way, what is correct indentation options for qemu? I configure my vim
with softwidth=4 and set expandtab. Is it correct?
> > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > index 40e985a..7e67093 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> > @@ -1611,7 +1611,6 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
> > }
> > #endif
> >
> > -#ifdef TARGET_NR_ipc
> > #define N_SHM_REGIONS 32
> >
> > static struct shm_region {
> > @@ -1845,20 +1844,26 @@ static inline abi_long do_semctl(int first, int second, int third,
> >
> > struct target_msqid_ds
> > {
> > - struct target_ipc_perm msg_perm;
> > - abi_ulong msg_stime;
> > - abi_ulong __unused1;
> > - abi_ulong msg_rtime;
> > - abi_ulong __unused2;
> > - abi_ulong msg_ctime;
> > - abi_ulong __unused3;
> > - abi_ulong __msg_cbytes;
> > - abi_ulong msg_qnum;
> > - abi_ulong msg_qbytes;
> > - abi_ulong msg_lspid;
> > - abi_ulong msg_lrpid;
> > - abi_ulong __unused4;
> > - abi_ulong __unused5;
> > + struct target_ipc_perm msg_perm;
> > + abi_ulong msg_stime;
> > +#if TARGET_ABI_BITS == 32
> > + abi_ulong __unused1;
> > +#endif
> > + abi_ulong msg_rtime;
> > +#if TARGET_ABI_BITS == 32
> > + abi_ulong __unused2;
> > +#endif
> > + abi_ulong msg_ctime;
> > +#if TARGET_ABI_BITS == 32
> > + abi_ulong __unused3;
> > +#endif
>
> Could you explain me why those __unused* are only present with
> TARGET_ABI_BITS?
They needed to align following filds to 64-bit on 32-bit hosts. Since on
64-bit hosts sizeof(long) == 8, it's unneeded.
> This is not consistent with the kernel interface
> defined in the glibc.
Really?
glibc 2.5.1, /usr/include/bits/msq.h:
38 struct msqid_ds
39 {
40 struct ipc_perm msg_perm; /* structure describing operation permi
41 __time_t msg_stime; /* time of last msgsnd command */
42 #if __WORDSIZE == 32
43 unsigned long int __unused1;
44 #endif
45 __time_t msg_rtime; /* time of last msgrcv command */
46 #if __WORDSIZE == 32
47 unsigned long int __unused2;
48 #endif
49 __time_t msg_ctime; /* time of last change */
50 #if __WORDSIZE == 32
51 unsigned long int __unused3;
52 #endif
53 unsigned long int __msg_cbytes; /* current number of bytes on queue *
54 msgqnum_t msg_qnum; /* number of messages currently on queu
55 msglen_t msg_qbytes; /* max number of bytes allowed on queue
56 __pid_t msg_lspid; /* pid of last msgsnd() */
57 __pid_t msg_lrpid; /* pid of last msgrcv() */
58 unsigned long int __unused4;
59 unsigned long int __unused5;
60 };
> > + abi_ulong __msg_cbytes;
> > + abi_ulong msg_qnum;
> > + abi_ulong msg_qbytes;
> > + abi_ulong msg_lspid;
> > + abi_ulong msg_lrpid;
> > + abi_ulong __unused4;
> > + abi_ulong __unused5;
> > };
<skip/>
> > +static inline abi_long do_msgctl(int msgid, int cmd, abi_long ptr)
> > {
> > struct msqid_ds dsarg;
> > - int cmd = second&0xff;
> > - abi_long ret = 0;
> > - switch( cmd ) {
> > + struct msginfo msginfo;
> > + abi_long ret = -TARGET_EINVAL;
> > +
> > + cmd &= 0xff;
> > +
> > + switch (cmd) {
> > case IPC_STAT:
> > case IPC_SET:
> > - target_to_host_msqid_ds(&dsarg,ptr);
> > - ret = get_errno(msgctl(first, cmd, &dsarg));
> > - host_to_target_msqid_ds(ptr,&dsarg);
> > - default:
> > - ret = get_errno(msgctl(first, cmd, &dsarg));
>
> How is default handled now?
Since we handle all valid cmd, we just return -TARGET_EINVAL.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling
2008-10-13 18:48 ` Kirill A. Shutemov
@ 2008-10-13 20:52 ` Aurelien Jarno
0 siblings, 0 replies; 72+ messages in thread
From: Aurelien Jarno @ 2008-10-13 20:52 UTC (permalink / raw)
To: qemu-devel
On Mon, Oct 13, 2008 at 09:48:09PM +0300, Kirill A. Shutemov wrote:
> On Mon, Oct 13, 2008 at 05:53:11PM +0200, Aurelien Jarno wrote:
> > On Mon, Oct 13, 2008 at 01:10:30PM +0300, Kirill A. Shutemov wrote:
> > > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> > > ---
> > > linux-user/syscall.c | 173 ++++++++++++++++++++++++++++++++++----------------
> > > 1 files changed, 117 insertions(+), 56 deletions(-)
> >
> > Please find my comments below. In general, please avoid mixing
> > indentation changes with code changes. This only makes the code more
> > difficult to review.
>
> Ok.
>
> By the way, what is correct indentation options for qemu? I configure my vim
> with softwidth=4 and set expandtab. Is it correct?
I don't really think there is a standard, it seems to vary from file to
file. What I do care about is that lines of the patch actually have a code
change, not only an indentation change. Otherwise it is difficult to
read.
> > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > > index 40e985a..7e67093 100644
> > > --- a/linux-user/syscall.c
> > > +++ b/linux-user/syscall.c
> > > @@ -1611,7 +1611,6 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
> > > }
> > > #endif
> > >
> > > -#ifdef TARGET_NR_ipc
> > > #define N_SHM_REGIONS 32
> > >
> > > static struct shm_region {
> > > @@ -1845,20 +1844,26 @@ static inline abi_long do_semctl(int first, int second, int third,
> > >
> > > struct target_msqid_ds
> > > {
> > > - struct target_ipc_perm msg_perm;
> > > - abi_ulong msg_stime;
> > > - abi_ulong __unused1;
> > > - abi_ulong msg_rtime;
> > > - abi_ulong __unused2;
> > > - abi_ulong msg_ctime;
> > > - abi_ulong __unused3;
> > > - abi_ulong __msg_cbytes;
> > > - abi_ulong msg_qnum;
> > > - abi_ulong msg_qbytes;
> > > - abi_ulong msg_lspid;
> > > - abi_ulong msg_lrpid;
> > > - abi_ulong __unused4;
> > > - abi_ulong __unused5;
> > > + struct target_ipc_perm msg_perm;
> > > + abi_ulong msg_stime;
> > > +#if TARGET_ABI_BITS == 32
> > > + abi_ulong __unused1;
> > > +#endif
> > > + abi_ulong msg_rtime;
> > > +#if TARGET_ABI_BITS == 32
> > > + abi_ulong __unused2;
> > > +#endif
> > > + abi_ulong msg_ctime;
> > > +#if TARGET_ABI_BITS == 32
> > > + abi_ulong __unused3;
> > > +#endif
> >
> > Could you explain me why those __unused* are only present with
> > TARGET_ABI_BITS?
>
> They needed to align following filds to 64-bit on 32-bit hosts. Since on
> 64-bit hosts sizeof(long) == 8, it's unneeded.
>
> > This is not consistent with the kernel interface
> > defined in the glibc.
>
> Really?
>
> glibc 2.5.1, /usr/include/bits/msq.h:
This is not the right file to look at, as it may, and actually depends
on your architecture. You have to look at the source in the glibc.
On my side I was looking at sysdeps/unix/sysv/linux/bits/msq.h, which
doesn't have those #ifdef. It is overrided by architectures specific
versions.
But at the end you are lucky, if you look at all the different msq.h
files, your patch is correct.
> > > + abi_ulong __msg_cbytes;
> > > + abi_ulong msg_qnum;
> > > + abi_ulong msg_qbytes;
> > > + abi_ulong msg_lspid;
> > > + abi_ulong msg_lrpid;
> > > + abi_ulong __unused4;
> > > + abi_ulong __unused5;
> > > };
>
> <skip/>
>
> > > +static inline abi_long do_msgctl(int msgid, int cmd, abi_long ptr)
> > > {
> > > struct msqid_ds dsarg;
> > > - int cmd = second&0xff;
> > > - abi_long ret = 0;
> > > - switch( cmd ) {
> > > + struct msginfo msginfo;
> > > + abi_long ret = -TARGET_EINVAL;
> > > +
> > > + cmd &= 0xff;
> > > +
> > > + switch (cmd) {
> > > case IPC_STAT:
> > > case IPC_SET:
> > > - target_to_host_msqid_ds(&dsarg,ptr);
> > > - ret = get_errno(msgctl(first, cmd, &dsarg));
> > > - host_to_target_msqid_ds(ptr,&dsarg);
> > > - default:
> > > - ret = get_errno(msgctl(first, cmd, &dsarg));
> >
> > How is default handled now?
>
> Since we handle all valid cmd, we just return -TARGET_EINVAL.
ok.
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
2008-10-13 15:53 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Aurelien Jarno
@ 2008-10-13 21:09 ` Aurelien Jarno
2 siblings, 0 replies; 72+ messages in thread
From: Aurelien Jarno @ 2008-10-13 21:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
Applied, thanks.
On Mon, Oct 13, 2008 at 01:10:30PM +0300, Kirill A. Shutemov wrote:
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
> linux-user/syscall.c | 173 ++++++++++++++++++++++++++++++++++----------------
> 1 files changed, 117 insertions(+), 56 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 40e985a..7e67093 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1611,7 +1611,6 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
> }
> #endif
>
> -#ifdef TARGET_NR_ipc
> #define N_SHM_REGIONS 32
>
> static struct shm_region {
> @@ -1845,20 +1844,26 @@ static inline abi_long do_semctl(int first, int second, int third,
>
> struct target_msqid_ds
> {
> - struct target_ipc_perm msg_perm;
> - abi_ulong msg_stime;
> - abi_ulong __unused1;
> - abi_ulong msg_rtime;
> - abi_ulong __unused2;
> - abi_ulong msg_ctime;
> - abi_ulong __unused3;
> - abi_ulong __msg_cbytes;
> - abi_ulong msg_qnum;
> - abi_ulong msg_qbytes;
> - abi_ulong msg_lspid;
> - abi_ulong msg_lrpid;
> - abi_ulong __unused4;
> - abi_ulong __unused5;
> + struct target_ipc_perm msg_perm;
> + abi_ulong msg_stime;
> +#if TARGET_ABI_BITS == 32
> + abi_ulong __unused1;
> +#endif
> + abi_ulong msg_rtime;
> +#if TARGET_ABI_BITS == 32
> + abi_ulong __unused2;
> +#endif
> + abi_ulong msg_ctime;
> +#if TARGET_ABI_BITS == 32
> + abi_ulong __unused3;
> +#endif
> + abi_ulong __msg_cbytes;
> + abi_ulong msg_qnum;
> + abi_ulong msg_qbytes;
> + abi_ulong msg_lspid;
> + abi_ulong msg_lrpid;
> + abi_ulong __unused4;
> + abi_ulong __unused5;
> };
>
> static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md,
> @@ -1868,7 +1873,8 @@ static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md,
>
> if (!lock_user_struct(VERIFY_READ, target_md, target_addr, 1))
> return -TARGET_EFAULT;
> - target_to_host_ipc_perm(&(host_md->msg_perm),target_addr);
> + if (target_to_host_ipc_perm(&(host_md->msg_perm),target_addr))
> + return -TARGET_EFAULT;
> host_md->msg_stime = tswapl(target_md->msg_stime);
> host_md->msg_rtime = tswapl(target_md->msg_rtime);
> host_md->msg_ctime = tswapl(target_md->msg_ctime);
> @@ -1888,7 +1894,8 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr,
>
> if (!lock_user_struct(VERIFY_WRITE, target_md, target_addr, 0))
> return -TARGET_EFAULT;
> - host_to_target_ipc_perm(target_addr,&(host_md->msg_perm));
> + if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm)))
> + return -TARGET_EFAULT;
> target_md->msg_stime = tswapl(host_md->msg_stime);
> target_md->msg_rtime = tswapl(host_md->msg_rtime);
> target_md->msg_ctime = tswapl(host_md->msg_ctime);
> @@ -1901,26 +1908,69 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr,
> return 0;
> }
>
> -static inline abi_long do_msgctl(int first, int second, abi_long ptr)
> +struct target_msginfo {
> + int msgpool;
> + int msgmap;
> + int msgmax;
> + int msgmnb;
> + int msgmni;
> + int msgssz;
> + int msgtql;
> + unsigned short int msgseg;
> +};
> +
> +static inline abi_long host_to_target_msginfo(abi_ulong target_addr,
> + struct msginfo *host_msginfo)
> +{
> + struct target_msginfo *target_msginfo;
> + if (!lock_user_struct(VERIFY_WRITE, target_msginfo, target_addr, 0))
> + return -TARGET_EFAULT;
> + __put_user(host_msginfo->msgpool, &target_msginfo->msgpool);
> + __put_user(host_msginfo->msgmap, &target_msginfo->msgmap);
> + __put_user(host_msginfo->msgmax, &target_msginfo->msgmax);
> + __put_user(host_msginfo->msgmnb, &target_msginfo->msgmnb);
> + __put_user(host_msginfo->msgmni, &target_msginfo->msgmni);
> + __put_user(host_msginfo->msgssz, &target_msginfo->msgssz);
> + __put_user(host_msginfo->msgtql, &target_msginfo->msgtql);
> + __put_user(host_msginfo->msgseg, &target_msginfo->msgseg);
> + unlock_user_struct(target_msginfo, target_addr, 1);
> +}
> +
> +static inline abi_long do_msgctl(int msgid, int cmd, abi_long ptr)
> {
> struct msqid_ds dsarg;
> - int cmd = second&0xff;
> - abi_long ret = 0;
> - switch( cmd ) {
> + struct msginfo msginfo;
> + abi_long ret = -TARGET_EINVAL;
> +
> + cmd &= 0xff;
> +
> + switch (cmd) {
> case IPC_STAT:
> case IPC_SET:
> - target_to_host_msqid_ds(&dsarg,ptr);
> - ret = get_errno(msgctl(first, cmd, &dsarg));
> - host_to_target_msqid_ds(ptr,&dsarg);
> - default:
> - ret = get_errno(msgctl(first, cmd, &dsarg));
> + case MSG_STAT:
> + if (target_to_host_msqid_ds(&dsarg,ptr))
> + return -TARGET_EFAULT;
> + ret = get_errno(msgctl(msgid, cmd, &dsarg));
> + if (host_to_target_msqid_ds(ptr,&dsarg))
> + return -TARGET_EFAULT;
> + break;
> + case IPC_RMID:
> + ret = get_errno(msgctl(msgid, cmd, NULL));
> + break;
> + case IPC_INFO:
> + case MSG_INFO:
> + ret = get_errno(msgctl(msgid, cmd, (struct msqid_ds *)&msginfo));
> + if (host_to_target_msginfo(ptr, &msginfo))
> + return -TARGET_EFAULT;
> + break;
> }
> +
> return ret;
> }
>
> struct target_msgbuf {
> - abi_ulong mtype;
> - char mtext[1];
> + abi_long mtype;
> + char mtext[1];
> };
>
> static inline abi_long do_msgsnd(int msqid, abi_long msgp,
> @@ -1933,8 +1983,8 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
> if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))
> return -TARGET_EFAULT;
> host_mb = malloc(msgsz+sizeof(long));
> - host_mb->mtype = tswapl(target_mb->mtype);
> - memcpy(host_mb->mtext,target_mb->mtext,msgsz);
> + host_mb->mtype = (abi_long) tswapl(target_mb->mtype);
> + memcpy(host_mb->mtext, target_mb->mtext, msgsz);
> ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));
> free(host_mb);
> unlock_user_struct(target_mb, msgp, 0);
> @@ -1943,7 +1993,7 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
> }
>
> static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> - unsigned int msgsz, int msgtype,
> + unsigned int msgsz, abi_long msgtyp,
> int msgflg)
> {
> struct target_msgbuf *target_mb;
> @@ -1953,8 +2003,10 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
>
> if (!lock_user_struct(VERIFY_WRITE, target_mb, msgp, 0))
> return -TARGET_EFAULT;
> +
> host_mb = malloc(msgsz+sizeof(long));
> - ret = get_errno(msgrcv(msqid, host_mb, msgsz, 1, msgflg));
> + ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapl(msgtyp), msgflg));
> +
> if (ret > 0) {
> abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong);
> target_mtext = lock_user(VERIFY_WRITE, target_mtext_addr, ret, 0);
> @@ -1962,9 +2014,10 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> ret = -TARGET_EFAULT;
> goto end;
> }
> - memcpy(target_mb->mtext, host_mb->mtext, ret);
> + memcpy(target_mb->mtext, host_mb->mtext, ret);
> unlock_user(target_mtext, target_mtext_addr, ret);
> }
> +
> target_mb->mtype = tswapl(host_mb->mtype);
> free(host_mb);
>
> @@ -1974,6 +2027,7 @@ end:
> return ret;
> }
>
> +#ifdef TARGET_NR_ipc
> /* ??? This only works with linear mappings. */
> /* do_ipc() must return target values and target errnos. */
> static abi_long do_ipc(unsigned int call, int first,
> @@ -2006,34 +2060,41 @@ static abi_long do_ipc(unsigned int call, int first,
> ret = -TARGET_ENOSYS;
> break;
>
> - case IPCOP_msgget:
> - ret = get_errno(msgget(first, second));
> - break;
> + case IPCOP_msgget:
> + ret = get_errno(msgget(first, second));
> + break;
>
> - case IPCOP_msgsnd:
> - ret = do_msgsnd(first, ptr, second, third);
> - break;
> + case IPCOP_msgsnd:
> + ret = do_msgsnd(first, ptr, second, third);
> + break;
>
> - case IPCOP_msgctl:
> - ret = do_msgctl(first, second, ptr);
> - break;
> + case IPCOP_msgctl:
> + ret = do_msgctl(first, second, ptr);
> + break;
>
> - case IPCOP_msgrcv:
> - {
> - /* XXX: this code is not correct */
> - struct ipc_kludge
> - {
> - void *__unbounded msgp;
> - long int msgtyp;
> - };
> + case IPCOP_msgrcv:
> + switch (version) {
> + case 0:
> + {
> + struct target_ipc_kludge {
> + abi_long msgp;
> + abi_long msgtyp;
> + } *tmp;
>
> - struct ipc_kludge *foo = (struct ipc_kludge *)g2h(ptr);
> - struct msgbuf *msgp = (struct msgbuf *) foo->msgp;
> + if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) {
> + ret = -TARGET_EFAULT;
> + break;
> + }
>
> - ret = do_msgrcv(first, (long)msgp, second, 0, third);
> + ret = do_msgrcv(first, tmp->msgp, second, tmp->msgtyp, third);
>
> - }
> - break;
> + unlock_user_struct(tmp, ptr, 0);
> + break;
> + }
> + default:
> + ret = do_msgrcv(first, ptr, second, fifth, third);
> + }
> + break;
>
> case IPCOP_shmat:
> {
> --
> 1.5.6.5.GIT
>
>
>
>
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Implement msg* syscalls
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
@ 2008-10-13 21:09 ` Aurelien Jarno
1 sibling, 0 replies; 72+ messages in thread
From: Aurelien Jarno @ 2008-10-13 21:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
Applied, thanks.
On Mon, Oct 13, 2008 at 01:10:31PM +0300, Kirill A. Shutemov wrote:
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
> linux-user/syscall.c | 21 +++++++++++++++++++++
> 1 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 7e67093..cf0834f 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -4829,6 +4829,27 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);
> break;
> #endif
> +
> +#ifdef TARGET_NR_msgctl
> + case TARGET_NR_msgctl:
> + ret = do_msgctl(arg1, arg2, arg3);
> + break;
> +#endif
> +#ifdef TARGET_NR_msgget
> + case TARGET_NR_msgget:
> + ret = get_errno(msgget(arg1, arg2));
> + break;
> +#endif
> +#ifdef TARGET_NR_msgrcv
> + case TARGET_NR_msgrcv:
> + ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);
> + break;
> +#endif
> +#ifdef TARGET_NR_msgsnd
> + case TARGET_NR_msgsnd:
> + ret = do_msgsnd(arg1, arg2, arg3, arg4);
> + break;
> +#endif
> case TARGET_NR_fsync:
> ret = get_errno(fsync(arg1));
> break;
> --
> 1.5.6.5.GIT
>
>
>
>
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly
2008-10-13 10:10 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
@ 2008-10-14 4:04 ` Vince Weaver
2008-10-14 5:22 ` Kirill A. Shutemov
1 sibling, 1 reply; 72+ messages in thread
From: Vince Weaver @ 2008-10-14 4:04 UTC (permalink / raw)
To: qemu-devel
Since this is the first mmap() work I've seen for a while, I was wondering
if there is any interest in getting 32-bit mremap() working on 64-bit
platforms, as well as fixing the bug where a 32-bit mmap() can span the
4GB barrier on 64-bit system?
I posted some rough patches that work but are definitely not ready for
merging...
Vince
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly
2008-10-14 4:04 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Vince Weaver
@ 2008-10-14 5:22 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-14 5:22 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 593 bytes --]
On Tue, Oct 14, 2008 at 12:04:24AM -0400, Vince Weaver wrote:
>
> Since this is the first mmap() work I've seen for a while, I was wondering
> if there is any interest in getting 32-bit mremap() working on 64-bit
> platforms, as well as fixing the bug where a 32-bit mmap() can span the
> 4GB barrier on 64-bit system?
I'm interested in it.
Please, apply
http://lists.gnu.org/archive/html/qemu-devel/2008-10/msg00490.html
and this patch and test. I hope it should work.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov
@ 2008-10-16 20:55 ` Martin Mohring
2008-10-17 4:09 ` Kirill A. Shutemov
2008-11-01 9:56 ` Aurelien Jarno
1 sibling, 2 replies; 72+ messages in thread
From: Martin Mohring @ 2008-10-16 20:55 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel, Paul Brook
Thanks for providing these three sets of patches (msg calls already
incorporated into svn as of svn trunk).
I have tested them for x86 hosts running ARM targets for Debian:Etch,
Debian:Lenny and Debian:Sid
Now, the dpkg build environment for new debian releases using glibc 2.7
can be run in linux user mode.
Even the SYS V IPC based fakeroot command is now working (No need to use
fakeroot-tcp anymore).
There is only one downside I found while testing: Debian:Etch/fakeroot,
which worked correctly without these patches, is not working anymore.
fakeroot hangs forever somewhere I did not yet identify.
Any advise where I should look? Are you interested in that issue?
Martin
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls
2008-10-16 20:55 ` [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls Martin Mohring
@ 2008-10-17 4:09 ` Kirill A. Shutemov
2008-10-17 8:27 ` Martin Mohring
2008-11-01 9:56 ` Aurelien Jarno
1 sibling, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-17 4:09 UTC (permalink / raw)
To: Martin Mohring; +Cc: qemu-devel, Paul Brook
[-- Attachment #1: Type: text/plain, Size: 965 bytes --]
On Thu, Oct 16, 2008 at 10:55:54PM +0200, Martin Mohring wrote:
> Thanks for providing these three sets of patches (msg calls already
> incorporated into svn as of svn trunk).
> I have tested them for x86 hosts running ARM targets for Debian:Etch,
> Debian:Lenny and Debian:Sid
>
> Now, the dpkg build environment for new debian releases using glibc 2.7
> can be run in linux user mode.
> Even the SYS V IPC based fakeroot command is now working (No need to use
> fakeroot-tcp anymore).
>
> There is only one downside I found while testing: Debian:Etch/fakeroot,
> which worked correctly without these patches, is not working anymore.
> fakeroot hangs forever somewhere I did not yet identify.
>
> Any advise where I should look? Are you interested in that issue?
Can you run qemu under strace and with defined QEMU_STRACE and send me
logs?
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-10-13 10:10 ` [Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
@ 2008-10-17 6:34 ` Kirill A. Shutemov
2008-10-17 6:34 ` [Qemu-devel] [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables Kirill A. Shutemov
` (2 more replies)
2008-11-10 7:09 ` [Qemu-devel] [PATCH, v3] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
1 sibling, 3 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-17 6:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/mmap.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index bc20f4b..9a2f355 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
end = start + len;
real_end = HOST_PAGE_ALIGN(end);
+ if ((unsigned long)start + len > (abi_ulong) -1) {
+ errno = EINVAL;
+ goto fail;
+ }
+
for(addr = real_start; addr < real_end; addr += TARGET_PAGE_SIZE) {
flg = page_get_flags(addr);
if (flg & PAGE_RESERVED) {
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-10-17 6:34 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Kirill A. Shutemov
@ 2008-10-17 6:34 ` Kirill A. Shutemov
2008-11-01 9:33 ` [Qemu-devel] " Jan Kiszka
2008-11-01 10:06 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2008-10-27 13:08 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space andrzej zaborowski
2008-10-27 17:48 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2 siblings, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-17 6:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
env->*dt.base should fits target address space, so we should use
target_mmap to allocate it.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/main.c | 23 +++++++++++++++--------
linux-user/syscall.c | 10 ++++++----
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 25b2867..61d497e 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <sys/mman.h>
#include "qemu.h"
#include "qemu-common.h"
@@ -283,9 +284,8 @@ static void write_dt(void *ptr, unsigned long addr, unsigned long limit,
p[1] = tswap32(e2);
}
+uint64_t *idt_table;
#ifdef TARGET_X86_64
-uint64_t idt_table[512];
-
static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
uint64_t addr, unsigned int sel)
{
@@ -304,8 +304,6 @@ static void set_idt(int n, unsigned int dpl)
set_gate64(idt_table + n * 2, 0, dpl, 0, 0);
}
#else
-uint64_t idt_table[256];
-
static void set_gate(void *ptr, unsigned int type, unsigned int dpl,
uint32_t addr, unsigned int sel)
{
@@ -2500,8 +2498,15 @@ int main(int argc, char **argv, char **envp)
#endif
/* linux interrupt setup */
- env->idt.base = h2g(idt_table);
- env->idt.limit = sizeof(idt_table) - 1;
+#ifndef TARGET_ABI32
+ env->idt.limit = 511;
+#else
+ env->idt.limit = 255;
+#endif
+ env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1),
+ PROT_READ|PROT_WRITE,
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ idt_table = g2h(env->idt.base);
set_idt(0, 0);
set_idt(1, 0);
set_idt(2, 0);
@@ -2527,9 +2532,11 @@ int main(int argc, char **argv, char **envp)
/* linux segment setup */
{
uint64_t *gdt_table;
- gdt_table = qemu_mallocz(sizeof(uint64_t) * TARGET_GDT_ENTRIES);
- env->gdt.base = h2g((unsigned long)gdt_table);
+ env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES,
+ PROT_READ|PROT_WRITE,
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1;
+ gdt_table = g2h(env->gdt.base);
#ifdef TARGET_ABI32
write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index db3538b..27bd7e1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2823,12 +2823,14 @@ static abi_long write_ldt(CPUX86State *env,
}
/* allocate the LDT */
if (!ldt_table) {
- ldt_table = malloc(TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
- if (!ldt_table)
+ env->ldt.base = target_mmap(0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE,
+ PROT_READ|PROT_WRITE,
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ if (env->ldt.base == -1)
return -TARGET_ENOMEM;
- memset(ldt_table, 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
- env->ldt.base = h2g((unsigned long)ldt_table);
+ memset(g2h(env->ldt.base), 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
env->ldt.limit = 0xffff;
+ ldt_table = g2h(env->ldt.base);
}
/* NOTE: same code as Linux kernel */
--
1.5.6.5.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls
2008-10-17 4:09 ` Kirill A. Shutemov
@ 2008-10-17 8:27 ` Martin Mohring
2008-10-17 10:12 ` Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: Martin Mohring @ 2008-10-17 8:27 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel, Paul Brook
Kirill A. Shutemov wrote:
> On Thu, Oct 16, 2008 at 10:55:54PM +0200, Martin Mohring wrote:
>
>> Thanks for providing these three sets of patches (msg calls already
>> incorporated into svn as of svn trunk).
>> I have tested them for x86 hosts running ARM targets for Debian:Etch,
>> Debian:Lenny and Debian:Sid
>>
>> Now, the dpkg build environment for new debian releases using glibc 2.7
>> can be run in linux user mode.
>> Even the SYS V IPC based fakeroot command is now working (No need to use
>> fakeroot-tcp anymore).
>>
>> There is only one downside I found while testing: Debian:Etch/fakeroot,
>> which worked correctly without these patches, is not working anymore.
>> fakeroot hangs forever somewhere I did not yet identify.
>>
>> Any advise where I should look? Are you interested in that issue?
>>
>
> Can you run qemu under strace and with defined QEMU_STRACE and send me
> logs
Ok. I will do that. The shell command which calls fakeroot is:
chroot $BUILD_ROOT su -c "cd $TOPDIR/BUILD && dpkg-buildpackage -us -uc
-rfakeroot" - $BUILD_USER < /dev/null && BUILD_SUCCEDED=true
All things done in the chrooted environment are done with a registered
qemu via the "binfmt" feature. But I could run this specific command
also by involving qemu directly. Any specific options I should call strace?
Martin
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls
2008-10-17 8:27 ` Martin Mohring
@ 2008-10-17 10:12 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-17 10:12 UTC (permalink / raw)
To: Martin Mohring; +Cc: qemu-devel, Paul Brook
[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]
On Fri, Oct 17, 2008 at 10:27:40AM +0200, Martin Mohring wrote:
> Kirill A. Shutemov wrote:
> > On Thu, Oct 16, 2008 at 10:55:54PM +0200, Martin Mohring wrote:
> >
> >> Thanks for providing these three sets of patches (msg calls already
> >> incorporated into svn as of svn trunk).
> >> I have tested them for x86 hosts running ARM targets for Debian:Etch,
> >> Debian:Lenny and Debian:Sid
> >>
> >> Now, the dpkg build environment for new debian releases using glibc 2.7
> >> can be run in linux user mode.
> >> Even the SYS V IPC based fakeroot command is now working (No need to use
> >> fakeroot-tcp anymore).
> >>
> >> There is only one downside I found while testing: Debian:Etch/fakeroot,
> >> which worked correctly without these patches, is not working anymore.
> >> fakeroot hangs forever somewhere I did not yet identify.
> >>
> >> Any advise where I should look? Are you interested in that issue?
> >>
> >
> > Can you run qemu under strace and with defined QEMU_STRACE and send me
> > logs
> Ok. I will do that. The shell command which calls fakeroot is:
>
> chroot $BUILD_ROOT su -c "cd $TOPDIR/BUILD && dpkg-buildpackage -us -uc
> -rfakeroot" - $BUILD_USER < /dev/null && BUILD_SUCCEDED=true
>
> All things done in the chrooted environment are done with a registered
> qemu via the "binfmt" feature. But I could run this specific command
> also by involving qemu directly. Any specific options I should call strace?
Try -fF.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] Re: [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement sem* syscalls Kirill A. Shutemov
@ 2008-10-24 7:24 ` Kirill A. Shutemov
1 sibling, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-24 7:24 UTC (permalink / raw)
To: qemu-devel; +Cc: Paul Brook
[-- Attachment #1: Type: text/plain, Size: 240 bytes --]
Any progress with the patch set?
Why can't we test it after merging in the main tree if there is no problem
detected after reviewing?
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Kirill A. Shutemov
@ 2008-10-26 16:14 ` Vince Weaver
2008-10-27 17:49 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2 siblings, 0 replies; 72+ messages in thread
From: Vince Weaver @ 2008-10-26 16:14 UTC (permalink / raw)
To: qemu-devel
On Mon, 13 Oct 2008, Kirill A. Shutemov wrote:
> New version mmap_find_vma() uses mmap() without MAP_FIXED to find free
> memory.
This patch fixes the 64-bit/32-bit issue I was seeing with spec2k on
qemu-sparc32plus running on x86-64.
Hopefully this can be merged at some point.
Thanks
Vince
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-10-17 6:34 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Kirill A. Shutemov
2008-10-17 6:34 ` [Qemu-devel] [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables Kirill A. Shutemov
@ 2008-10-27 13:08 ` andrzej zaborowski
2008-10-27 15:48 ` Kirill A. Shutemov
2008-10-27 17:48 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2 siblings, 1 reply; 72+ messages in thread
From: andrzej zaborowski @ 2008-10-27 13:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
> linux-user/mmap.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/linux-user/mmap.c b/linux-user/mmap.c
> index bc20f4b..9a2f355 100644
> --- a/linux-user/mmap.c
> +++ b/linux-user/mmap.c
> @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
> end = start + len;
> real_end = HOST_PAGE_ALIGN(end);
>
> + if ((unsigned long)start + len > (abi_ulong) -1) {
> + errno = EINVAL;
> + goto fail;
> + }
I'm being picky but this would prevent the last byte from being used?
:p (or the last page because len is aligned?)
I'm not sure unsigned long is the best choice.
Cheers
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-10-27 13:08 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space andrzej zaborowski
@ 2008-10-27 15:48 ` Kirill A. Shutemov
2008-10-27 15:55 ` Andreas Schwab
2008-10-27 19:37 ` andrzej zaborowski
0 siblings, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-27 15:48 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]
On Mon, Oct 27, 2008 at 02:08:52PM +0100, andrzej zaborowski wrote:
> On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> > ---
> > linux-user/mmap.c | 5 +++++
> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >
> > diff --git a/linux-user/mmap.c b/linux-user/mmap.c
> > index bc20f4b..9a2f355 100644
> > --- a/linux-user/mmap.c
> > +++ b/linux-user/mmap.c
> > @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
> > end = start + len;
> > real_end = HOST_PAGE_ALIGN(end);
> >
> > + if ((unsigned long)start + len > (abi_ulong) -1) {
> > + errno = EINVAL;
> > + goto fail;
> > + }
>
> I'm being picky but this would prevent the last byte from being used?
> :p (or the last page because len is aligned?)
No, it returns error if start + len is more than 0xFFFFFFFF (32-bit
target).
>
> I'm not sure unsigned long is the best choice.
Why?
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-10-27 15:48 ` Kirill A. Shutemov
@ 2008-10-27 15:55 ` Andreas Schwab
2008-10-27 17:32 ` Kirill A. Shutemov
2008-10-27 19:37 ` andrzej zaborowski
1 sibling, 1 reply; 72+ messages in thread
From: Andreas Schwab @ 2008-10-27 15:55 UTC (permalink / raw)
To: qemu-devel
"Kirill A. Shutemov" <kirill@shutemov.name> writes:
> On Mon, Oct 27, 2008 at 02:08:52PM +0100, andrzej zaborowski wrote:
>> On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
>> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
>> > ---
>> > linux-user/mmap.c | 5 +++++
>> > 1 files changed, 5 insertions(+), 0 deletions(-)
>> >
>> > diff --git a/linux-user/mmap.c b/linux-user/mmap.c
>> > index bc20f4b..9a2f355 100644
>> > --- a/linux-user/mmap.c
>> > +++ b/linux-user/mmap.c
>> > @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
>> > end = start + len;
>> > real_end = HOST_PAGE_ALIGN(end);
>> >
>> > + if ((unsigned long)start + len > (abi_ulong) -1) {
>> > + errno = EINVAL;
>> > + goto fail;
>> > + }
>>
>> I'm being picky but this would prevent the last byte from being used?
>> :p (or the last page because len is aligned?)
>
> No, it returns error if start + len is more than 0xFFFFFFFF (32-bit
> target).
start + len is one past the last used address.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-10-27 15:55 ` Andreas Schwab
@ 2008-10-27 17:32 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-27 17:32 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]
On Mon, Oct 27, 2008 at 04:55:07PM +0100, Andreas Schwab wrote:
> "Kirill A. Shutemov" <kirill@shutemov.name> writes:
>
> > On Mon, Oct 27, 2008 at 02:08:52PM +0100, andrzej zaborowski wrote:
> >> On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
> >> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> >> > ---
> >> > linux-user/mmap.c | 5 +++++
> >> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >> >
> >> > diff --git a/linux-user/mmap.c b/linux-user/mmap.c
> >> > index bc20f4b..9a2f355 100644
> >> > --- a/linux-user/mmap.c
> >> > +++ b/linux-user/mmap.c
> >> > @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
> >> > end = start + len;
> >> > real_end = HOST_PAGE_ALIGN(end);
> >> >
> >> > + if ((unsigned long)start + len > (abi_ulong) -1) {
> >> > + errno = EINVAL;
> >> > + goto fail;
> >> > + }
> >>
> >> I'm being picky but this would prevent the last byte from being used?
> >> :p (or the last page because len is aligned?)
> >
> > No, it returns error if start + len is more than 0xFFFFFFFF (32-bit
> > target).
>
> start + len is one past the last used address.
Oops.. You are right. I'll post updated patches soon.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH, v2] mmap: add check if requested memory area fits target address space
2008-10-17 6:34 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Kirill A. Shutemov
2008-10-17 6:34 ` [Qemu-devel] [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables Kirill A. Shutemov
2008-10-27 13:08 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space andrzej zaborowski
@ 2008-10-27 17:48 ` Kirill A. Shutemov
2008-11-10 7:11 ` [Qemu-devel] [PATCH, v3] " Kirill A. Shutemov
2 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-27 17:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/mmap.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 6677014..b420065 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
end = start + len;
real_end = HOST_PAGE_ALIGN(end);
+ if ((unsigned long)start + len - 1 > (abi_ulong) -1) {
+ errno = EINVAL;
+ goto fail;
+ }
+
for(addr = real_start; addr < real_end; addr += TARGET_PAGE_SIZE) {
flg = page_get_flags(addr);
if (flg & PAGE_RESERVED) {
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Kirill A. Shutemov
2008-10-26 16:14 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Vince Weaver
@ 2008-10-27 17:49 ` Kirill A. Shutemov
2008-11-01 16:51 ` Jamie Lokier
2008-11-10 7:07 ` [Qemu-devel] [PATCH, v3] " Kirill A. Shutemov
2 siblings, 2 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-27 17:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
qemu's page table can be incomple if /proc/self/maps is unavailable or
host allocating a memory with mmap(), so we can't use it to find free
memory area.
New version mmap_find_vma() uses mmap() without MAP_FIXED to find free
memory.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/mmap.c | 78 ++++++++++++++++++++++++++++------------------------
1 files changed, 42 insertions(+), 36 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index d5f22b8..f891411 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -255,52 +255,58 @@ static abi_ulong mmap_next_start = 0x40000000;
unsigned long last_brk;
-/* find a free memory area of size 'size'. The search starts at
- 'start'. If 'start' == 0, then a default start address is used.
- Return -1 if error.
-*/
-/* page_init() marks pages used by the host as reserved to be sure not
- to use them. */
-static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
+/*
+ * Find and reserve a free memory area of size 'size'. The search
+ * starts at 'start'.
+ * Return -1 if error.
+ */
+abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
{
- abi_ulong addr, addr1, addr_start;
- int prot;
- unsigned long new_brk;
-
- new_brk = (unsigned long)sbrk(0);
- if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) {
- /* This is a hack to catch the host allocating memory with brk().
- If it uses mmap then we loose.
- FIXME: We really want to avoid the host allocating memory in
- the first place, and maybe leave some slack to avoid switching
- to mmap. */
- page_set_flags(last_brk & TARGET_PAGE_MASK,
- TARGET_PAGE_ALIGN(new_brk),
- PAGE_RESERVED);
- }
- last_brk = new_brk;
+ void *ptr;
+ abi_ulong addr;
size = HOST_PAGE_ALIGN(size);
- start = start & qemu_host_page_mask;
+ start &= qemu_host_page_mask;
+
+ /* If 'start' == 0, then a default start address is used. */
+ if (start == 0)
+ start = mmap_next_start;
+
addr = start;
- if (addr == 0)
- addr = mmap_next_start;
- addr_start = addr;
+
for(;;) {
- prot = 0;
- for(addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) {
- prot |= page_get_flags(addr1);
- }
- if (prot == 0)
+ /*
+ * Reserve needed memory area to avoid a race.
+ * It should be discarded using:
+ * - mmap() with MAP_FIXED flag
+ * - mremap() with MREMAP_FIXED flag
+ * - shmat() with SHM_REMAP flag
+ */
+ ptr = mmap((void *)(unsigned long)addr, size, PROT_NONE,
+ MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
+
+ /* ENOMEM, if host address space has no memory */
+ if (ptr == MAP_FAILED)
+ return (abi_ulong)-1;
+
+ /* If address fits target address space we've found what we need */
+ if ((unsigned long)ptr + size - 1 <= (abi_ulong)-1)
break;
+
+ /* Unmap and try again with new page */
+ munmap(ptr, size);
addr += qemu_host_page_size;
- /* we found nothing */
- if (addr == addr_start)
+
+ /* ENOMEM if we check whole of target address space */
+ if (addr == start)
return (abi_ulong)-1;
}
+
+ /* Update default start address */
if (start == 0)
- mmap_next_start = addr + size;
- return addr;
+ mmap_next_start = (unsigned long)ptr + size;
+
+ return h2g(ptr);
}
/* NOTE: all the constants are the HOST ones */
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-10-27 15:48 ` Kirill A. Shutemov
2008-10-27 15:55 ` Andreas Schwab
@ 2008-10-27 19:37 ` andrzej zaborowski
2008-10-27 20:06 ` Kirill A. Shutemov
1 sibling, 1 reply; 72+ messages in thread
From: andrzej zaborowski @ 2008-10-27 19:37 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel
2008/10/27 Kirill A. Shutemov <kirill@shutemov.name>:
> On Mon, Oct 27, 2008 at 02:08:52PM +0100, andrzej zaborowski wrote:
>> On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
>> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
>> > ---
>> > linux-user/mmap.c | 5 +++++
>> > 1 files changed, 5 insertions(+), 0 deletions(-)
>> >
>> > diff --git a/linux-user/mmap.c b/linux-user/mmap.c
>> > index bc20f4b..9a2f355 100644
>> > --- a/linux-user/mmap.c
>> > +++ b/linux-user/mmap.c
>> > @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
>> > end = start + len;
>> > real_end = HOST_PAGE_ALIGN(end);
>> >
>> > + if ((unsigned long)start + len > (abi_ulong) -1) {
>> > + errno = EINVAL;
>> > + goto fail;
>> > + }
>>
>> I'm being picky but this would prevent the last byte from being used?
>> :p (or the last page because len is aligned?)
>
> No, it returns error if start + len is more than 0xFFFFFFFF (32-bit
> target).
>
>>
>> I'm not sure unsigned long is the best choice.
>
> Why?
I may be misunderstanding but I think the range of valid addresses
should depend on target word size, not host (even if the combination
where it matters is not yet supported). On a 32-bit host the
condition is always false.
Cheers
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-10-27 19:37 ` andrzej zaborowski
@ 2008-10-27 20:06 ` Kirill A. Shutemov
2008-11-10 3:30 ` andrzej zaborowski
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-10-27 20:06 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1775 bytes --]
On Mon, Oct 27, 2008 at 08:37:39PM +0100, andrzej zaborowski wrote:
> 2008/10/27 Kirill A. Shutemov <kirill@shutemov.name>:
> > On Mon, Oct 27, 2008 at 02:08:52PM +0100, andrzej zaborowski wrote:
> >> On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
> >> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> >> > ---
> >> > linux-user/mmap.c | 5 +++++
> >> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >> >
> >> > diff --git a/linux-user/mmap.c b/linux-user/mmap.c
> >> > index bc20f4b..9a2f355 100644
> >> > --- a/linux-user/mmap.c
> >> > +++ b/linux-user/mmap.c
> >> > @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
> >> > end = start + len;
> >> > real_end = HOST_PAGE_ALIGN(end);
> >> >
> >> > + if ((unsigned long)start + len > (abi_ulong) -1) {
> >> > + errno = EINVAL;
> >> > + goto fail;
> >> > + }
> >>
> >> I'm being picky but this would prevent the last byte from being used?
> >> :p (or the last page because len is aligned?)
> >
> > No, it returns error if start + len is more than 0xFFFFFFFF (32-bit
> > target).
> >
> >>
> >> I'm not sure unsigned long is the best choice.
> >
> > Why?
>
> I may be misunderstanding but I think the range of valid addresses
> should depend on target word size, not host (even if the combination
> where it matters is not yet supported).
start + len can be more than 0xFFFFFFFF ((abi_ulong) -1) on 32-bit targets,
so we should use host's long.
> On a 32-bit host the condition is always false.
It's ok. It can be true, only on 64-bit host.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] Re: [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-10-17 6:34 ` [Qemu-devel] [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables Kirill A. Shutemov
@ 2008-11-01 9:33 ` Jan Kiszka
2008-11-01 10:27 ` Kirill A. Shutemov
2008-11-01 11:34 ` Laurent Desnogues
2008-11-01 10:06 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
1 sibling, 2 replies; 72+ messages in thread
From: Jan Kiszka @ 2008-11-01 9:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
[-- Attachment #1: Type: text/plain, Size: 4570 bytes --]
Kirill A. Shutemov wrote:
> env->*dt.base should fits target address space, so we should use
> target_mmap to allocate it.
I just noticed that this bug is still unfixed upstream, was about to
repost my corresponding patch [1], but then found this even nicer
approach. Could someone please finally merge a fix?
Kirill, do you also have a patch for the problem [2] addresses in your
queue?
Last time I posted my series, Anthony remarked that the role of the
linux-user maintainer is vacant. My impression is that this is still the
case while at the same time Kirill is doing quite a good job now getting
this corner of qemu in shape again...... :->
Jan
[1] http://permalink.gmane.org/gmane.comp.emulators.qemu/28386
[2] http://permalink.gmane.org/gmane.comp.emulators.qemu/28385
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
> linux-user/main.c | 23 +++++++++++++++--------
> linux-user/syscall.c | 10 ++++++----
> 2 files changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 25b2867..61d497e 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -23,6 +23,7 @@
> #include <string.h>
> #include <errno.h>
> #include <unistd.h>
> +#include <sys/mman.h>
>
> #include "qemu.h"
> #include "qemu-common.h"
> @@ -283,9 +284,8 @@ static void write_dt(void *ptr, unsigned long addr, unsigned long limit,
> p[1] = tswap32(e2);
> }
>
> +uint64_t *idt_table;
This should become static...
> #ifdef TARGET_X86_64
> -uint64_t idt_table[512];
...as this is now static as well.
> -
> static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
> uint64_t addr, unsigned int sel)
> {
> @@ -304,8 +304,6 @@ static void set_idt(int n, unsigned int dpl)
> set_gate64(idt_table + n * 2, 0, dpl, 0, 0);
> }
> #else
> -uint64_t idt_table[256];
> -
> static void set_gate(void *ptr, unsigned int type, unsigned int dpl,
> uint32_t addr, unsigned int sel)
> {
> @@ -2500,8 +2498,15 @@ int main(int argc, char **argv, char **envp)
> #endif
>
> /* linux interrupt setup */
> - env->idt.base = h2g(idt_table);
> - env->idt.limit = sizeof(idt_table) - 1;
> +#ifndef TARGET_ABI32
> + env->idt.limit = 511;
> +#else
> + env->idt.limit = 255;
> +#endif
> + env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1),
> + PROT_READ|PROT_WRITE,
> + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
> + idt_table = g2h(env->idt.base);
> set_idt(0, 0);
> set_idt(1, 0);
> set_idt(2, 0);
> @@ -2527,9 +2532,11 @@ int main(int argc, char **argv, char **envp)
> /* linux segment setup */
> {
> uint64_t *gdt_table;
> - gdt_table = qemu_mallocz(sizeof(uint64_t) * TARGET_GDT_ENTRIES);
> - env->gdt.base = h2g((unsigned long)gdt_table);
> + env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES,
> + PROT_READ|PROT_WRITE,
> + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
> env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1;
> + gdt_table = g2h(env->gdt.base);
> #ifdef TARGET_ABI32
> write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
> DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index db3538b..27bd7e1 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2823,12 +2823,14 @@ static abi_long write_ldt(CPUX86State *env,
> }
> /* allocate the LDT */
> if (!ldt_table) {
> - ldt_table = malloc(TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
> - if (!ldt_table)
> + env->ldt.base = target_mmap(0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE,
> + PROT_READ|PROT_WRITE,
> + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
> + if (env->ldt.base == -1)
> return -TARGET_ENOMEM;
> - memset(ldt_table, 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
> - env->ldt.base = h2g((unsigned long)ldt_table);
> + memset(g2h(env->ldt.base), 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
> env->ldt.limit = 0xffff;
> + ldt_table = g2h(env->ldt.base);
> }
>
> /* NOTE: same code as Linux kernel */
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls
2008-10-16 20:55 ` [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls Martin Mohring
2008-10-17 4:09 ` Kirill A. Shutemov
@ 2008-11-01 9:56 ` Aurelien Jarno
2008-11-01 10:08 ` Kirill A. Shutemov
1 sibling, 1 reply; 72+ messages in thread
From: Aurelien Jarno @ 2008-11-01 9:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Paul Brook
On Thu, Oct 16, 2008 at 10:55:54PM +0200, Martin Mohring wrote:
> Thanks for providing these three sets of patches (msg calls already
> incorporated into svn as of svn trunk).
> I have tested them for x86 hosts running ARM targets for Debian:Etch,
> Debian:Lenny and Debian:Sid
>
> Now, the dpkg build environment for new debian releases using glibc 2.7
> can be run in linux user mode.
> Even the SYS V IPC based fakeroot command is now working (No need to use
> fakeroot-tcp anymore).
>
> There is only one downside I found while testing: Debian:Etch/fakeroot,
> which worked correctly without these patches, is not working anymore.
> fakeroot hangs forever somewhere I did not yet identify.
>
> Any advise where I should look? Are you interested in that issue?
>
Has this problem been solved? If not, could you please apply patches of
the series one by one in order to detect which one is buggy?
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH, v2] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-10-17 6:34 ` [Qemu-devel] [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables Kirill A. Shutemov
2008-11-01 9:33 ` [Qemu-devel] " Jan Kiszka
@ 2008-11-01 10:06 ` Kirill A. Shutemov
1 sibling, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-01 10:06 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
env->*dt.base should fits target address space, so we should use
target_mmap to allocate it.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/main.c | 23 +++++++++++++++--------
linux-user/syscall.c | 10 ++++++----
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 72df96e..45104a2 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <sys/mman.h>
#include "qemu.h"
#include "qemu-common.h"
@@ -283,9 +284,8 @@ static void write_dt(void *ptr, unsigned long addr, unsigned long limit,
p[1] = tswap32(e2);
}
+static uint64_t *idt_table;
#ifdef TARGET_X86_64
-static uint64_t idt_table[512];
-
static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
uint64_t addr, unsigned int sel)
{
@@ -304,8 +304,6 @@ static void set_idt(int n, unsigned int dpl)
set_gate64(idt_table + n * 2, 0, dpl, 0, 0);
}
#else
-static uint64_t idt_table[256];
-
static void set_gate(void *ptr, unsigned int type, unsigned int dpl,
uint32_t addr, unsigned int sel)
{
@@ -2500,8 +2498,15 @@ int main(int argc, char **argv, char **envp)
#endif
/* linux interrupt setup */
- env->idt.base = h2g(idt_table);
- env->idt.limit = sizeof(idt_table) - 1;
+#ifndef TARGET_ABI32
+ env->idt.limit = 511;
+#else
+ env->idt.limit = 255;
+#endif
+ env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1),
+ PROT_READ|PROT_WRITE,
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ idt_table = g2h(env->idt.base);
set_idt(0, 0);
set_idt(1, 0);
set_idt(2, 0);
@@ -2527,9 +2532,11 @@ int main(int argc, char **argv, char **envp)
/* linux segment setup */
{
uint64_t *gdt_table;
- gdt_table = qemu_mallocz(sizeof(uint64_t) * TARGET_GDT_ENTRIES);
- env->gdt.base = h2g((unsigned long)gdt_table);
+ env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES,
+ PROT_READ|PROT_WRITE,
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1;
+ gdt_table = g2h(env->gdt.base);
#ifdef TARGET_ABI32
write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index effafb6..4ec8d0b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2824,12 +2824,14 @@ static abi_long write_ldt(CPUX86State *env,
}
/* allocate the LDT */
if (!ldt_table) {
- ldt_table = malloc(TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
- if (!ldt_table)
+ env->ldt.base = target_mmap(0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE,
+ PROT_READ|PROT_WRITE,
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ if (env->ldt.base == -1)
return -TARGET_ENOMEM;
- memset(ldt_table, 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
- env->ldt.base = h2g((unsigned long)ldt_table);
+ memset(g2h(env->ldt.base), 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
env->ldt.limit = 0xffff;
+ ldt_table = g2h(env->ldt.base);
}
/* NOTE: same code as Linux kernel */
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls
2008-11-01 9:56 ` Aurelien Jarno
@ 2008-11-01 10:08 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-01 10:08 UTC (permalink / raw)
To: Aurelien Jarno; +Cc: qemu-devel, Paul Brook
[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]
On Sat, Nov 01, 2008 at 10:56:14AM +0100, Aurelien Jarno wrote:
> On Thu, Oct 16, 2008 at 10:55:54PM +0200, Martin Mohring wrote:
> > Thanks for providing these three sets of patches (msg calls already
> > incorporated into svn as of svn trunk).
> > I have tested them for x86 hosts running ARM targets for Debian:Etch,
> > Debian:Lenny and Debian:Sid
> >
> > Now, the dpkg build environment for new debian releases using glibc 2.7
> > can be run in linux user mode.
> > Even the SYS V IPC based fakeroot command is now working (No need to use
> > fakeroot-tcp anymore).
> >
> > There is only one downside I found while testing: Debian:Etch/fakeroot,
> > which worked correctly without these patches, is not working anymore.
> > fakeroot hangs forever somewhere I did not yet identify.
> >
> > Any advise where I should look? Are you interested in that issue?
> >
>
> Has this problem been solved? If not, could you please apply patches of
> the series one by one in order to detect which one is buggy?
I still haven't got any logs. :(
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH, v2] Introduce --enable-binfmt-misc configure option
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Kirill A. Shutemov
@ 2008-11-01 10:10 ` Kirill A. Shutemov
2008-11-10 13:03 ` andrzej zaborowski
1 sibling, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-01 10:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
It makes qemu compatible with binfmt_misc's flags 'P' and 'O'.
'P' - preserve-argv[0]. Legacy behavior of binfmt_misc is to overwrite the
original argv[0] with the full path to the binary. When this flag is
included, binfmt_misc will add an argument to the argument vector for
this purpose, thus preserving the original argv[0].
'O' - open-binary. Legacy behavior of binfmt_misc is to pass the full path
of the binary to the interpreter as an argument. When this flag is
included, binfmt_misc will open the file for reading and pass its
descriptor as an argument, instead of the full path, thus allowing
the interpreter to execute non-readable binaries.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
configure | 86 ++++++++++++++++++++++++++----------------------
linux-user/linuxload.c | 7 +---
linux-user/main.c | 39 ++++++++++++++++++++-
linux-user/qemu.h | 2 +-
4 files changed, 87 insertions(+), 47 deletions(-)
diff --git a/configure b/configure
index ccc4ae0..c7e2732 100755
--- a/configure
+++ b/configure
@@ -114,6 +114,7 @@ aio="yes"
nptl="yes"
mixemu="no"
bluez="yes"
+binfmt_misc="no"
# OS specific
targetos=`uname -s`
@@ -355,6 +356,8 @@ for opt do
;;
--disable-aio) aio="no"
;;
+ --enable-binfmt-misc) binfmt_misc="yes"
+ ;;
*) echo "ERROR: unknown option $opt"; show_help="yes"
;;
esac
@@ -461,6 +464,7 @@ echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
echo " --disable-vde disable support for vde network"
echo " --disable-aio disable AIO support"
+echo " --enable-binfmt-misc makes usermode compatible with binfmt_misc's flags 'P' and 'O'"
echo ""
echo "NOTE: The object files are built at the place where configure is launched"
exit 1
@@ -984,55 +988,56 @@ else
binsuffix="/bin"
fi
-echo "Install prefix $prefix"
-echo "BIOS directory $prefix$datasuffix"
-echo "binary directory $prefix$binsuffix"
+echo "Install prefix $prefix"
+echo "BIOS directory $prefix$datasuffix"
+echo "binary directory $prefix$binsuffix"
if test "$mingw32" = "no" ; then
-echo "Manual directory $prefix$mansuffix"
-echo "ELF interp prefix $interp_prefix"
-fi
-echo "Source path $source_path"
-echo "C compiler $cc"
-echo "Host C compiler $host_cc"
-echo "ARCH_CFLAGS $ARCH_CFLAGS"
-echo "make $make"
-echo "install $install"
-echo "host CPU $cpu"
-echo "host big endian $bigendian"
-echo "target list $target_list"
-echo "gprof enabled $gprof"
-echo "sparse enabled $sparse"
-echo "profiler $profiler"
-echo "static build $static"
-echo "-Werror enabled $werror"
+echo "Manual directory $prefix$mansuffix"
+echo "ELF interp prefix $interp_prefix"
+fi
+echo "Source path $source_path"
+echo "C compiler $cc"
+echo "Host C compiler $host_cc"
+echo "ARCH_CFLAGS $ARCH_CFLAGS"
+echo "make $make"
+echo "install $install"
+echo "host CPU $cpu"
+echo "host big endian $bigendian"
+echo "target list $target_list"
+echo "gprof enabled $gprof"
+echo "sparse enabled $sparse"
+echo "profiler $profiler"
+echo "static build $static"
+echo "-Werror enabled $werror"
if test "$darwin" = "yes" ; then
- echo "Cocoa support $cocoa"
+ echo "Cocoa support $cocoa"
fi
echo "SDL support $sdl"
if test "$sdl" != "no" ; then
- echo "SDL static link $sdl_static"
-fi
-echo "curses support $curses"
-echo "mingw32 support $mingw32"
-echo "Audio drivers $audio_drv_list"
-echo "Extra audio cards $audio_card_list"
-echo "Mixer emulation $mixemu"
-echo "VNC TLS support $vnc_tls"
+ echo "SDL static link $sdl_static"
+fi
+echo "curses support $curses"
+echo "mingw32 support $mingw32"
+echo "Audio drivers $audio_drv_list"
+echo "Extra audio cards $audio_card_list"
+echo "Mixer emulation $mixemu"
+echo "VNC TLS support $vnc_tls"
if test "$vnc_tls" = "yes" ; then
- echo " TLS CFLAGS $vnc_tls_cflags"
- echo " TLS LIBS $vnc_tls_libs"
+ echo " TLS CFLAGS $vnc_tls_cflags"
+ echo " TLS LIBS $vnc_tls_libs"
fi
if test -n "$sparc_cpu"; then
- echo "Target Sparc Arch $sparc_cpu"
+ echo "Target Sparc Arch $sparc_cpu"
fi
-echo "kqemu support $kqemu"
-echo "brlapi support $brlapi"
-echo "Documentation $build_docs"
+echo "kqemu support $kqemu"
+echo "brlapi support $brlapi"
+echo "Documentation $build_docs"
[ ! -z "$uname_release" ] && \
-echo "uname -r $uname_release"
-echo "NPTL support $nptl"
-echo "vde support $vde"
-echo "AIO support $aio"
+echo "uname -r $uname_release"
+echo "NPTL support $nptl"
+echo "vde support $vde"
+echo "AIO support $aio"
+echo "binfmt_misc support $binfmt_misc"
if test $sdl_too_old = "yes"; then
echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1608,6 +1613,9 @@ if test "$target_bsd_user" = "yes" ; then
echo "CONFIG_BSD_USER=yes" >> $config_mak
echo "#define CONFIG_BSD_USER 1" >> $config_h
fi
+if test "$target_user_only" = "yes" -a "$binfmt_misc" = "yes"; then
+ echo "#define BINFMT_MISC 1" >> $config_h
+fi
test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c
index ada7c69..cbd90f7 100644
--- a/linux-user/linuxload.c
+++ b/linux-user/linuxload.c
@@ -154,7 +154,7 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
return sp;
}
-int loader_exec(const char * filename, char ** argv, char ** envp,
+int loader_exec(int fd, const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop)
{
struct linux_binprm bprm;
@@ -164,10 +164,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp,
bprm.p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int);
for (i=0 ; i<MAX_ARG_PAGES ; i++) /* clear page-table */
bprm.page[i] = 0;
- retval = open(filename, O_RDONLY);
- if (retval < 0)
- return retval;
- bprm.fd = retval;
+ bprm.fd = fd;
bprm.filename = (char *)filename;
bprm.argc = count(argv);
bprm.argv = argv;
diff --git a/linux-user/main.c b/linux-user/main.c
index a5aefce..72df96e 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -26,6 +26,7 @@
#include "qemu.h"
#include "qemu-common.h"
+#include "elf.h"
/* For tb_lock */
#include "exec-all.h"
@@ -2217,9 +2218,10 @@ void init_task_state(TaskState *ts)
ts->sigqueue_table[i].next = NULL;
}
-int main(int argc, char **argv)
+int main(int argc, char **argv, char **envp)
{
const char *filename;
+ int fd = -1;
const char *cpu_model;
struct target_pt_regs regs1, *regs = ®s1;
struct image_info info1, *info = &info1;
@@ -2380,7 +2382,40 @@ int main(int argc, char **argv)
}
*dst = NULL; /* NULL terminate target_environ */
- if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
+#ifdef BINFMT_MISC
+#if HOST_LONG_BITS == 32
+#define Elf_Dyn Elf32_Dyn
+#else
+#define Elf_Dyn Elf64_Dyn
+#endif
+ {
+ Elf_Dyn *auxv;
+
+ optind++; /* Handle binfmt_misc's option 'P' */
+
+ /* Handle binfmt_misc's option 'O' */
+ while(*envp++ != NULL); /* skip envp. we are on auxv now */
+ for(auxv = (Elf_Dyn *)envp; auxv->d_tag != AT_NULL; auxv++) {
+ if( auxv->d_tag == AT_EXECFD) {
+ fd = auxv->d_un.d_val;
+ break;
+ }
+ }
+
+ if (fd < 0) {
+ printf("Cannot find binary file descriptor\n");
+ _exit(1);
+ }
+ }
+#else
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ printf("Cannot open file %s: %s\n", filename, strerror(errno));
+ _exit(1);
+ }
+#endif
+
+ if (loader_exec(fd, filename, argv+optind, target_environ, regs, info) != 0) {
printf("Error loading %s\n", filename);
_exit(1);
}
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index a2abe51..52835ec 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -168,7 +168,7 @@ struct linux_binprm {
void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
abi_ulong stringp, int push_ptr);
-int loader_exec(const char * filename, char ** argv, char ** envp,
+int loader_exec(int fd, const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop);
int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] Re: [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-11-01 9:33 ` [Qemu-devel] " Jan Kiszka
@ 2008-11-01 10:27 ` Kirill A. Shutemov
2008-11-01 10:54 ` Jan Kiszka
2008-11-01 11:34 ` Laurent Desnogues
1 sibling, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-01 10:27 UTC (permalink / raw)
To: Jan Kiszka; +Cc: qemu-devel
[-- Attachment #1.1: Type: text/plain, Size: 1543 bytes --]
On Sat, Nov 01, 2008 at 10:33:07AM +0100, Jan Kiszka wrote:
> Kirill A. Shutemov wrote:
> > env->*dt.base should fits target address space, so we should use
> > target_mmap to allocate it.
>
> I just noticed that this bug is still unfixed upstream, was about to
> repost my corresponding patch [1], but then found this even nicer
> approach. Could someone please finally merge a fix?
>
> Kirill, do you also have a patch for the problem [2] addresses in your
> queue?
No, I don't. But we also can use target_mmap(with my mmap_find_vma()) for
it, I guess. Can you provide any testcase to reproduce the bug?
>
> Last time I posted my series, Anthony remarked that the role of the
> linux-user maintainer is vacant. My impression is that this is still the
> case while at the same time Kirill is doing quite a good job now getting
> this corner of qemu in shape again...... :->
I'm interested in commit access. I've already asked about it, but I haven't
got any responce.
I've attached ssh-key just in case. ;)
>
> Jan
>
> [1] http://permalink.gmane.org/gmane.comp.emulators.qemu/28386
> [2] http://permalink.gmane.org/gmane.comp.emulators.qemu/28385
<skip/>
> > @@ -283,9 +284,8 @@ static void write_dt(void *ptr, unsigned long addr, unsigned long limit,
> > p[1] = tswap32(e2);
> > }
> >
> > +uint64_t *idt_table;
>
> This should become static...
Updated patch has been sent.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #1.2: id_dsa.pub --]
[-- Type: text/plain, Size: 1128 bytes --]
ssh-dss AAAAB3NzaC1kc3MAAAEBAOlkJ0ucchMEy6shLwYplKpRx8RO1WtJbtMsspWDQlMu6X9DnRZZbiBCo5FwSWuHQbGF+cjUEQM9vYezdyz+slmZQ0Dv8eS/8eqQPpUi9QVpiVOWK8JTh/kqUmXjoFf+oiRAvaXhzGz0nWOtqxQimxMVYD3rxHcM44/TztMOI0J1vZVxep86Uw0jgMfEITanJk65xAEo5dQkF6UbQ5eOw7+Y8ZFurjTQ6R2ZNNPB0tc7HyinDdyRzx8gIA7VYC1yLi3UWcX4in2dczFfLDYRlfLW0Jpz/1i22IGC5Iww27ab+CYSxPNFh36Gc1vrC67F9IE2DC7JFhCNl34Bdt3wEE0AAAAVANjSWDGw+eHsj2U1BLVFNWyMisorAAABAQC2c9ey+myRb4wqcPrHwl0CgmL7Ct2fpqYFSHtphQiL0q6PS8t0/wKKnmquOTrnGkiYMbqBY9OyEg9/c9dAHfZsw+Y3/yDhATIJV18nuyX6OV9lGy1O2E7yUrR9AiO4MinG+aERx2QehTwlwPTy2ANO1B54hCVGfv9oThbB2Sb2tqegjvoWRlfzLyXg0xyCPkB9USkRajxbIMvkZ9JYPaQsKGtJIfDqVHL9moJzGdo83UU5vkAJCZDYumOe+PDIGlrpY1z3bl1MhWfggT+eVKxQsrU/rFh7sI0LQ7+ENLSQq6MWxYdNFVUFDrqWJxOc/1FlkgOMnMFFOkRkOFCqSuKyAAABAH21LqMMxYNaJ23nYumWeJHVPbXLMZBCRHX0c9krdnqN67xNI2WPfJ3kD+qs7quiCIlWt5FGopeH9LjDluVBBz/U7aK072BA3fm5kVlgmlZPgktskMysm8D6UhZvDOgfUgP8qofOPXF9kP5mI7mI8RIxHIiOmyCl+2NbAw/p9owyTzPvwd/kMh6O9ImBtLk5TxTFJIUskCmp1rRx/ZqYqXgp8+DGhCGVqIUaiI2KE32ZMlCY9Mp0Eif18UggldRbgITX2xgPuewk496i2MbObT8TF/yHOtXAsnCSdjmRLR556TmiW5g0qQisxs+xyxWeUhN7Cwyz0pYLrNuFngJggUA= kir@localhost.localdomain
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] Re: [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-11-01 10:27 ` Kirill A. Shutemov
@ 2008-11-01 10:54 ` Jan Kiszka
2008-11-01 11:12 ` Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: Jan Kiszka @ 2008-11-01 10:54 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]
Kirill A. Shutemov wrote:
> On Sat, Nov 01, 2008 at 10:33:07AM +0100, Jan Kiszka wrote:
>> Kirill A. Shutemov wrote:
>>> env->*dt.base should fits target address space, so we should use
>>> target_mmap to allocate it.
>> I just noticed that this bug is still unfixed upstream, was about to
>> repost my corresponding patch [1], but then found this even nicer
>> approach. Could someone please finally merge a fix?
>>
>> Kirill, do you also have a patch for the problem [2] addresses in your
>> queue?
>
> No, I don't. But we also can use target_mmap(with my mmap_find_vma()) for
> it, I guess. Can you provide any testcase to reproduce the bug?
I don't have a testcase for this. I just came across it at the time this
h2g usage caused a compiler warning. Laster on, this warning was papered
over, but the bug remained though I reminded people a few times.
We don't need special allocation here (that's what I originally thought
as well), we just need a robust way of detecting the guest-host address
conflict:
http://article.gmane.org/gmane.comp.emulators.qemu/28381
Maybe you can go through my old series and pick up the bits that still
make sense. The user emulation is not on my daily radar, so these things
could be forgotten again if I have to track them. :-]
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 258 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] Re: [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-11-01 10:54 ` Jan Kiszka
@ 2008-11-01 11:12 ` Kirill A. Shutemov
2008-11-01 11:16 ` Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-01 11:12 UTC (permalink / raw)
To: Jan Kiszka; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1576 bytes --]
On Sat, Nov 01, 2008 at 11:54:00AM +0100, Jan Kiszka wrote:
> Kirill A. Shutemov wrote:
> > On Sat, Nov 01, 2008 at 10:33:07AM +0100, Jan Kiszka wrote:
> >> Kirill A. Shutemov wrote:
> >>> env->*dt.base should fits target address space, so we should use
> >>> target_mmap to allocate it.
> >> I just noticed that this bug is still unfixed upstream, was about to
> >> repost my corresponding patch [1], but then found this even nicer
> >> approach. Could someone please finally merge a fix?
> >>
> >> Kirill, do you also have a patch for the problem [2] addresses in your
> >> queue?
> >
> > No, I don't. But we also can use target_mmap(with my mmap_find_vma()) for
> > it, I guess. Can you provide any testcase to reproduce the bug?
>
> I don't have a testcase for this. I just came across it at the time this
> h2g usage caused a compiler warning. Laster on, this warning was papered
> over, but the bug remained though I reminded people a few times.
>
> We don't need special allocation here (that's what I originally thought
> as well), we just need a robust way of detecting the guest-host address
> conflict:
You are right.
>
> http://article.gmane.org/gmane.comp.emulators.qemu/28381
>
> Maybe you can go through my old series and pick up the bits that still
> make sense. The user emulation is not on my daily radar, so these things
> could be forgotten again if I have to track them. :-]
Your patches 1,4,5 look good for me.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] Re: [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-11-01 11:12 ` Kirill A. Shutemov
@ 2008-11-01 11:16 ` Kirill A. Shutemov
2008-11-02 19:36 ` Jan Kiszka
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-01 11:16 UTC (permalink / raw)
To: Jan Kiszka; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 276 bytes --]
On Sat, Nov 01, 2008 at 01:12:13PM +0200, Kirill A. Shutemov wrote:
> Your patches 1,4,5 look good for me.
But, I think you should use abi_ulong instead of target_ulong.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-11-01 9:33 ` [Qemu-devel] " Jan Kiszka
2008-11-01 10:27 ` Kirill A. Shutemov
@ 2008-11-01 11:34 ` Laurent Desnogues
1 sibling, 0 replies; 72+ messages in thread
From: Laurent Desnogues @ 2008-11-01 11:34 UTC (permalink / raw)
To: qemu-devel
On Sat, Nov 1, 2008 at 10:33 AM, Jan Kiszka <jan.kiszka@web.de> wrote:
>
> Last time I posted my series, Anthony remarked that the role of the
> linux-user maintainer is vacant. My impression is that this is still the
> case while at the same time Kirill is doing quite a good job now getting
> this corner of qemu in shape again...... :->
FWIW, I agree it's time someone takes the role of official maintainer for
user emulation, having small corrections (sometimes buggy) here and
there every two or three months is nice, but certainly not good enough.
Laurent
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-10-27 17:49 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
@ 2008-11-01 16:51 ` Jamie Lokier
2008-11-01 16:55 ` Kirill A. Shutemov
2008-11-10 7:07 ` [Qemu-devel] [PATCH, v3] " Kirill A. Shutemov
1 sibling, 1 reply; 72+ messages in thread
From: Jamie Lokier @ 2008-11-01 16:51 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
Kirill A. Shutemov wrote:
> + /* Unmap and try again with new page */
> + munmap(ptr, size);
> addr += qemu_host_page_size;
Won't this be rather slow if it has to skip a large mapped area, one
page at a time?
-- Jamie
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-01 16:51 ` Jamie Lokier
@ 2008-11-01 16:55 ` Kirill A. Shutemov
2008-11-10 3:54 ` andrzej zaborowski
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-01 16:55 UTC (permalink / raw)
To: Jamie Lokier; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 485 bytes --]
On Sat, Nov 01, 2008 at 04:51:10PM +0000, Jamie Lokier wrote:
> Kirill A. Shutemov wrote:
> > + /* Unmap and try again with new page */
> > + munmap(ptr, size);
> > addr += qemu_host_page_size;
>
> Won't this be rather slow if it has to skip a large mapped area, one
> page at a time?
If we skip more than one page we increase memory fragmentation.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] Re: [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables
2008-11-01 11:16 ` Kirill A. Shutemov
@ 2008-11-02 19:36 ` Jan Kiszka
0 siblings, 0 replies; 72+ messages in thread
From: Jan Kiszka @ 2008-11-02 19:36 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 333 bytes --]
Kirill A. Shutemov wrote:
> On Sat, Nov 01, 2008 at 01:12:13PM +0200, Kirill A. Shutemov wrote:
>> Your patches 1,4,5 look good for me.
>
> But, I think you should use abi_ulong instead of target_ulong.
>
Yes, makes sense.
Again, I would welcome if pick up the remaining patches and carry them
in your queue.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-10-27 20:06 ` Kirill A. Shutemov
@ 2008-11-10 3:30 ` andrzej zaborowski
2008-11-10 5:55 ` Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: andrzej zaborowski @ 2008-11-10 3:30 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel
Sorry to resurrect this old thread, I still can't convince myself.
2008/10/27 Kirill A. Shutemov <kirill@shutemov.name>:
> On Mon, Oct 27, 2008 at 08:37:39PM +0100, andrzej zaborowski wrote:
>> 2008/10/27 Kirill A. Shutemov <kirill@shutemov.name>:
>> > On Mon, Oct 27, 2008 at 02:08:52PM +0100, andrzej zaborowski wrote:
>> >> On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
>> >> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
>> >> > ---
>> >> > linux-user/mmap.c | 5 +++++
>> >> > 1 files changed, 5 insertions(+), 0 deletions(-)
>> >> >
>> >> > diff --git a/linux-user/mmap.c b/linux-user/mmap.c
>> >> > index bc20f4b..9a2f355 100644
>> >> > --- a/linux-user/mmap.c
>> >> > +++ b/linux-user/mmap.c
>> >> > @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
>> >> > end = start + len;
>> >> > real_end = HOST_PAGE_ALIGN(end);
>> >> >
>> >> > + if ((unsigned long)start + len > (abi_ulong) -1) {
>> >> > + errno = EINVAL;
>> >> > + goto fail;
>> >> > + }
>> >>
>> >> I'm being picky but this would prevent the last byte from being used?
>> >> :p (or the last page because len is aligned?)
>> >
>> > No, it returns error if start + len is more than 0xFFFFFFFF (32-bit
>> > target).
>> >
>> >>
>> >> I'm not sure unsigned long is the best choice.
>> >
>> > Why?
>>
>> I may be misunderstanding but I think the range of valid addresses
>> should depend on target word size, not host (even if the combination
>> where it matters is not yet supported).
>
> start + len can be more than 0xFFFFFFFF ((abi_ulong) -1) on 32-bit targets,
> so we should use host's long.
>
>> On a 32-bit host the condition is always false.
>
> It's ok. It can be true, only on 64-bit host.
Let's say we have a 32-bit host and target, the call receives start ==
0xffff0050 and len == 0x100000, the check passes, when it shouldn't
(?). On a 64-bit host it would fail, but this check should be
independent of the host type.
(It'll probably fail later in the host mmap() -- but in the meantime
mmap_frag() might succeed for example)
Cheers
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-01 16:55 ` Kirill A. Shutemov
@ 2008-11-10 3:54 ` andrzej zaborowski
2008-11-10 6:07 ` Kirill A. Shutemov
2008-11-10 8:02 ` Jamie Lokier
0 siblings, 2 replies; 72+ messages in thread
From: andrzej zaborowski @ 2008-11-10 3:54 UTC (permalink / raw)
To: qemu-devel
Hi,
2008/11/1 Kirill A. Shutemov <kirill@shutemov.name>:
> On Sat, Nov 01, 2008 at 04:51:10PM +0000, Jamie Lokier wrote:
>> Kirill A. Shutemov wrote:
>> > + /* Unmap and try again with new page */
>> > + munmap(ptr, size);
>> > addr += qemu_host_page_size;
>>
>> Won't this be rather slow if it has to skip a large mapped area, one
>> page at a time?
>
> If we skip more than one page we increase memory fragmentation.
This approach makes sense, however the iterating over all pages may
indeed have performance consequences, plus it would be great if people
who better know linux-user/ than me commented. I'll assume that
everyone is happy with this otherwise.
It may be useful adding a comment on top of the function that it must
be called with mmap_lock held.
Cheers
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-11-10 3:30 ` andrzej zaborowski
@ 2008-11-10 5:55 ` Kirill A. Shutemov
2008-11-10 12:45 ` andrzej zaborowski
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-10 5:55 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2663 bytes --]
On Mon, Nov 10, 2008 at 04:30:39AM +0100, andrzej zaborowski wrote:
> Sorry to resurrect this old thread, I still can't convince myself.
>
> 2008/10/27 Kirill A. Shutemov <kirill@shutemov.name>:
> > On Mon, Oct 27, 2008 at 08:37:39PM +0100, andrzej zaborowski wrote:
> >> 2008/10/27 Kirill A. Shutemov <kirill@shutemov.name>:
> >> > On Mon, Oct 27, 2008 at 02:08:52PM +0100, andrzej zaborowski wrote:
> >> >> On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
> >> >> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> >> >> > ---
> >> >> > linux-user/mmap.c | 5 +++++
> >> >> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >> >> >
> >> >> > diff --git a/linux-user/mmap.c b/linux-user/mmap.c
> >> >> > index bc20f4b..9a2f355 100644
> >> >> > --- a/linux-user/mmap.c
> >> >> > +++ b/linux-user/mmap.c
> >> >> > @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
> >> >> > end = start + len;
> >> >> > real_end = HOST_PAGE_ALIGN(end);
> >> >> >
> >> >> > + if ((unsigned long)start + len > (abi_ulong) -1) {
> >> >> > + errno = EINVAL;
> >> >> > + goto fail;
> >> >> > + }
> >> >>
> >> >> I'm being picky but this would prevent the last byte from being used?
> >> >> :p (or the last page because len is aligned?)
> >> >
> >> > No, it returns error if start + len is more than 0xFFFFFFFF (32-bit
> >> > target).
> >> >
> >> >>
> >> >> I'm not sure unsigned long is the best choice.
> >> >
> >> > Why?
> >>
> >> I may be misunderstanding but I think the range of valid addresses
> >> should depend on target word size, not host (even if the combination
> >> where it matters is not yet supported).
> >
> > start + len can be more than 0xFFFFFFFF ((abi_ulong) -1) on 32-bit targets,
> > so we should use host's long.
> >
> >> On a 32-bit host the condition is always false.
> >
> > It's ok. It can be true, only on 64-bit host.
>
> Let's say we have a 32-bit host and target, the call receives start ==
> 0xffff0050 and len == 0x100000, the check passes, when it shouldn't
> (?). On a 64-bit host it would fail, but this check should be
> independent of the host type.
> (It'll probably fail later in the host mmap() -- but in the meantime
> mmap_frag() might succeed for example)
mmap_frag() will not be called if host mmap() fail. mmap can fail on many
conditions, it's one of them.
Probably, I should add comment to this check, that it's for 64-bit host
only. Ok?
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-10 3:54 ` andrzej zaborowski
@ 2008-11-10 6:07 ` Kirill A. Shutemov
2008-11-10 8:02 ` Jamie Lokier
1 sibling, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-10 6:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Paul Brook
[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]
On Mon, Nov 10, 2008 at 04:54:35AM +0100, andrzej zaborowski wrote:
> Hi,
>
> 2008/11/1 Kirill A. Shutemov <kirill@shutemov.name>:
> > On Sat, Nov 01, 2008 at 04:51:10PM +0000, Jamie Lokier wrote:
> >> Kirill A. Shutemov wrote:
> >> > + /* Unmap and try again with new page */
> >> > + munmap(ptr, size);
> >> > addr += qemu_host_page_size;
> >>
> >> Won't this be rather slow if it has to skip a large mapped area, one
> >> page at a time?
> >
> > If we skip more than one page we increase memory fragmentation.
>
> This approach makes sense, however the iterating over all pages may
> indeed have performance consequences, plus it would be great if people
> who better know linux-user/ than me commented. I'll assume that
> everyone is happy with this otherwise.
Paul, can you comment it?
> It may be useful adding a comment on top of the function that it must
> be called with mmap_lock held.
Ok, I'll do it.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH, v3] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-10-27 17:49 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2008-11-01 16:51 ` Jamie Lokier
@ 2008-11-10 7:07 ` Kirill A. Shutemov
2008-11-14 13:57 ` [Qemu-devel] [PATCH, v4] " Kirill A. Shutemov
1 sibling, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-10 7:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
qemu's page table can be incomple if /proc/self/maps is unavailable or
host allocating a memory with mmap(), so we can't use it to find free
memory area.
New version mmap_find_vma() uses mmap() without MAP_FIXED to find free
memory.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/mmap.c | 79 +++++++++++++++++++++++++++++------------------------
1 files changed, 43 insertions(+), 36 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index d5f22b8..f3ad2eb 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -255,52 +255,59 @@ static abi_ulong mmap_next_start = 0x40000000;
unsigned long last_brk;
-/* find a free memory area of size 'size'. The search starts at
- 'start'. If 'start' == 0, then a default start address is used.
- Return -1 if error.
-*/
-/* page_init() marks pages used by the host as reserved to be sure not
- to use them. */
-static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
+/*
+ * Find and reserve a free memory area of size 'size'. The search
+ * starts at 'start'.
+ * It must be called with mmap_lock() held.
+ * Return -1 if error.
+ */
+abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
{
- abi_ulong addr, addr1, addr_start;
- int prot;
- unsigned long new_brk;
-
- new_brk = (unsigned long)sbrk(0);
- if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) {
- /* This is a hack to catch the host allocating memory with brk().
- If it uses mmap then we loose.
- FIXME: We really want to avoid the host allocating memory in
- the first place, and maybe leave some slack to avoid switching
- to mmap. */
- page_set_flags(last_brk & TARGET_PAGE_MASK,
- TARGET_PAGE_ALIGN(new_brk),
- PAGE_RESERVED);
- }
- last_brk = new_brk;
+ void *ptr;
+ abi_ulong addr;
size = HOST_PAGE_ALIGN(size);
- start = start & qemu_host_page_mask;
+ start &= qemu_host_page_mask;
+
+ /* If 'start' == 0, then a default start address is used. */
+ if (start == 0)
+ start = mmap_next_start;
+
addr = start;
- if (addr == 0)
- addr = mmap_next_start;
- addr_start = addr;
+
for(;;) {
- prot = 0;
- for(addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) {
- prot |= page_get_flags(addr1);
- }
- if (prot == 0)
+ /*
+ * Reserve needed memory area to avoid a race.
+ * It should be discarded using:
+ * - mmap() with MAP_FIXED flag
+ * - mremap() with MREMAP_FIXED flag
+ * - shmat() with SHM_REMAP flag
+ */
+ ptr = mmap((void *)(unsigned long)addr, size, PROT_NONE,
+ MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
+
+ /* ENOMEM, if host address space has no memory */
+ if (ptr == MAP_FAILED)
+ return (abi_ulong)-1;
+
+ /* If address fits target address space we've found what we need */
+ if ((unsigned long)ptr + size - 1 <= (abi_ulong)-1)
break;
+
+ /* Unmap and try again with new page */
+ munmap(ptr, size);
addr += qemu_host_page_size;
- /* we found nothing */
- if (addr == addr_start)
+
+ /* ENOMEM if we check whole of target address space */
+ if (addr == start)
return (abi_ulong)-1;
}
+
+ /* Update default start address */
if (start == 0)
- mmap_next_start = addr + size;
- return addr;
+ mmap_next_start = (unsigned long)ptr + size;
+
+ return h2g(ptr);
}
/* NOTE: all the constants are the HOST ones */
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH, v3] shmat(): use mmap_find_vma to find free memory area
2008-10-13 10:10 ` [Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
2008-10-17 6:34 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Kirill A. Shutemov
@ 2008-11-10 7:09 ` Kirill A. Shutemov
1 sibling, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-10 7:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7142606..ebf7375 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2271,25 +2271,40 @@ static inline abi_long do_shmctl(int shmid, int cmd, abi_long buf)
static inline abi_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
unsigned long *raddr)
{
+ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size);
abi_long ret;
struct shmid_ds shm_info;
int i;
- /* SHM_* flags are the same on all linux platforms */
- *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
-
- if (*raddr == -1) {
- return get_errno(*raddr);
- }
-
/* find out the length of the shared memory segment */
ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info));
if (is_error(ret)) {
/* can't get length, bail out */
- shmdt((void *) *raddr);
return get_errno(ret);
}
+ mmap_lock();
+
+ if (shmaddr)
+ *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
+ else {
+ abi_ulong mmap_start;
+
+ mmap_start = mmap_find_vma(0, shm_info.shm_segsz);
+
+ if (mmap_start == -1) {
+ errno = ENOMEM;
+ *raddr = -1;
+ } else
+ *raddr = (unsigned long) shmat(shmid, g2h(mmap_start),
+ shmflg | SHM_REMAP);
+ }
+
+ if (*raddr == -1) {
+ mmap_unlock();
+ return get_errno(*raddr);
+ }
+
page_set_flags(h2g(*raddr), h2g(*raddr) + shm_info.shm_segsz,
PAGE_VALID | PAGE_READ |
((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
@@ -2302,6 +2317,7 @@ static inline abi_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
}
}
+ mmap_unlock();
return 0;
}
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH, v3] mmap: add check if requested memory area fits target address space
2008-10-27 17:48 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
@ 2008-11-10 7:11 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-10 7:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/mmap.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index acb005d..01fd7e9 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -389,6 +389,16 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
end = start + len;
real_end = HOST_PAGE_ALIGN(end);
+ /*
+ * Test if requested memory area fits target address space
+ * It can fail only on 64-bit host with 32-bit target.
+ * On any other target/host host mmap() handles this error correctly.
+ */
+ if ((unsigned long)start + len - 1 > (abi_ulong) -1) {
+ errno = EINVAL;
+ goto fail;
+ }
+
for(addr = real_start; addr < real_end; addr += TARGET_PAGE_SIZE) {
flg = page_get_flags(addr);
if (flg & PAGE_RESERVED) {
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-10 3:54 ` andrzej zaborowski
2008-11-10 6:07 ` Kirill A. Shutemov
@ 2008-11-10 8:02 ` Jamie Lokier
2008-11-10 12:55 ` andrzej zaborowski
1 sibling, 1 reply; 72+ messages in thread
From: Jamie Lokier @ 2008-11-10 8:02 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: qemu-devel
andrzej zaborowski wrote:
> Hi,
>
> 2008/11/1 Kirill A. Shutemov <kirill@shutemov.name>:
> > On Sat, Nov 01, 2008 at 04:51:10PM +0000, Jamie Lokier wrote:
> >> Kirill A. Shutemov wrote:
> >> > + /* Unmap and try again with new page */
> >> > + munmap(ptr, size);
> >> > addr += qemu_host_page_size;
> >>
> >> Won't this be rather slow if it has to skip a large mapped area, one
> >> page at a time?
> >
> > If we skip more than one page we increase memory fragmentation.
>
> This approach makes sense, however the iterating over all pages may
> indeed have performance consequences, plus it would be great if people
> who better know linux-user/ than me commented. I'll assume that
> everyone is happy with this otherwise.
Just briefly to mention that binary search using shorter
probe-mappings can eliminate the page-by-page iteration in this case,
but alas I don't have time in this email to explain how :-)
-- Jamie
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space
2008-11-10 5:55 ` Kirill A. Shutemov
@ 2008-11-10 12:45 ` andrzej zaborowski
0 siblings, 0 replies; 72+ messages in thread
From: andrzej zaborowski @ 2008-11-10 12:45 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel
2008/11/10 Kirill A. Shutemov <kirill@shutemov.name>:
> On Mon, Nov 10, 2008 at 04:30:39AM +0100, andrzej zaborowski wrote:
>> Sorry to resurrect this old thread, I still can't convince myself.
>>
>> 2008/10/27 Kirill A. Shutemov <kirill@shutemov.name>:
>> > On Mon, Oct 27, 2008 at 08:37:39PM +0100, andrzej zaborowski wrote:
>> >> 2008/10/27 Kirill A. Shutemov <kirill@shutemov.name>:
>> >> > On Mon, Oct 27, 2008 at 02:08:52PM +0100, andrzej zaborowski wrote:
>> >> >> On 17/10/2008, Kirill A. Shutemov <kirill@shutemov.name> wrote:
>> >> >> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
>> >> >> > ---
>> >> >> > linux-user/mmap.c | 5 +++++
>> >> >> > 1 files changed, 5 insertions(+), 0 deletions(-)
>> >> >> >
>> >> >> > diff --git a/linux-user/mmap.c b/linux-user/mmap.c
>> >> >> > index bc20f4b..9a2f355 100644
>> >> >> > --- a/linux-user/mmap.c
>> >> >> > +++ b/linux-user/mmap.c
>> >> >> > @@ -388,6 +388,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
>> >> >> > end = start + len;
>> >> >> > real_end = HOST_PAGE_ALIGN(end);
>> >> >> >
>> >> >> > + if ((unsigned long)start + len > (abi_ulong) -1) {
>> >> >> > + errno = EINVAL;
>> >> >> > + goto fail;
>> >> >> > + }
>> >> >>
>> >> >> I'm being picky but this would prevent the last byte from being used?
>> >> >> :p (or the last page because len is aligned?)
>> >> >
>> >> > No, it returns error if start + len is more than 0xFFFFFFFF (32-bit
>> >> > target).
>> >> >
>> >> >>
>> >> >> I'm not sure unsigned long is the best choice.
>> >> >
>> >> > Why?
>> >>
>> >> I may be misunderstanding but I think the range of valid addresses
>> >> should depend on target word size, not host (even if the combination
>> >> where it matters is not yet supported).
>> >
>> > start + len can be more than 0xFFFFFFFF ((abi_ulong) -1) on 32-bit targets,
>> > so we should use host's long.
>> >
>> >> On a 32-bit host the condition is always false.
>> >
>> > It's ok. It can be true, only on 64-bit host.
>>
>> Let's say we have a 32-bit host and target, the call receives start ==
>> 0xffff0050 and len == 0x100000, the check passes, when it shouldn't
>> (?). On a 64-bit host it would fail, but this check should be
>> independent of the host type.
>> (It'll probably fail later in the host mmap() -- but in the meantime
>> mmap_frag() might succeed for example)
>
> mmap_frag() will not be called if host mmap() fail. mmap can fail on many
> conditions, it's one of them.
Note that mmap() is called at the end, after mmap'ping the start and
the end chunks.
>
> Probably, I should add comment to this check, that it's for 64-bit host
> only. Ok?
This doesn't make it independent of the host type :p
Cheers
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-10 8:02 ` Jamie Lokier
@ 2008-11-10 12:55 ` andrzej zaborowski
2008-11-10 14:38 ` Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: andrzej zaborowski @ 2008-11-10 12:55 UTC (permalink / raw)
To: Jamie Lokier; +Cc: qemu-devel
2008/11/10 Jamie Lokier <jamie@shareable.org>:
> andrzej zaborowski wrote:
>> Hi,
>>
>> 2008/11/1 Kirill A. Shutemov <kirill@shutemov.name>:
>> > On Sat, Nov 01, 2008 at 04:51:10PM +0000, Jamie Lokier wrote:
>> >> Kirill A. Shutemov wrote:
>> >> > + /* Unmap and try again with new page */
>> >> > + munmap(ptr, size);
>> >> > addr += qemu_host_page_size;
>> >>
>> >> Won't this be rather slow if it has to skip a large mapped area, one
>> >> page at a time?
>> >
>> > If we skip more than one page we increase memory fragmentation.
>>
>> This approach makes sense, however the iterating over all pages may
>> indeed have performance consequences, plus it would be great if people
>> who better know linux-user/ than me commented. I'll assume that
>> everyone is happy with this otherwise.
>
> Just briefly to mention that binary search using shorter
> probe-mappings can eliminate the page-by-page iteration in this case,
> but alas I don't have time in this email to explain how :-)
I was wondering the same, but I think binary search won't work:
whenever you make a step greater than page size you risk having missed
a free page closer to you. In the end you need to check all of them.
The in-kernel allocator probably is in a better position to have a
smart algorithm.
Cheers
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Introduce --enable-binfmt-misc configure option
2008-11-01 10:10 ` [Qemu-devel] [PATCH, v2] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
@ 2008-11-10 13:03 ` andrzej zaborowski
0 siblings, 0 replies; 72+ messages in thread
From: andrzej zaborowski @ 2008-11-10 13:03 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
2008/11/1 Kirill A. Shutemov <kirill@shutemov.name>:
> It makes qemu compatible with binfmt_misc's flags 'P' and 'O'.
>
> 'P' - preserve-argv[0]. Legacy behavior of binfmt_misc is to overwrite the
> original argv[0] with the full path to the binary. When this flag is
> included, binfmt_misc will add an argument to the argument vector for
> this purpose, thus preserving the original argv[0].
>
> 'O' - open-binary. Legacy behavior of binfmt_misc is to pass the full path
> of the binary to the interpreter as an argument. When this flag is
> included, binfmt_misc will open the file for reading and pass its
> descriptor as an argument, instead of the full path, thus allowing
> the interpreter to execute non-readable binaries.
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
> configure | 86 ++++++++++++++++++++++++++----------------------
> linux-user/linuxload.c | 7 +---
> linux-user/main.c | 39 ++++++++++++++++++++-
> linux-user/qemu.h | 2 +-
> 4 files changed, 87 insertions(+), 47 deletions(-)
>
> diff --git a/configure b/configure
> index ccc4ae0..c7e2732 100755
> --- a/configure
> +++ b/configure
> @@ -114,6 +114,7 @@ aio="yes"
> nptl="yes"
> mixemu="no"
> bluez="yes"
> +binfmt_misc="no"
>
> # OS specific
> targetos=`uname -s`
> @@ -355,6 +356,8 @@ for opt do
> ;;
> --disable-aio) aio="no"
> ;;
> + --enable-binfmt-misc) binfmt_misc="yes"
> + ;;
I don't know what binfmt-misc is good for, but there's nothing in the
new code that must be done in compile time, I think the #ifdef could
just be an if ().
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-10 12:55 ` andrzej zaborowski
@ 2008-11-10 14:38 ` Kirill A. Shutemov
2008-11-11 0:53 ` Jamie Lokier
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-10 14:38 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1736 bytes --]
On Mon, Nov 10, 2008 at 01:55:38PM +0100, andrzej zaborowski wrote:
> 2008/11/10 Jamie Lokier <jamie@shareable.org>:
> > andrzej zaborowski wrote:
> >> Hi,
> >>
> >> 2008/11/1 Kirill A. Shutemov <kirill@shutemov.name>:
> >> > On Sat, Nov 01, 2008 at 04:51:10PM +0000, Jamie Lokier wrote:
> >> >> Kirill A. Shutemov wrote:
> >> >> > + /* Unmap and try again with new page */
> >> >> > + munmap(ptr, size);
> >> >> > addr += qemu_host_page_size;
> >> >>
> >> >> Won't this be rather slow if it has to skip a large mapped area, one
> >> >> page at a time?
> >> >
> >> > If we skip more than one page we increase memory fragmentation.
> >>
> >> This approach makes sense, however the iterating over all pages may
> >> indeed have performance consequences, plus it would be great if people
> >> who better know linux-user/ than me commented. I'll assume that
> >> everyone is happy with this otherwise.
> >
> > Just briefly to mention that binary search using shorter
> > probe-mappings can eliminate the page-by-page iteration in this case,
> > but alas I don't have time in this email to explain how :-)
>
> I was wondering the same, but I think binary search won't work:
> whenever you make a step greater than page size you risk having missed
> a free page closer to you. In the end you need to check all of them.
>
> The in-kernel allocator probably is in a better position to have a
> smart algorithm.
To have smarter algorithm we must know about every mapping in self address
space. But it's impossible without /proc/self/maps. Unfortunately it isn't
always available.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-10 14:38 ` Kirill A. Shutemov
@ 2008-11-11 0:53 ` Jamie Lokier
2008-11-14 12:23 ` Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: Jamie Lokier @ 2008-11-11 0:53 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: qemu-devel
Kirill A. Shutemov wrote:
> > > Just briefly to mention that binary search using shorter
> > > probe-mappings can eliminate the page-by-page iteration in this case,
> > > but alas I don't have time in this email to explain how :-)
> >
> > I was wondering the same, but I think binary search won't work:
> > whenever you make a step greater than page size you risk having missed
> > a free page closer to you. In the end you need to check all of them.
> >
> > The in-kernel allocator probably is in a better position to have a
> > smart algorithm.
>
> To have smarter algorithm we must know about every mapping in self address
> space. But it's impossible without /proc/self/maps. Unfortunately it isn't
> always available.
You're both wrong :-)
Assume you're looking for a hole of size N without missing any free
pages. You can search forwards in N/2-size steps with N/2-size probe
mappings (actually ceiling(N/2)), then when you find an N/2-size hole,
search _backwards_ from that address to confirm the larger N-size
hole. You are guaranteed that if there exists an N-size hole at any
address in range, then the probe mappings will find a hole within the
larger hole, even though they skip N/2 pages at a time. For the
backward search you can do binary search, i.e. use the remaining
search range / 2 for _its_ probe, repeat, rinse, recurse, so that
large N is fast.
-- Jamie
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-11 0:53 ` Jamie Lokier
@ 2008-11-14 12:23 ` Kirill A. Shutemov
2008-11-14 12:51 ` Paul Brook
0 siblings, 1 reply; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-14 12:23 UTC (permalink / raw)
To: Jamie Lokier; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1704 bytes --]
On Tue, Nov 11, 2008 at 12:53:17AM +0000, Jamie Lokier wrote:
> Kirill A. Shutemov wrote:
> > > > Just briefly to mention that binary search using shorter
> > > > probe-mappings can eliminate the page-by-page iteration in this case,
> > > > but alas I don't have time in this email to explain how :-)
> > >
> > > I was wondering the same, but I think binary search won't work:
> > > whenever you make a step greater than page size you risk having missed
> > > a free page closer to you. In the end you need to check all of them.
> > >
> > > The in-kernel allocator probably is in a better position to have a
> > > smart algorithm.
> >
> > To have smarter algorithm we must know about every mapping in self address
> > space. But it's impossible without /proc/self/maps. Unfortunately it isn't
> > always available.
>
> You're both wrong :-)
>
> Assume you're looking for a hole of size N without missing any free
> pages. You can search forwards in N/2-size steps with N/2-size probe
> mappings (actually ceiling(N/2)), then when you find an N/2-size hole,
> search _backwards_ from that address to confirm the larger N-size
> hole. You are guaranteed that if there exists an N-size hole at any
> address in range, then the probe mappings will find a hole within the
> larger hole, even though they skip N/2 pages at a time. For the
> backward search you can do binary search, i.e. use the remaining
> search range / 2 for _its_ probe, repeat, rinse, recurse, so that
> large N is fast.
Sorry, but I can't understand your algorithm. Can you provide pseudo-code?
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.org/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-14 12:23 ` Kirill A. Shutemov
@ 2008-11-14 12:51 ` Paul Brook
2008-11-14 13:08 ` Jamie Lokier
0 siblings, 1 reply; 72+ messages in thread
From: Paul Brook @ 2008-11-14 12:51 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
On Friday 14 November 2008, Kirill A. Shutemov wrote:
> On Tue, Nov 11, 2008 at 12:53:17AM +0000, Jamie Lokier wrote:
> > Kirill A. Shutemov wrote:
> > > > > Just briefly to mention that binary search using shorter
> > > > > probe-mappings can eliminate the page-by-page iteration in this
> > > > > case, but alas I don't have time in this email to explain how :-)
> > > >
> > > > I was wondering the same, but I think binary search won't work:
> > > > whenever you make a step greater than page size you risk having
> > > > missed a free page closer to you. In the end you need to check all
> > > > of them.
> > > >
> > > > The in-kernel allocator probably is in a better position to have a
> > > > smart algorithm.
> > >
> > > To have smarter algorithm we must know about every mapping in self
> > > address space. But it's impossible without /proc/self/maps.
> > > Unfortunately it isn't always available.
> >
> > You're both wrong :-)
> >
> > Assume you're looking for a hole of size N without missing any free
> > pages. You can search forwards in N/2-size steps with N/2-size probe
> > mappings (actually ceiling(N/2)), then when you find an N/2-size hole,
> > search _backwards_ from that address to confirm the larger N-size
> > hole. You are guaranteed that if there exists an N-size hole at any
> > address in range, then the probe mappings will find a hole within the
> > larger hole, even though they skip N/2 pages at a time. For the
> > backward search you can do binary search, i.e. use the remaining
> > search range / 2 for _its_ probe, repeat, rinse, recurse, so that
> > large N is fast.
>
> Sorry, but I can't understand your algorithm. Can you provide pseudo-code?
It's a basic binary search. The problem with it being that as with any other
binary search it relies on being able to do "probes". In this case that
involves mapping and unmapping the region, which I'd expect to be fairly high
overhead.
Paul
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-14 12:51 ` Paul Brook
@ 2008-11-14 13:08 ` Jamie Lokier
2008-11-14 13:51 ` Kirill A. Shutemov
0 siblings, 1 reply; 72+ messages in thread
From: Jamie Lokier @ 2008-11-14 13:08 UTC (permalink / raw)
To: Paul Brook; +Cc: Kirill A. Shutemov, qemu-devel
Paul Brook wrote:
> It's a basic binary search. The problem with it being that as with
> any other binary search it relies on being able to do "probes". In
> this case that involves mapping and unmapping the region, which I'd
> expect to be fairly high overhead.
But much less overhead than probing every page address as the current
linear search does. The linear algorithm also does a map+unmap in its
probes. That's the point.
-- Jamie
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [Qemu-devel] [PATCH, v2] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-14 13:08 ` Jamie Lokier
@ 2008-11-14 13:51 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-14 13:51 UTC (permalink / raw)
To: Jamie Lokier; +Cc: Paul Brook, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 778 bytes --]
On Fri, Nov 14, 2008 at 01:08:45PM +0000, Jamie Lokier wrote:
> Paul Brook wrote:
> > It's a basic binary search. The problem with it being that as with
> > any other binary search it relies on being able to do "probes". In
> > this case that involves mapping and unmapping the region, which I'd
> > expect to be fairly high overhead.
>
> But much less overhead than probing every page address as the current
> linear search does. The linear algorithm also does a map+unmap in its
> probes. That's the point.
Overhead is not very big. It takes 0,7 seconds on my Core2 T7200 to make
150000 probes.
Anyway, in most cases mmap_find_vma() need only one probe.
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.org/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH, v4] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2008-11-10 7:07 ` [Qemu-devel] [PATCH, v3] " Kirill A. Shutemov
@ 2008-11-14 13:57 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-11-14 13:57 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
qemu's page table can be incomple if /proc/self/maps is unavailable or
host allocating a memory with mmap(), so we can't use it to find free
memory area.
New version mmap_find_vma() uses mmap() without MAP_FIXED to find free
memory.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/mmap.c | 81 ++++++++++++++++++++++++++++------------------------
1 files changed, 44 insertions(+), 37 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index d5f22b8..d96917d 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -255,52 +255,59 @@ static abi_ulong mmap_next_start = 0x40000000;
unsigned long last_brk;
-/* find a free memory area of size 'size'. The search starts at
- 'start'. If 'start' == 0, then a default start address is used.
- Return -1 if error.
-*/
-/* page_init() marks pages used by the host as reserved to be sure not
- to use them. */
-static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
+/*
+ * Find and reserve a free memory area of size 'size'. The search
+ * starts at 'start'.
+ * It must be called with mmap_lock() held.
+ * Return -1 if error.
+ */
+abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
{
- abi_ulong addr, addr1, addr_start;
- int prot;
- unsigned long new_brk;
-
- new_brk = (unsigned long)sbrk(0);
- if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) {
- /* This is a hack to catch the host allocating memory with brk().
- If it uses mmap then we loose.
- FIXME: We really want to avoid the host allocating memory in
- the first place, and maybe leave some slack to avoid switching
- to mmap. */
- page_set_flags(last_brk & TARGET_PAGE_MASK,
- TARGET_PAGE_ALIGN(new_brk),
- PAGE_RESERVED);
- }
- last_brk = new_brk;
+ void *ptr;
+ abi_ulong addr;
size = HOST_PAGE_ALIGN(size);
- start = start & qemu_host_page_mask;
+ start &= qemu_host_page_mask;
+
+ /* If 'start' == 0, then a default start address is used. */
+ if (start == 0)
+ start = mmap_next_start;
+
addr = start;
- if (addr == 0)
- addr = mmap_next_start;
- addr_start = addr;
+
for(;;) {
- prot = 0;
- for(addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) {
- prot |= page_get_flags(addr1);
- }
- if (prot == 0)
+ /*
+ * Reserve needed memory area to avoid a race.
+ * It should be discarded using:
+ * - mmap() with MAP_FIXED flag
+ * - mremap() with MREMAP_FIXED flag
+ * - shmat() with SHM_REMAP flag
+ */
+ ptr = mmap((void *)(unsigned long)addr, size, PROT_NONE,
+ MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
+
+ /* ENOMEM, if host address space has no memory */
+ if (ptr == MAP_FAILED)
+ return (abi_ulong)-1;
+
+ /* If address fits target address space we've found what we need */
+ if ((unsigned long)ptr + size - 1 <= (abi_ulong)-1)
break;
+
+ /* Unmap and try again with new page */
+ munmap(ptr, size);
addr += qemu_host_page_size;
- /* we found nothing */
- if (addr == addr_start)
+
+ /* ENOMEM if we check whole of target address space */
+ if (addr == start)
return (abi_ulong)-1;
}
- if (start == 0)
- mmap_next_start = addr + size;
- return addr;
+
+ /* Update default start address */
+ if (start == mmap_next_start)
+ mmap_next_start = (unsigned long)ptr + size;
+
+ return h2g(ptr);
}
/* NOTE: all the constants are the HOST ones */
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation
2008-12-03 11:29 [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
@ 2008-12-03 11:29 ` Kirill A. Shutemov
0 siblings, 0 replies; 72+ messages in thread
From: Kirill A. Shutemov @ 2008-12-03 11:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov
There are two different syscall names for the same goal.
On systems with sizeof(long) == 64 it calls newfstatat.
On systems with sizeof(long) == 32 it calls fstatat64.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
linux-user/syscall.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4065917..dc65a77 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -169,6 +169,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
#define __NR_sys_linkat __NR_linkat
#define __NR_sys_mkdirat __NR_mkdirat
#define __NR_sys_mknodat __NR_mknodat
+#define __NR_sys_newfstatat __NR_newfstatat
#define __NR_sys_openat __NR_openat
#define __NR_sys_readlinkat __NR_readlinkat
#define __NR_sys_renameat __NR_renameat
@@ -210,7 +211,8 @@ _syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
_syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
uid_t,owner,gid_t,group,int,flags)
#endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+ defined(__NR_fstatat64)
_syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname,
struct stat *,buf,int,flags)
#endif
@@ -241,6 +243,11 @@ _syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode)
_syscall4(int,sys_mknodat,int,dirfd,const char *,pathname,
mode_t,mode,dev_t,dev)
#endif
+#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \
+ defined(__NR_newfstatat)
+_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname,
+ struct stat *,buf,int,flags)
+#endif
#if defined(TARGET_NR_openat) && defined(__NR_openat)
_syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode)
#endif
@@ -3246,7 +3253,7 @@ static inline abi_long host_to_target_timespec(abi_ulong target_addr,
return 0;
}
-#ifdef TARGET_NR_stat64
+#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat)
static inline abi_long host_to_target_stat64(void *cpu_env,
abi_ulong target_addr,
struct stat *host_st)
@@ -3278,11 +3285,15 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
} else
#endif
{
+#if TARGET_LONG_BITS == 64
+ struct target_stat *target_st;
+#else
struct target_stat64 *target_st;
+#endif
if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0))
return -TARGET_EFAULT;
- memset(target_st, 0, sizeof(struct target_stat64));
+ memset(target_st, 0, sizeof(*target_st));
__put_user(host_st->st_dev, &target_st->st_dev);
__put_user(host_st->st_ino, &target_st->st_ino);
#ifdef TARGET_STAT64_HAS_BROKEN_ST_INO
@@ -5373,11 +5384,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+ (defined(__NR_fstatat64) || defined(__NR_newfstatat))
+#ifdef TARGET_NR_fstatat64
case TARGET_NR_fstatat64:
+#endif
+#ifdef TARGET_NR_newfstatat
+ case TARGET_NR_newfstatat:
+#endif
if (!(p = lock_user_string(arg2)))
goto efault;
+#ifdef __NR_fstatat64
ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4));
+#else
+ ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4));
+#endif
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg3, &st);
break;
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 72+ messages in thread
end of thread, other threads:[~2008-12-03 11:28 UTC | newest]
Thread overview: 72+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-13 10:10 [Qemu-devel] [PATCH] Add readahead syscall Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement sem* syscalls Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
2008-10-17 6:34 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Kirill A. Shutemov
2008-10-17 6:34 ` [Qemu-devel] [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables Kirill A. Shutemov
2008-11-01 9:33 ` [Qemu-devel] " Jan Kiszka
2008-11-01 10:27 ` Kirill A. Shutemov
2008-11-01 10:54 ` Jan Kiszka
2008-11-01 11:12 ` Kirill A. Shutemov
2008-11-01 11:16 ` Kirill A. Shutemov
2008-11-02 19:36 ` Jan Kiszka
2008-11-01 11:34 ` Laurent Desnogues
2008-11-01 10:06 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2008-10-27 13:08 ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space andrzej zaborowski
2008-10-27 15:48 ` Kirill A. Shutemov
2008-10-27 15:55 ` Andreas Schwab
2008-10-27 17:32 ` Kirill A. Shutemov
2008-10-27 19:37 ` andrzej zaborowski
2008-10-27 20:06 ` Kirill A. Shutemov
2008-11-10 3:30 ` andrzej zaborowski
2008-11-10 5:55 ` Kirill A. Shutemov
2008-11-10 12:45 ` andrzej zaborowski
2008-10-27 17:48 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2008-11-10 7:11 ` [Qemu-devel] [PATCH, v3] " Kirill A. Shutemov
2008-11-10 7:09 ` [Qemu-devel] [PATCH, v3] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
2008-10-14 4:04 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Vince Weaver
2008-10-14 5:22 ` Kirill A. Shutemov
2008-10-26 16:14 ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Vince Weaver
2008-10-27 17:49 ` [Qemu-devel] [PATCH, v2] " Kirill A. Shutemov
2008-11-01 16:51 ` Jamie Lokier
2008-11-01 16:55 ` Kirill A. Shutemov
2008-11-10 3:54 ` andrzej zaborowski
2008-11-10 6:07 ` Kirill A. Shutemov
2008-11-10 8:02 ` Jamie Lokier
2008-11-10 12:55 ` andrzej zaborowski
2008-11-10 14:38 ` Kirill A. Shutemov
2008-11-11 0:53 ` Jamie Lokier
2008-11-14 12:23 ` Kirill A. Shutemov
2008-11-14 12:51 ` Paul Brook
2008-11-14 13:08 ` Jamie Lokier
2008-11-14 13:51 ` Kirill A. Shutemov
2008-11-10 7:07 ` [Qemu-devel] [PATCH, v3] " Kirill A. Shutemov
2008-11-14 13:57 ` [Qemu-devel] [PATCH, v4] " Kirill A. Shutemov
2008-11-01 10:10 ` [Qemu-devel] [PATCH, v2] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
2008-11-10 13:03 ` andrzej zaborowski
2008-10-16 20:55 ` [Qemu-devel] [PATCH] Implement shm* syscalls + Implement sem* syscalls Martin Mohring
2008-10-17 4:09 ` Kirill A. Shutemov
2008-10-17 8:27 ` Martin Mohring
2008-10-17 10:12 ` Kirill A. Shutemov
2008-11-01 9:56 ` Aurelien Jarno
2008-11-01 10:08 ` Kirill A. Shutemov
2008-10-24 7:24 ` [Qemu-devel] Re: [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-10-13 21:09 ` [Qemu-devel] [PATCH] Implement msg* syscalls Aurelien Jarno
2008-10-13 15:53 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Aurelien Jarno
2008-10-13 18:48 ` Kirill A. Shutemov
2008-10-13 20:52 ` Aurelien Jarno
2008-10-13 21:09 ` Aurelien Jarno
2008-10-13 12:48 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Aurelien Jarno
2008-10-13 12:59 ` Kirill A. Shutemov
2008-10-13 13:10 ` Aurelien Jarno
-- strict thread matches above, loose matches on Subject: below --
2008-12-03 11:29 [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
2008-12-03 11:29 ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov
2008-10-08 18:54 [Qemu-devel] [PATCH] Add readahead syscall Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Implement sem* syscalls Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).