* [Qemu-devel] [PULL 0/1] linux-user: fix file offset for preadv/pwritev
@ 2018-04-10 2:17 Max Filippov
2018-04-10 2:17 ` [Qemu-devel] [PULL 1/1] linux-user: fix preadv/pwritev offsets Max Filippov
2018-04-10 11:48 ` [Qemu-devel] [PULL 0/1] linux-user: fix file offset for preadv/pwritev Peter Maydell
0 siblings, 2 replies; 6+ messages in thread
From: Max Filippov @ 2018-04-10 2:17 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Max Filippov, Riku Voipio, Laurent Vivier,
Richard Henderson
Hi Peter,
please pull the following linux-user fix for QEMU-2.12.
The following changes since commit 9abfc88af3ffd3b33c7fab4471da86462ee71d95:
Merge remote-tracking branch 'remotes/xtensa/tags/20180402-xtensa' into staging (2018-04-03 19:02:46 +0100)
are available in the git repository at:
git://github.com/OSLL/qemu-xtensa.git tags/20180409-xtensa
for you to fetch changes up to 9ac225171c9d6b2a1cba35a94ae7eeaa0106cf7d:
linux-user: fix preadv/pwritev offsets (2018-04-09 18:57:49 -0700)
----------------------------------------------------------------
Fix file offset for preadv/pwritev linux-user syscalls.
----------------------------------------------------------------
Max Filippov (1):
linux-user: fix preadv/pwritev offsets
linux-user/syscall.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 1/1] linux-user: fix preadv/pwritev offsets
2018-04-10 2:17 [Qemu-devel] [PULL 0/1] linux-user: fix file offset for preadv/pwritev Max Filippov
@ 2018-04-10 2:17 ` Max Filippov
2018-04-10 3:20 ` Richard Henderson
2018-04-10 11:48 ` [Qemu-devel] [PULL 0/1] linux-user: fix file offset for preadv/pwritev Peter Maydell
1 sibling, 1 reply; 6+ messages in thread
From: Max Filippov @ 2018-04-10 2:17 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Max Filippov, Riku Voipio, Laurent Vivier,
Richard Henderson
preadv/pwritev accept low and high parts of file offset in two separate
parameters. When host bitness doesn't match guest bitness these parts
must be appropriately recombined.
Introduce target_to_host_low_high that does this recombination and use
it in preadv/pwritev syscalls.
This fixes glibc testsuite test misc/tst-preadvwritev64.
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
linux-user/syscall.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 5ef517613577..0eab5cc6ade1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3386,6 +3386,23 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
return ret;
}
+/* Convert target low/high pair representing file offset into the host
+ * low/high pair. This function doesn't handle offsets bigger than 64 bits
+ * as the kernel doesn't handle them either.
+ */
+static void target_to_host_low_high(abi_ulong tlow,
+ abi_ulong thigh,
+ unsigned long *hlow,
+ unsigned long *hhigh)
+{
+ uint64_t off = tlow |
+ ((unsigned long long)thigh << TARGET_LONG_BITS / 2) <<
+ TARGET_LONG_BITS / 2;
+
+ *hlow = off;
+ *hhigh = (off >> HOST_LONG_BITS / 2) >> HOST_LONG_BITS / 2;
+}
+
static struct iovec *lock_iovec(int type, abi_ulong target_addr,
abi_ulong count, int copy)
{
@@ -10449,7 +10466,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
if (vec != NULL) {
- ret = get_errno(safe_preadv(arg1, vec, arg3, arg4, arg5));
+ unsigned long low, high;
+
+ target_to_host_low_high(arg4, arg5, &low, &high);
+ ret = get_errno(safe_preadv(arg1, vec, arg3, low, high));
unlock_iovec(vec, arg2, arg3, 1);
} else {
ret = -host_to_target_errno(errno);
@@ -10462,7 +10482,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
if (vec != NULL) {
- ret = get_errno(safe_pwritev(arg1, vec, arg3, arg4, arg5));
+ unsigned long low, high;
+
+ target_to_host_low_high(arg4, arg5, &low, &high);
+ ret = get_errno(safe_pwritev(arg1, vec, arg3, low, high));
unlock_iovec(vec, arg2, arg3, 0);
} else {
ret = -host_to_target_errno(errno);
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PULL 1/1] linux-user: fix preadv/pwritev offsets
2018-04-10 2:17 ` [Qemu-devel] [PULL 1/1] linux-user: fix preadv/pwritev offsets Max Filippov
@ 2018-04-10 3:20 ` Richard Henderson
2018-04-10 3:29 ` Max Filippov
0 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2018-04-10 3:20 UTC (permalink / raw)
To: Max Filippov, qemu-devel; +Cc: Peter Maydell, Riku Voipio, Laurent Vivier
On 04/10/2018 12:17 PM, Max Filippov wrote:
> + uint64_t off = tlow |
> + ((unsigned long long)thigh << TARGET_LONG_BITS / 2) <<
There's a second instance of long long here; needs uint64_t.
r~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PULL 1/1] linux-user: fix preadv/pwritev offsets
2018-04-10 3:20 ` Richard Henderson
@ 2018-04-10 3:29 ` Max Filippov
2018-04-10 4:05 ` Richard Henderson
0 siblings, 1 reply; 6+ messages in thread
From: Max Filippov @ 2018-04-10 3:29 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, Peter Maydell, Riku Voipio, Laurent Vivier
On Mon, Apr 9, 2018 at 8:20 PM, Richard Henderson
<richard.henderson@linaro.org> wrote:
> On 04/10/2018 12:17 PM, Max Filippov wrote:
>> + uint64_t off = tlow |
>> + ((unsigned long long)thigh << TARGET_LONG_BITS / 2) <<
>
> There's a second instance of long long here; needs uint64_t.
Ehh, will fix.
BTW, why is uint64_t here better than unsigned long long? Just
shorter?
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PULL 1/1] linux-user: fix preadv/pwritev offsets
2018-04-10 3:29 ` Max Filippov
@ 2018-04-10 4:05 ` Richard Henderson
0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2018-04-10 4:05 UTC (permalink / raw)
To: Max Filippov; +Cc: qemu-devel, Peter Maydell, Riku Voipio, Laurent Vivier
On 04/10/2018 01:29 PM, Max Filippov wrote:
> On Mon, Apr 9, 2018 at 8:20 PM, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>> On 04/10/2018 12:17 PM, Max Filippov wrote:
>>> + uint64_t off = tlow |
>>> + ((unsigned long long)thigh << TARGET_LONG_BITS / 2) <<
>>
>> There's a second instance of long long here; needs uint64_t.
>
> Ehh, will fix.
> BTW, why is uint64_t here better than unsigned long long? Just
> shorter?
Because it's more explicit about the number of bits we're talking about.
r~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PULL 0/1] linux-user: fix file offset for preadv/pwritev
2018-04-10 2:17 [Qemu-devel] [PULL 0/1] linux-user: fix file offset for preadv/pwritev Max Filippov
2018-04-10 2:17 ` [Qemu-devel] [PULL 1/1] linux-user: fix preadv/pwritev offsets Max Filippov
@ 2018-04-10 11:48 ` Peter Maydell
1 sibling, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2018-04-10 11:48 UTC (permalink / raw)
To: Max Filippov
Cc: QEMU Developers, Riku Voipio, Laurent Vivier, Richard Henderson
On 10 April 2018 at 03:17, Max Filippov <jcmvbkbc@gmail.com> wrote:
> Hi Peter,
>
> please pull the following linux-user fix for QEMU-2.12.
>
> The following changes since commit 9abfc88af3ffd3b33c7fab4471da86462ee71d95:
>
> Merge remote-tracking branch 'remotes/xtensa/tags/20180402-xtensa' into staging (2018-04-03 19:02:46 +0100)
>
> are available in the git repository at:
>
> git://github.com/OSLL/qemu-xtensa.git tags/20180409-xtensa
>
> for you to fetch changes up to 9ac225171c9d6b2a1cba35a94ae7eeaa0106cf7d:
>
> linux-user: fix preadv/pwritev offsets (2018-04-09 18:57:49 -0700)
>
> ----------------------------------------------------------------
> Fix file offset for preadv/pwritev linux-user syscalls.
>
> ----------------------------------------------------------------
> Max Filippov (1):
> linux-user: fix preadv/pwritev offsets
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-04-10 11:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10 2:17 [Qemu-devel] [PULL 0/1] linux-user: fix file offset for preadv/pwritev Max Filippov
2018-04-10 2:17 ` [Qemu-devel] [PULL 1/1] linux-user: fix preadv/pwritev offsets Max Filippov
2018-04-10 3:20 ` Richard Henderson
2018-04-10 3:29 ` Max Filippov
2018-04-10 4:05 ` Richard Henderson
2018-04-10 11:48 ` [Qemu-devel] [PULL 0/1] linux-user: fix file offset for preadv/pwritev Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.