qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches
@ 2019-09-11  6:49 Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 01/15] linux-user: remove useless variable Laurent Vivier
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier

The following changes since commit 89ea03a7dc83ca36b670ba7f787802791fcb04b1:

  Merge remote-tracking branch 'remotes/huth-gitlab/tags/m68k-pull-2019-09-07' into staging (2019-09-09 09:48:34 +0100)

are available in the Git repository at:

  git://github.com/vivier/qemu.git tags/linux-user-for-4.2-pull-request

for you to fetch changes up to 5eea942900536b76ad13bef35e1d8f276566ae9e:

  linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls (2019-09-11 08:47:06 +0200)

----------------------------------------------------------------
Add several floppy drive ioctl,
xtensa call0 ABI support, arm MAX_RESERVED_VA for M-profile,
aarch64 AT_HWCAP2, qOffsets' query for ELF, memfd_create,
and some code cleanup

----------------------------------------------------------------

Aleksandar Markovic (4):
  linux-user: Add support for RNDRESEEDCRNG ioctl
  linux-user: Add support for FIOGETOWN and FIOSETOWN ioctls
  linux-user: Add support for FDMSGON and FDMSGOFF ioctls
  linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT
    ioctls

Alex Bennée (1):
  linux-user: fail and report on bad dfilter specs

Josh Kunz (1):
  linux-user: Support gdb 'qOffsets' query for ELF

Laurent Vivier (1):
  linux-user: remove useless variable

Max Filippov (2):
  target/xtensa: linux-user: add call0 ABI support
  linux-user: drop redundant handling of environment variables

Richard Henderson (3):
  linux-user: Add AT_HWCAP2 for aarch64-linux-user
  linux-user: Pass CPUState to MAX_RESERVED_VA
  linux-user/arm: Adjust MAX_RESERVED_VA for M-profile

Shu-Chun Weng (2):
  linux-user: erroneous fd_trans_unregister call
  linux-user: add memfd_create

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

 include/qemu/memfd.h        |  4 +++
 linux-user/arm/target_cpu.h | 24 +++++++++++--
 linux-user/elfload.c        | 33 +++++++++++++++---
 linux-user/ioctls.h         | 13 +++++++
 linux-user/main.c           | 69 +++++++++++++++++++++----------------
 linux-user/syscall.c        | 14 +++++++-
 linux-user/syscall_defs.h   | 15 ++++++++
 linux-user/xtensa/signal.c  | 25 +++++++++-----
 target/xtensa/cpu.c         | 24 ++++++++++---
 target/xtensa/cpu.h         |  3 ++
 util/memfd.c                |  2 +-
 11 files changed, 175 insertions(+), 51 deletions(-)

-- 
2.21.0



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

* [Qemu-devel] [PULL v2 01/15] linux-user: remove useless variable
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 02/15] linux-user: Add AT_HWCAP2 for aarch64-linux-user Laurent Vivier
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Filippov, Riku Voipio, Philippe Mathieu-Daudé,
	Laurent Vivier, Stefano Garzarella

filename is only used to open the file if AT_EXECFD is not provided.
But exec_path already contains the path of the file to open.
Remove filename as it is only used in main.c whereas exec_path is
also used in syscall.c.

Fixes: d088d664f201 ("linux-user: identify running binary in /proc/self/exe")
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20190714134028.315-1-laurent@vivier.eu>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 47917bbb20fc..28f0065b6ddf 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -49,7 +49,6 @@
 char *exec_path;
 
 int singlestep;
-static const char *filename;
 static const char *argv0;
 static int gdbstub_port;
 static envlist_t *envlist;
@@ -586,7 +585,6 @@ static int parse_args(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
 
-    filename = argv[optind];
     exec_path = argv[optind];
 
     return optind;
@@ -657,9 +655,9 @@ int main(int argc, char **argv, char **envp)
 
     execfd = qemu_getauxval(AT_EXECFD);
     if (execfd == 0) {
-        execfd = open(filename, O_RDONLY);
+        execfd = open(exec_path, O_RDONLY);
         if (execfd < 0) {
-            printf("Error while loading %s: %s\n", filename, strerror(errno));
+            printf("Error while loading %s: %s\n", exec_path, strerror(errno));
             _exit(EXIT_FAILURE);
         }
     }
@@ -784,10 +782,10 @@ int main(int argc, char **argv, char **envp)
     cpu->opaque = ts;
     task_settid(ts);
 
-    ret = loader_exec(execfd, filename, target_argv, target_environ, regs,
+    ret = loader_exec(execfd, exec_path, target_argv, target_environ, regs,
         info, &bprm);
     if (ret != 0) {
-        printf("Error while loading %s: %s\n", filename, strerror(-ret));
+        printf("Error while loading %s: %s\n", exec_path, strerror(-ret));
         _exit(EXIT_FAILURE);
     }
 
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 02/15] linux-user: Add AT_HWCAP2 for aarch64-linux-user
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 01/15] linux-user: remove useless variable Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 03/15] linux-user: erroneous fd_trans_unregister call Laurent Vivier
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Filippov, Riku Voipio, Richard Henderson, Laurent Vivier,
	Peter Maydell

