[Bug 1859310] [NEW] libvirt probing fails due to assertion failure with KVM and 'none' machine type

2020-01-11 Thread Joey Adams
Public bug reported:

Using libvirt on Ubuntu 19.10, I get the following error when I try to
set  to the latest qemu from git (commit dc65a5bdc9):

error: internal error: Failed to start QEMU binary /usr/local/bin
/qemu-system-x86_64 for probing:
/home/joey/git/qemu/target/i386/kvm.c:2176:kvm_arch_init: Object
0x564bfd5c3200 is not an instance of type x86-machine

Qemu command line to reproduce:

sudo x86_64-softmmu/qemu-system-x86_64 -machine 'none,accel=kvm'

Commit ed9e923c3c (Dec 12, 2019) introduced the issue by removing an
object_dynamic_cast call.  In this scenario, kvm_arch_init is passed an
instance of "none-machine" instead of "x86-machine".

The following one-line change to target/i386/kvm.c reintroduces the
cast:

 if (kvm_check_extension(s, KVM_CAP_X86_SMM) &&
+object_dynamic_cast(OBJECT(ms), TYPE_X86_MACHINE) &&
 x86_machine_is_smm_enabled(X86_MACHINE(ms))) {
 smram_machine_done.notify = register_smram_listener;
 qemu_add_machine_init_done_notifier(_machine_done);
 }

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1859310

Title:
  libvirt probing fails due to assertion failure with KVM and 'none'
  machine type

Status in QEMU:
  New

Bug description:
  Using libvirt on Ubuntu 19.10, I get the following error when I try to
  set  to the latest qemu from git (commit dc65a5bdc9):

  error: internal error: Failed to start QEMU binary /usr/local/bin
  /qemu-system-x86_64 for probing:
  /home/joey/git/qemu/target/i386/kvm.c:2176:kvm_arch_init: Object
  0x564bfd5c3200 is not an instance of type x86-machine

  Qemu command line to reproduce:

  sudo x86_64-softmmu/qemu-system-x86_64 -machine 'none,accel=kvm'

  Commit ed9e923c3c (Dec 12, 2019) introduced the issue by removing an
  object_dynamic_cast call.  In this scenario, kvm_arch_init is passed
  an instance of "none-machine" instead of "x86-machine".

  The following one-line change to target/i386/kvm.c reintroduces the
  cast:

   if (kvm_check_extension(s, KVM_CAP_X86_SMM) &&
  +object_dynamic_cast(OBJECT(ms), TYPE_X86_MACHINE) &&
   x86_machine_is_smm_enabled(X86_MACHINE(ms))) {
   smram_machine_done.notify = register_smram_listener;
   qemu_add_machine_init_done_notifier(_machine_done);
   }

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1859310/+subscriptions



Re: xlnx-zynqmp doesn't set psci-conduit on the R-cores

2020-01-11 Thread Edgar E. Iglesias
On Fri, 10 Jan. 2020, 08:42 Peter Maydell,  wrote:

> Hi; somebody pointed out to me that hw/arm/xlnx-zynqmp.c only
> sets the psci-conduit on the A-profile cores, not the R. This
> means you can't set the boot-cpu to an R-profile core and
> use PSCI to wake up the other one. Is the omission deliberate?
>
> thanks
> -- PMM
>


Hi,

I don't think this was given much thought.

AFAIK, we don't have any r5 software that implements PSCI (should that be
done over svc? Hmm not sure if that's possible). The ATF port that runs on
the a53s only handles the A cores IIRC.

I'll need to double check but in our sw stack the R5s are controlled via
EEMI, a SoC specific smc interface that runs on the PMU (MicroBlaze).

Do you know how other SoCs with heterogeneous cores handle this?

Best regards,
Edgar


Re: [PATCH v3 01/17] hw/arm: add Allwinner H3 System-on-Chip

2020-01-11 Thread Niek Linnenbank
On Thu, Jan 9, 2020 at 12:13 AM Philippe Mathieu-Daudé 
wrote:

> On 1/8/20 9:00 PM, Niek Linnenbank wrote:
> > The Allwinner H3 is a System on Chip containing four ARM Cortex A7
> > processor cores. Features and specifications include DDR2/DDR3 memory,
> > SD/MMC storage cards, 10/100/1000Mbit ethernet, USB 2.0, HDMI and
>
> "Ethernet"
>
> > various I/O modules. This commit adds support for the Allwinner H3
> > System on Chip.
> >
> > Signed-off-by: Niek Linnenbank 
> > ---
> >   default-configs/arm-softmmu.mak |   1 +
> >   include/hw/arm/allwinner-h3.h   | 107 +++
> >   hw/arm/allwinner-h3.c   | 328 
> >   MAINTAINERS |   7 +
> >   hw/arm/Kconfig  |   8 +
> >   hw/arm/Makefile.objs|   1 +
> >   6 files changed, 452 insertions(+)
> >   create mode 100644 include/hw/arm/allwinner-h3.h
> >   create mode 100644 hw/arm/allwinner-h3.c
> >
> > diff --git a/default-configs/arm-softmmu.mak
> b/default-configs/arm-softmmu.mak
> > index 1f2e0e7fde..d75a239c2c 100644
> > --- a/default-configs/arm-softmmu.mak
> > +++ b/default-configs/arm-softmmu.mak
> > @@ -40,3 +40,4 @@ CONFIG_FSL_IMX25=y
> >   CONFIG_FSL_IMX7=y
> >   CONFIG_FSL_IMX6UL=y
> >   CONFIG_SEMIHOSTING=y
> > +CONFIG_ALLWINNER_H3=y
> > diff --git a/include/hw/arm/allwinner-h3.h
> b/include/hw/arm/allwinner-h3.h
> > new file mode 100644
> > index 00..4e2e6202a9
> > --- /dev/null
> > +++ b/include/hw/arm/allwinner-h3.h
> > @@ -0,0 +1,107 @@
> > +/*
> > + * Allwinner H3 System on Chip emulation
> > + *
> > + * Copyright (C) 2019 Niek Linnenbank 
> > + *
> > + * This program is free software: you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation, either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program.  If not, see  >.
> > + */
> > +
> > +/*
> > + * The Allwinner H3 is a System on Chip containing four ARM Cortex A7
> > + * processor cores. Features and specifications include DDR2/DDR3
> memory,
> > + * SD/MMC storage cards, 10/100/1000Mbit ethernet, USB 2.0, HDMI and
> > + * various I/O modules.
> > + *
> > + * This implementation is based on the following datasheet:
> > + *
> > + *   https://linux-sunxi.org/File:Allwinner_H3_Datasheet_V1.2.pdf
> > + *
> > + * The latest datasheet and more info can be found on the Linux Sunxi
> wiki:
> > + *
> > + *   https://linux-sunxi.org/H3
> > + */
> > +
> > +#ifndef HW_ARM_ALLWINNER_H3_H
> > +#define HW_ARM_ALLWINNER_H3_H
> > +
> > +#include "qemu/osdep.h"
>
> Check CODING_STYLE.rst:
>
>Do not include "qemu/osdep.h" from header files since
>the .c file will have already included it.
>
> > +#include "qom/object.h"
> > +#include "qemu/error-report.h"
> > +#include "qemu/units.h"
> > +#include "hw/qdev-core.h"
> > +#include "hw/arm/boot.h"
>
> Please only keep the minimum required headers here, move the rest to the
> source files.
>
> > +#include "hw/timer/allwinner-a10-pit.h"
> > +#include "hw/intc/arm_gic.h"
> > +#include "target/arm/cpu.h"
>
> These looks OK in this header.
>
> Thanks, I'll also apply these changes to the other patches as well. I did
the same there.


> > +
> > +/**
> > + * Allwinner H3 device list
> > + *
> > + * This enumeration is can be used refer to a particular device in the
> > + * Allwinner H3 SoC. For example, the physical memory base address for
> > + * each device can be found in the AwH3State object in the memmap member
> > + * using the device enum value as index.
> > + *
> > + * @see AwH3State
> > + */
> > +enum {
> > +AW_H3_SRAM_A1,
> > +AW_H3_SRAM_A2,
> > +AW_H3_SRAM_C,
> > +AW_H3_PIT,
> > +AW_H3_UART0,
> > +AW_H3_UART1,
> > +AW_H3_UART2,
> > +AW_H3_UART3,
> > +AW_H3_GIC_DIST,
> > +AW_H3_GIC_CPU,
> > +AW_H3_GIC_HYP,
> > +AW_H3_GIC_VCPU,
> > +AW_H3_SDRAM
> > +};
> > +
> > +/** Total number of CPU cores in the SoC */
>
> "the H3 SoC"
>
> > +#define AW_H3_NUM_CPUS  (4)
> > +
> > +/**
> > + * Allwinner H3 object model
> > + * @{
> > + */
> > +
> > +/** Object type for the Allwinner H3 SoC */
> > +#define TYPE_AW_H3 "allwinner-h3"
> > +
> > +/** Convert input object to Allwinner H3 state object */
> > +#define AW_H3(obj) OBJECT_CHECK(AwH3State, (obj), TYPE_AW_H3)
> > +
> > +/** @} */
> > +
> > +/**
> > + * Allwinner H3 object instance state
>
> I find this comment more noisy than helpful.
>
> > + */
> > +typedef struct AwH3State {
> > +/*< private >*/
> > +DeviceState parent_obj;
> > +

[Bug 1856834] Re: PCI broken in qemu ppc e500 in v2.12.0 and other versions

2020-01-11 Thread ecsdn
Thanks for all the help Laurent! I'm new to git so not surre how to
'properly' revert a previous commit on top of master, so I'll google,
but if you have some a good link please do send.

Also, I've heard of the term "bisect" for figuring out at which commit
something breaks and if there were some good documentation to spell out
the steps to do that for users that aren't, well advanced kernel gurus
:D , I'm sure we'd be happy to save you smarter guys time with any
mundane testing steps when possible :) thx!

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1856834

