Re: [Qemu-devel] RFC: x86_64 Best way to fix 'cast to pointer from integer of different size' problems?

2007-11-06 Thread Stuart Anderson
On Tue, 6 Nov 2007, Paul Brook wrote: If you're not careful you get double-copying. Once copying the struct from guest to host space, and then again when converting layout/endianess. Yes, it would be easy to do that by mistake. The approach that has been taken has been to use typed

Re: [Qemu-devel] RFC: x86_64 Best way to fix 'cast to pointer from integer of different size' problems?

2007-11-06 Thread Stuart Anderson
On Tue, 6 Nov 2007, Fabrice Bellard wrote: Paul Brook wrote: [...] Personally I like the locking interface as it allows a zero-copy implementation. However the kernel uses a copying interface, and my understanding is that other qemu maintainers also prefer the copying interface. At least I

Re: [Qemu-devel] Re: [PATCH] linux-user utimensat() syscall

2007-09-23 Thread Stuart Anderson
On Sun, 23 Sep 2007, Thiemo Seufer wrote: Thayne Harbaugh wrote: This patch adds the utimensat syscall to linux-user. Doesn't build: gcc-3.4 -g -Wl,-T,/home/ths/qemu/qemu-work/ppc.ld -o qemu-arm main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o elfload.o linuxload.o flatload.o

Re: [Qemu-devel] RFC: [0/11] EFAULT patch

2007-09-19 Thread Stuart Anderson
On Wed, 19 Sep 2007, J. Mayer wrote: The idea is great but there seem to be a problem in those patches: you directly cast syscall arguments, which are (or should be) target_ulong to pointers in the host environment. You should to use the g2h / h2g macros to get the pointer in the host memory

Re: [Qemu-devel] RFC: [0/11] EFAULT patch

2007-09-19 Thread Stuart Anderson
On Wed, 19 Sep 2007, J. Mayer wrote: Then, the changes you've done, changing long arguments (which should be target_long to be correct, you can take a look at the last patch I sent on the list) to pointers, for example in function prototypes, are incorrect. I just went, and looked at the

Re: [Qemu-devel] RFC: [0/11] EFAULT patch

2007-09-19 Thread Stuart Anderson
On Wed, 19 Sep 2007, Paul Brook wrote: No. We're doing more than most 32-64 syscall thunks. To a first approximation the syscall thunks can bindly zero extend all values. In qemu we need to know whether something is a pointer or a value. Isn't that was the code in do_syscall() does? or am I