From: Richard Henderson <richard.henderson@linaro.org>

Add the HWCAP2_* bits from kernel version v5.3-rc3.
Enable the bits corresponding to ARMv8.5-CondM and ARMv8.5-FRINT.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20190809171156.3476-1-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/elfload.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 3365e192eb3f..43c16a846d33 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -607,9 +607,23 @@ enum {
     ARM_HWCAP_A64_SB            = 1 << 29,
     ARM_HWCAP_A64_PACA          = 1 << 30,
     ARM_HWCAP_A64_PACG          = 1UL << 31,
+
+    ARM_HWCAP2_A64_DCPODP       = 1 << 0,
+    ARM_HWCAP2_A64_SVE2         = 1 << 1,
+    ARM_HWCAP2_A64_SVEAES       = 1 << 2,
+    ARM_HWCAP2_A64_SVEPMULL     = 1 << 3,
+    ARM_HWCAP2_A64_SVEBITPERM   = 1 << 4,
+    ARM_HWCAP2_A64_SVESHA3      = 1 << 5,
+    ARM_HWCAP2_A64_SVESM4       = 1 << 6,
+    ARM_HWCAP2_A64_FLAGM2       = 1 << 7,
+    ARM_HWCAP2_A64_FRINT        = 1 << 8,
 };
 
-#define ELF_HWCAP get_elf_hwcap()
+#define ELF_HWCAP   get_elf_hwcap()
+#define ELF_HWCAP2  get_elf_hwcap2()
+
+#define GET_FEATURE_ID(feat, hwcap) \
+    do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0)
 
 static uint32_t get_elf_hwcap(void)
 {
@@ -621,8 +635,6 @@ static uint32_t get_elf_hwcap(void)
     hwcaps |= ARM_HWCAP_A64_CPUID;
 
     /* probe for the extra features */
-#define GET_FEATURE_ID(feat, hwcap) \
-    do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0)
 
     GET_FEATURE_ID(aa64_aes, ARM_HWCAP_A64_AES);
     GET_FEATURE_ID(aa64_pmull, ARM_HWCAP_A64_PMULL);
@@ -645,11 +657,22 @@ static uint32_t get_elf_hwcap(void)
     GET_FEATURE_ID(aa64_sb, ARM_HWCAP_A64_SB);
     GET_FEATURE_ID(aa64_condm_4, ARM_HWCAP_A64_FLAGM);
 
-#undef GET_FEATURE_ID
+    return hwcaps;
+}
+
+static uint32_t get_elf_hwcap2(void)
+{
+    ARMCPU *cpu = ARM_CPU(thread_cpu);
+    uint32_t hwcaps = 0;
+
+    GET_FEATURE_ID(aa64_condm_5, ARM_HWCAP2_A64_FLAGM2);
+    GET_FEATURE_ID(aa64_frint, ARM_HWCAP2_A64_FRINT);
 
     return hwcaps;
 }
 
+#undef GET_FEATURE_ID
+
 #endif /* not TARGET_AARCH64 */
 #endif /* TARGET_ARM */
 
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 03/15] linux-user: erroneous fd_trans_unregister call
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 01/15] linux-user: remove useless variable Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 02/15] linux-user: Add AT_HWCAP2 for aarch64-linux-user Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 04/15] linux-user: fail and report on bad dfilter specs Laurent Vivier
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier, Shu-Chun Weng

From: Shu-Chun Weng <scw@google.com>

timer_getoverrun returns the "overrun count" for the timer, which is not
a file descriptor and thus should not call fd_trans_unregister on it.

Signed-off-by: Shu-Chun Weng <scw@google.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20190819185348.221825-1-scw@google.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8b41a03901d4..b42f59a32c8d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11847,7 +11847,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             timer_t htimer = g_posix_timers[timerid];
             ret = get_errno(timer_getoverrun(htimer));
         }