Title:
  PCI broken in qemu ppc e500 in v2.12.0 and other versions

Status in QEMU:
  New

Bug description:
  The same qemu -M mpc... command that works on qemu-system-ppc version
  2.8.0 freezes guest on bootup and shows error for qemu-system-ppc
  version 4.2.0release and 4.19dirtygit:

  qemu-system-ppc: virtio-blk failed to set guest notifier (-24), ensure -accel 
kvm is set.
  qemu-system-ppc: virtio_bus_start_ioeventfd: failed. Fallback to userspace 
(slower).

  ends/freezes at:
  nbd: registered device at major 43
   vda:

  I'm using -drive file=/home/me/rawimage.dd,if=virtio and works fine in
  version 2.8.0 installed with apt-get install (Ubuntu 17.04) and also
  with 2.8.0 official release from git/github that I compiled/built
  myself. But both of the newer releases fail on the same exact machine
  same config.

  I also noticed that qemu-2.8.0 was fine with mtd but the newer ones I tried 
weren't, ie gave
  qemu-system-ppc: -drive if=mtd: machine type does not support 
if=mtd,bus=0,unit=0
  (but I removed -drive if=mtd since wasn't using it anyway)

  I also tried on windows but I think virtio doesn't work on windows
  hosts at all? On windows host it fails the same way, even version 2.12
  as well as 4.1.10...

  used:
  ./configure --prefix=/opt/... --enable-fdt --enable-kvm --enable-debug

  (basically all steps the same on same exact system same config, yet
  2.8.0 works fine whether apt-get installed or built from source while
  the others I built, 4.19/4.2.0 or 2.12/4.1.10(win) don't.)

  In case newer qemu versions act weird on various kernels, I did try with both 
vmlinuz-4.10.0-19-generic and vmlinuz-4.13.12-041312-generic (I didn't compile 
them but I can provide config-..files. This is on Ubuntu 17.04 x86_64 host 
emulating e500v2 cpm guest, ie -M mpc... GUEST kernel 2.6.32.44 which is why I 
can't use -M ppce500 instead..)
  tx
   ecs

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1856834/+subscriptions



Re: [PATCH v4 07/19] linux-user: xtensa: Remove unused constant TARGET_NR_syscall_count

2020-01-11 Thread Max Filippov
On Sat, Jan 11, 2020 at 7:43 AM Aleksandar Markovic
 wrote:
>
> From: Aleksandar Markovic 
>
> Currently, there is no usage of TARGET_NR_syscall_count for target
> xtensa, and there is no obvious indication if there is some planned
> usage in future.
>
> ---
>
> cc: Max Filippov 
> ---
>  linux-user/xtensa/syscall_nr.h | 2 --
>  1 file changed, 2 deletions(-)

Acked-by: Max Filippov 

-- 
Thanks.
-- Max



[Bug 1859291] [NEW] RISC-V incorrect exception generated

2020-01-11 Thread Teodori Serge
Public bug reported:

When using 'ecall' from supervisor mode, user exception is raised
instead of supervisor exception. The problem is located under
'target/riscv/insn_trans/trans_priviledged.inc.c' in function 'static
bool trans_ecall(DisasContext *ctx, arg_ecall *a)'. Best regards, Serge
Teodori

** Affects: qemu
 Importance: Undecided
 Status: New


** Tags: risc-v

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1859291

Title:
  RISC-V incorrect exception generated

Status in QEMU:
  New

Bug description:
  When using 'ecall' from supervisor mode, user exception is raised
  instead of supervisor exception. The problem is located under
  'target/riscv/insn_trans/trans_priviledged.inc.c' in function 'static
  bool trans_ecall(DisasContext *ctx, arg_ecall *a)'. Best regards,
  Serge Teodori

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1859291/+subscriptions



Re: [PATCH v4 00/19] linux-user: Misc patches for 5.0

2020-01-11 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/1578757241-29583-1-git-send-email-aleksandar.marko...@rt-rk.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH v4 00/19] linux-user: Misc patches for 5.0 
Type: series
Message-id: 1578757241-29583-1-git-send-email-aleksandar.marko...@rt-rk.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
400f993 linux-user: Add support for KCOV_INIT_TRACE ioctl
8929677 linux-user: Add support for KCOV_ ioctls
b20d5c0 configure: Detect kcov support and introduce CONFIG_KCOV
566462d linux-user: Add support for FDGETFDCSTAT ioctl
1519b94 linux-user: Add support for FDFMT ioctls
e0210c1 linux-user: Add support for FD 
ioctls
5217d67 linux-user: Add support for FIFREEZE and FITHAW ioctls
5d091c7 linux-user: Add support for FITRIM ioctl
b39749e linux-user: Add support for FS_IOC_FSXATTR ioctls
0014ebb linux-user: Add support for FS_IOC32_VERSION ioctls
f4000fd linux-user: Add support for FS_IOC32_FLAGS ioctls
4f6b25b linux-user: Add support for FS_IOC_VERSION ioctls
e273af4 linux-user: xtensa: Remove unused constant TARGET_NR_syscall_count
45583a2 linux-user: xtensa: Update syscall numbers to kernel 5.5 rc3 level
cb3ec39 linux-user: x86_64: Update syscall numbers to kernel 5.5 rc3 level
d2f11c1 linux-user: mips: Update syscall numbers to kernel 5.5 rc3 level
7670230 linux-user: microblaze: Update syscall numbers to kernel 5.5 rc3 level
ecbf45f linux-user: m68k: Update syscall numbers to kernel 5.5 rc3 level
cca9367 linux-user: Fix some constants in termbits.h

=== OUTPUT BEGIN ===
1/19 Checking commit cca936770168 (linux-user: Fix some constants in termbits.h)
2/19 Checking commit ecbf45fd21a9 (linux-user: m68k: Update syscall numbers to 
kernel 5.5 rc3 level)
3/19 Checking commit 7670230d1ddb (linux-user: microblaze: Update syscall 
numbers to kernel 5.5 rc3 level)
4/19 Checking commit d2f11c122963 (linux-user: mips: Update syscall numbers to 
kernel 5.5 rc3 level)
5/19 Checking commit cb3ec39377e8 (linux-user: x86_64: Update syscall numbers 
to kernel 5.5 rc3 level)
6/19 Checking commit 45583a29d092 (linux-user: xtensa: Update syscall numbers 
to kernel 5.5 rc3 level)
7/19 Checking commit e273af4f4e08 (linux-user: xtensa: Remove unused constant 
TARGET_NR_syscall_count)
ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 0 warnings, 6 lines checked

Patch 7/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

8/19 Checking commit 4f6b25b36f59 (linux-user: Add support for 
FS_IOC_VERSION ioctls)
9/19 Checking commit f4000fd1a019 (linux-user: Add support for 
FS_IOC32_FLAGS ioctls)
10/19 Checking commit 0014ebb01339 (linux-user: Add support for 
FS_IOC32_VERSION ioctls)
11/19 Checking commit b39749eac0d4 (linux-user: Add support for 
FS_IOC_FSXATTR ioctls)
12/19 Checking commit 5d091c7a4d8e (linux-user: Add support for FITRIM ioctl)
13/19 Checking commit 5217d67b408e (linux-user: Add support for FIFREEZE and 
FITHAW ioctls)
14/19 Checking commit e0210c1065b8 (linux-user: Add support for 
FD ioctls)
15/19 Checking commit 1519b94efae4 (linux-user: Add support for 
FDFMT ioctls)
16/19 Checking commit 566462d5371b (linux-user: Add support for FDGETFDCSTAT 
ioctl)
17/19 Checking commit b20d5c03e76f (configure: Detect kcov support and 
introduce CONFIG_KCOV)
18/19 Checking commit 8929677a6277 (linux-user: Add support for 
KCOV_ ioctls)
19/19 Checking commit 400f993ae8ed (linux-user: Add support for KCOV_INIT_TRACE 
ioctl)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/1578757241-29583-1-git-send-email-aleksandar.marko...@rt-rk.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

[PATCH v4 18/19] linux-user: Add support for KCOV_ ioctls

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

KCOV_ENABLE and KCOV_DISABLE play the role in kernel coverage
tracing. These ioctls do not use the third argument of ioctl()
system call and are straightforward to implement in QEMU.

Signed-off-by: Aleksandar Markovic 
---
 linux-user/ioctls.h   | 5 +
 linux-user/syscall.c  | 3 +++
 linux-user/syscall_defs.h | 4 
 3 files changed, 12 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index d72cd76..39b3825 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -552,3 +552,8 @@
   IOCTL_IGNORE(TIOCSTART)
   IOCTL_IGNORE(TIOCSTOP)
 #endif
+
+#ifdef CONFIG_KCOV
+  IOCTL(KCOV_ENABLE, 0, TYPE_NULL)
+  IOCTL(KCOV_DISABLE, 0, TYPE_NULL)
+#endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 171c0ca..6edcb0d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -73,6 +73,9 @@
 #ifdef CONFIG_SENDFILE
 #include 
 #endif
+#ifdef CONFIG_KCOV
+#include 
+#endif
 
 #define termios host_termios
 #define winsize host_winsize
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 225dcfb..87e390d 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2457,6 +2457,10 @@ struct target_mtpos {
 #define TARGET_MTIOCGETTARGET_IOR('m', 2, struct target_mtget)
 #define TARGET_MTIOCPOSTARGET_IOR('m', 3, struct target_mtpos)
 
+/* kcov ioctls */
+#define TARGET_KCOV_ENABLE TARGET_IO('c', 100)
+#define TARGET_KCOV_DISABLETARGET_IO('c', 101)
+
 struct target_sysinfo {
 abi_long uptime;/* Seconds since boot */
 abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */
-- 
2.7.4




[PATCH v4 15/19] linux-user: Add support for FDFMT ioctls

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

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

FDFMTTRK's third agrument is a pointer to the structure:

struct format_descr {
unsigned int device,head,track;
};

defined in Linux kernel header .

Since all fields of the structure are of type 'unsigned int', there is
no need to define "target_format_descr".

FDFMTBEG and FDFMTEND ioctls do not use the third argument.

Signed-off-by: Aleksandar Markovic 
---
 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 9e3ca90..e754a6b 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -115,6 +115,9 @@
  IOCTL(FDMSGON, 0, TYPE_NULL)
  IOCTL(FDMSGOFF, 0, TYPE_NULL)
  IOCTL(FDSETEMSGTRESH, 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(FDSETMAXERRS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors)))
  IOCTL(FDGETMAXERRS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index efe3860..d85ab46 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -899,6 +899,9 @@ struct target_pollfd {
 
 #define TARGET_FDMSGONTARGET_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 format_descr)
+#define TARGET_FDFMTEND   TARGET_IO(2, 0x49)
 #define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
 #define TARGET_FDFLUSHTARGET_IO(2, 0x4b)
 #define TARGET_FDSETMAXERRS  TARGET_IOW(2, 0x4c, struct floppy_max_errors)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index e4e0429..8ff78a6 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 */
+
 STRUCT(floppy_max_errors,
TYPE_INT, /* abort */
TYPE_INT, /* read_track */
-- 
2.7.4




[PATCH v4 16/19] linux-user: Add support for FDGETFDCSTAT ioctl

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

FDGETFDCSTAT's third agrument is a pointer to the structure:

struct floppy_fdc_state {
int spec1;
int spec2;
int dtr;
unsigned char version;
unsigned char dor;
unsigned long address;
unsigned int rawcmd:2;
unsigned int reset:1;
unsigned int need_configure:1;
unsigned int perp_mode:2;
unsigned int has_fifo:1;
unsigned int driver_version;
unsigned char track[4];
};

defined in Linux kernel header .

Since there is a fields of the structure of type 'unsigned long', there is
a need to define "target_format_descr". Also, five fields rawcmd, reset,
need_configure, perp_mode, and has_fifo are all just bitfields and are
part od a single 'unsigned int' field.

Signed-off-by: Aleksandar Markovic 
---
 linux-user/ioctls.h|  2 ++
 linux-user/syscall_defs.h  | 18 ++
 linux-user/syscall_types.h | 12 
 3 files changed, 32 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index e754a6b..d72cd76 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -122,6 +122,8 @@
  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(FDGETFDCSTAT, IOC_R,
+   MK_PTR(MK_STRUCT(STRUCT_target_floppy_fdc_state)))
  IOCTL(FDRAWCMD, 0, TYPE_NULL)
  IOCTL(FDTWADDLE, 0, TYPE_NULL)
  IOCTL(FDEJECT, 0, TYPE_NULL)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index d85ab46..225dcfb 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -897,6 +897,23 @@ struct target_pollfd {
 
 /* From  */
 
+struct target_floppy_fdc_state {
+int spec1;  /* spec1 value last used */
+int spec2;  /* spec2 value last used */
+int dtr;
+unsigned char version;  /* FDC version code */
+unsigned char dor;
+abi_long address;  /* io address */
+unsigned int rawcmd:2;
+unsigned int reset:1;
+unsigned int need_configure:1;
+unsigned int perp_mode:2;
+unsigned int has_fifo:1;
+unsigned int driver_version;/* version code for floppy driver */
+unsigned char track[4];
+};
+
+
 #define TARGET_FDMSGONTARGET_IO(2, 0x45)
 #define TARGET_FDMSGOFF   TARGET_IO(2, 0x46)
 #define TARGET_FDFMTBEG   TARGET_IO(2, 0x47)
@@ -907,6 +924,7 @@ struct target_pollfd {
 #define TARGET_FDSETMAXERRS  TARGET_IOW(2, 0x4c, struct floppy_max_errors)
 #define TARGET_FDGETMAXERRS  TARGET_IOR(2, 0x0e, struct floppy_max_errors)
 #define TARGET_FDRESETTARGET_IO(2, 0x54)
+#define TARGET_FDGETFDCSTAT  TARGET_IOR(2, 0x15, struct 
target_floppy_fdc_state)
 #define TARGET_FDRAWCMD   TARGET_IO(2, 0x58)
 #define TARGET_FDTWADDLE  TARGET_IO(2, 0x59)
 #define TARGET_FDEJECTTARGET_IO(2, 0x5a)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 8ff78a6..a111c61 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -273,6 +273,18 @@ STRUCT(floppy_max_errors,
TYPE_INT, /* recal */
TYPE_INT) /* reporting */
 
+STRUCT(target_floppy_fdc_state,
+   TYPE_INT, /* spec1 */
+   TYPE_INT, /* spec2 */
+   TYPE_INT, /* dtr */
+   TYPE_CHAR, /* version */
+   TYPE_CHAR, /* dor */
+   TYPE_ULONG, /* address */
+   TYPE_INT, /* bit field for rawcmd:2, reset:1, need_configure:1, */
+ /* perp_mode:2, and has_fifo:1 */
+   TYPE_INT, /* driver_version */
+   MK_ARRAY(TYPE_CHAR, 4)) /* track */
+
 #if defined(CONFIG_USBFS)
 /* usb device ioctls */
 STRUCT(usbdevfs_ctrltransfer,
-- 
2.7.4




[PATCH v4 17/19] configure: Detect kcov support and introduce CONFIG_KCOV

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

kcov is kernel code coverage tracing tool. It requires kernel 4.4+
compiled with certain kernel options. Its interface consists of
three ioctls.

This patch checks if kcov support is present on build machine, and
stores the result in variable CONFIG_KCOV, meant to be used in
linux-user code related to the support for above mentioned ioctls.

Signed-off-by: Aleksandar Markovic 
---
 configure | 21 +
 1 file changed, 21 insertions(+)

diff --git a/configure b/configure
index 940bf9e..dbdba8f 100755
--- a/configure
+++ b/configure
@@ -4752,6 +4752,24 @@ if compile_prog "" "" ; then
   syncfs=yes
 fi
 
+# check for kcov support (kernel must be 4.4+, compiled with certain options)
+kcov=no
+cat > $TMPC << EOF
+#include 
+
+int main(void)
+{
+ioctl(-1, KCOV_ENABLE, NULL);
+ioctl(-1, KCOV_DISABLE, NULL);
+ioctl(-1, KCOV_INIT_TRACE, NULL);
+
+return 0;
+}
+EOF
+if compile_prog "" "" ; then
+  kcov=yes
+fi
+
 # Check we have a new enough version of sphinx-build
 has_sphinx_build() {
 # This is a bit awkward but works: create a trivial document and
@@ -6874,6 +6892,9 @@ fi
 if test "$syncfs" = "yes" ; then
   echo "CONFIG_SYNCFS=y" >> $config_host_mak
 fi
+if test "$kcov" = "yes" ; then
+  echo "CONFIG_KCOV=y" >> $config_host_mak
+fi
 if test "$inotify" = "yes" ; then
   echo "CONFIG_INOTIFY=y" >> $config_host_mak
 fi
-- 
2.7.4




[PATCH v4 12/19] linux-user: Add support for FITRIM ioctl

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

FITRIM ioctl accepts a pointer to the structure

struct fstrim_range {
__u64 start;
__u64 len;
__u64 minlen;
};

as its third argument.

All ioctls in this group (FI* ioctl) are guarded with "#ifdef", so the
guards are used in this implementation too for consistency (however,
many of ioctls in FI* group became old enough that their #ifdef guards
could be removed, bit this is out of the scope of this patch).

Signed-off-by: Aleksandar Markovic 
---
 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 e1b89a7..e4f0a04 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -123,6 +123,9 @@
 #ifdef FIBMAP
  IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG))
 #endif
+#ifdef FITRIM
+ IOCTL(FITRIM, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_fstrim_range)))
+#endif
 #ifdef FICLONE
  IOCTL(FICLONE, IOC_W, TYPE_INT)
  IOCTL(FICLONERANGE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_file_clone_range)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 12cd3de..40851e9 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -908,6 +908,7 @@ struct target_pollfd {
 #define TARGET_FIBMAP TARGET_IO(0x00,1)  /* bmap access */
 #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for 
bmap */
 
+#define TARGET_FITRIM TARGET_IOWR('X', 121, struct fstrim_range)
 #define TARGET_FICLONETARGET_IOW(0x94, 9, int)
 #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
 
-- 
2.7.4




[PATCH v4 19/19] linux-user: Add support for KCOV_INIT_TRACE ioctl

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

KCOV_INIT_TRACE ioctl plays the role in kernel coverage tracing.
This ioctl's third argument is of type 'unsigned long', and the
implementation in QEMU is straightforward.

Signed-off-by: Aleksandar Markovic 
---
 linux-user/ioctls.h   | 1 +
 linux-user/syscall_defs.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 39b3825..1da71dd 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -556,4 +556,5 @@
 #ifdef CONFIG_KCOV
   IOCTL(KCOV_ENABLE, 0, TYPE_NULL)
   IOCTL(KCOV_DISABLE, 0, TYPE_NULL)
+  IOCTL(KCOV_INIT_TRACE, IOC_R, TYPE_ULONG)
 #endif
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 87e390d..209c138 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2460,6 +2460,7 @@ struct target_mtpos {
 /* kcov ioctls */
 #define TARGET_KCOV_ENABLE TARGET_IO('c', 100)
 #define TARGET_KCOV_DISABLETARGET_IO('c', 101)
+#define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong)
 
 struct target_sysinfo {
 abi_long uptime;/* Seconds since boot */
-- 
2.7.4




[PATCH v4 11/19] linux-user: Add support for FS_IOC_FSXATTR ioctls

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Both FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR accept a pointer to
the structure

struct file_clone_range {
__s64 src_fd;
__u64 src_offset;
__u64 src_length;
__u64 dest_offset;
};

as their third argument.

These ioctls were relatively recently introduced, so the "#ifdef"
guards are used in this implementation.

Signed-off-by: Aleksandar Markovic 
---
 linux-user/ioctls.h   | 7 +++
 linux-user/syscall_defs.h | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 3affd88..e1b89a7 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -144,6 +144,13 @@
  IOCTL(FS_IOC32_SETFLAGS, IOC_W, MK_PTR(TYPE_INT))
  IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT))
  IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
+#ifdef FS_IOC_FSGETXATTR
+ IOCTL(FS_IOC_FSGETXATTR, IOC_W, MK_PTR(MK_STRUCT(STRUCT_fsxattr)))
+#endif
+#ifdef FS_IOC_FSSETXATTR
+ IOCTL(FS_IOC_FSSETXATTR, IOC_W, MK_PTR(MK_STRUCT(STRUCT_fsxattr)))
+#endif
+
 
 #ifdef CONFIG_USBFS
   /* USB ioctls */
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index a73cc3d..12cd3de 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -924,6 +924,8 @@ struct target_pollfd {
 #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
 #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
 #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
+#define TARGET_FS_IOC_FSGETXATTR TARGET_IOR('X', 31, struct file_clone_range)
+#define TARGET_FS_IOC_FSSETXATTR TARGET_IOR('X', 32, struct file_clone_range)
 
 /* usb ioctls */
 #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
-- 
2.7.4




[PATCH v4 13/19] linux-user: Add support for FIFREEZE and FITHAW ioctls

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Both FIFREEZE and FITHAW ioctls accept an integer as their third
argument.

All ioctls in this group (FI* ioctl) are guarded with "#ifdef", so the
guards are used in this implementation too for consistency (however,
many of ioctls in FI* group became old enough that their #ifdef guards
could be removed, bit this is out of the scope of this patch).

Signed-off-by: Aleksandar Markovic 
---
 linux-user/ioctls.h   | 6 ++
 linux-user/syscall_defs.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index e4f0a04..66f8c4e 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -123,6 +123,12 @@
 #ifdef FIBMAP
  IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG))
 #endif
+#ifdef FIFREEZE
+ IOCTL(FIFREEZE, IOC_W | IOC_R, TYPE_INT)
+#endif
+#ifdef FITHAW
+ IOCTL(FITHAW, IOC_W | IOC_R, TYPE_INT)
+#endif
 #ifdef FITRIM
  IOCTL(FITRIM, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_fstrim_range)))
 #endif
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 40851e9..6b88030 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -908,6 +908,8 @@ struct target_pollfd {
 #define TARGET_FIBMAP TARGET_IO(0x00,1)  /* bmap access */
 #define TARGET_FIGETBSZ   TARGET_IO(0x00,2)  /* get the block size used for 
bmap */
 
+#define TARGET_FIFREEZE   TARGET_IOWR('X', 119, int)/* Freeze */
+#define TARGET_FITHAW TARGET_IOWR('X', 120, int)/* Thaw */
 #define TARGET_FITRIM TARGET_IOWR('X', 121, struct fstrim_range)
 #define TARGET_FICLONETARGET_IOW(0x94, 9, int)
 #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
-- 
2.7.4




[PATCH v4 09/19] linux-user: Add support for FS_IOC32_FLAGS ioctls

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

These FS_IOC32_FLAGS ioctls are identical to
FS_IOC_FLAGS ioctls, but without the anomaly of their
number defined as if their third argument is of type long, while
it is treated internally in kernel as is of type int.

Signed-off-by: Aleksandar Markovic 
---
 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 c44f42e..4fd6939 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -140,6 +140,8 @@
  IOCTL(FS_IOC_SETFLAGS, IOC_W, MK_PTR(TYPE_INT))
  IOCTL(FS_IOC_GETVERSION, IOC_R, MK_PTR(TYPE_INT))
  IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
+ IOCTL(FS_IOC32_GETFLAGS, IOC_R, MK_PTR(TYPE_INT))
+ IOCTL(FS_IOC32_SETFLAGS, IOC_W, MK_PTR(TYPE_INT))
 
 #ifdef CONFIG_USBFS
   /* USB ioctls */
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index f68a8b6..964b2b4 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -920,6 +920,8 @@ struct target_pollfd {
 #define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
 #define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
 #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
+#define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
+#define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
 
 /* usb ioctls */
 #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
-- 
2.7.4




[PATCH v4 14/19] linux-user: Add support for FD ioctls

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

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

FDSETEMSGTRESH's third agrument is a pointer to the structure:

struct floppy_max_errors {
unsigned int
  abort,  /* number of errors to be reached before aborting */
  read_track, /* maximal number of errors permitted to read an
   * entire track at once */
  reset,  /* maximal number of errors before a reset is tried */
  recal,  /* maximal number of errors before a recalibrate is
   * tried */
  /*
   * Threshold for reporting FDC errors to the console.
   * Setting this to zero may flood your screen when using
   * ultra cheap floppies ;-)
   */
  reporting;
};

defined in Linux kernel header .

Since all fields of the structure are of type 'unsigned int', there is
no need to define "target_floppy_max_errors".

FDSETMAXERRS and FDGETMAXERRS ioctls do not use the third argument.

Signed-off-by: Aleksandar Markovic 
---
 linux-user/ioctls.h| 3 +++
 linux-user/syscall_defs.h  | 3 +++
 linux-user/syscall_types.h | 7 +++
 3 files changed, 13 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 66f8c4e..9e3ca90 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -114,7 +114,10 @@
 
  IOCTL(FDMSGON, 0, TYPE_NULL)
  IOCTL(FDMSGOFF, 0, TYPE_NULL)
+ IOCTL(FDSETEMSGTRESH, 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 6b88030..efe3860 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -899,7 +899,10 @@ struct target_pollfd {
 
 #define TARGET_FDMSGONTARGET_IO(2, 0x45)
 #define TARGET_FDMSGOFF   TARGET_IO(2, 0x46)
+#define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
 #define TARGET_FDFLUSHTARGET_IO(2, 0x4b)
+#define TARGET_FDSETMAXERRS  TARGET_IOW(2, 0x4c, struct floppy_max_errors)
+#define TARGET_FDGETMAXERRS  TARGET_IOR(2, 0x0e, struct floppy_max_errors)
 #define TARGET_FDRESETTARGET_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 4e36983..e4e0429 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 */
+
 #if defined(CONFIG_USBFS)
 /* usb device ioctls */
 STRUCT(usbdevfs_ctrltransfer,
-- 
2.7.4




[PATCH v4 10/19] linux-user: Add support for FS_IOC32_VERSION ioctls

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

These FS_IOC32_VERSION ioctls are identical to
FS_IOC_VERSION ioctls, but without the anomaly of their
number defined as if their third argument is of type long, while
it is treated internally in kernel as is of type int.

Signed-off-by: Aleksandar Markovic 
---
 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 4fd6939..3affd88 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -142,6 +142,8 @@
  IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
  IOCTL(FS_IOC32_GETFLAGS, IOC_R, MK_PTR(TYPE_INT))
  IOCTL(FS_IOC32_SETFLAGS, IOC_W, MK_PTR(TYPE_INT))
+ IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT))
+ IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
 
 #ifdef CONFIG_USBFS
   /* USB ioctls */
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 964b2b4..a73cc3d 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -922,6 +922,8 @@ struct target_pollfd {
 #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
 #define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
 #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
+#define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
+#define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
 
 /* usb ioctls */
 #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
-- 
2.7.4




[PATCH v4 05/19] linux-user: x86_64: Update syscall numbers to kernel 5.5 rc3 level

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Update x86_64 syscall numbers based on Linux kernel tag v5.5-rc3
(commit 46cf053e).

Signed-off-by: Aleksandar Markovic 

---

cc: Paolo Bonzini 
cc: Richard Henderson 
cc: Eduardo Habkost 
---
 linux-user/x86_64/syscall_nr.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/linux-user/x86_64/syscall_nr.h b/linux-user/x86_64/syscall_nr.h
index 9b6981e..e5d14ec 100644
--- a/linux-user/x86_64/syscall_nr.h
+++ b/linux-user/x86_64/syscall_nr.h
@@ -328,5 +328,29 @@
 #define TARGET_NR_membarrier324
 #define TARGET_NR_mlock2325
 #define TARGET_NR_copy_file_range   326
+#define TARGET_NR_preadv2   327
+#define TARGET_NR_pwritev2  328
+#define TARGET_NR_pkey_mprotect 329
+#define TARGET_NR_pkey_alloc330
+#define TARGET_NR_pkey_free 331
+#define TARGET_NR_statx 332
+#define TARGET_NR_io_pgetevents 333
+#define TARGET_NR_rseq  334
+/*
+ * don't use numbers 387 through 423, add new calls after the last
+ * 'common' entry
+ */
+#define TARGET_NR_pidfd_send_signal 424
+#define TARGET_NR_io_uring_setup425
+#define TARGET_NR_io_uring_enter426
+#define TARGET_NR_io_uring_register 427
+#define TARGET_NR_open_tree 428
+#define TARGET_NR_move_mount429
+#define TARGET_NR_fsopen430
+#define TARGET_NR_fsconfig  431
+#define TARGET_NR_fsmount   432
+#define TARGET_NR_fspick433
+#define TARGET_NR_pidfd_open434
+#define TARGET_NR_clone3435
 
 #endif
-- 
2.7.4




[PATCH v4 07/19] linux-user: xtensa: Remove unused constant TARGET_NR_syscall_count

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Currently, there is no usage of TARGET_NR_syscall_count for target
xtensa, and there is no obvious indication if there is some planned
usage in future.

---

cc: Max Filippov 
---
 linux-user/xtensa/syscall_nr.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/linux-user/xtensa/syscall_nr.h b/linux-user/xtensa/syscall_nr.h
index 3d19d0c..39bff65 100644
--- a/linux-user/xtensa/syscall_nr.h
+++ b/linux-user/xtensa/syscall_nr.h
@@ -466,6 +466,4 @@
 #define TARGET_NR_pidfd_open 434
 #define TARGET_NR_clone3 435
 
-#define TARGET_NR_syscall_count  436
-
 #endif /* XTENSA_SYSCALL_NR_H */
-- 
2.7.4




[PATCH v4 08/19] linux-user: Add support for FS_IOC_VERSION ioctls

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

A very specific thing for these two ioctls is that their code
implies that their third argument is of type 'long', but the
kernel uses that argument as if it is of type 'int'. This anomaly
is recognized also in commit 6080723 (linux-user: Implement
FS_IOC_GETFLAGS and FS_IOC_SETFLAGS ioctls).

Signed-off-by: Aleksandar Markovic 
---
 linux-user/ioctls.h   | 2 ++
 linux-user/syscall_defs.h | 8 +---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index c6b9d6a..c44f42e 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -138,6 +138,8 @@
 
  IOCTL(FS_IOC_GETFLAGS, IOC_R, MK_PTR(TYPE_INT))
  IOCTL(FS_IOC_SETFLAGS, IOC_W, MK_PTR(TYPE_INT))
+ IOCTL(FS_IOC_GETVERSION, IOC_R, MK_PTR(TYPE_INT))
+ IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
 
 #ifdef CONFIG_USBFS
   /* USB ioctls */
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 98c2119..f68a8b6 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -911,12 +911,14 @@ struct target_pollfd {
 #define TARGET_FICLONETARGET_IOW(0x94, 9, int)
 #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
 
-/* Note that the ioctl numbers claim type "long" but the actual type
- * used by the kernel is "int".
+/*
+ * Note that the ioctl numbers for FS_IOC_
+ * claim type "long" but the actual type used by the kernel is "int".
  */
 #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
 #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
-
+#define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
+#define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
 #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
 
 /* usb ioctls */
-- 
2.7.4




[PATCH v4 04/19] linux-user: mips: Update syscall numbers to kernel 5.5 rc3 level

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Update mips syscall numbers based on Linux kernel tag v5.5-rc3
(commit 46cf053e).

Signed-off-by: Aleksandar Markovic 
---
 linux-user/mips/cpu_loop.c | 78 +-
 linux-user/mips/syscall_nr.h   | 45 
 linux-user/mips64/syscall_nr.h | 13 +++
 3 files changed, 135 insertions(+), 1 deletion(-)

diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
index 39915b3..b81479b 100644
--- a/linux-user/mips/cpu_loop.c
+++ b/linux-user/mips/cpu_loop.c
@@ -25,8 +25,9 @@
 #include "internal.h"
 
 # ifdef TARGET_ABI_MIPSO32
+#  define MIPS_SYSCALL_NUMBER_UNUSED -1
 #  define MIPS_SYS(name, args) args,
-static const uint8_t mips_syscall_args[] = {
+static const int8_t mips_syscall_args[] = {
 MIPS_SYS(sys_syscall, 8)/* 4000 */
 MIPS_SYS(sys_exit   , 1)
 MIPS_SYS(sys_fork   , 0)
@@ -390,6 +391,75 @@ static const uint8_t mips_syscall_args[] = {
 MIPS_SYS(sys_copy_file_range, 6) /* 360 */
 MIPS_SYS(sys_preadv2, 6)
 MIPS_SYS(sys_pwritev2, 6)
+MIPS_SYS(sys_pkey_mprotect, 4)
+MIPS_SYS(sys_pkey_alloc, 2)
+MIPS_SYS(sys_pkey_free, 1) /* 365 */
+MIPS_SYS(sys_statx, 5)
+MIPS_SYS(sys_rseq, 4)
+MIPS_SYS(sys_io_pgetevents, 6)
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 370 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 375 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 380 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 385 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,/* 390 */
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYSCALL_NUMBER_UNUSED,
+MIPS_SYS(sys_semget, 3)
+MIPS_SYS(sys_semctl, 4)
+MIPS_SYS(sys_shmget, 3)/* 395 */
+MIPS_SYS(sys_shmctl, 3)
+MIPS_SYS(sys_shmat, 3)
+MIPS_SYS(sys_shmdt, 1)
+MIPS_SYS(sys_msgget, 2)
+MIPS_SYS(sys_msgsnd, 4)/* 400 */
+MIPS_SYS(sys_msgrcv, 5)
+MIPS_SYS(sys_msgctl, 3)
+MIPS_SYS(sys_timer_gettime64, 2)
+MIPS_SYS(sys_timer_settime64, 4)
+MIPS_SYS(sys_timerfd_gettime64, 2) /* 410 */
+MIPS_SYS(sys_timerfd_settime64, 4)
+MIPS_SYS(sys_utimensat_time64, 4)
+MIPS_SYS(sys_pselect6_time64, 6)
+MIPS_SYS(sys_ppoll_time64, 5)
+MIPS_SYSCALL_NUMBER_UNUSED,/* 415 */
+MIPS_SYS(sys_io_pgetevents_time64, 6)
+MIPS_SYS(sys_recvmmsg_time64, 5)
+MIPS_SYS(sys_mq_timedsend_time64, 5)
+MIPS_SYS(sys_mq_timedreceive_time64, 5)
+MIPS_SYS(sys_semtimedop_time64, 4) /* 420 */
+MIPS_SYS(sys_rt_sigtimedwait_time64, 4)
+MIPS_SYS(sys_futex_time64, 6)
+MIPS_SYS(sys_sched_rr_get_interval_time64, 2)
+MIPS_SYS(sys_pidfd_send_signal, 4)
+MIPS_SYS(sys_io_uring_setup, 2)/* 425 */
+MIPS_SYS(sys_io_uring_enter, 6)
+MIPS_SYS(sys_io_uring_register, 4)
+MIPS_SYS(sys_open_tree, 3)
+MIPS_SYS(sys_move_mount, 5)
+MIPS_SYS(sys_fsopen, 2)/* 430 */
+MIPS_SYS(sys_fsconfig, 5)
+MIPS_SYS(sys_fsmount, 3)
+MIPS_SYS(sys_fspick, 3)
+MIPS_SYS(sys_pidfd_open, 2)
+MIPS_SYS(sys_clone3, 2)/* 435 */
+
 };
 #  undef MIPS_SYS
 # endif /* O32 */
@@ -447,8 +517,14 @@ void cpu_loop(CPUMIPSState *env)
 # ifdef TARGET_ABI_MIPSO32
 syscall_num = env->active_tc.gpr[2] - 4000;
 if (syscall_num >= sizeof(mips_syscall_args)) {
+/* syscall_num is larger that any defined for MIPS O32 */
+ret = -TARGET_ENOSYS;
+} else if (mips_syscall_args[syscall_num] ==
+   MIPS_SYSCALL_NUMBER_UNUSED) {
+/* syscall_num belongs to the range not defined for MIPS O32 */
 ret = -TARGET_ENOSYS;
 } else {
+/* syscall_num is valid */
 int nb_args;
 abi_ulong sp_reg;
 abi_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0;
diff --git a/linux-user/mips/syscall_nr.h b/linux-user/mips/syscall_nr.h
index 7fa7fa5..0be3af1 100644
--- a/linux-user/mips/syscall_nr.h
+++ 

[PATCH v4 06/19] linux-user: xtensa: Update syscall numbers to kernel 5.5 rc3 level

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Update xtensa syscall numbers based on Linux kernel tag v5.5-rc3
(commit 46cf053e).

Signed-off-by: Aleksandar Markovic 

---

cc: Max Filippov 
---
 linux-user/xtensa/syscall_nr.h | 38 --
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/linux-user/xtensa/syscall_nr.h b/linux-user/xtensa/syscall_nr.h
index 27645be..3d19d0c 100644
--- a/linux-user/xtensa/syscall_nr.h
+++ b/linux-user/xtensa/syscall_nr.h
@@ -431,7 +431,41 @@
 #define TARGET_NR_pkey_free  350
 
 #define TARGET_NR_statx  351
-
-#define TARGET_NR_syscall_count  352
+#define TARGET_NR_rseq   352
+/* 353 through 402 are unassigned to sync up with generic numbers */
+#define TARGET_NR_clock_gettime64403
+#define TARGET_NR_clock_settime64404
+#define TARGET_NR_clock_adjtime64405
+#define TARGET_NR_clock_getres_time64406
+#define TARGET_NR_clock_nanosleep_time64 407
+#define TARGET_NR_timer_gettime64408
+#define TARGET_NR_timer_settime64409
+#define TARGET_NR_timerfd_gettime64  410
+#define TARGET_NR_timerfd_settime64  411
+#define TARGET_NR_utimensat_time64   412
+#define TARGET_NR_pselect6_time64413
+#define TARGET_NR_ppoll_time64   414
+#define TARGET_NR_io_pgetevents_time64   416
+#define TARGET_NR_recvmmsg_time64417
+#define TARGET_NR_mq_timedsend_time64418
+#define TARGET_NR_mq_timedreceive_time64 419
+#define TARGET_NR_semtimedop_time64  420
+#define TARGET_NR_rt_sigtimedwait_time64 421
+#define TARGET_NR_futex_time64   422
+#define TARGET_NR_sched_rr_get_interval_time64   423
+#define TARGET_NR_pidfd_send_signal  424
+#define TARGET_NR_io_uring_setup 425
+#define TARGET_NR_io_uring_enter 426
+#define TARGET_NR_io_uring_register  427
+#define TARGET_NR_open_tree  428
+#define TARGET_NR_move_mount 429
+#define TARGET_NR_fsopen 430
+#define TARGET_NR_fsconfig   431
+#define TARGET_NR_fsmount432
+#define TARGET_NR_fspick 433
+#define TARGET_NR_pidfd_open 434
+#define TARGET_NR_clone3 435
+
+#define TARGET_NR_syscall_count  436
 
 #endif /* XTENSA_SYSCALL_NR_H */
-- 
2.7.4




[PATCH v4 01/19] linux-user: Fix some constants in termbits.h

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Some constants were defined in terms of host, instead of target,
as they should be.

Some additional trivial changes in this patch were forced by
checkpatch.pl.

Reviewed-by: Max Filippov 
Signed-off-by: Aleksandar Markovic 
---
 linux-user/aarch64/termbits.h|   4 +-
 linux-user/alpha/termbits.h  |  10 +--
 linux-user/arm/termbits.h|   4 +-
 linux-user/cris/termbits.h   |   4 +-
 linux-user/hppa/termbits.h   |   4 +-
 linux-user/i386/termbits.h   |   4 +-
 linux-user/m68k/termbits.h   |   4 +-
 linux-user/microblaze/termbits.h |   4 +-
 linux-user/mips/termbits.h   |   4 +-
 linux-user/nios2/termbits.h  |   4 +-
 linux-user/openrisc/termbits.h   |   6 +-
 linux-user/ppc/termbits.h|   4 +-
 linux-user/riscv/termbits.h  |   4 +-
 linux-user/s390x/termbits.h  |  26 ---
 linux-user/sh4/termbits.h|   4 +-
 linux-user/sparc/termbits.h  |   4 +-
 linux-user/sparc64/termbits.h|   4 +-
 linux-user/x86_64/termbits.h |   6 +-
 linux-user/xtensa/termbits.h | 156 ++-
 19 files changed, 141 insertions(+), 119 deletions(-)

diff --git a/linux-user/aarch64/termbits.h b/linux-user/aarch64/termbits.h
index 0ab448d..998fc1d 100644
--- a/linux-user/aarch64/termbits.h
+++ b/linux-user/aarch64/termbits.h
@@ -83,8 +83,8 @@ struct target_termios {
 #define  TARGET_B9600  015
 #define  TARGET_B19200 016
 #define  TARGET_B38400 017
-#define TARGET_EXTA B19200
-#define TARGET_EXTB B38400
+#define TARGET_EXTATARGET_B19200
+#define TARGET_EXTBTARGET_B38400
 #define TARGET_CSIZE   060
 #define   TARGET_CS5   000
 #define   TARGET_CS6   020
diff --git a/linux-user/alpha/termbits.h b/linux-user/alpha/termbits.h
index a714251..ace19be 100644
--- a/linux-user/alpha/termbits.h
+++ b/linux-user/alpha/termbits.h
@@ -108,8 +108,8 @@ struct target_termios {
 #define  TARGET_B9600  015
 #define  TARGET_B19200 016
 #define  TARGET_B38400 017
-#define TARGET_EXTA B19200
-#define TARGET_EXTB B38400
+#define TARGET_EXTA TARGET_B19200
+#define TARGET_EXTB TARGET_B38400
 #define TARGET_CBAUDEX 000
 #define  TARGET_B57600   00020
 #define  TARGET_B115200  00021
@@ -165,7 +165,7 @@ struct target_termios {
 #define TARGET_FIOASYNCTARGET_IOW('f', 125, int)
 #define TARGET_FIONBIO TARGET_IOW('f', 126, int)
 #define TARGET_FIONREADTARGET_IOR('f', 127, int)
-#define TARGET_TIOCINQ FIONREAD
+#define TARGET_TIOCINQ  TARGET_FIONREAD
 #define TARGET_FIOQSIZETARGET_IOR('f', 128, loff_t)
 
 #define TARGET_TIOCGETPTARGET_IOR('t', 8, struct target_sgttyb)
@@ -217,8 +217,8 @@ struct target_termios {
 # define TARGET_TIOCM_CAR  0x040
 # define TARGET_TIOCM_RNG  0x080
 # define TARGET_TIOCM_DSR  0x100
-# define TARGET_TIOCM_CD   TIOCM_CAR
-# define TARGET_TIOCM_RI   TIOCM_RNG
+# define TARGET_TIOCM_CDTARGET_TIOCM_CAR
+# define TARGET_TIOCM_RITARGET_TIOCM_RNG
 # define TARGET_TIOCM_OUT1 0x2000
 # define TARGET_TIOCM_OUT2 0x4000
 # define TARGET_TIOCM_LOOP 0x8000
diff --git a/linux-user/arm/termbits.h b/linux-user/arm/termbits.h
index e555cff..7170b8a 100644
--- a/linux-user/arm/termbits.h
+++ b/linux-user/arm/termbits.h
@@ -83,8 +83,8 @@ struct target_termios {
 #define  TARGET_B9600  015
 #define  TARGET_B19200 016
 #define  TARGET_B38400 017
-#define TARGET_EXTA B19200
-#define TARGET_EXTB B38400
+#define TARGET_EXTATARGET_B19200
+#define TARGET_EXTBTARGET_B38400
 #define TARGET_CSIZE   060
 #define   TARGET_CS5   000
 #define   TARGET_CS6   020
diff --git a/linux-user/cris/termbits.h b/linux-user/cris/termbits.h
index 475ee70..76d5ed0 100644
--- a/linux-user/cris/termbits.h
+++ b/linux-user/cris/termbits.h
@@ -81,8 +81,8 @@ struct target_termios {
 #define  TARGET_B9600  015
 #define  TARGET_B19200 016
 #define  TARGET_B38400 017
-#define TARGET_EXTA B19200
-#define TARGET_EXTB B38400
+#define TARGET_EXTATARGET_B19200
+#define TARGET_EXTBTARGET_B38400
 #define TARGET_CSIZE   060
 #define   TARGET_CS5   000
 #define   TARGET_CS6   020
diff --git a/linux-user/hppa/termbits.h b/linux-user/hppa/termbits.h
index 8fba839..3094710 100644
--- a/linux-user/hppa/termbits.h
+++ b/linux-user/hppa/termbits.h
@@ -82,8 +82,8 @@ struct target_termios {
 #define  TARGET_B9600  015
 #define  TARGET_B19200 016
 #define  TARGET_B38400 017
-#define TARGET_EXTA B19200
-#define TARGET_EXTB B38400
+#define TARGET_EXTATARGET_B19200
+#define TARGET_EXTBTARGET_B38400
 #define TARGET_CSIZE   060
 #define   TARGET_CS5   000
 #define   TARGET_CS6   020
diff --git a/linux-user/i386/termbits.h b/linux-user/i386/termbits.h
index 88264bb..3b16977 100644
--- a/linux-user/i386/termbits.h
+++ b/linux-user/i386/termbits.h
@@ -82,8 +82,8 @@ struct target_termios {
 #define  TARGET_B9600  015
 #define  

[PATCH v4 03/19] linux-user: microblaze: Update syscall numbers to kernel 5.5 rc3 level

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Update microblaze syscall numbers based on Linux kernel tag v5.5-rc3
(commit 46cf053e).

Signed-off-by: Aleksandar Markovic 

---

cc: Edgar E. Iglesias 
---
 linux-user/microblaze/syscall_nr.h | 45 ++
 1 file changed, 45 insertions(+)

diff --git a/linux-user/microblaze/syscall_nr.h 
b/linux-user/microblaze/syscall_nr.h
index aa2eb93..ec1758e 100644
--- a/linux-user/microblaze/syscall_nr.h
+++ b/linux-user/microblaze/syscall_nr.h
@@ -393,5 +393,50 @@
 #define TARGET_NR_memfd_create  386
 #define TARGET_NR_bpf   387
 #define TARGET_NR_execveat  388
+#define TARGET_NR_userfaultfd   389
+#define TARGET_NR_membarrier390
+#define TARGET_NR_mlock2391
+#define TARGET_NR_copy_file_range   392
+#define TARGET_NR_preadv2   393
+#define TARGET_NR_pwritev2  394
+#define TARGET_NR_pkey_mprotect 395
+#define TARGET_NR_pkey_alloc396
+#define TARGET_NR_pkey_free 397
+#define TARGET_NR_statx 398
+#define TARGET_NR_io_pgetevents 399
+#define TARGET_NR_rseq  400
+/* 401 and 402 are unused */
+#define TARGET_NR_clock_gettime64   403
+#define TARGET_NR_clock_settime64   404
+#define TARGET_NR_clock_adjtime64   405
+#define TARGET_NR_clock_getres_time64   406
+#define TARGET_NR_clock_nanosleep_time64 407
+#define TARGET_NR_timer_gettime64   408
+#define TARGET_NR_timer_settime64   409
+#define TARGET_NR_timerfd_gettime64 410
+#define TARGET_NR_timerfd_settime64 411
+#define TARGET_NR_utimensat_time64  412
+#define TARGET_NR_pselect6_time64   413
+#define TARGET_NR_ppoll_time64  414
+#define TARGET_NR_io_pgetevents_time64  416
+#define TARGET_NR_recvmmsg_time64   417
+#define TARGET_NR_mq_timedsend_time64   418
+#define TARGET_NR_mq_timedreceive_time64 419
+#define TARGET_NR_semtimedop_time64 420
+#define TARGET_NR_rt_sigtimedwait_time64 421
+#define TARGET_NR_futex_time64  422
+#define TARGET_NR_sched_rr_get_interval_time64 423
+#define TARGET_NR_pidfd_send_signal 424
+#define TARGET_NR_io_uring_setup425
+#define TARGET_NR_io_uring_enter426
+#define TARGET_NR_io_uring_register 427
+#define TARGET_NR_open_tree 428
+#define TARGET_NR_move_mount429
+#define TARGET_NR_fsopen430
+#define TARGET_NR_fsconfig  431
+#define TARGET_NR_fsmount   432
+#define TARGET_NR_fspick433
+#define TARGET_NR_pidfd_open434
+#define TARGET_NR_clone3435
 
 #endif
-- 
2.7.4




[PATCH v4 02/19] linux-user: m68k: Update syscall numbers to kernel 5.5 rc3 level

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Update m68k syscall numbers based on Linux kernel tag v5.5-rc3
(commit 46cf053e).

Signed-off-by: Aleksandar Markovic 

---

cc: Laurent Vivier 
---
 linux-user/m68k/syscall_nr.h | 50 +++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/linux-user/m68k/syscall_nr.h b/linux-user/m68k/syscall_nr.h
index d33d8e9..01aee34 100644
--- a/linux-user/m68k/syscall_nr.h
+++ b/linux-user/m68k/syscall_nr.h
@@ -382,5 +382,53 @@
 #define TARGET_NR_copy_file_range   376
 #define TARGET_NR_preadv2   377
 #define TARGET_NR_pwritev2  378
-
+#define TARGET_NR_statx 379
+#define TARGET_NR_seccomp   380
+#define TARGET_NR_pkey_mprotect 381
+#define TARGET_NR_pkey_alloc382
+#define TARGET_NR_pkey_free 383
+#define TARGET_NR_rseq  384
+/* room for arch specific calls */
+#define TARGET_NR_semget393
+#define TARGET_NR_semctl394
+#define TARGET_NR_shmget395
+#define TARGET_NR_shmctl396
+#define TARGET_NR_shmat 397
+#define TARGET_NR_shmdt 398
+#define TARGET_NR_msgget399
+#define TARGET_NR_msgsnd400
+#define TARGET_NR_msgrcv401
+#define TARGET_NR_msgctl402
+#define TARGET_NR_clock_gettime64   403
+#define TARGET_NR_clock_settime64   404
+#define TARGET_NR_clock_adjtime64   405
+#define TARGET_NR_clock_getres_time64   406
+#define TARGET_NR_clock_nanosleep_time64 407
+#define TARGET_NR_timer_gettime64   408
+#define TARGET_NR_timer_settime64   409
+#define TARGET_NR_timerfd_gettime64 410
+#define TARGET_NR_timerfd_settime64 411
+#define TARGET_NR_utimensat_time64  412
+#define TARGET_NR_pselect6_time64   413
+#define TARGET_NR_ppoll_time64  414
+#define TARGET_NR_io_pgetevents_time64  416
+#define TARGET_NR_recvmmsg_time64   417
+#define TARGET_NR_mq_timedsend_time64   418
+#define TARGET_NR_mq_timedreceive_time64 419
+#define TARGET_NR_semtimedop_time64 420
+#define TARGET_NR_rt_sigtimedwait_time64 421
+#define TARGET_NR_futex_time64  422
+#define TARGET_NR_sched_rr_get_interval_time64 423
+#define TARGET_NR_pidfd_send_signal 424
+#define TARGET_NR_io_uring_setup425
+#define TARGET_NR_io_uring_enter426
+#define TARGET_NR_io_uring_register 427
+#define TARGET_NR_open_tree 428
+#define TARGET_NR_move_mount429
+#define TARGET_NR_fsopen430
+#define TARGET_NR_fsconfig  431
+#define TARGET_NR_fsmount   432
+#define TARGET_NR_fspick433
+#define TARGET_NR_pidfd_open434
+/* 435 reserved for clone3 */
 #endif
-- 
2.7.4




[PATCH v4 00/19] linux-user: Misc patches for 5.0

2020-01-11 Thread Aleksandar Markovic
From: Aleksandar Markovic 

This series is a collection of linux-user patches I recently
accumulated. The summary of patches is as follows:

Patch 1: Fix for some issues in termbits.h files.
Patches 2-6: Updating syscall numbers
Patch 7: A minor xtensa cleanup
Patches 8-13: Adding support for some filesystem-related ioctls
Patches 14-16: Adding support for some floppy-drive-related ioctls
Patches 17-19: Adding support for kcov-related ioctls

History of the series:

v3->v4:

  - added support for three filesystem-related ioctls
  - added syscall number update for m68k, microblaze, x86_64 and xtensa
  - fixed some issues related to unused ranges of syscall numbers for
mips o32
  - several minor corrections

v2->v3:

  - added support for seven floppy-drive-related ioctls
  - added support for three kcov-related ioctls

v1->v2:

  - fixed a constant in xtensa's termbits.h that was missed in v1
  - redid syscall numbers for mips o32
  - minor formatting and wording changes

Aleksandar Markovic (19):
  linux-user: Fix some constants in termbits.h
  linux-user: m68k: Update syscall numbers to kernel 5.5 rc3 level
  linux-user: microblaze: Update syscall numbers to kernel 5.5 rc3 level
  linux-user: mips: Update syscall numbers to kernel 5.5 rc3 level
  linux-user: x86_64: Update syscall numbers to kernel 5.5 rc3 level
  linux-user: xtensa: Update syscall numbers to kernel 5.5 rc3 level
  linux-user: xtensa: Remove unused constant TARGET_NR_syscall_count
  linux-user: Add support for FS_IOC_VERSION ioctls
  linux-user: Add support for FS_IOC32_FLAGS ioctls
  linux-user: Add support for FS_IOC32_VERSION ioctls
  linux-user: Add support for FS_IOC_FSXATTR ioctls
  linux-user: Add support for FITRIM ioctl
  linux-user: Add support for FIFREEZE and FITHAW ioctls
  linux-user: Add support for FD
ioctls
  linux-user: Add support for FDFMT ioctls
  linux-user: Add support for FDGETFDCSTAT ioctl
  configure: Detect kcov support and introduce CONFIG_KCOV
  linux-user: Add support for KCOV_ ioctls
  linux-user: Add support for KCOV_INIT_TRACE ioctl

 configure  |  21 +
 linux-user/aarch64/termbits.h  |   4 +-
 linux-user/alpha/termbits.h|  10 +--
 linux-user/arm/termbits.h  |   4 +-
 linux-user/cris/termbits.h |   4 +-
 linux-user/hppa/termbits.h |   4 +-
 linux-user/i386/termbits.h |   4 +-
 linux-user/ioctls.h|  36 +
 linux-user/m68k/syscall_nr.h   |  50 +++-
 linux-user/m68k/termbits.h |   4 +-
 linux-user/microblaze/syscall_nr.h |  45 +++
 linux-user/microblaze/termbits.h   |   4 +-
 linux-user/mips/cpu_loop.c |  78 ++-
 linux-user/mips/syscall_nr.h   |  45 +++
 linux-user/mips/termbits.h |   4 +-
 linux-user/mips64/syscall_nr.h |  13 
 linux-user/nios2/termbits.h|   4 +-
 linux-user/openrisc/termbits.h |   6 +-
 linux-user/ppc/termbits.h  |   4 +-
 linux-user/riscv/termbits.h|   4 +-
 linux-user/s390x/termbits.h|  26 ---
 linux-user/sh4/termbits.h  |   4 +-
 linux-user/sparc/termbits.h|   4 +-
 linux-user/sparc64/termbits.h  |   4 +-
 linux-user/syscall.c   |   3 +
 linux-user/syscall_defs.h  |  46 ++-
 linux-user/syscall_types.h |  24 ++
 linux-user/x86_64/syscall_nr.h |  24 ++
 linux-user/x86_64/termbits.h   |   6 +-
 linux-user/xtensa/syscall_nr.h |  36 -
 linux-user/xtensa/termbits.h   | 156 +
 31 files changed, 555 insertions(+), 126 deletions(-)

-- 
2.7.4




[Bug 1856834] Re: PCI broken in qemu ppc e500 in v2.12.0 and other versions

2020-01-11 Thread Laurent Vivier
If I revert 67113c03423a on top of master, vda is correctly detected.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1856834

Title:
  PCI broken in qemu ppc e500 in v2.12.0 and other versions

Status in QEMU:
  New

Bug description:
  The same qemu -M mpc... command that works on qemu-system-ppc version
  2.8.0 freezes guest on bootup and shows error for qemu-system-ppc
  version 4.2.0release and 4.19dirtygit:

  qemu-system-ppc: virtio-blk failed to set guest notifier (-24), ensure -accel 
kvm is set.
  qemu-system-ppc: virtio_bus_start_ioeventfd: failed. Fallback to userspace 
(slower).

  ends/freezes at:
  nbd: registered device at major 43
   vda:

  I'm using -drive file=/home/me/rawimage.dd,if=virtio and works fine in
  version 2.8.0 installed with apt-get install (Ubuntu 17.04) and also
  with 2.8.0 official release from git/github that I compiled/built
  myself. But both of the newer releases fail on the same exact machine
  same config.

  I also noticed that qemu-2.8.0 was fine with mtd but the newer ones I tried 
weren't, ie gave
  qemu-system-ppc: -drive if=mtd: machine type does not support 
if=mtd,bus=0,unit=0
  (but I removed -drive if=mtd since wasn't using it anyway)

  I also tried on windows but I think virtio doesn't work on windows
  hosts at all? On windows host it fails the same way, even version 2.12
  as well as 4.1.10...

  used:
  ./configure --prefix=/opt/... --enable-fdt --enable-kvm --enable-debug

  (basically all steps the same on same exact system same config, yet
  2.8.0 works fine whether apt-get installed or built from source while
  the others I built, 4.19/4.2.0 or 2.12/4.1.10(win) don't.)

  In case newer qemu versions act weird on various kernels, I did try with both 
vmlinuz-4.10.0-19-generic and vmlinuz-4.13.12-041312-generic (I didn't compile 
them but I can provide config-..files. This is on Ubuntu 17.04 x86_64 host 
emulating e500v2 cpm guest, ie -M mpc... GUEST kernel 2.6.32.44 which is why I 
can't use -M ppce500 instead..)
  tx
   ecs

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1856834/+subscriptions



[Bug 1856834] Re: Virtio broken in qemu ppc in 4.2.0 and other versions

2020-01-11 Thread Laurent Vivier
This is broken by:

commit 67113c03423a23e60915574275aed7d60e9f85e1
Author: Michael Davidsaver 
Date:   Sun Nov 26 15:59:05 2017 -0600

e500: fix pci host bridge class/type

Correct some confusion wrt. the PCI facing
side of the PCI host bridge (not PCIe root complex).
The ref. manual for the mpc8533 (as well as
mpc8540 and mpc8540) give the class code as
PCI_CLASS_PROCESSOR_POWERPC.
While the PCI_HEADER_TYPE field is oddly omitted,
the tables in the "PCI Configuration Header"
section shows a type 0 layout using all 6 BAR
registers (as 2x 32, and 2x 64 bit regions)

So 997505065dc92e533debf5cb23012ba4e673d387
seems to be in error.  Although there was
perhaps some confusion as the mpc8533
has a separate PCIe root complex.
With PCIe, a root complex has PCI_HEADER_TYPE=1.

Neither the PCI host bridge, nor the PCIe
root complex advertise class PCI_CLASS_BRIDGE_PCI.

This was confusing Linux guests, which try
to interpret the host bridge as a pci-pci
bridge, but get confused and re-enumerate
the bus when the primary/secondary/subordinate
bus registers don't have valid values.

Signed-off-by: Michael Davidsaver 
Signed-off-by: David Gibson 


** Summary changed:

- Virtio broken in qemu ppc in 4.2.0 and other versions
+ PCI broken in qemu ppc e500 in v2.12.0 and other versions

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1856834

Title:
  PCI broken in qemu ppc e500 in v2.12.0 and other versions

Status in QEMU:
  New

Bug description:
  The same qemu -M mpc... command that works on qemu-system-ppc version
  2.8.0 freezes guest on bootup and shows error for qemu-system-ppc
  version 4.2.0release and 4.19dirtygit:

  qemu-system-ppc: virtio-blk failed to set guest notifier (-24), ensure -accel 
kvm is set.
  qemu-system-ppc: virtio_bus_start_ioeventfd: failed. Fallback to userspace 
(slower).

  ends/freezes at:
  nbd: registered device at major 43
   vda:

  I'm using -drive file=/home/me/rawimage.dd,if=virtio and works fine in
  version 2.8.0 installed with apt-get install (Ubuntu 17.04) and also
  with 2.8.0 official release from git/github that I compiled/built
  myself. But both of the newer releases fail on the same exact machine
  same config.

  I also noticed that qemu-2.8.0 was fine with mtd but the newer ones I tried 
weren't, ie gave
  qemu-system-ppc: -drive if=mtd: machine type does not support 
if=mtd,bus=0,unit=0
  (but I removed -drive if=mtd since wasn't using it anyway)

  I also tried on windows but I think virtio doesn't work on windows
  hosts at all? On windows host it fails the same way, even version 2.12
  as well as 4.1.10...

  used:
  ./configure --prefix=/opt/... --enable-fdt --enable-kvm --enable-debug

  (basically all steps the same on same exact system same config, yet
  2.8.0 works fine whether apt-get installed or built from source while
  the others I built, 4.19/4.2.0 or 2.12/4.1.10(win) don't.)

  In case newer qemu versions act weird on various kernels, I did try with both 
vmlinuz-4.10.0-19-generic and vmlinuz-4.13.12-041312-generic (I didn't compile 
them but I can provide config-..files. This is on Ubuntu 17.04 x86_64 host 
emulating e500v2 cpm guest, ie -M mpc... GUEST kernel 2.6.32.44 which is why I 
can't use -M ppce500 instead..)
  tx
   ecs

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1856834/+subscriptions



[Bug 1653577] Re: Ability to set umask for 9pfs

2020-01-11 Thread Thomas Huth
** Changed in: qemu
   Status: New => Incomplete

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1653577

Title:
  Ability to set umask for 9pfs

Status in QEMU:
  Incomplete

Bug description:
  We should be able to specify the umask for 9pfs so that files created
  by the guest can be accessed by other users on the host. Currently
  they're only accessible by the user running qemu (and of course,
  root).

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1653577/+subscriptions



Re: [PATCH v2 1/3] tests/acceptance: avocado_qemu: Introduce the 'accel' test parameter

2020-01-11 Thread Thomas Huth
On 10/01/2020 21.02, Wainer dos Santos Moschetta wrote:
> Hi Thomas,
> 
> On 12/18/19 4:48 PM, Thomas Huth wrote:
>> On 18/12/2019 18.00, Wainer dos Santos Moschetta wrote:
>>> The test case may need to boot the VM with an accelerator that
>>> isn't actually enabled on the QEMU binary and/or present in the host. In
>>> this case the test behavior is undefined, and the best course of
>>> action is to skip its execution.
>>>
>>> This change introduced the 'accel' parameter (and the handler of
>>> tag with same name) used to indicate the test case requires a
>>> given accelerator available. It was implemented a mechanism to
>>> skip the test case if the accelerator is not available. Moreover,
>>>   the QEMU --accel argument is set automatically to any VM
>>> launched if the parameter is present.
>>>
>>> Signed-off-by: Wainer dos Santos Moschetta 
>>> ---
>>>   docs/devel/testing.rst    | 16 
>>>   tests/acceptance/avocado_qemu/__init__.py | 23 +++
>>>   2 files changed, 39 insertions(+)
>>>
>>> diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
>>> index 27f286858a..6c2e0718e1 100644
>>> --- a/docs/devel/testing.rst
>>> +++ b/docs/devel/testing.rst
>>> @@ -757,6 +757,17 @@ name.  If one is not given explicitly, it will
>>> either be set to
>>>   ``None``, or, if the test is tagged with one (and only one)
>>>   ``:avocado: tags=machine:VALUE`` tag, it will be set to ``VALUE``.
>>>   +accel
>>> +~
>>> +The accelerator that will be set to all QEMUMachine instances created
>>> +by the test.
>>> +
>>> +The ``accel`` attribute will be set to the test parameter of the same
>>> +name.  If one is not given explicitly, it will either be set to
>>> +``None``, or, if the test is tagged with one (and only one)
>>> +``:avocado: tags=accel:VALUE`` tag, it will be set to ``VALUE``.
>>> Currently
>>> +``VALUE`` should be either ``kvm`` or ``tcg``.
>>> +
>>>   qemu_bin
>>>   
>>>   @@ -798,6 +809,11 @@ machine
>>>   The machine type that will be set to all QEMUMachine instances created
>>>   by the test.
>>>   +accel
>>> +~
>>> +The accelerator that will be set to all QEMUMachine instances created
>>> +by the test. In case the accelerator is not available (both QEMU
>>> +binary and the host system are checked) then the test is canceled.
>>>     qemu_bin
>>>   
>>> diff --git a/tests/acceptance/avocado_qemu/__init__.py
>>> b/tests/acceptance/avocado_qemu/__init__.py
>>> index 6618ea67c1..aff32668d9 100644
>>> --- a/tests/acceptance/avocado_qemu/__init__.py
>>> +++ b/tests/acceptance/avocado_qemu/__init__.py
>>> @@ -20,6 +20,7 @@ SRC_ROOT_DIR =
>>> os.path.join(os.path.dirname(__file__), '..', '..', '..')
>>>   sys.path.append(os.path.join(SRC_ROOT_DIR, 'python'))
>>>     from qemu.machine import QEMUMachine
>>> +from qemu.accel import kvm_available, tcg_available
>>>     def is_readable_executable_file(path):
>>>   return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK)
>>> @@ -111,6 +112,8 @@ class Test(avocado.Test):
>>>     def setUp(self):
>>>   self._vms = {}
>>> +    # VM argumments that are mapped from parameters
>>> +    self._param_to_vm_args = []
>>>     self.arch = self.params.get('arch',
>>>  
>>> default=self._get_unique_tag_val('arch'))
>>> @@ -124,10 +127,30 @@ class Test(avocado.Test):
>>>   if self.qemu_bin is None:
>>>   self.cancel("No QEMU binary defined or found in the
>>> source tree")
>>>   +    self.accel = self.params.get('accel',
>>> +
>>> default=self._get_unique_tag_val('accel'))
>>> +    if self.accel:
>>> +    avail = False
>>> +    if self.accel == 'kvm':
>>> +    if kvm_available(self.arch, self.qemu_bin):
>>> +    self._param_to_vm_args.append('-enable-kvm')
>> Could you please use "-accel kvm" instead? "-accel" is now our official
>> way to configure an accelerator ... so we should not use the old
>> wrappers in new code anymore if possible.
> Sure, I am going to adjust that on v3.
>>
>>   Thanks,
>>    Thomas
>>
>>
>> PS: Travis supports KVM now, too (with some tweaking of the permissions)
>> ... maybe we should now try to get some QEMU tests running with KVM
>> there, too...
> 
> I heard that but I failed miserably to enable nested virt on Travis.
> Actually I was expecting it enabled by default but not the case. I did
> not find documentation so I tried some tweaks like setting
> 'sudo:required' and using bionic but none of that worked out.
> 
> Do you know what needs to be done?

Yes, I recently enabled it for the kvm-unit-tests ... and yes, it's a
bit ugly: The user has to be in the "kvm" group which is not the case
for the user that runs the travis scripts. Tweaking the access rights of
/dev/kvm unfortunately does not work (at least not directly via chmod
o+rwx /dev/kvm ... but maybe there is a way via udev or something