qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2
@ 2019-07-29 13:09 Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 1/7] linux user: Add support for FDFLUSH ioctl Aleksandar Markovic
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent, amarkovic

From: Aleksandar Markovic <amarkovic@wavecomp.com>

A set of misc linux user patches for 4.2.


v2->v3:

  - minor code formatting improvements
  - added a patch on semtimedop()

v1->v2:

  - updated commit messages
  - minor improvements of code formatting
  - added three patches containing support for ten additional
    ioctls

Aleksandar Markovic (5):
  linux-user: Add support for FDMSGON and FDMSGOFF ioctls
  linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT
    ioctls
  linux-user: Add support for FDFMTBEG, FDFMTTRK, and FDFMTEND ioctls
  linux-user: Add support for FDSETEMSGTRESH, FDSETMAXERRS, and
    FDGETMAXERRS ioctls
  linux-user: Add support for RNDRESEEDCRNG ioctl

Aleksandar Rikalo (1):
  linux-user: Add support for semtimedop() syscall

Yunqiang Su (1):
  linux user: Add support for FDFLUSH ioctl

 linux-user/ioctls.h        | 16 ++++++++++++++++
 linux-user/syscall.c       | 37 +++++++++++++++++++++++++++++++++++++
 linux-user/syscall_defs.h  | 33 +++++++++++++++++++++++++++++++++
 linux-user/syscall_types.h | 12 ++++++++++++
 4 files changed, 98 insertions(+)

-- 
2.7.4



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH for 4.1 v2 1/7] linux user: Add support for FDFLUSH ioctl
  2019-07-29 13:09 [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2 Aleksandar Markovic
@ 2019-07-29 13:09 ` Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 2/7] linux-user: Add support for FDMSGON and FDMSGOFF ioctls Aleksandar Markovic
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Yunqiang Su, laurent, amarkovic

From: Yunqiang Su <ysu@wavecomp.com>

FDFLUSH is used for flushing buffers of floppy drives. Support in
QEMU is needed because some of Debian packages use this ioctl while
running post-build tests. One such example is 'tar' package.

Signed-off-by: Yunqiang Su <ysu@wavecomp.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/ioctls.h       | 2 ++
 linux-user/syscall.c      | 1 +
 linux-user/syscall_defs.h | 4 ++++
 3 files changed, 7 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 3281c97..fb7b014 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -112,6 +112,8 @@
      IOCTL(BLKZEROOUT, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2)))
 #endif
 
+     IOCTL(FDFLUSH, 0, TYPE_NULL)
+
 #ifdef FIBMAP
      IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG))
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8367cb1..ee80175 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -87,6 +87,7 @@
 #include <linux/kd.h>
 #include <linux/mtio.h>
 #include <linux/fs.h>
+#include <linux/fd.h>
 #if defined(CONFIG_FIEMAP)
 #include <linux/fiemap.h>
 #endif
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 0662270..fb30bce 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -883,6 +883,10 @@ struct target_pollfd {
 #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
 #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
 
+/* From <linux/fd.h> */
+
+#define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
+
 #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
 #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH for 4.1 v2 2/7] linux-user: Add support for FDMSGON and FDMSGOFF ioctls
  2019-07-29 13:09 [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2 Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 1/7] linux user: Add support for FDFLUSH ioctl Aleksandar Markovic
@ 2019-07-29 13:09 ` Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 3/7] linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls Aleksandar Markovic
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent, amarkovic

From: Aleksandar Markovic <amarkovic@wavecomp.com>

FDMSGON and FDMSGOFF switch informational messages of floppy drives
on and off.

Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/ioctls.h       | 2 ++
 linux-user/syscall_defs.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index fb7b014..9978163 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -112,6 +112,8 @@
      IOCTL(BLKZEROOUT, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2)))
 #endif
 
+     IOCTL(FDMSGON, 0, TYPE_NULL)
+     IOCTL(FDMSGOFF, 0, TYPE_NULL)
      IOCTL(FDFLUSH, 0, TYPE_NULL)
 
 #ifdef FIBMAP
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index fb30bce..cd97e9b 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -885,6 +885,8 @@ struct target_pollfd {
 
 /* From <linux/fd.h> */
 
+#define TARGET_FDMSGON        TARGET_IO(2, 0x45)
+#define TARGET_FDMSGOFF       TARGET_IO(2, 0x46)
 #define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
 
 #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH for 4.1 v2 3/7] linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls
  2019-07-29 13:09 [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2 Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 1/7] linux user: Add support for FDFLUSH ioctl Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 2/7] linux-user: Add support for FDMSGON and FDMSGOFF ioctls Aleksandar Markovic