-        fd_trans_unregister(ret);
         return ret;
     }
 #endif
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 04/15] linux-user: fail and report on bad dfilter specs
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (2 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 03/15] linux-user: erroneous fd_trans_unregister call Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 05/15] linux-user: add memfd_create Laurent Vivier
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Alex Bennée, Laurent Vivier

From: Alex Bennée <alex.bennee@linaro.org>

Just passing NULL means we end up ignoring the bad dfilter spec
instead of reporting it and exiting as we should.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20190830143648.2967-1-alex.bennee@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 28f0065b6ddf..c257b063dbc1 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -235,7 +235,7 @@ static void handle_arg_log(const char *arg)
 
 static void handle_arg_dfilter(const char *arg)
 {
-    qemu_set_dfilter_ranges(arg, NULL);
+    qemu_set_dfilter_ranges(arg, &error_fatal);
 }
 
 static void handle_arg_log_filename(const char *arg)
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 05/15] linux-user: add memfd_create
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (3 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 04/15] linux-user: fail and report on bad dfilter specs Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 06/15] linux-user: Pass CPUState to MAX_RESERVED_VA Laurent Vivier
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier, Shu-Chun Weng

From: Shu-Chun Weng <scw@google.com>

Add support for the memfd_create syscall. If the host does not have the
libc wrapper, translate to a direct syscall with NC-macro.

Buglink: https://bugs.launchpad.net/qemu/+bug/1734792
Signed-off-by: Shu-Chun Weng <scw@google.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20190819180947.180725-1-scw@google.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 include/qemu/memfd.h |  4 ++++
 linux-user/syscall.c | 12 ++++++++++++
 util/memfd.c         |  2 +-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/qemu/memfd.h b/include/qemu/memfd.h
index d551c28b6850..975b6bdb7797 100644
--- a/include/qemu/memfd.h
+++ b/include/qemu/memfd.h
@@ -32,6 +32,10 @@
 #define MFD_HUGE_SHIFT 26
 #endif
 
+#if defined CONFIG_LINUX && !defined CONFIG_MEMFD
+int memfd_create(const char *name, unsigned int flags);
+#endif
+
 int qemu_memfd_create(const char *name, size_t size, bool hugetlb,
                       uint64_t hugetlbsize, unsigned int seals, Error **errp);
 bool qemu_memfd_alloc_check(void);
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b42f59a32c8d..6928f654ced3 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu/cutils.h"
 #include "qemu/path.h"
+#include "qemu/memfd.h"
 #include "qemu/queue.h"
 #include <elf.h>
 #include <endian.h>
@@ -11938,6 +11939,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         /* PowerPC specific.  */
         return do_swapcontext(cpu_env, arg1, arg2, arg3);
 #endif
+#ifdef TARGET_NR_memfd_create
+    case TARGET_NR_memfd_create:
+        p = lock_user_string(arg1);
+        if (!p) {
+            return -TARGET_EFAULT;
+        }
+        ret = get_errno(memfd_create(p, arg2));
+        fd_trans_unregister(ret);
+        unlock_user(p, arg1, 0);
+        return ret;
+#endif
 
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
diff --git a/util/memfd.c b/util/memfd.c
index 00334e5b218f..4a3c07e0bee6 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -35,7 +35,7 @@
 #include <sys/syscall.h>
 #include <asm/unistd.h>
 
-static int memfd_create(const char *name, unsigned int flags)
+int memfd_create(const char *name, unsigned int flags)
 {
 #ifdef __NR_memfd_create
     return syscall(__NR_memfd_create, name, flags);
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 06/15] linux-user: Pass CPUState to MAX_RESERVED_VA
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (4 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 05/15] linux-user: add memfd_create Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 07/15] linux-user/arm: Adjust MAX_RESERVED_VA for M-profile Laurent Vivier
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Filippov, Riku Voipio, Richard Henderson, Laurent Vivier,
	Peter Maydell

From: Richard Henderson <richard.henderson@linaro.org>

Turn the scalar macro into a functional macro.  Move the creation
of the cpu up a bit within main() so that we can pass it to the
invocation of MAX_RESERVED_VA.  Delay the validation of the -R
parameter until MAX_RESERVED_VA is computed.

So far no changes to any of the MAX_RESERVED_VA macros to actually
use the cpu in any way, but ARM will need it.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20190822185929.16891-2-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/arm/target_cpu.h |  2 +-
 linux-user/main.c           | 43 +++++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h
