qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Barcelo <abarcelo@ac.upc.edu>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Riku Voipio <riku.voipio@iki.fi>, Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] pwrite64 error because of argument position
Date: Sun, 30 Sep 2012 20:50:28 +0200	[thread overview]
Message-ID: <CAFKAgTcXrqmH+zo0FB_pYwNgduzUnixqfs2uek_wDLSkbNb27w@mail.gmail.com> (raw)

This error may be a PPC specific problem, but I don't have another
environment where I can test it (i386 doesn't seem to use pwrite64),
so I ask for a bit of help/check.

I am in a 32bit linux testing the qemu-ppc.

My test program:

// -------------------------------
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main (void) {
    int fd, len;

    char* asd = "This is a random test";
    char asd2[20];

    fd = open ("./test.pwrite", O_RDWR | O_CREAT);

    printf ( "fd: %d\n", fd);
    pwrite ( fd, asd, 15, 0 );
    pwrite ( fd, asd+5, 6, 10);
    pwrite ( fd, asd, 4, 30);

    len = pread ( fd, asd2, 5, 5);
    asd2[len]='\0';	
    printf ( "Read %d bytes: %s", len, asd2);

    // This is to force two int arguments for 64bit
    //len = pread ( fd, asd2, -1, -1);
    close(fd);
    return 0;
}
// -------------------------------

Then I do
$ powerpc-linux-gnu-gcc -g --static -o pwrite-alien pwrite-test.c

and when I launch a qemu-ppc to test, it should be (on the file)
This is a is a rThis

instead I get:
This rs a randorThis

and if I print some debug information inside pwrite64 and pread64 I see:
syscall: pwrite	arg_i: 3 268909324 15 0 0 0 0 0
syscall: pwrite	arg_i: 3 268909329 6 0 0 10 0 0
syscall: pwrite	arg_i: 3 268909324 4 0 0 30 0 0
syscall: pread	arg_i: 3 1082133156 5 0 0 5 0 0
(those are arg1, arg2, arg3, arg4, arg5, arg6 and the unused arg7 and arg8)

As can be seen, arg4 is not used, and the line
ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
should be, in my case
ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg5, arg6)));

With this changes, the qemu "Works For Me (TM)".

So, anybody can confirm it or (if it is indeed my problem) can give me
some pointers? I will not post this as a patch until I understand the
problem... and first step is making sure that it really is a qemu
problem. And not my toolchain or something random.

             reply	other threads:[~2012-09-30 18:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-30 18:50 Alex Barcelo [this message]
2012-10-01 11:52 ` [Qemu-devel] pwrite64 error because of argument position Alexander Graf
2012-10-01 16:57   ` Alex Barcelo
2012-10-01 16:59     ` Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFKAgTcXrqmH+zo0FB_pYwNgduzUnixqfs2uek_wDLSkbNb27w@mail.gmail.com \
    --to=abarcelo@ac.upc.edu \
    --cc=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).