@ 2019-07-29 13:09 ` Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 4/7] linux-user: Add support for FDFMTBEG, FDFMTTRK, and FDFMTEND ioctls Aleksandar Markovic
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent, amarkovic

From: Aleksandar Markovic <amarkovic@wavecomp.com>

FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls are misc commands
for controlling a floppy drive.

Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
---
 linux-user/ioctls.h       | 4 ++++
 linux-user/syscall_defs.h | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 9978163..ab4ef2e 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -115,6 +115,10 @@
      IOCTL(FDMSGON, 0, TYPE_NULL)
      IOCTL(FDMSGOFF, 0, TYPE_NULL)
      IOCTL(FDFLUSH, 0, TYPE_NULL)
+     IOCTL(FDRESET, 0, TYPE_NULL)
+     IOCTL(FDRAWCMD, 0, TYPE_NULL)
+     IOCTL(FDTWADDLE, 0, TYPE_NULL)
+     IOCTL(FDEJECT, 0, TYPE_NULL)
 
 #ifdef FIBMAP
      IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index cd97e9b..4185391 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -888,6 +888,10 @@ struct target_pollfd {
 #define TARGET_FDMSGON        TARGET_IO(2, 0x45)
 #define TARGET_FDMSGOFF       TARGET_IO(2, 0x46)
 #define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
+#define TARGET_FDRESET        TARGET_IO(2, 0x54)
+#define TARGET_FDRAWCMD       TARGET_IO(2, 0x58)
+#define TARGET_FDTWADDLE      TARGET_IO(2, 0x59)
+#define TARGET_FDEJECT        TARGET_IO(2, 0x5a)
 
 #define TARGET_FIBMAP     TARGET_IO(0x00,1)  /* bmap access */
 #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for bmap */
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH for 4.1 v2 4/7] linux-user: Add support for FDFMTBEG, FDFMTTRK, and FDFMTEND ioctls
  2019-07-29 13:09 [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2 Aleksandar Markovic
                   ` (2 preceding siblings ...)
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 3/7] linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls Aleksandar Markovic
@ 2019-07-29 13:09 ` Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 5/7] linux-user: Add support for FDSETEMSGTRESH, FDSETMAXERRS, and FDGETMAXERRS ioctls Aleksandar Markovic
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent, amarkovic

From: Aleksandar Markovic <amarkovic@wavecomp.com>

FDFMTBEG, FDFMTTRK, and FDFMTEND ioctls provide means for controlling
formatting of a floppy drive.

Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
---
 linux-user/ioctls.h        | 3 +++
 linux-user/syscall_defs.h  | 3 +++
 linux-user/syscall_types.h | 5 +++++
 3 files changed, 11 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index ab4ef2e..e393ad6 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -114,6 +114,9 @@
 
      IOCTL(FDMSGON, 0, TYPE_NULL)
      IOCTL(FDMSGOFF, 0, TYPE_NULL)
+     IOCTL(FDFMTBEG, 0, TYPE_NULL)
+     IOCTL(FDFMTTRK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_format_descr)))
+     IOCTL(FDFMTEND, 0, TYPE_NULL)
      IOCTL(FDFLUSH, 0, TYPE_NULL)
      IOCTL(FDRESET, 0, TYPE_NULL)
      IOCTL(FDRAWCMD, 0, TYPE_NULL)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 4185391..1ca115d 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -887,6 +887,9 @@ struct target_pollfd {
 
 #define TARGET_FDMSGON        TARGET_IO(2, 0x45)
 #define TARGET_FDMSGOFF       TARGET_IO(2, 0x46)
+#define TARGET_FDFMTBEG       TARGET_IO(2, 0x47)
+#define TARGET_FDFMTTRK      TARGET_IOW(2, 0x48, struct target_format_descr)
+#define TARGET_FDFMTEND       TARGET_IO(2, 0x49)
 #define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
 #define TARGET_FDRESET        TARGET_IO(2, 0x54)
 #define TARGET_FDRAWCMD       TARGET_IO(2, 0x58)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 4e36983..d82d1a5 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -261,6 +261,11 @@ STRUCT(blkpg_ioctl_arg,
        TYPE_INT, /* datalen */
        TYPE_PTRVOID) /* data */
 
+STRUCT(format_descr,
+       TYPE_INT,     /* device */
+       TYPE_INT,     /* head */
+       TYPE_INT)     /* track */
+
 #if defined(CONFIG_USBFS)
 /* usb device ioctls */
 STRUCT(usbdevfs_ctrltransfer,
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH for 4.1 v2 5/7] linux-user: Add support for FDSETEMSGTRESH, FDSETMAXERRS, and FDGETMAXERRS ioctls
  2019-07-29 13:09 [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2 Aleksandar Markovic
                   ` (3 preceding siblings ...)
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 4/7] linux-user: Add support for FDFMTBEG, FDFMTTRK, and FDFMTEND ioctls Aleksandar Markovic
@ 2019-07-29 13:09 ` Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 6/7] linux-user: Add support for RNDRESEEDCRNG ioctl Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall Aleksandar Markovic
  6 siblings, 0 replies; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent, amarkovic

From: Aleksandar Markovic <amarkovic@wavecomp.com>

FDSETEMSGTRESH, FDSETMAXERRS, and FDGETMAXERRS ioctls are commands
for controlling error reporting of a floppy drive.

Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
---
 linux-user/ioctls.h        |  2 ++
 linux-user/syscall_defs.h  | 19 +++++++++++++++++++
 linux-user/syscall_types.h |  7 +++++++
 3 files changed, 28 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index e393ad6..6551938 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -118,6 +118,8 @@
      IOCTL(FDFMTTRK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_format_descr)))
      IOCTL(FDFMTEND, 0, TYPE_NULL)
      IOCTL(FDFLUSH, 0, TYPE_NULL)
+     IOCTL(FDSETMAXERRS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors)))
+     IOCTL(FDGETMAXERRS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors)))
      IOCTL(FDRESET, 0, TYPE_NULL)
      IOCTL(FDRAWCMD, 0, TYPE_NULL)
      IOCTL(FDTWADDLE, 0, TYPE_NULL)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 1ca115d..36256b0 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -885,12 +885,31 @@ struct target_pollfd {
 
 /* From <linux/fd.h> */
 
+struct target_floppy_max_errors {
+    abi_uint        abort;
+    abi_uint        read_track;
+    abi_uint        reset;
+    abi_uint        recal;
+    abi_uint        reporting;
+};
+
+struct target_format_descr {
+    abi_uint        device;
+    abi_uint        head;
+    abi_uint        track;
+};
+
 #define TARGET_FDMSGON        TARGET_IO(2, 0x45)
 #define TARGET_FDMSGOFF       TARGET_IO(2, 0x46)
 #define TARGET_FDFMTBEG       TARGET_IO(2, 0x47)
 #define TARGET_FDFMTTRK      TARGET_IOW(2, 0x48, struct target_format_descr)
 #define TARGET_FDFMTEND       TARGET_IO(2, 0x49)
+#define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
 #define TARGET_FDFLUSH        TARGET_IO(2, 0x4b)
+#define TARGET_FDSETMAXERRS  TARGET_IOW(2, 0x4c,                               \
+                                        struct target_floppy_max_errors)
+#define TARGET_FDGETMAXERRS  TARGET_IOR(2, 0x0e,                               \
+                                        struct target_floppy_max_errors)
 #define TARGET_FDRESET        TARGET_IO(2, 0x54)
 #define TARGET_FDRAWCMD       TARGET_IO(2, 0x58)
 #define TARGET_FDTWADDLE      TARGET_IO(2, 0x59)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index d82d1a5..5ba7c34 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -261,6 +261,13 @@ STRUCT(blkpg_ioctl_arg,
        TYPE_INT, /* datalen */
        TYPE_PTRVOID) /* data */
 
+STRUCT(floppy_max_errors,
+       TYPE_INT,     /* abort */
+       TYPE_INT,     /* read_track */
+       TYPE_INT,     /* reset */
+       TYPE_INT,     /* recal */
+       TYPE_INT)     /* reporting */
+
 STRUCT(format_descr,
        TYPE_INT,     /* device */
        TYPE_INT,     /* head */
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH for 4.1 v2 6/7] linux-user: Add support for RNDRESEEDCRNG ioctl
  2019-07-29 13:09 [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2 Aleksandar Markovic
                   ` (4 preceding siblings ...)
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 5/7] linux-user: Add support for FDSETEMSGTRESH, FDSETMAXERRS, and FDGETMAXERRS ioctls Aleksandar Markovic
@ 2019-07-29 13:09 ` Aleksandar Markovic
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall Aleksandar Markovic
  6 siblings, 0 replies; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent, amarkovic

From: Aleksandar Markovic <amarkovic@wavecomp.com>

RNDRESEEDCRNG is a newer ioctl (added in kernel 4.17), and an
"ifdef" guard is used for that reason in this patch.

Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/ioctls.h       | 3 +++
 linux-user/syscall_defs.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 6551938..c1fcf7b 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -259,6 +259,9 @@
   IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT))
   IOCTL(RNDZAPENTCNT, 0, TYPE_NULL)
   IOCTL(RNDCLEARPOOL, 0, TYPE_NULL)
+#ifdef RNDRESEEDCRNG
+  IOCTL(RNDRESEEDCRNG, 0, TYPE_NULL)
+#endif
 
   IOCTL(CDROMPAUSE, 0, TYPE_NULL)
   IOCTL(CDROMSTART, 0, TYPE_NULL)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 36256b0..85b732b 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -850,6 +850,7 @@ struct target_pollfd {
 #define TARGET_RNDADDTOENTCNT  TARGET_IOW('R', 0x01, int)
 #define TARGET_RNDZAPENTCNT    TARGET_IO('R', 0x04)
 #define TARGET_RNDCLEARPOOL    TARGET_IO('R', 0x06)
+#define TARGET_RNDRESEEDCRNG   TARGET_IO('R', 0x07)
 
 /* From <linux/fs.h> */
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall
  2019-07-29 13:09 [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2 Aleksandar Markovic
                   ` (5 preceding siblings ...)
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 6/7] linux-user: Add support for RNDRESEEDCRNG ioctl Aleksandar Markovic
@ 2019-07-29 13:09 ` Aleksandar Markovic
  2019-07-29 13:26   ` Aleksandar Markovic
  2019-07-29 13:28   ` Laurent Vivier
  6 siblings, 2 replies; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Rikalo, laurent, amarkovic

From: Aleksandar Rikalo <arikalo@wavecomp.com>

Add support for semtimedop() emulation. It is based on invocation
of safe_semtimedop().

Conversion is left out of safe_semtimedop(), since other safe_xxx()
usually don't contain similar conversions.

Signed-off-by: Aleksandar Rikalo <arikalo@wavecomp.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
---
 linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ee80175..c7b08f5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6650,7 +6650,39 @@ static inline abi_long host_to_target_statx(struct target_statx *host_stx,
     return 0;
 }
 #endif
+#ifdef TARGET_NR_semtimedop
+static inline abi_long do_semtimedop(int semid, abi_long ptr, unsigned nsops,
+                                     abi_long timeout)
+{
+    struct sembuf *sops;
+    struct timespec ts, *pts;
+    abi_long ret;
+
+    if (timeout) {
+        pts = &ts;
+        if (target_to_host_timespec(pts, timeout)) {
+            return -TARGET_EFAULT;
+        }
+    } else {
+        pts = NULL;
+    }
 
+    sops = g_malloc(sizeof(struct sembuf) * nsops);
+    if (sops == NULL) {
+        return -TARGET_EFAULT;
+    }
+
+    if (target_to_host_sembuf(sops, ptr, nsops)) {
+        g_free(sops);
+        return -TARGET_EFAULT;
+    }
+
+    ret = get_errno(safe_semtimedop(semid, sops, nsops, pts));
+    g_free(sops);
+
+    return ret;
+}
+#endif
 
 /* ??? Using host futex calls even when target atomic operations
    are not really atomic probably breaks things.  However implementing
@@ -9194,6 +9226,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_semop:
         return do_semop(arg1, arg2, arg3);
 #endif
+#ifdef TARGET_NR_semtimedop
+    case TARGET_NR_semtimedop:
+        return do_semtimedop(arg1, arg2, arg3, arg4);
+#endif
 #ifdef TARGET_NR_semctl
     case TARGET_NR_semctl:
         return do_semctl(arg1, arg2, arg3, arg4);
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall Aleksandar Markovic
@ 2019-07-29 13:26   ` Aleksandar Markovic
  2019-07-29 13:29     ` Laurent Vivier
  2019-07-29 13:28   ` Laurent Vivier
  1 sibling, 1 reply; 11+ messages in thread