index 8a3764919ad9..279ea532d5b7 100644
--- a/linux-user/arm/target_cpu.h
+++ b/linux-user/arm/target_cpu.h
@@ -21,7 +21,7 @@
 
 /* We need to be able to map the commpage.
    See validate_guest_space in linux-user/elfload.c.  */
-#define MAX_RESERVED_VA  0xffff0000ul
+#define MAX_RESERVED_VA(CPU)  0xffff0000ul
 
 static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp)
 {
diff --git a/linux-user/main.c b/linux-user/main.c
index c257b063dbc1..24cb24f0bf8f 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -77,12 +77,12 @@ int have_guest_base;
       (TARGET_LONG_BITS == 32 || defined(TARGET_ABI32))
 /* There are a number of places where we assign reserved_va to a variable
    of type abi_ulong and expect it to fit.  Avoid the last page.  */
-#   define MAX_RESERVED_VA  (0xfffffffful & TARGET_PAGE_MASK)
+#   define MAX_RESERVED_VA(CPU)  (0xfffffffful & TARGET_PAGE_MASK)
 #  else
-#   define MAX_RESERVED_VA  (1ul << TARGET_VIRT_ADDR_SPACE_BITS)
+#   define MAX_RESERVED_VA(CPU)  (1ul << TARGET_VIRT_ADDR_SPACE_BITS)
 #  endif
 # else
-#  define MAX_RESERVED_VA  0
+#  define MAX_RESERVED_VA(CPU)  0
 # endif
 #endif
 
@@ -356,8 +356,7 @@ static void handle_arg_reserved_va(const char *arg)
         unsigned long unshifted = reserved_va;
         p++;
         reserved_va <<= shift;
-        if (reserved_va >> shift != unshifted
-            || (MAX_RESERVED_VA && reserved_va > MAX_RESERVED_VA)) {
+        if (reserved_va >> shift != unshifted) {
             fprintf(stderr, "Reserved virtual address too big\n");
             exit(EXIT_FAILURE);
         }
@@ -605,6 +604,7 @@ int main(int argc, char **argv, char **envp)
     int i;
     int ret;
     int execfd;
+    unsigned long max_reserved_va;
 
     error_init(argv[0]);
     module_call_init(MODULE_INIT_TRACE);
@@ -670,24 +670,31 @@ int main(int argc, char **argv, char **envp)
     /* init tcg before creating CPUs and to get qemu_host_page_size */
     tcg_exec_init(0);
 
-    /* Reserving *too* much vm space via mmap can run into problems
-       with rlimits, oom due to page table creation, etc.  We will still try it,
-       if directed by the command-line option, but not by default.  */
-    if (HOST_LONG_BITS == 64 &&
-        TARGET_VIRT_ADDR_SPACE_BITS <= 32 &&
-        reserved_va == 0) {
-        /* reserved_va must be aligned with the host page size
-         * as it is used with mmap()
-         */
-        reserved_va = MAX_RESERVED_VA & qemu_host_page_mask;
-    }
-
     cpu = cpu_create(cpu_type);
     env = cpu->env_ptr;
     cpu_reset(cpu);
-
     thread_cpu = cpu;
 
+    /*
+     * Reserving too much vm space via mmap can run into problems
+     * with rlimits, oom due to page table creation, etc.  We will
+     * still try it, if directed by the command-line option, but
+     * not by default.
+     */
+    max_reserved_va = MAX_RESERVED_VA(cpu);
+    if (reserved_va != 0) {
+        if (max_reserved_va && reserved_va > max_reserved_va) {
+            fprintf(stderr, "Reserved virtual address too big\n");
+            exit(EXIT_FAILURE);
+        }
+    } else if (HOST_LONG_BITS == 64 && TARGET_VIRT_ADDR_SPACE_BITS <= 32) {
+        /*
+         * reserved_va must be aligned with the host page size
+         * as it is used with mmap()
+         */
+        reserved_va = max_reserved_va & qemu_host_page_mask;
+    }
+
     if (getenv("QEMU_STRACE")) {
         do_strace = 1;
     }
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 07/15] linux-user/arm: Adjust MAX_RESERVED_VA for M-profile
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (5 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 06/15] linux-user: Pass CPUState to MAX_RESERVED_VA Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 08/15] linux-user: Support gdb 'qOffsets' query for ELF Laurent Vivier
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Filippov, Riku Voipio, Richard Henderson, Laurent Vivier,
	Peter Maydell

From: Richard Henderson <richard.henderson@linaro.org>

