Message ID | CAHpsRN-XzxjJZb=rb0iHMv4Afv=2H3N5U7p4+NNJFPkxgSLMXg@mail.gmail.com |
---|---|
State | New |
Headers | show |
Series | linux-user: Add random ioctls | expand |
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
> > 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...
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
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 >
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 */
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(+)