[Qemu-devel] RFC: [0/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
Following this message, are the 11 parts of the patch that implements EFAULT detection in the linux-user mode. Hopefully, this reflects what was discussed following the first RFC of this patch. Also, hopefully, it is easier to digest in smaller pieces like this. In short, the (un)lock_user*()

[Qemu-devel] RFC: [1/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
This first part contains the additions to the existing infrastructure needed to implement the new interfaces used in the rest of the patch. In exec.c, page_check_range() has been added to take an address and a size and and check to see if it is contained in a valid page that belongs to the

[Qemu-devel] RCF: [2/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
In this section, the functions for reading and writing fdsets, reading rusage, and reading and writing timevals have been updated to use the new kernel like interfaces. Also, places where these function have been used are adjusted to match, this includes do_select(), and the do_syscall() code

[Qemu-devel] RFC: [3/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
This part contains the changes to teh socket interfaces. This includes updates to the functions for reading and writing struct sockaddr, as well as updates and some fixes to do_setsockopt() and do_getsockopt(). The implementations of bind() connect(), accept(), getpeername() and getsockname()

[Qemu-devel] RFC: [4/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
This part contains the updates for the semaphore IPC syscalls. In addition to the changes to use the new APIs, there are also fixes for some of the semop() and semctl() actions. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network

[Qemu-devel] RFC: [5/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
This part contains the changes to the message queue IPC syscalls. The functions for reading and writing the msqid_ds structure have been updated to use the kernel-like APIs. Also, additional checking has been added to the implementations of msgsnd() and msgrecv().

[Qemu-devel] RFC: [6/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
This part contains the changes to write_ldt() to use the newer APIs. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software Engineering http://www.netsweng.com/ 1024D/37A79149:

[Qemu-devel] RFC: [7/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
This part updates do_fcntl() to use the new kernel-like APIs. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software Engineering http://www.netsweng.com/ 1024D/37A79149:

[Qemu-devel] RFC: [9/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
Thsi part updates stat(64)fs and fstat(64)fs implementations to use the new APIs in a more optimal manner. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software Engineering http://www.netsweng.com/

[Qemu-devel] RFC: [10/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
This part contains the rest of the updates to do_syscall() that contain the changes to the new API for several systcalls, including utime(), sigaction(), rt_sigaction(), rt_sigpending(), sigsuspend(), rt_sigtimedwait(), rt_sigqueueinfo(), stat() and stat64().

[Qemu-devel] RFC: [11/11] EFAULT patch

2007-09-18 Thread Stuart Anderson
Last, but not least, this part contains the changes to the function that read and write iovec structures. This part will require one more pass to eliminate the inner calls to the old API. Stuart Stuart R. Anderson [EMAIL PROTECTED]

[Qemu-devel] [PATCH] linux-user discrete IPC calls

2007-07-20 Thread Stuart Anderson
At least armel implements discreet IPC calls instead of multiplexing them through a single syscall. This patch adds support for this. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software Engineering

Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation

2007-07-11 Thread Stuart Anderson
On Tue, 10 Jul 2007, Fabrice Bellard wrote: I confirm that I expected g2h() to be completely removed in case the Linux user access API is used. I agree too that it should not be used. I'm testing ARM on x86_64, and used it in a few places to clean up some warnings. The real fix is to change

Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation

2007-07-09 Thread Stuart Anderson
On Fri, 6 Jul 2007, Stuart Anderson wrote: So, the question is: Can I simplify this code to assume that guest and host addresses coexist and use the copy_*_user() or just the access_ok() interfaces? Attached is a diff that shows what this will look like for the struct

Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation

2007-07-09 Thread Stuart Anderson
On Mon, 9 Jul 2007, Stuart Anderson wrote: Attached is a diff ... Here's the diff. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software Engineering http://www.netsweng.com/ 1024D/37A79149

[Qemu-devel] [PATCH] tkill

2007-07-06 Thread Stuart Anderson
This small patch implements tkill(). It parallels the tgkill() implementation that was added recently. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software Engineering http://www.netsweng.com/

Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation

2007-07-06 Thread Stuart Anderson
On Fri, 6 Jul 2007, Fabrice Bellard wrote: Please update page_check_range() (and other related functions) to return -EFAULT instead of EFAULT in case of error. Will do. Moreover, I believe using similar functions as Linux for memory access (copyfromuser, copytouser, get_user, put_user)

Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation

2007-07-06 Thread Stuart Anderson
On Fri, 6 Jul 2007, Stuart Anderson wrote: Moreover, I believe using similar functions as Linux for memory access (copyfromuser, copytouser, get_user, put_user) would be cleaner. This makes sense. That code that I sent was based on the idea that I was just extending the model that was already

Re: [Qemu-devel] [PATCH] linux-user semaphore structure mapping

2007-06-02 Thread Stuart Anderson
On Fri, 1 Jun 2007, Thiemo Seufer wrote: Stuart Anderson wrote: This is a refresh (vs 5/28 cvs) of a patch sent several weeks ago. This patch implments the structure handling for the semaphore IPC related structures used by semctl(). It produces too many compiler warnings to be comfortable

Re: [Qemu-devel] [PATCH] linux-user semaphore structure mapping

2007-06-01 Thread Stuart Anderson
On Fri, 1 Jun 2007, Thiemo Seufer wrote: Stuart Anderson wrote: This is a refresh (vs 5/28 cvs) of a patch sent several weeks ago. This patch implments the structure handling for the semaphore IPC related structures used by semctl(). This was tested using LTP on an ARM target. Were

Re: [Qemu-devel] [PATCH] message queue IPC structures

2007-06-01 Thread Stuart Anderson
On Fri, 1 Jun 2007, Thiemo Seufer wrote: Stuart Anderson wrote: This is a refresh (vs 05/28 cvs) of a patch sent several weeks ago. This patch implements the structure handling for the structures used by the Message queue IPC interfaces msgctl(), msgrcv() and msgsnd(). This was tested using

Re: [Qemu-devel] [PATCH] mips-linux-user errno mapping

2007-05-31 Thread Stuart Anderson
On Thu, 31 May 2007, Thiemo Seufer wrote: Please clean up the compiler warnings. This one ist just the most obvious, I also see many more of the form: Sorry. I missed those in the noise caused by another, yet to be completed patch, which is also in my patch stack. Attached is the cleaned up

[Qemu-devel] [PATCH] mips-linux-user errno mapping

2007-05-30 Thread Stuart Anderson
The linux user code was completely missing the ability to map errnos from the host to the target. This patch adds this ability, with the mapping needed for MIPS. With this patch, an appreciable number of the tests in LTP now PASS (remaining failures are due to other bugs not yet fixed).

[Qemu-devel] [mips-linux-user] patch for struct stat mapping

2007-05-29 Thread Stuart Anderson
The code that maps struct stat is wrong for MIPS. It uses the wrong sized calls (16 vs 32) for swapping some of the structure members. A patch to fix this is attached. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software

[Qemu-devel] [PATCH] linux-user semaphore structure mapping

2007-05-29 Thread Stuart Anderson
This is a refresh (vs 5/28 cvs) of a patch sent several weeks ago. This patch implments the structure handling for the semaphore IPC related structures used by semctl(). This was tested using LTP on an ARM target. Were there any objections to this patch?

[Qemu-devel] [PATCH] message queue IPC structures

2007-05-29 Thread Stuart Anderson
This is a refresh (vs 05/28 cvs) of a patch sent several weeks ago. This patch implements the structure handling for the structures used by the Message queue IPC interfaces msgctl(), msgrcv() and msgsnd(). This was tested using LTP on an ARM target. Stuart

[Qemu-devel] [mips-linux-user] patch for pipe() result handling

2007-05-29 Thread Stuart Anderson
pipe(2) on MIPS does some funny, non-standard stuff with it's return data. This patch implments this unusual handling. Without this patch, bash closes it's own stdin by mistake and therefore exits immediately after presenting the prompt. The LTP test results for the pipe() tests are improved

Re: [Qemu-devel] linux-user target

2007-04-19 Thread Stuart Anderson
On Thu, 19 Apr 2007, J. Mayer wrote: And I checked the code generated on my machine. I got the repz at the end of the op_goto_tb0 and op_goto_tb1 and it seems to work well here with the bash version I got. IIrc from yesterday, they ended up in front of lea instuctions, which I think always

Re: [Qemu-devel] linux-user target

2007-04-18 Thread Stuart Anderson
On Tue, 17 Apr 2007, Stuart Anderson wrote: I've continued to work on this all week, and I still haven't managed to solve it. I've chased down a lot of paths, but none of them have lead to a solution. Here is a summary of the situation now. * programs other than bash will run * bash --version

Re: [Qemu-devel] [PATCH] PPC termios structure ordering

2007-04-18 Thread Stuart Anderson
On Wed, 18 Apr 2007, J. Mayer wrote: With this change, both host and target 'stty -a' give the same output. Thanks. I'll take a better look to this patch then apply. There maybe the same issue in the ppc64 strucutre ? Yes, it looks like the same changes it needed in

Re: [Qemu-devel] linux-user target

2007-04-18 Thread Stuart Anderson
On Wed, 18 Apr 2007, J. Mayer wrote: You're right: I think all TLS specific code is located in the glibc. In my last tracing through qemu.log, I did check for r2 references, and there was one store near the beginning that looked like what glibc would do (r2 = ptr+0x700), and the rest of the

Re: [Qemu-devel] linux-user target

2007-04-18 Thread Stuart Anderson
On Wed, 18 Apr 2007, Igor Kovalenko wrote: This should be solved for x86_64 host with -mtune=nocona patch posted a while ago. I'll go dig that up. The problem is with dyngen being confused by repz retq sequence. That's what caught my attention earlier today. It was only showing up in two

Re: [Qemu-devel] linux-user target

2007-04-18 Thread Stuart Anderson
On Thu, 19 Apr 2007, Igor Kovalenko wrote: as discussed before, to do this in dyngen you need to know the context better or you'll skip more than intended; that amounts to moving a large bit of decoder there as far as I understand that Yes, it was a quick hack along w/ visual inspection of

[Qemu-devel] [PATCH] PPC termios structure ordering

2007-04-17 Thread Stuart Anderson
Just found a small problem w/ the termios structure as defined for PPC linux user. It doesn't match the one in include/asm-powerpc/termbits.h. Index: linux-user/ppc/termbits.h === --- linux-user/ppc/termbits.h (revision 44) +++

Re: [Qemu-devel] linux-user target

2007-04-17 Thread Stuart Anderson
On Tue, 10 Apr 2007, Jocelyn Mayer wrote: PPC: I am unable to get any executable to run. projects:~/upstream/qemu# ./ppc-linux-user/qemu-ppc -L /mirror0/chroots/ppc/ /mirror0/chroots/ppc/bin/bash init_ppc_proc: PVR 0008 mask = 0008 Segmentation fault

[Qemu-devel] (no subject)

2007-04-10 Thread Stuart Anderson
I'm trying to test my fixes to the linux-user emulation on some additonal architectures now, but I'm running into problems. I can debug these some, but any suggestions or guidence, especially from people more familiar with the architecture core code, would be appreciated. The environment is a

Re: [Qemu-devel] linux-user target

2007-04-10 Thread Stuart Anderson
On Tue, 10 Apr 2007, Jocelyn Mayer wrote: Just checked, on an amd64 host with a random powerpc bash version I got on my hard disk drive: I also tried to really launch the shell and use it and it worked. Interesting... But I think recent builds using glibc with TLS/NPTL would not run. Ahh.

Re: [Qemu-devel] [PATCH] semaphore syscalls - refresh

2007-03-31 Thread Stuart Anderson
On Sat, 31 Mar 2007, Thiemo Seufer wrote: +switch( cmd ) { + case GETALL: + case SETALL: + case IPC_STAT: + case IPC_SET: + lock_user_struct(target_su, target_addr, 1); + target_to_host_semid_ds(ds,target_su-buf); + host_su-buf = ds; +

Re: [Qemu-devel] [PATCH] clone syscall fix

2007-03-31 Thread Stuart Anderson
On Sat, 31 Mar 2007, Thiemo Seufer wrote: Stuart Anderson wrote: Even though clone() and fork() are related, they don't seem to be close enough to allow a single routine to be used to implement both. With this patch, the LTP tests for clone now pass. But it still does the same, assuming

[Qemu-devel] [PATCH] semaphore syscalls - refresh

2007-03-29 Thread Stuart Anderson
This is a refresh of a prior patch to fix the semaphore system calls sem*() in user-linux mode. Some additional cases have been dealt with, and a small amount of code re-arrainging to prepare for the EFAULT patch. Tested using Linux Test Project in the target.

[Qemu-devel] [PATCH] message queue fixes - refresh

2007-03-29 Thread Stuart Anderson
Here is a refresh of the message queue syscall (msg*()) fixes. These are analgous to the just posted sempahore fixes. Tested with LTP on the target. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software Engineering

[Qemu-devel] [PATCH] clone syscall fix

2007-03-29 Thread Stuart Anderson
Even though clone() and fork() are related, they don't seem to be close enough to allow a single routine to be used to implement both. With this patch, the LTP tests for clone now pass. It may be possible to fold this back into do_fork(), but this just seemed to be a little bit more

[Qemu-devel] [PATCH] signal syscall fixes

2007-03-29 Thread Stuart Anderson
This patch fixes a couple of problems with signals(). The first fix, in cpu-exec.c, is needed for the case where a process does a kill(SIGSEGV) on itself (as is done in a test suite). This fix for ARM is similar to what is done for some of the other architectures. I'm not 100% certain this is

[Qemu-devel] [PATCH] EFAULT refresh

2007-03-29 Thread Stuart Anderson
Here is a refresh of the EFAULT patch. This fixes a lot of crashes in LTP, and presumably in regular applications too. This still needs to have the checking foldded into lock_user(), but there were a handful of small fixes since this patch was last sent out.

Re: [Qemu-devel] generating EFAULT in linux-user

2007-03-23 Thread Stuart Anderson
Here is an updated patch that show more of the changes that are needed to detect EFAULT situations in linux-user. The areas I focused on are the socket, semaphore, and message queue family of syscalls as they all make interesting use of pointers to structures. This patch does sit on top of the

[Qemu-devel] generating EFAULT in linux-user

2007-03-22 Thread Stuart Anderson
With a little help from Paul yesterday, I was able to come up with a scheme for detecting bad pointers passed to system calls in linux-user mode. This is used to return EFAULT as would be done on a real kernel. The attached patch is very preliminary, but shows how it can be done. I'm sending it

[Qemu-devel] [PATCH] Refresh of sem* implementation

2007-03-22 Thread Stuart Anderson
Attached is a refreshed patch w/ a couple of additional fixes. This patch provides an implementation of semaphore interfaces (semget(), semctl(), semop()) that consists mostly of the structure mapping needed for 32 bit guest on 64 host such as arm on x86_64.

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-21 Thread Stuart Anderson
On Wed, 21 Mar 2007, Kirill A. Shutemov wrote: Primarily, I also thought that problem is in padding, because, without the patch F_GETLK, on 32-bit target recognises as F_GETLK64 on 64-bit host. It's happen because on 64-bit host and 32-bit target F_GETLK == F_GETLK64 == TARGET_F_GETLK. So if

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-21 Thread Stuart Anderson
On Tue, 20 Mar 2007, Paul Brook wrote: Now that the dust has settled, I see where the change is probably a no-op anyway. A quick little test program indicates that on x86_64, l_start will have an offset of 8 wether the structure is packed or not, and wether the __pad member is present or not.

[Qemu-devel] [PATCH] message queue completion

2007-03-21 Thread Stuart Anderson
Like the semaphore patch a couple of days ago, this patch completes the implementation of the message queue syscalls. With this patch, most of the message queue tests in LTP now pass in the guest. The remaining ones will require fixes in other syscall to fix, or at least eliminate the noise to

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-20 Thread Stuart Anderson
On Tue, 20 Mar 2007, Kirill A. Shutemov wrote: Kiril, What 32 bit host and 64 bit host are you using? I'm working on arm on x86_64, and I'm starting to think that perhaps all of the different parts of the fix are needed to ensure it works correctly on all target/host combinations.

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-20 Thread Stuart Anderson
On Tue, 20 Mar 2007, Kirill A. Shutemov wrote: What are you using as a test app? I got error when runing Debian's apt-get and tried to fix it. OK, that's what got me started on this one, but I switched to using the ltp-kernel-test package for a more comprehensive set of tests once I got

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-20 Thread Stuart Anderson
On Tue, 20 Mar 2007, Kirill A. Shutemov wrote: No. Remap is needed: $ uname -m; echo -e '#include fcntl.h\nF_GETLK64' | cpp | tail -1 x86_64 5 $ uname -m; echo -e '#include fcntl.h\nF_GETLK64' | cpp | tail -1 armv5l 12 Same for F_SETLK64 and F_SETLKW64. You are right. I had previously

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-20 Thread Stuart Anderson
OK, I think I finally have it all sorted out. Sorry if I sounded dense along the way.. there were multiple variable, which increases the number of possible combinations quickly. The patch from Kirill is needed, and makes things better. One thing I notice with it is that we now handle

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-20 Thread Stuart Anderson
On Tue, 20 Mar 2007, Thiemo Seufer wrote: Still, this part makes no sense to me since it is in a packed struct. Can you explain why this works better for you? It worked better, in that it fixed a problem that let me continue on to fix other issues. After revisiting fcntl() and coming up with

[Qemu-devel] [PATCH] Correct setuid behavious in linux-user

2007-03-19 Thread Stuart Anderson
The attached patch is needed to correctly emulate setuid executables. With this change, and by making qemu be setuid root (and assumming all of the risks and responsibilites of doing so), executables such as /bin/su will be able to create the correct environment.

[Qemu-devel] [PATCH] EABI fcntl on x86_64

2007-03-19 Thread Stuart Anderson
When running ARM EABI binaries on x86_64, the target_eabi_flock64 structure is already padded correct so the padding is not needed. This patch adds an #ifdef to only include the _pad member on 32-but hosts. Stuart Stuart R. Anderson

Re: [Qemu-devel] [PATCH] EABI fcntl on x86_64

2007-03-19 Thread Stuart Anderson
On Mon, 19 Mar 2007, Paul Brook wrote: On Monday 19 March 2007 15:30, Stuart Anderson wrote: When running ARM EABI binaries on x86_64, the target_eabi_flock64 structure is already padded correct so the padding is not needed. This patch adds an #ifdef to only include the _pad member on 32

[Qemu-devel] [PATCH] semctl support is incomplete

2007-03-19 Thread Stuart Anderson
The attached patch finishes adding support for semctl(). This was verified on ARM using the semctl test from LTP in the target. Stuart Stuart R. Anderson [EMAIL PROTECTED] Network Software Engineering

Re: [Qemu-devel] [PATCH] EABI fcntl on x86_64

2007-03-19 Thread Stuart Anderson
On Mon, 19 Mar 2007, Stuart Anderson wrote: I have a debian arm chroot setup. Just to clarify, this is from the applieddata.net repository, not the normal debian one (which is not eabi). Stuart Stuart R. Anderson [EMAIL

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-19 Thread Stuart Anderson
My initial fix was before I started using LTP, and just took care of a single case that was holding me up. Now I have run the fcntl tests in LTP on ARM (both oABI and EABI) and there are a lot of failures indicating that there is a lot more work to be done yet on fcntl(). I'll take a look into

Re: [Qemu-devel] [PATCH] fcntl64 fix

2007-03-19 Thread Stuart Anderson
On Mon, 19 Mar 2007, Stuart Anderson wrote: My initial fix was before I started using LTP, and just took care of a single case that was holding me up. Now I have run the fcntl tests in LTP on ARM (both oABI and EABI) and there are a lot of failures indicating that there is a lot more work