Limit the virtual address space for M-profile cpus to 2GB,
so that we avoid all of the magic addresses in the top half
of the M-profile system map.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20190822185929.16891-3-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/arm/target_cpu.h | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h
index 279ea532d5b7..3f79356a07fc 100644
--- a/linux-user/arm/target_cpu.h
+++ b/linux-user/arm/target_cpu.h
@@ -19,9 +19,27 @@
 #ifndef ARM_TARGET_CPU_H
 #define ARM_TARGET_CPU_H
 
-/* We need to be able to map the commpage.
-   See validate_guest_space in linux-user/elfload.c.  */
-#define MAX_RESERVED_VA(CPU)  0xffff0000ul
+static inline unsigned long arm_max_reserved_va(CPUState *cs)
+{
+    ARMCPU *cpu = ARM_CPU(cs);
+
+    if (arm_feature(&cpu->env, ARM_FEATURE_M)) {
+        /*
+         * There are magic return addresses above 0xfe000000,
+         * and in general a lot of M-profile system stuff in
+         * the high addresses.  Restrict linux-user to the
+         * cached write-back RAM in the system map.
+         */
+        return 0x80000000ul;
+    } else {
+        /*
+         * We need to be able to map the commpage.
+         * See validate_guest_space in linux-user/elfload.c.
+         */
+        return 0xffff0000ul;
+    }
+}
+#define MAX_RESERVED_VA  arm_max_reserved_va
 
 static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp)
 {
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 08/15] linux-user: Support gdb 'qOffsets' query for ELF
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (6 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 07/15] linux-user/arm: Adjust MAX_RESERVED_VA for M-profile Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 09/15] target/xtensa: linux-user: add call0 ABI support Laurent Vivier
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Filippov, Riku Voipio, Philippe Mathieu-Daudé,
	Laurent Vivier, Josh Kunz

From: Josh Kunz <jkz@google.com>

This is needed to support debugging PIE ELF binaries running under QEMU
user mode. Currently, `code_offset` and `data_offset` remain unset for
all ELF binaries, so GDB is unable to correctly locate the position of
the binary's text and data.

The fields `code_offset`, and `data_offset` were originally added way
back in 2006 to support debugging of bFMT executables (978efd6aac6),
and support was just never added for ELF. Since non-PIE binaries are
loaded at exactly the address specified in the binary, GDB does not need
to relocate any symbols, so the buggy behavior is not normally observed.

http://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qOffsets-packet

Buglink: https://bugs.launchpad.net/qemu/+bug/1528239
Signed-off-by: Josh Kunz <jkz@google.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190816233422.16715-1-jkz@google.com>
[lv: added link to documentation]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/elfload.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 43c16a846d33..f6693e576098 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2403,6 +2403,8 @@ static void load_elf_image(const char *image_name, int image_fd,
     }
 
     info->load_bias = load_bias;
+    info->code_offset = load_bias;
+    info->data_offset = load_bias;
     info->load_addr = load_addr;
     info->entry = ehdr->e_entry + load_bias;
     info->start_code = -1;
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 09/15] target/xtensa: linux-user: add call0 ABI support
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (7 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 08/15] linux-user: Support gdb 'qOffsets' query for ELF Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 10/15] linux-user: drop redundant handling of environment variables Laurent Vivier
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier

From: Max Filippov <jcmvbkbc@gmail.com>

Xtensa binaries built for call0 ABI don't rotate register window on
function calls and returns. Invocation of signal handlers from the
kernel is therefore different in windowed and call0 ABIs.
There's currently no way to determine xtensa ELF binary ABI from the
binary itself. Add handler for the -xtensa-abi-call0 command line
parameter/QEMU_XTENSA_ABI_CALL0 envitonment variable to the qemu-user
and record ABI choice. Use it to initialize PS.WOE in xtensa_cpu_reset.
Check PS.WOE in setup_rt_frame to determine how a signal should be
delivered.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Message-Id: <20190906165713.5558-1-jcmvbkbc@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/main.c          | 11 +++++++++++
 linux-user/xtensa/signal.c | 25 +++++++++++++++++--------
 target/xtensa/cpu.c        | 24 ++++++++++++++++++++----
 target/xtensa/cpu.h        |  3 +++
 4 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 24cb24f0bf8f..27d9a87bc83d 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -391,6 +391,13 @@ static void handle_arg_trace(const char *arg)
     trace_file = trace_opt_parse(arg);
 }
 
