* [Qemu-devel] [PATCH] linux-user: Add random ioctls
@ 2017-10-04 22:06 Marco A L Barbosa
2017-10-05 7:12 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
0 siblings, 1 reply; 5+ messages in thread
From: Marco A L Barbosa @ 2017-10-04 22:06 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
I don't know how (and if it is necessary) to add buf field to
rand_pool_info struct. See
https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/include/uapi/linux/random.h#L17
Signed-off-by: Marco A L Barbosa <malbarbo@gmail.com>
---
linux-user/ioctls.h | 7 +++++++
linux-user/syscall.c | 1 +
linux-user/syscall_defs.h | 9 +++++++++
linux-user/syscall_types.h | 4 ++++
4 files changed, 21 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index e6997ff230..9240a83f30 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -173,6 +173,13 @@
IOCTL(SIOCGSTAMP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval)))
IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))
+ IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT))
+ IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rand_pool_info)))
+ IOCTL(RNDGETPOOL, IOC_R, MK_PTR(TYPE_INT))
+ IOCTL(RNDADDENTROPY, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rand_pool_info)))
+ IOCTL(RNDZAPENTCNT, 0, TYPE_NULL)
+ IOCTL(RNDCLEARPOOL, 0, TYPE_NULL)
+
IOCTL(CDROMPAUSE, 0, TYPE_NULL)
IOCTL(CDROMSTART, 0, TYPE_NULL)
IOCTL(CDROMSTOP, 0, TYPE_NULL)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9b6364a266..d4c21a557c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -59,6 +59,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
#include <linux/icmp.h>
#include <linux/icmpv6.h>
#include <linux/errqueue.h>
+#include <linux/random.h>
#include "qemu-common.h"
#ifdef CONFIG_TIMERFD
#include <sys/timerfd.h>
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 40c5027e93..d14fdd82ce 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1060,6 +1060,15 @@ struct target_pollfd {
#define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless
protocol */
+/* From <linux/random.h> */
+
+#define TARGET_RNDGETENTCNT TARGET_IOR('R', 0x00, int)
+#define TARGET_RNDADDTOENTCNT TARGET_IOW('R', 0x01, int)
+#define TARGET_RNDGETPOOL TARGET_IOR('R', 0x02, struct rand_pool_info)
+#define TARGET_RNDADDENTROPY TARGET_IOW('R', 0x03, struct rand_pool_info)
+#define TARGET_RNDZAPENTCNT TARGET_IO('R', 0x04)
+#define TARGET_RNDCLEARPOOL TARGET_IO('R', 0x06)
+
/* From <linux/fs.h> */
#define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 =
read-write) */
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 24631b09be..2e2e000424 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -266,3 +266,7 @@ STRUCT(blkpg_ioctl_arg,
TYPE_INT, /* flags */
TYPE_INT, /* datalen */
TYPE_PTRVOID) /* data */
+
+STRUCT(rand_pool_info,
+ TYPE_INT, /* entropy_count */
+ TYPE_INT) /* buf_size */
--
2.11.0
--
Marco A L Barbosa
http://malbarbo.pro.br
--
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] linux-user: Add random ioctls
2017-10-04 22:06 [Qemu-devel] [PATCH] linux-user: Add random ioctls Marco A L Barbosa
@ 2017-10-05 7:12 ` Laurent Vivier
2017-10-05 10:24 ` Marco A L Barbosa
0 siblings, 1 reply; 5+ messages in thread
From: Laurent Vivier @ 2017-10-05 7:12 UTC (permalink / raw)
To: Marco A L Barbosa, qemu-devel; +Cc: qemu-trivial
On 05/10/2017 00:06, Marco A L Barbosa wrote:
> I don't know how (and if it is necessary) to add buf field to
> rand_pool_info struct. See
> https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/include/uapi/linux/random.h#L17
I doesn't look really trivial...
To manage the buf field you must read buf_size and it cannot be done in
a generic way: you must define a function to translate the buffer, use
IOCTL_SPECIAL() with RNDADDENTROPY and RNDGETPOOL.
You should send your patch using "git send-email" or "git publish"
instead of adding it in you email client.
> Signed-off-by: Marco A L Barbosa <malbarbo@gmail.com
> <mailto:malbarbo@gmail.com>>
> ---
> linux-user/ioctls.h | 7 +++++++
> linux-user/syscall.c | 1 +
> linux-user/syscall_defs.h | 9 +++++++++
> linux-user/syscall_types.h | 4 ++++
> 4 files changed, 21 insertions(+)
>
> diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
> index e6997ff230..9240a83f30 100644
> --- a/linux-user/ioctls.h
> +++ b/linux-user/ioctls.h
> @@ -173,6 +173,13 @@
> IOCTL(SIOCGSTAMP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval)))
> IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))
>
> + IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT))
> + IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rand_pool_info)))
..., MK_PTR(TYPE_INT)
> + IOCTL(RNDGETPOOL, IOC_R, MK_PTR(TYPE_INT))
... MK_PTR(MK_STRUCT(STRUCT_rand_pool_info))
Thanks,
Laurent
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] linux-user: Add random ioctls
2017-10-05 7:12 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
@ 2017-10-05 10:24 ` Marco A L Barbosa
2017-10-05 10:35 ` Laurent Vivier
0 siblings, 1 reply; 5+ messages in thread
From: Marco A L Barbosa @ 2017-10-05 10:24 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, qemu-trivial
>
> I doesn't look really trivial...
>
> To manage the buf field you must read buf_size and it cannot be done in
> a generic way: you must define a function to translate the buffer, use
> IOCTL_SPECIAL() with RNDADDENTROPY and RNDGETPOOL.
>
> You should send your patch using "git send-email" or "git publish"
> instead of adding it in you email client.
>
Thanks for your advices.
My use case only requires support for RNDGETENTCNT... Considering that
RNDADDENTROPY and RNDGETPOOL are non trivial, would a patch with only
RNDGETENTCNT, RNDADDTOENTCNT, RNDZAPENTCNT and RNDCLEARPOOL be accepted?
Note: I swapped the types of RNDADDTOENTCNT and RNDGETPOOL...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] linux-user: Add random ioctls
2017-10-05 10:24 ` Marco A L Barbosa
@ 2017-10-05 10:35 ` Laurent Vivier
2017-10-05 13:22 ` Marco A L Barbosa
0 siblings, 1 reply; 5+ messages in thread
From: Laurent Vivier @ 2017-10-05 10:35 UTC (permalink / raw)
To: Marco A L Barbosa; +Cc: qemu-devel, qemu-trivial
On 05/10/2017 12:24, Marco A L Barbosa wrote:
> I doesn't look really trivial...
>
> To manage the buf field you must read buf_size and it cannot be done in
> a generic way: you must define a function to translate the buffer, use
> IOCTL_SPECIAL() with RNDADDENTROPY and RNDGETPOOL.
>
> You should send your patch using "git send-email" or "git publish"
> instead of adding it in you email client.
>
>
> Thanks for your advices.
>
> My use case only requires support for RNDGETENTCNT... Considering that
> RNDADDENTROPY and RNDGETPOOL are non trivial, would a patch with only
> RNDGETENTCNT, RNDADDTOENTCNT, RNDZAPENTCNT and RNDCLEARPOOL be accepted?
I think you can only post what you use. If it is tested, it's better...
Thanks,
Laurent
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] linux-user: Add random ioctls
2017-10-05 10:35 ` Laurent Vivier
@ 2017-10-05 13:22 ` Marco A L Barbosa
0 siblings, 0 replies; 5+ messages in thread
From: Marco A L Barbosa @ 2017-10-05 13:22 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, qemu-trivial
I submitted a new patch. Thanks.
On Thu, Oct 5, 2017 at 7:35 AM, Laurent Vivier <lvivier@redhat.com> wrote:
> On 05/10/2017 12:24, Marco A L Barbosa wrote:
> > I doesn't look really trivial...
> >
> > To manage the buf field you must read buf_size and it cannot be done
> in
> > a generic way: you must define a function to translate the buffer,
> use
> > IOCTL_SPECIAL() with RNDADDENTROPY and RNDGETPOOL.
> >
> > You should send your patch using "git send-email" or "git publish"
> > instead of adding it in you email client.
> >
> >
> > Thanks for your advices.
> >
> > My use case only requires support for RNDGETENTCNT... Considering that
> > RNDADDENTROPY and RNDGETPOOL are non trivial, would a patch with only
> > RNDGETENTCNT, RNDADDTOENTCNT, RNDZAPENTCNT and RNDCLEARPOOL be accepted?
>
> I think you can only post what you use. If it is tested, it's better...
>
> Thanks,
> Laurent
>
--
Marco A L Barbosa
http://malbarbo.pro.br
--
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-05 13:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-04 22:06 [Qemu-devel] [PATCH] linux-user: Add random ioctls Marco A L Barbosa
2017-10-05 7:12 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
2017-10-05 10:24 ` Marco A L Barbosa
2017-10-05 10:35 ` Laurent Vivier
2017-10-05 13:22 ` Marco A L Barbosa
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).