From: Aleksandar Markovic @ 2019-07-29 13:26 UTC (permalink / raw)
  To: Aleksandar Markovic
  Cc: Aleksandar Rikalo, QEMU Developers, Aleksandar Markovic, Laurent Vivier

On Mon, Jul 29, 2019 at 3:11 PM Aleksandar Markovic <
aleksandar.markovic@rt-rk.com> wrote:

> From: Aleksandar Rikalo <arikalo@wavecomp.com>
>
> Add support for semtimedop() emulation. It is based on invocation
> of safe_semtimedop().
>
> Conversion is left out of safe_semtimedop(), since other safe_xxx()
> usually don't contain similar conversions.
>
> Signed-off-by: Aleksandar Rikalo <arikalo@wavecomp.com>
> Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
> ---
>

Aleksandar R., Laurent,

Please note that I just rebased the patch compared to its last incarnation
- no code change.

Laurent's hints were as follows last time:

"To avoid duplicate code (and cleanup the stack allocation), you should

remove do_semop()  and call do_semtimedop(..., NULL) from IPCOP_semop
and TARGET_NR_semop.

Thanks, Laurent"

 I guess they are still valid.

Thanks,
Aleksandar



>  linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ee80175..c7b08f5 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -6650,7 +6650,39 @@ static inline abi_long host_to_target_statx(struct
> target_statx *host_stx,
>      return 0;
>  }
>  #endif
> +#ifdef TARGET_NR_semtimedop
> +static inline abi_long do_semtimedop(int semid, abi_long ptr, unsigned
> nsops,
> +                                     abi_long timeout)
> +{
> +    struct sembuf *sops;
> +    struct timespec ts, *pts;
> +    abi_long ret;
> +
> +    if (timeout) {
> +        pts = &ts;
> +        if (target_to_host_timespec(pts, timeout)) {
> +            return -TARGET_EFAULT;
> +        }
> +    } else {
> +        pts = NULL;
> +    }
>
> +    sops = g_malloc(sizeof(struct sembuf) * nsops);
> +    if (sops == NULL) {
> +        return -TARGET_EFAULT;
> +    }
> +
> +    if (target_to_host_sembuf(sops, ptr, nsops)) {
> +        g_free(sops);
> +        return -TARGET_EFAULT;
> +    }
> +
> +    ret = get_errno(safe_semtimedop(semid, sops, nsops, pts));
> +    g_free(sops);
> +
> +    return ret;
> +}
> +#endif
>
>  /* ??? Using host futex calls even when target atomic operations
>     are not really atomic probably breaks things.  However implementing
> @@ -9194,6 +9226,10 @@ static abi_long do_syscall1(void *cpu_env, int num,
> abi_long arg1,
>      case TARGET_NR_semop:
>          return do_semop(arg1, arg2, arg3);
>  #endif
> +#ifdef TARGET_NR_semtimedop
> +    case TARGET_NR_semtimedop:
> +        return do_semtimedop(arg1, arg2, arg3, arg4);
> +#endif
>  #ifdef TARGET_NR_semctl
>      case TARGET_NR_semctl:
>          return do_semctl(arg1, arg2, arg3, arg4);
> --
> 2.7.4
>
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall
  2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall Aleksandar Markovic
  2019-07-29 13:26   ` Aleksandar Markovic
@ 2019-07-29 13:28   ` Laurent Vivier
  1 sibling, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2019-07-29 13:28 UTC (permalink / raw)
  To: Aleksandar Markovic, qemu-devel; +Cc: Aleksandar Rikalo, amarkovic

Le 29/07/2019 à 15:09, Aleksandar Markovic a écrit :
> From: Aleksandar Rikalo <arikalo@wavecomp.com>
> 
> Add support for semtimedop() emulation. It is based on invocation
> of safe_semtimedop().
> 
> Conversion is left out of safe_semtimedop(), since other safe_xxx()
> usually don't contain similar conversions.
> 
> Signed-off-by: Aleksandar Rikalo <arikalo@wavecomp.com>
> Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
> ---
>  linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ee80175..c7b08f5 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -6650,7 +6650,39 @@ static inline abi_long host_to_target_statx(struct target_statx *host_stx,
>      return 0;
>  }
>  #endif
> +#ifdef TARGET_NR_semtimedop
> +static inline abi_long do_semtimedop(int semid, abi_long ptr, unsigned nsops,
> +                                     abi_long timeout)
> +{
> +    struct sembuf *sops;
> +    struct timespec ts, *pts;
> +    abi_long ret;
> +
> +    if (timeout) {
> +        pts = &ts;
> +        if (target_to_host_timespec(pts, timeout)) {
> +            return -TARGET_EFAULT;
> +        }
> +    } else {
> +        pts = NULL;
> +    }
>  
> +    sops = g_malloc(sizeof(struct sembuf) * nsops);
> +    if (sops == NULL) {
> +        return -TARGET_EFAULT;
> +    }
> +
> +    if (target_to_host_sembuf(sops, ptr, nsops)) {
> +        g_free(sops);
> +        return -TARGET_EFAULT;
> +    }
> +
> +    ret = get_errno(safe_semtimedop(semid, sops, nsops, pts));
> +    g_free(sops);
> +
> +    return ret;
> +}
> +#endif

As we have a "#ifdef__NR_semtimedop" around the definition of
safe_semtimedop() you need the same #ifdef around its use:
perhaps you can update the existing do_semop() to implement do_semtimedop().

>  
>  /* ??? Using host futex calls even when target atomic operations
>     are not really atomic probably breaks things.  However implementing
> @@ -9194,6 +9226,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
>      case TARGET_NR_semop:
>          return do_semop(arg1, arg2, arg3);
>  #endif
> +#ifdef TARGET_NR_semtimedop
> +    case TARGET_NR_semtimedop:
> +        return do_semtimedop(arg1, arg2, arg3, arg4);
> +#endif
>  #ifdef TARGET_NR_semctl
>      case TARGET_NR_semctl:
>          return do_semctl(arg1, arg2, arg3, arg4);
> 

You should also implement in do_ipc() the IPCOP_semtimedop operation.

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall
  2019-07-29 13:26   ` Aleksandar Markovic
@ 2019-07-29 13:29     ` Laurent Vivier
  0 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2019-07-29 13:29 UTC (permalink / raw)
  To: Aleksandar Markovic, Aleksandar Markovic
  Cc: Aleksandar Rikalo, QEMU Developers, Aleksandar Markovic

Le 29/07/2019 à 15:26, Aleksandar Markovic a écrit :
> 
> 
> On Mon, Jul 29, 2019 at 3:11 PM Aleksandar Markovic
> <aleksandar.markovic@rt-rk.com <mailto:aleksandar.markovic@rt-rk.com>>
> wrote:
> 
>     From: Aleksandar Rikalo <arikalo@wavecomp.com
>     <mailto:arikalo@wavecomp.com>>
> 
>     Add support for semtimedop() emulation. It is based on invocation
>     of safe_semtimedop().
> 
>     Conversion is left out of safe_semtimedop(), since other safe_xxx()
>     usually don't contain similar conversions.
> 
>     Signed-off-by: Aleksandar Rikalo <arikalo@wavecomp.com
>     <mailto:arikalo@wavecomp.com>>
>     Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com
>     <mailto:amarkovic@wavecomp.com>>
>     ---
> 
> 
> Aleksandar R., Laurent,
> 
> Please note that I just rebased the patch compared to its last
> incarnation - no code change.
> 
> Laurent's hints were as follows last time:
> 
> "To avoid duplicate code (and cleanup the stack allocation), you should
> 
> remove do_semop()  and call do_semtimedop(..., NULL) from IPCOP_semop
> and TARGET_NR_semop.
> 
> Thanks, Laurent"
> 
>  I guess they are still valid.

Yes, I didn't remember my comment and do the same again...

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-07-29 13:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 13:09 [Qemu-devel] [PATCH for 4.1 v2 0/7] linux-user: Misc patches for 4.2 Aleksandar Markovic
2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 1/7] linux user: Add support for FDFLUSH ioctl Aleksandar Markovic
2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 2/7] linux-user: Add support for FDMSGON and FDMSGOFF ioctls Aleksandar Markovic
2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 3/7] linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls Aleksandar Markovic
2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 4/7] linux-user: Add support for FDFMTBEG, FDFMTTRK, and FDFMTEND ioctls Aleksandar Markovic
2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 5/7] linux-user: Add support for FDSETEMSGTRESH, FDSETMAXERRS, and FDGETMAXERRS ioctls Aleksandar Markovic
2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 6/7] linux-user: Add support for RNDRESEEDCRNG ioctl Aleksandar Markovic
2019-07-29 13:09 ` [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall Aleksandar Markovic
2019-07-29 13:26   ` Aleksandar Markovic
2019-07-29 13:29     ` Laurent Vivier
2019-07-29 13:28   ` Laurent Vivier

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).