+#if defined(TARGET_XTENSA)
+static void handle_arg_abi_call0(const char *arg)
+{
+    xtensa_set_abi_call0();
+}
+#endif
+
 struct qemu_argument {
     const char *argv;
     const char *env;
@@ -444,6 +451,10 @@ static const struct qemu_argument arg_table[] = {
      "",           "[[enable=]<pattern>][,events=<file>][,file=<file>]"},
     {"version",    "QEMU_VERSION",     false, handle_arg_version,
      "",           "display version information and exit"},
+#if defined(TARGET_XTENSA)
+    {"xtensa-abi-call0", "QEMU_XTENSA_ABI_CALL0", false, handle_arg_abi_call0,
+     "",           "assume CALL0 Xtensa ABI"},
+#endif
     {NULL, NULL, false, NULL, NULL, NULL}
 };
 
diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c
index 8d54ef3ae34b..590f0313ffe9 100644
--- a/linux-user/xtensa/signal.c
+++ b/linux-user/xtensa/signal.c
@@ -134,6 +134,8 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
     abi_ulong frame_addr;
     struct target_rt_sigframe *frame;
     uint32_t ra;
+    bool abi_call0;
+    unsigned base;
     int i;
 
     frame_addr = get_sigframe(ka, env, sizeof(*frame));
@@ -182,20 +184,27 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
         __put_user(0x00, &frame->retcode[5]);
 #endif
     }
-    env->sregs[PS] = PS_UM | (3 << PS_RING_SHIFT);
-    if (xtensa_option_enabled(env->config, XTENSA_OPTION_WINDOWED_REGISTER)) {
-        env->sregs[PS] |= PS_WOE | (1 << PS_CALLINC_SHIFT);
-    }
     memset(env->regs, 0, sizeof(env->regs));
     env->pc = ka->_sa_handler;
     env->regs[1] = frame_addr;
     env->sregs[WINDOW_BASE] = 0;
     env->sregs[WINDOW_START] = 1;
 
-    env->regs[4] = (ra & 0x3fffffff) | 0x40000000;
-    env->regs[6] = sig;
-    env->regs[7] = frame_addr + offsetof(struct target_rt_sigframe, info);
-    env->regs[8] = frame_addr + offsetof(struct target_rt_sigframe, uc);
+    abi_call0 = (env->sregs[PS] & PS_WOE) == 0;
+    env->sregs[PS] = PS_UM | (3 << PS_RING_SHIFT);
+
+    if (abi_call0) {
+        base = 0;
+        env->regs[base] = ra;
+    } else {
+        env->sregs[PS] |= PS_WOE | (1 << PS_CALLINC_SHIFT);
+        base = 4;
+        env->regs[base] = (ra & 0x3fffffff) | 0x40000000;
+    }
+    env->regs[base + 2] = sig;
+    env->regs[base + 3] = frame_addr + offsetof(struct target_rt_sigframe,
+                                                info);
+    env->regs[base + 4] = frame_addr + offsetof(struct target_rt_sigframe, uc);
     unlock_user_struct(frame, frame_addr, 1);
     return;
 
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index 76db1741a796..c65dcf9dd782 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -53,6 +53,20 @@ static bool xtensa_cpu_has_work(CPUState *cs)
 #endif
 }
 
+#ifdef CONFIG_USER_ONLY
+static bool abi_call0;
+
+void xtensa_set_abi_call0(void)
+{
+    abi_call0 = true;
+}
+
+bool xtensa_abi_call0(void)
+{
+    return abi_call0;
+}
+#endif
+
 /* CPUClass::reset() */
 static void xtensa_cpu_reset(CPUState *s)
 {
@@ -70,10 +84,12 @@ static void xtensa_cpu_reset(CPUState *s)
             XTENSA_OPTION_INTERRUPT) ? 0x1f : 0x10;
     env->pending_irq_level = 0;
 #else
-    env->sregs[PS] =
-        (xtensa_option_enabled(env->config,
-                               XTENSA_OPTION_WINDOWED_REGISTER) ? PS_WOE : 0) |
-        PS_UM | (3 << PS_RING_SHIFT);
+    env->sregs[PS] = PS_UM | (3 << PS_RING_SHIFT);
+    if (xtensa_option_enabled(env->config,
+                              XTENSA_OPTION_WINDOWED_REGISTER) &&
+        !xtensa_abi_call0()) {
+        env->sregs[PS] |= PS_WOE;
+    }
 #endif
     env->sregs[VECBASE] = env->config->vecbase;
     env->sregs[IBREAKENABLE] = 0;
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 0459243e6bb1..b363ffcf1066 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -673,6 +673,9 @@ static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env)
 {
     return env->system_er;
 }
