* [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd()
@ 2017-03-01 9:37 Laurent Vivier
2017-03-01 9:37 ` [Qemu-devel] [PATCH 1/2] linux-user: call fd_trans_target_to_host_data() for write() Laurent Vivier
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Laurent Vivier @ 2017-03-01 9:37 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier
This patch series byte-swap the uint64_t data stream
of a file-descriptor opened with eventfd().
It allows to pass more LTP test cases:
eventfd01 1 TPASS : counter value matches required
eventfd01 2 TPASS : read failed with EAGAIN as expected
eventfd01 3 TPASS : counter value matches required
eventfd01 4 TPASS : write failed with EAGAIN as expected
eventfd01 5 TPASS : read failed with EINVAL as expected
eventfd01 6 TPASS : write failed with EINVAL as expected
eventfd01 7 TPASS : write failed with EINVAL as expected
eventfd01 8 TPASS : fd is set in readfds
eventfd01 9 TPASS : fd is not set in readfds
eventfd01 10 TPASS : fd is set in writefds
eventfd01 11 TPASS : fd is not set in writefds
eventfd01 1 TPASS : counter value matches required
eventfd01 2 TPASS : read failed with EAGAIN as expected
eventfd01 3 TPASS : counter value matches required
eventfd01 4 TPASS : write failed with EAGAIN as expected
eventfd01 5 TPASS : read failed with EINVAL as expected
eventfd01 6 TPASS : write failed with EINVAL as expected
eventfd01 7 TPASS : write failed with EINVAL as expected
eventfd01 8 TPASS : fd is set in readfds
eventfd01 9 TPASS : fd is not set in readfds
eventfd01 10 TPASS : fd is set in writefds
eventfd01 11 TPASS : fd is not set in writefds
eventfd01 12 TPASS : counter value write from child successful
eventfd01 13 TCONF : eventfd01.c:642: eventfd support is not available in AIO subsystem
eventfd01 14 TCONF : eventfd01.c:647: eventfd support is not available in AIO subsystem
eventfd01 15 TCONF : eventfd01.c:652: eventfd support is not available in AIO subsystem
Laurent Vivier (2):
linux-user: call fd_trans_target_to_host_data() for write()
linux-user: fix eventfd
linux-user/syscall.c | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
--
2.9.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/2] linux-user: call fd_trans_target_to_host_data() for write()
2017-03-01 9:37 [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd() Laurent Vivier
@ 2017-03-01 9:37 ` Laurent Vivier
2017-03-01 9:37 ` [Qemu-devel] [PATCH 2/2] linux-user: fix eventfd Laurent Vivier
2017-04-25 16:32 ` [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd() Laurent Vivier
2 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2017-03-01 9:37 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier
As for sendmsg() or sendto(), we must call the target to
host data translator if it is defined. This is needed for
eventfd(): the write() syscall allows to add a value to
the internal counter, and so, it must be byte-swapped to
the host order.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index cec8428..b2b563e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7767,7 +7767,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
case TARGET_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
- ret = get_errno(safe_write(arg1, p, arg3));
+ if (fd_trans_target_to_host_data(arg1)) {
+ void *copy = g_malloc(arg3);
+ memcpy(copy, p, arg3);
+ ret = fd_trans_target_to_host_data(arg1)(copy, arg3);
+ if (ret >= 0) {
+ ret = get_errno(safe_write(arg1, copy, ret));
+ }
+ g_free(copy);
+ } else {
+ ret = get_errno(safe_write(arg1, p, arg3));
+ }
unlock_user(p, arg2, 0);
break;
#ifdef TARGET_NR_open
--
2.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/2] linux-user: fix eventfd
2017-03-01 9:37 [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd() Laurent Vivier
2017-03-01 9:37 ` [Qemu-devel] [PATCH 1/2] linux-user: call fd_trans_target_to_host_data() for write() Laurent Vivier
@ 2017-03-01 9:37 ` Laurent Vivier
2017-04-25 16:32 ` [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd() Laurent Vivier
2 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2017-03-01 9:37 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier
When a fd is opened using eventfd(), a read provides
a 64bit counter in the host byte order, and a
write increase the internal counter by the provided
64bit value.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b2b563e..2da8426 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7671,6 +7671,28 @@ static target_timer_t get_timer_id(abi_long arg)
return timerid;
}
+static abi_long swap_data_eventfd(void *buf, size_t len)
+{
+ uint64_t *counter = buf;
+ int i;
+
+ if (len < sizeof(uint64_t)) {
+ return -EINVAL;
+ }
+
+ for (i = 0; i < len; i += sizeof(uint64_t)) {
+ *counter = tswap64(*counter);
+ counter++;
+ }
+
+ return len;
+}
+
+static TargetFdTrans target_eventfd_trans = {
+ .host_to_target_data = swap_data_eventfd,
+ .target_to_host_data = swap_data_eventfd,
+};
+
/* do_syscall() should always have a single exit point at the end so
that actions, such as logging of syscall results, can be performed.
All errnos that do_syscall() returns must be -TARGET_<errcode>. */
@@ -11876,7 +11898,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#if defined(TARGET_NR_eventfd)
case TARGET_NR_eventfd:
ret = get_errno(eventfd(arg1, 0));
- fd_trans_unregister(ret);
+ fd_trans_register(ret, &target_eventfd_trans);
break;
#endif
#if defined(TARGET_NR_eventfd2)
@@ -11890,7 +11912,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
host_flags |= O_CLOEXEC;
}
ret = get_errno(eventfd(arg1, host_flags));
- fd_trans_unregister(ret);
+ fd_trans_register(ret, &target_eventfd_trans);
break;
}
#endif
--
2.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd()
2017-03-01 9:37 [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd() Laurent Vivier
2017-03-01 9:37 ` [Qemu-devel] [PATCH 1/2] linux-user: call fd_trans_target_to_host_data() for write() Laurent Vivier
2017-03-01 9:37 ` [Qemu-devel] [PATCH 2/2] linux-user: fix eventfd Laurent Vivier
@ 2017-04-25 16:32 ` Laurent Vivier
2017-05-19 13:34 ` Riku Voipio
2 siblings, 1 reply; 5+ messages in thread
From: Laurent Vivier @ 2017-04-25 16:32 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel
Ping?
Laurent
Le 01/03/2017 à 10:37, Laurent Vivier a écrit :
> This patch series byte-swap the uint64_t data stream
> of a file-descriptor opened with eventfd().
>
> It allows to pass more LTP test cases:
>
> eventfd01 1 TPASS : counter value matches required
> eventfd01 2 TPASS : read failed with EAGAIN as expected
> eventfd01 3 TPASS : counter value matches required
> eventfd01 4 TPASS : write failed with EAGAIN as expected
> eventfd01 5 TPASS : read failed with EINVAL as expected
> eventfd01 6 TPASS : write failed with EINVAL as expected
> eventfd01 7 TPASS : write failed with EINVAL as expected
> eventfd01 8 TPASS : fd is set in readfds
> eventfd01 9 TPASS : fd is not set in readfds
> eventfd01 10 TPASS : fd is set in writefds
> eventfd01 11 TPASS : fd is not set in writefds
> eventfd01 1 TPASS : counter value matches required
> eventfd01 2 TPASS : read failed with EAGAIN as expected
> eventfd01 3 TPASS : counter value matches required
> eventfd01 4 TPASS : write failed with EAGAIN as expected
> eventfd01 5 TPASS : read failed with EINVAL as expected
> eventfd01 6 TPASS : write failed with EINVAL as expected
> eventfd01 7 TPASS : write failed with EINVAL as expected
> eventfd01 8 TPASS : fd is set in readfds
> eventfd01 9 TPASS : fd is not set in readfds
> eventfd01 10 TPASS : fd is set in writefds
> eventfd01 11 TPASS : fd is not set in writefds
> eventfd01 12 TPASS : counter value write from child successful
> eventfd01 13 TCONF : eventfd01.c:642: eventfd support is not available in AIO subsystem
> eventfd01 14 TCONF : eventfd01.c:647: eventfd support is not available in AIO subsystem
> eventfd01 15 TCONF : eventfd01.c:652: eventfd support is not available in AIO subsystem
>
> Laurent Vivier (2):
> linux-user: call fd_trans_target_to_host_data() for write()
> linux-user: fix eventfd
>
> linux-user/syscall.c | 38 +++++++++++++++++++++++++++++++++++---
> 1 file changed, 35 insertions(+), 3 deletions(-)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd()
2017-04-25 16:32 ` [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd() Laurent Vivier
@ 2017-05-19 13:34 ` Riku Voipio
0 siblings, 0 replies; 5+ messages in thread
From: Riku Voipio @ 2017-05-19 13:34 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel
On Tue, Apr 25, 2017 at 06:32:30PM +0200, Laurent Vivier wrote:
> Ping?
Applied, thanks.
> Laurent
>
> Le 01/03/2017 à 10:37, Laurent Vivier a écrit :
> > This patch series byte-swap the uint64_t data stream
> > of a file-descriptor opened with eventfd().
> >
> > It allows to pass more LTP test cases:
> >
> > eventfd01 1 TPASS : counter value matches required
> > eventfd01 2 TPASS : read failed with EAGAIN as expected
> > eventfd01 3 TPASS : counter value matches required
> > eventfd01 4 TPASS : write failed with EAGAIN as expected
> > eventfd01 5 TPASS : read failed with EINVAL as expected
> > eventfd01 6 TPASS : write failed with EINVAL as expected
> > eventfd01 7 TPASS : write failed with EINVAL as expected
> > eventfd01 8 TPASS : fd is set in readfds
> > eventfd01 9 TPASS : fd is not set in readfds
> > eventfd01 10 TPASS : fd is set in writefds
> > eventfd01 11 TPASS : fd is not set in writefds
> > eventfd01 1 TPASS : counter value matches required
> > eventfd01 2 TPASS : read failed with EAGAIN as expected
> > eventfd01 3 TPASS : counter value matches required
> > eventfd01 4 TPASS : write failed with EAGAIN as expected
> > eventfd01 5 TPASS : read failed with EINVAL as expected
> > eventfd01 6 TPASS : write failed with EINVAL as expected
> > eventfd01 7 TPASS : write failed with EINVAL as expected
> > eventfd01 8 TPASS : fd is set in readfds
> > eventfd01 9 TPASS : fd is not set in readfds
> > eventfd01 10 TPASS : fd is set in writefds
> > eventfd01 11 TPASS : fd is not set in writefds
> > eventfd01 12 TPASS : counter value write from child successful
> > eventfd01 13 TCONF : eventfd01.c:642: eventfd support is not available in AIO subsystem
> > eventfd01 14 TCONF : eventfd01.c:647: eventfd support is not available in AIO subsystem
> > eventfd01 15 TCONF : eventfd01.c:652: eventfd support is not available in AIO subsystem
> >
> > Laurent Vivier (2):
> > linux-user: call fd_trans_target_to_host_data() for write()
> > linux-user: fix eventfd
> >
> > linux-user/syscall.c | 38 +++++++++++++++++++++++++++++++++++---
> > 1 file changed, 35 insertions(+), 3 deletions(-)
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-19 13:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-01 9:37 [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd() Laurent Vivier
2017-03-01 9:37 ` [Qemu-devel] [PATCH 1/2] linux-user: call fd_trans_target_to_host_data() for write() Laurent Vivier
2017-03-01 9:37 ` [Qemu-devel] [PATCH 2/2] linux-user: fix eventfd Laurent Vivier
2017-04-25 16:32 ` [Qemu-devel] [PATCH 0/2] linux-user: fix eventfd() Laurent Vivier
2017-05-19 13:34 ` Riku Voipio
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).