From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <laurent@vivier.eu>
Cc: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>,
riku.voipio@iki.fi, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4] linux-user: ppc64: use the correct values for F_*LK64s
Date: Sat, 14 Jul 2018 19:26:32 +1000 [thread overview]
Message-ID: <20180714092632.GB2599@umbus.fritz.box> (raw)
In-Reply-To: <eb7a52ea-57ce-46eb-c84e-96b5887d6e71@vivier.eu>
[-- Attachment #1: Type: text/plain, Size: 3321 bytes --]
On Sat, Jul 14, 2018 at 07:37:43AM +0200, Laurent Vivier wrote:
> Le 14/07/2018 à 03:07, David Gibson a écrit :
> > On Fri, Jul 13, 2018 at 07:34:46AM -0500, Shivaprasad G Bhat wrote:
> >> Qemu includes the glibc headers for the host defines and target headers are
> >> part of the qemu source themselves. The glibc has the F_GETLK64, F_SETLK64
> >> and F_SETLKW64 defined to 12, 13 and 14 for all archs in
> >> sysdeps/unix/sysv/linux/bits/fcntl-linux.h. The linux kernel generic
> >> definition for F_*LK is 5, 6 & 7 and F_*LK64* is 12,13, and 14 as seen in
> >> include/uapi/asm-generic/fcntl.h. On 64bit machine, by default the kernel
> >> assumes all F_*LK to 64bit calls and doesnt support use of F_*LK64* as
> >> can be seen in include/linux/fcntl.h in linux source.
> >>
> >> On x86_64 host, the values for F_*LK64* are set to 5, 6 and 7
> >> explicitly in /usr/include/x86_64-linux-gnu/bits/fcntl.h by the glibc.
> >> Whereas, a PPC64 host doesn't have such a definition in
> >> /usr/include/powerpc64le-linux-gnu/bits/fcntl.h by the glibc. So,
> >> the sources on PPC64 host sees the default value of F_*LK64*
> >> as 12, 13 & 14(fcntl-linux.h).
> >>
> >> Since the 64bit kernel doesnt support 12, 13 & 14; the glibc fcntl syscall
> >> implementation(__libc_fcntl*(), __fcntl64_nocancel) does the F_*LK64* value
> >> convertion back to F_*LK* values on PPC64 as seen in
> >> sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h with FCNTL_ADJUST_CMD()
> >> macro. Whereas on x86_64 host the values for F_*LK64* are set to 5, 6 and 7
> >> and no adjustments are needed.
> >>
> >> Since qemu doesnt use the glibc fcntl, but makes the safe_syscall* on its
> >> own, the PPC64 qemu is calling the syscall with 12, 13, and 14(without
> >> adjustment) and they all fail. The fcntl calls to F_GETLK/F_SETLK|W all
> >> fail by all pplications run on PPC64 host user emulation.
> >>
> >> The fix here could be to see why on PPC64 the glibc is still keeping
> >> F_*LK64* different from F_*LK and why adjusting them to 5, 6 and 7 before
> >> the syscall for PPC only. See if we can make the
> >> /usr/include/powerpc64le-linux-gnu/bits/fcntl.h to have the values
> >> 5, 6 & 7 just like x86_64 and remove the adjustment code in glibc. That
> >> way, qemu sources see the kernel supported values in glibc headers.
> >>
> >> OR
> >>
> >> On PPC64 host, qemu sources see both F_*LK & F_*LK64* as same and set to
> >> 12, 13 and 14 because __USE_FILE_OFFSET64 is defined in qemu
> >> sources(also refer sysdeps/unix/sysv/linux/bits/fcntl-linux.h).
> >> Do the value adjustment just like it is done by glibc source by using
> >> F_GETLK value of 5. That way, we make the syscalls with the actual
> >> supported values in Qemu. The patch is taking this approach.
> >>
> >> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
> >
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> >
> > I'm not sure if this should go in through my tree or not.
>
> I will take it through my linux-user tree, I have some fixes to send for
> the next -rc.
Great, thanks.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2018-07-14 9:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-13 12:34 [Qemu-devel] [PATCH v4] linux-user: ppc64: use the correct values for F_*LK64s Shivaprasad G Bhat
2018-07-13 12:37 ` Laurent Vivier
2018-07-14 1:07 ` David Gibson
2018-07-14 5:37 ` Laurent Vivier
2018-07-14 9:26 ` David Gibson [this message]
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=20180714092632.GB2599@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=sbhat@linux.vnet.ibm.com \
/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).