+#else
+void xtensa_set_abi_call0(void);
+bool xtensa_abi_call0(void);
 #endif
 
 static inline uint32_t xtensa_replicate_windowstart(CPUXtensaState *env)
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 10/15] linux-user: drop redundant handling of environment variables
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (8 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 09/15] target/xtensa: linux-user: add call0 ABI support Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 11/15] linux-user: Add support for RNDRESEEDCRNG ioctl Laurent Vivier
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier

From: Max Filippov <jcmvbkbc@gmail.com>

QEMU_STRACE and QEMU_RAND_SEED are handled by the parse_args, no need to
do it again in main.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20190906165736.5612-1-jcmvbkbc@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/main.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 27d9a87bc83d..560d053f7249 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -706,13 +706,6 @@ int main(int argc, char **argv, char **envp)
         reserved_va = max_reserved_va & qemu_host_page_mask;
     }
 
-    if (getenv("QEMU_STRACE")) {
-        do_strace = 1;
-    }
-
-    if (seed_optarg == NULL) {
-        seed_optarg = getenv("QEMU_RAND_SEED");
-    }
     {
         Error *err = NULL;
         if (seed_optarg != NULL) {
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 11/15] linux-user: Add support for RNDRESEEDCRNG ioctl
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (9 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 10/15] linux-user: drop redundant handling of environment variables Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 12/15] linux-user: Add support for FIOGETOWN and FIOSETOWN ioctls Laurent Vivier
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier, Aleksandar Markovic

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>
Message-Id: <1567601968-26946-3-git-send-email-aleksandar.markovic@rt-rk.com>
Signed-off-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 3281c97ca263..cd9b6f9a8d45 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -246,6 +246,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 06622703008a..19a1d39cbc82 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.21.0



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

* [Qemu-devel] [PULL v2 12/15] linux-user: Add support for FIOGETOWN and FIOSETOWN ioctls
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (10 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 11/15] linux-user: Add support for RNDRESEEDCRNG ioctl Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 13/15] linux-user: Add support for FDFLUSH ioctl Laurent Vivier
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier, Aleksandar Markovic

From: Aleksandar Markovic <amarkovic@wavecomp.com>

FIOGETOWN and FIOSETOWN ioctls have platform-specific definitions,
hence non-standard definition in QEMU too.

Other than that, they both have a single integer argument, and their
functionality is emulated in a straightforward way.

Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <1567601968-26946-4-git-send-email-aleksandar.markovic@rt-rk.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/ioctls.h       | 2 ++
 linux-user/syscall_defs.h | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index cd9b6f9a8d45..1830de96e12b 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -177,6 +177,8 @@
 #endif
 #endif /* CONFIG_USBFS */
 
+  IOCTL(FIOGETOWN, IOC_R, MK_PTR(TYPE_INT))
+  IOCTL(FIOSETOWN, IOC_W, MK_PTR(TYPE_INT))
   IOCTL(SIOCATMARK, IOC_R, MK_PTR(TYPE_INT))
   IOCTL(SIOCGIFNAME, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_int_ifreq)))
   IOCTL(SIOCGIFFLAGS, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_short_ifreq)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 19a1d39cbc82..498223b77787 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -758,10 +758,14 @@ struct target_pollfd {
 
 #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) ||    \
        defined(TARGET_XTENSA)
+#define TARGET_FIOGETOWN       TARGET_IOR('f', 123, int)
+#define TARGET_FIOSETOWN       TARGET_IOW('f', 124, int)
 #define TARGET_SIOCATMARK      TARGET_IOR('s', 7, int)
 #define TARGET_SIOCSPGRP       TARGET_IOW('s', 8, pid_t)
 #define TARGET_SIOCGPGRP       TARGET_IOR('s', 9, pid_t)
 #else
+#define TARGET_FIOGETOWN       0x8903
+#define TARGET_FIOSETOWN       0x8901
 #define TARGET_SIOCATMARK      0x8905
 #define TARGET_SIOCSPGRP       0x8902
 #define TARGET_SIOCGPGRP       0x8904
-- 
2.21.0



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

* [Qemu-devel] [PULL v2 13/15] linux-user: Add support for FDFLUSH ioctl
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (11 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 12/15] linux-user: Add support for FIOGETOWN and FIOSETOWN ioctls Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 14/15] linux-user: Add support for FDMSGON and FDMSGOFF ioctls Laurent Vivier
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Filippov, Riku Voipio, Yunqiang Su, Laurent Vivier,
	Aleksandar Markovic

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>
Message-Id: <1567601968-26946-5-git-send-email-aleksandar.markovic@rt-rk.com>
Signed-off-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 1830de96e12b..bc1944804220 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 6928f654ced3..e2af3c1494fa 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -89,6 +89,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 498223b77787..917202a2035d 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -888,6 +888,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.21.0



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

* [Qemu-devel] [PULL v2 14/15] linux-user: Add support for FDMSGON and FDMSGOFF ioctls
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (12 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 13/15] linux-user: Add support for FDFLUSH ioctl Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 15/15] linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls Laurent Vivier
  2019-09-12 17:09 ` [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Peter Maydell
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier, Aleksandar Markovic

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>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <1567601968-26946-6-git-send-email-aleksandar.markovic@rt-rk.com>
Signed-off-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 bc1944804220..b253469999ee 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 917202a2035d..4e33ef396be4 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -890,6 +890,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.21.0



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

* [Qemu-devel] [PULL v2 15/15] linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (13 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 14/15] linux-user: Add support for FDMSGON and FDMSGOFF ioctls Laurent Vivier
@ 2019-09-11  6:49 ` Laurent Vivier
  2019-09-12 17:09 ` [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Peter Maydell
  15 siblings, 0 replies; 17+ messages in thread
From: Laurent Vivier @ 2019-09-11  6:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Riku Voipio, Laurent Vivier, Aleksandar Markovic

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>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <1567601968-26946-7-git-send-email-aleksandar.markovic@rt-rk.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 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 b253469999ee..c6b9d6ad6653 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 4e33ef396be4..fa69c6ab8d01 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -893,6 +893,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.21.0



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

* Re: [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches
  2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
                   ` (14 preceding siblings ...)
  2019-09-11  6:49 ` [Qemu-devel] [PULL v2 15/15] linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls Laurent Vivier
@ 2019-09-12 17:09 ` Peter Maydell
  15 siblings, 0 replies; 17+ messages in thread
From: Peter Maydell @ 2019-09-12 17:09 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Max Filippov, Riku Voipio, QEMU Developers

On Wed, 11 Sep 2019 at 07:53, Laurent Vivier <laurent@vivier.eu> wrote:
>
> The following changes since commit 89ea03a7dc83ca36b670ba7f787802791fcb04b1:
>
>   Merge remote-tracking branch 'remotes/huth-gitlab/tags/m68k-pull-2019-09-07' into staging (2019-09-09 09:48:34 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/vivier/qemu.git tags/linux-user-for-4.2-pull-request
>
> for you to fetch changes up to 5eea942900536b76ad13bef35e1d8f276566ae9e:
>
>   linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls (2019-09-11 08:47:06 +0200)
>
> ----------------------------------------------------------------
> Add several floppy drive ioctl,
> xtensa call0 ABI support, arm MAX_RESERVED_VA for M-profile,
> aarch64 AT_HWCAP2, qOffsets' query for ELF, memfd_create,
> and some code cleanup
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.2
for any user-visible changes.

-- PMM


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

end of thread, other threads:[~2019-09-12 17:11 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11  6:49 [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 01/15] linux-user: remove useless variable Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 02/15] linux-user: Add AT_HWCAP2 for aarch64-linux-user Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 03/15] linux-user: erroneous fd_trans_unregister call Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 04/15] linux-user: fail and report on bad dfilter specs Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 05/15] linux-user: add memfd_create Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 06/15] linux-user: Pass CPUState to MAX_RESERVED_VA Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 07/15] linux-user/arm: Adjust MAX_RESERVED_VA for M-profile Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 08/15] linux-user: Support gdb 'qOffsets' query for ELF Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 09/15] target/xtensa: linux-user: add call0 ABI support Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 10/15] linux-user: drop redundant handling of environment variables Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 11/15] linux-user: Add support for RNDRESEEDCRNG ioctl Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 12/15] linux-user: Add support for FIOGETOWN and FIOSETOWN ioctls Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 13/15] linux-user: Add support for FDFLUSH ioctl Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 14/15] linux-user: Add support for FDMSGON and FDMSGOFF ioctls Laurent Vivier
2019-09-11  6:49 ` [Qemu-devel] [PULL v2 15/15] linux-user: Add support for FDRESET, FDRAWCMD, FDTWADDLE, and FDEJECT ioctls Laurent Vivier
2019-09-12 17:09 ` [Qemu-devel] [PULL v2 00/15] Linux user for 4.2 patches Peter Maydell

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