Re: [Qemu-devel] [[Qemu devel] RFC] hw/net: Add Smartfusion2 emac block

2018-05-26 Thread Philippe Mathieu-Daudé
On 05/26/2018 06:53 AM, Subbaraya Sundeep wrote:
> Modelled Ethernet MAC of Smartfusion2 SoC.
> Micrel KSZ8051 PHY is present on Emcraft's SOM kit hence same
> PHY is emulated.
> 
> Signed-off-by: Subbaraya Sundeep 
> ---
>  hw/arm/msf2-soc.c |  21 +-
>  hw/net/Makefile.objs  |   1 +
>  hw/net/mss-emac.c | 544 
> ++
>  include/hw/arm/msf2-soc.h |   3 +
>  include/hw/net/mss-emac.h |  23 ++
>  5 files changed, 591 insertions(+), 1 deletion(-)
>  create mode 100644 hw/net/mss-emac.c
>  create mode 100644 include/hw/net/mss-emac.h
> 
> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
> index 75c44ad..ed3d0f5 100644
> --- a/hw/arm/msf2-soc.c
> +++ b/hw/arm/msf2-soc.c
> @@ -35,6 +35,7 @@
>  
>  #define MSF2_TIMER_BASE   0x40004000
>  #define MSF2_SYSREG_BASE  0x40038000
> +#define MSF2_EMAC_BASE0x40041000
>  
>  #define ENVM_BASE_ADDRESS 0x6000
>  
> @@ -55,6 +56,7 @@ static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 
> 0x4000 , 0x4001 };
>  static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
>  static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
>  static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
> +static const int emac_irq[MSF2_NUM_EMACS] = { 12 };
>  
>  static void do_sys_reset(void *opaque, int n, int level)
>  {
> @@ -82,6 +84,13 @@ static void m2sxxx_soc_initfn(Object *obj)
>TYPE_MSS_SPI);
>  qdev_set_parent_bus(DEVICE(>spi[i]), sysbus_get_default());
>  }
> +
> +object_initialize(>emac, sizeof(s->emac), TYPE_MSS_EMAC);
> +qdev_set_parent_bus(DEVICE(>emac), sysbus_get_default());
> +if (nd_table[0].used) {
> +qemu_check_nic_model(_table[0], TYPE_MSS_EMAC);
> +qdev_set_nic_properties(DEVICE(>emac), _table[0]);
> +}
>  }
>  
>  static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
> @@ -192,6 +201,17 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, 
> Error **errp)
>  g_free(bus_name);
>  }
>  
> +dev = DEVICE(>emac);
> +object_property_set_bool(OBJECT(>emac), true, "realized", );
> +if (err != NULL) {
> +error_propagate(errp, err);
> +return;
> +}
> +busdev = SYS_BUS_DEVICE(dev);
> +sysbus_mmio_map(busdev, 0, MSF2_EMAC_BASE);
> +sysbus_connect_irq(busdev, 0,
> +   qdev_get_gpio_in(armv7m, emac_irq[0]));
> +
>  /* Below devices are not modelled yet. */
>  create_unimplemented_device("i2c_0", 0x40002000, 0x1000);
>  create_unimplemented_device("dma", 0x40003000, 0x1000);
> @@ -202,7 +222,6 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, 
> Error **errp)
>  create_unimplemented_device("can", 0x40015000, 0x1000);
>  create_unimplemented_device("rtc", 0x40017000, 0x1000);
>  create_unimplemented_device("apb_config", 0x4002, 0x1);
> -create_unimplemented_device("emac", 0x40041000, 0x1000);
>  create_unimplemented_device("usb", 0x40043000, 0x1000);
>  }
>  
> diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs
> index ab22968..d9b4cae 100644
> --- a/hw/net/Makefile.objs
> +++ b/hw/net/Makefile.objs
> @@ -48,3 +48,4 @@ common-obj-$(CONFIG_ROCKER) += rocker/rocker.o 
> rocker/rocker_fp.o \
>  obj-$(call lnot,$(CONFIG_ROCKER)) += rocker/qmp-norocker.o
>  
>  common-obj-$(CONFIG_CAN_BUS) += can/
> +common-obj-$(CONFIG_MSF2) += mss-emac.o
> diff --git a/hw/net/mss-emac.c b/hw/net/mss-emac.c
> new file mode 100644
> index 000..a9588c0
> --- /dev/null
> +++ b/hw/net/mss-emac.c
> @@ -0,0 +1,544 @@
> +/*
> + * QEMU model of the Smartfusion2 Ethernet MAC.
> + *
> + * Copyright (c) 2018 Subbaraya Sundeep .
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "qemu/log.h"
> +#include 

[Qemu-devel] [Bug 1649233] Re: scrolling does not work once mouse is grabbed

2018-05-26 Thread Krupp
I am also having trouble with this bug. I have QEMU version 2.11.1 on
kubuntu. I have the same symptoms as above, and would be willing to
assist in troubleshooting. The mouse I am using has two side buttons for
forward and back on web-browsing and a scroll wheel with scroll button.
I am using QEMU/KVM through Virtual Machine Manager.

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

Title:
  scrolling does not work once mouse is grabbed

Status in QEMU:
  New

Bug description:
  The title pretty much told it all. It occurs in Windows 10 RS1 on qemu
  2.7.0. Interestingly, I can scroll in the guest if the mouse is not
  grabbed. So using usb-tablet sort of works around it, but if I
  explicitly grab the mouse with Ctrl+Alt+G, scrolling will also stop
  working.

  The host is Arch Linux so the qemu build uses gtk(3) for GUI by
  default. I wanted to test with sdl but it seems sdl support in qemu is
  sort of broken that I can't even start the virtual machine properly
  with that.

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



Re: [Qemu-devel] [PATCH 0/6] Update Linux headers to 4.17-rc6

2018-05-26 Thread no-reply
Hi,

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

Type: series
Message-id: 20180525132755.21839-1-peter.mayd...@linaro.org
Subject: [Qemu-devel] [PATCH 0/6] Update Linux headers to 4.17-rc6

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]   
patchew/20180525132755.21839-1-peter.mayd...@linaro.org -> 
patchew/20180525132755.21839-1-peter.mayd...@linaro.org
Switched to a new branch 'test'
30d4ec272e target/i386/kvm.c: Remove compatibility shim for KVM_HINTS_REALTIME
c90891dc4e Update Linux headers to 4.17-rc6
70a9bbf798 target/i386/kvm.c: Handle renaming of KVM_HINTS_DEDICATED
fe7501a7db scripts/update-linux-headers: Handle kernel license no longer being 
one file
ac4d8a51d6 scripts/update-linux-headers: Handle __aligned_u64
c49a47a568 virtio-gpu-3d: Define VIRTIO_GPU_CAPSET_VIRGL2 elsewhere

=== OUTPUT BEGIN ===
Checking PATCH 1/6: virtio-gpu-3d: Define VIRTIO_GPU_CAPSET_VIRGL2 elsewhere...
Checking PATCH 2/6: scripts/update-linux-headers: Handle __aligned_u64...
Checking PATCH 3/6: scripts/update-linux-headers: Handle kernel license no 
longer being one file...
Checking PATCH 4/6: target/i386/kvm.c: Handle renaming of KVM_HINTS_DEDICATED...
Checking PATCH 5/6: Update Linux headers to 4.17-rc6...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#13: 
deleted file mode 100644

ERROR: Invalid UTF-8, patch and commit message should be encoded in UTF-8
#930: FILE: linux-headers/LICENSES/preferred/GPL-2.0:71:
+
 ^

ERROR: Invalid UTF-8, patch and commit message should be encoded in UTF-8
#985: FILE: linux-headers/LICENSES/preferred/GPL-2.0:126:
+
 ^

ERROR: Invalid UTF-8, patch and commit message should be encoded in UTF-8
#1043: FILE: linux-headers/LICENSES/preferred/GPL-2.0:184:
+
 ^

ERROR: Invalid UTF-8, patch and commit message should be encoded in UTF-8
#1100: FILE: linux-headers/LICENSES/preferred/GPL-2.0:241:
+
 ^

ERROR: Invalid UTF-8, patch and commit message should be encoded in UTF-8
#1153: FILE: linux-headers/LICENSES/preferred/GPL-2.0:294:
+
 ^

total: 5 errors, 1 warnings, 1281 lines checked

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

Checking PATCH 6/6: target/i386/kvm.c: Remove compatibility shim for 
KVM_HINTS_REALTIME...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

[Qemu-devel] Not able to install QNX into a VM

2018-05-26 Thread info

Hi all,


I tried to create a VM for QNX in a Virtualbox first. It installed 
successfully, but then could not boot from the virtual HDD. I googled, 
and found a couple of posts about how at some point VB and QEMU both 
implemented the busmaster bit for storage controllers and that broke QNX 
and some other OSs, but then VB team refused to address that, while QEMU 
team created a patch which is in the latest QEMU.


So I installed QEMU (the latest as of this moment) into a Fedora 26 host 
and created a new VM. I set CDROM to be the device 0 on IDE and HDD to 
be the device 1. Then I booted into this VM and hit F2 to advance into 
the "Auto-detecting Hardware..." screen of the QNX installer.


Unlike Virtualbox, the QEMU VM takes quite some time to detect the 
devices, and especially long to detect cd0.0. Once detection completes, 
I see not one CD device, but two:


Then if I press F2, QNX installer asks to insert the installation CD 
into the drive.


This does not occur under Virtualbox. It only shows one CD device.

and once I hit F2 it advances to the next screen w/o a prompt to insert 
the CDROM


What is missing in QEMU VM that it does not see the CD which it just 
booted the OS installer from?



Thank you

Alex



Re: [Qemu-devel] [PATCH 01/13] 9p: linux: Fix a couple Linux assumptions

2018-05-26 Thread Keno Fischer
>>> diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
>>> index 3fa062b..a13e729 100644
>>> --- a/fsdev/file-op-9p.h
>>> +++ b/fsdev/file-op-9p.h
>>> @@ -16,7 +16,9 @@
>>>
>>>  #include 
>>>  #include 
>>> +#ifdef CONFIG_LINUX
>>
>> What about a less restrictive:
>>
>> #ifndef __APPLE__
>
> In general I would recommend checking for specific
> features (usually in configure), rather than adding
> ifdef tests for particular OSes. In this case presumably
> we're including these headers because we're after
> a specific function or define or whatever, so we can
> check in configure for what header that's in (or
> if it's not available at all).
>
> thanks
> -- PMM

This header is used for struct statfs. I would be fine
with a configure check for this, though it looks like
other places in the code base that use this header
(e.g. util/mmap-alloc.c) also guard it in
CONFIG_LINUX, so that seemed like the right check
to me given the current code base.

Would you like me to submit a patch to switch these
to a configure check?



Re: [Qemu-devel] [PATCH 09/13] 9p: darwin: Provide a compatibility definition for XATTR_SIZE_MAX

2018-05-26 Thread Keno Fischer
> > +#if defined(CONFIG_DARWIN) && !defined(XATTR_SIZE_MAX)
> > +/* Darwin doesn't seem to define a maximum xattr size in its user
> > +   user space header, but looking at the kernel source, HFS supports
> > +   up to INT32_MAX, so use that as the maximum.
> > +*/
> > +#define XATTR_SIZE_MAX INT32_MAX
> > +#endif
>
> Do we really need the CONFIG_DARWIN part of this check?

Right now this code only runs on Linux (and Darwin after this series).
On Linux it's always defined,
but I'd rather this code give an error when somebody tries to port it
to a new OS than have it
silently use an incorrect value. The ` !defined(XATTR_SIZE_MAX)` is
just there in case Apple ever
decides to define it in their headers. I can remove that part if you
would prefer.



Re: [Qemu-devel] [PATCH v1 22/30] RISC-V: Add misa runtime write support

2018-05-26 Thread Richard Henderson
On 05/22/2018 05:15 PM, Michael Clark wrote:
> +/* Suppress 'C' if next instruction is not aligned
> +   TODO: this should check next_pc */
> +if ((val & RVC) && (GETPC() & ~3) != 0) {
> +val &= ~RVC;
> +}

This is checking the host PC, which is useless.

Isn't this backward anyway?  Why would *setting* C require an aligned address?
Surely it's *clearing* C that would require an aligned address.

You can read the guest PC of the current instruction by doing

  cpu_restore_state(cs, GETPC(), false);
  xxx = env->pc;

In order to get the next pc, I guess you'd just need to add 4, since all of the
csr insns are not in the compact encoding space?

Alternately, to save the not insignificant amount of work that
cpu_restore_state does, and since all of the csr insns end the TB anyway, you
could move

tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn);

before the call to helper_csr*.  If an exception is raised by the helper, this
store to PC will be overwritten by the existing cpu_restore_state in
do_raise_exception_err so that the correct PC value is seen on entry to
do_interrupt.


r~



Re: [Qemu-devel] [Bug 1768246] [NEW] cpu-exec.c:648: cpu_loop_exec_tb: Assertion `use_icount' failed.

2018-05-26 Thread John Paul Adrian Glaubitz
This bug also affects GHC on qemu-sh4:

checking version of ghc... ./configure: line 3199: 55879 Segmentation fault 
 "${WithGhc-ghc}" --version > conftestghc 2>&1
8.2.2
qemu-sh4-static: /build/qemu-fWXVPw/qemu-2.12+dfsg/accel/tcg/cpu-exec.c:648: 
cpu_loop_exec_tb: Assertion `use_icount' failed.
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
qemu-sh4-static: /build/qemu-fWXVPw/qemu-2.12+dfsg/accel/tcg/cpu-exec.c:648: 
cpu_loop_exec_tb: Assertion `use_icount' failed.
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
qemu-sh4-static: /build/qemu-fWXVPw/qemu-2.12+dfsg/accel/tcg/cpu-exec.c:648: 
cpu_loop_exec_tb: Assertion `use_icount' failed.
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
qemu-sh4-static: /build/qemu-fWXVPw/qemu-2.12+dfsg/accel/tcg/cpu-exec.c:648: 
cpu_loop_exec_tb: Assertion `use_icount' failed.
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
qemu-sh4-static: /build/qemu-fWXVPw/qemu-2.12+dfsg/accel/tcg/cpu-exec.c:648: 
cpu_loop_exec_tb: Assertion `use_icount' failed.
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

Just tested with qemu 5a5c383b1373aeb6c87a0d6060f6c3dc7c53082b.

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

Title:
  cpu-exec.c:648: cpu_loop_exec_tb: Assertion `use_icount' failed.

Status in QEMU:
  New

Bug description:
  OpenJDK no longer works on qemu-sh4, it previously did after #1735384
  was fixed.

  Crash indicates an assertion failure:

  (sid-sh4-sbuild)root@nofan:/# java --version
  qemu-sh4-static: /root/qemu/accel/tcg/cpu-exec.c:648: cpu_loop_exec_tb: 
Assertion `use_icount' failed.
  qemu: uncaught target signal 6 (Aborted) - core dumped
  Aborted
  (sid-sh4-sbuild)root@nofan:/#

  Haven't bi-sected the issue yet, but will do so later.

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



[Qemu-devel] [Bug 1396052] Re: migration failed when running BurnInTest in guest

2018-05-26 Thread z08687
I think the bug is still there. And I have repaired it myself.  
Migration process need wait all nbd-flying-data completion before 
bdrv_invalidate_cache_all was called.  The solution is working well but not 
graceful,so I didn't commit to open source community.

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

Title:
  migration failed when running BurnInTest in guest

Status in QEMU:
  Incomplete

Bug description:
  Hi,  
  I found a live migration problem and have found out the reason, but I can't 
fix it up myself. I really need help.
  When live migration vm and it's block device in save time, it will occur 
probabilistic .

  Step:
  1.  start a windows vm,and run burnInTest(it will write dirty data to block 
device in migration)
  2.  migrate vm with it's block device.
  3.  a few minutes later,  dest vm was killed and migration will be failed 
(probabilistic )

  Reason:
  when migraion start, in source host libvirt will send command to qemu,and 
qemu will call mirror_run coroutine to copy blcok device data to dest vm block 
device.mirror_run running in qemu main thread.   When this 
finished(actually it still running because in following steps,there may 
generate dirty data by vm), qemu will  start migration_thread to migration ram 
and other device.
  In dest vm, qemu will call "bdrv_invalidate_cache --> 
qcow2_invalidate_cache" function after vm read "QEMU_VM_EOF" byte. 
qcow2_invalidate_cache fuction call qcow2_close ,  in qcow2_close fuction set 
"s->l1_table = NULL" and then call qcow2_cache_flush fuction.   In 
qcow2_cache_flush fuction will call 
"bdrv_flush-->bdrv_flush_co_entry-->bdrv_co_flush-->qemu_coroutine_yield".   
This will let itself back to mian loop.   If source vm send block device dirty 
data to dest vm at this time, in dest vm will occur the following segmentation 
fault.
  The primary reason is mirror_run and migration run in two thread.  
although qemu stopping vm before write "QEMU_VM_EOF" byte, it still can't 
ensure mirror_run coroutine do not write dirty data  after migration thread  
sending "QEMU_VM_EOF" byte.

  
  Program received signal SIGSEGV, Segmentation fault.
  0x7f90d250db24 in get_cluster_table (bs=0x7f90d493f500, 
offset=1832189952, new_l2_table=0x7f8fbd6faa88, 
  new_l2_index=0x7f8fbd6faaa0) at block/qcow2-cluster.c:573
  573 l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;
  (gdb) bt
  #0  0x7f90d250db24 in get_cluster_table (bs=0x7f90d493f500, 
offset=1832189952, new_l2_table=0x7f8fbd6faa88, 
  new_l2_index=0x7f8fbd6faaa0) at block/qcow2-cluster.c:573
  #1  0x7f90d250e577 in handle_copied (bs=0x7f90d493f500, 
guest_offset=1832189952, host_offset=0x7f8fbd6fab18, 
  bytes=0x7f8fbd6fab20, m=0x7f8fbd6fabc8) at block/qcow2-cluster.c:927
  #2  0x7f90d250ef45 in qcow2_alloc_cluster_offset (bs=0x7f90d493f500, 
offset=1832189952, num=0x7f8fbd6fabfc, 
  host_offset=0x7f8fbd6fabc0, m=0x7f8fbd6fabc8) at 
block/qcow2-cluster.c:1269
  #3  0x7f90d250445f in qcow2_co_writev (bs=0x7f90d493f500, 
sector_num=3578496, remaining_sectors=2040, 
  qiov=0x7f8fbd6fae90) at block/qcow2.c:1171
  #4  0x7f90d24d4764 in bdrv_aligned_pwritev (bs=0x7f90d493f500, 
req=0x7f8fbd6facd0, offset=1832189952, bytes=1044480, 
  qiov=0x7f8fbd6fae90, flags=0) at block.c:3321
  #5  0x7f90d24d4d21 in bdrv_co_do_pwritev (bs=0x7f90d493f500, 
offset=1832189952, bytes=1044480, qiov=0x7f8fbd6fae90, 
  flags=0) at block.c:3447
  #6  0x7f90d24d3115 in bdrv_rw_co_entry (opaque=0x7f8fbd6fae10) at 
block.c:2710
  #7  0x7f90d24d31e7 in bdrv_prwv_co (bs=0x7f90d493f500, offset=1832189952, 
qiov=0x7f8fbd6fae90, is_write=true, flags=0)
  at block.c:2746
  #8  0x7f90d24d32eb in bdrv_rw_co (bs=0x7f90d493f500, sector_num=3578496, 
  buf=0x7f90d4e3d400 
"\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037
 
!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312",
 ..., nb_sectors=2040, is_write=true, flags=0) at 
block.c:2776
  #9  0x7f90d24d3429 in bdrv_write (bs=0x7f90d493f500, sector_num=3578496, 
  buf=0x7f90d4e3d400 
"\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037
 

Re: [Qemu-devel] [PATCH 09/13] 9p: darwin: Provide a compatibility definition for XATTR_SIZE_MAX

2018-05-26 Thread Peter Maydell
On 26 May 2018 at 06:23,   wrote:
> From: Keno Fischer 
>
> Signed-off-by: Keno Fischer 
> ---
>  hw/9pfs/9p.c | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index f5f00aa..4ae4da6 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -3351,6 +3351,13 @@ out_nofid:
>  v9fs_string_free();
>  }
>
> +#if defined(CONFIG_DARWIN) && !defined(XATTR_SIZE_MAX)
> +/* Darwin doesn't seem to define a maximum xattr size in its user
> +   user space header, but looking at the kernel source, HFS supports
> +   up to INT32_MAX, so use that as the maximum.
> +*/
> +#define XATTR_SIZE_MAX INT32_MAX
> +#endif

Do we really need the CONFIG_DARWIN part of this check?

thanks
-- PMM



Re: [Qemu-devel] [PATCH 01/13] 9p: linux: Fix a couple Linux assumptions

2018-05-26 Thread Peter Maydell
On 26 May 2018 at 07:30, Philippe Mathieu-Daudé  wrote:
> Hi Keno,
>
> On 05/26/2018 02:23 AM, k...@juliacomputing.com wrote:
>> From: Keno Fischer 
>>
>>  - Guard two Linux only headers.
>>  - Define `ENOATTR` only if not only defined
>>(it's defined in system headers on Darwin).
>>
>> Signed-off-by: Keno Fischer 
>> ---
>>  fsdev/file-op-9p.h   | 2 ++
>>  hw/9pfs/9p-local.c   | 2 ++
>>  include/qemu/xattr.h | 4 +++-
>>  3 files changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
>> index 3fa062b..a13e729 100644
>> --- a/fsdev/file-op-9p.h
>> +++ b/fsdev/file-op-9p.h
>> @@ -16,7 +16,9 @@
>>
>>  #include 
>>  #include 
>> +#ifdef CONFIG_LINUX
>
> What about a less restrictive:
>
> #ifndef __APPLE__

In general I would recommend checking for specific
features (usually in configure), rather than adding
ifdef tests for particular OSes. In this case presumably
we're including these headers because we're after
a specific function or define or whatever, so we can
check in configure for what header that's in (or
if it's not available at all).

thanks
-- PMM



[Qemu-devel] [[Qemu devel] RFC] hw/net: Add Smartfusion2 emac block

2018-05-26 Thread Subbaraya Sundeep
Modelled Ethernet MAC of Smartfusion2 SoC.
Micrel KSZ8051 PHY is present on Emcraft's SOM kit hence same
PHY is emulated.

Signed-off-by: Subbaraya Sundeep 
---
 hw/arm/msf2-soc.c |  21 +-
 hw/net/Makefile.objs  |   1 +
 hw/net/mss-emac.c | 544 ++
 include/hw/arm/msf2-soc.h |   3 +
 include/hw/net/mss-emac.h |  23 ++
 5 files changed, 591 insertions(+), 1 deletion(-)
 create mode 100644 hw/net/mss-emac.c
 create mode 100644 include/hw/net/mss-emac.h

diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 75c44ad..ed3d0f5 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -35,6 +35,7 @@
 
 #define MSF2_TIMER_BASE   0x40004000
 #define MSF2_SYSREG_BASE  0x40038000
+#define MSF2_EMAC_BASE0x40041000
 
 #define ENVM_BASE_ADDRESS 0x6000
 
@@ -55,6 +56,7 @@ static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 
0x4000 , 0x4001 };
 static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
 static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
 static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
+static const int emac_irq[MSF2_NUM_EMACS] = { 12 };
 
 static void do_sys_reset(void *opaque, int n, int level)
 {
@@ -82,6 +84,13 @@ static void m2sxxx_soc_initfn(Object *obj)
   TYPE_MSS_SPI);
 qdev_set_parent_bus(DEVICE(>spi[i]), sysbus_get_default());
 }
+
+object_initialize(>emac, sizeof(s->emac), TYPE_MSS_EMAC);
+qdev_set_parent_bus(DEVICE(>emac), sysbus_get_default());
+if (nd_table[0].used) {
+qemu_check_nic_model(_table[0], TYPE_MSS_EMAC);
+qdev_set_nic_properties(DEVICE(>emac), _table[0]);
+}
 }
 
 static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
@@ -192,6 +201,17 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error 
**errp)
 g_free(bus_name);
 }
 
+dev = DEVICE(>emac);
+object_property_set_bool(OBJECT(>emac), true, "realized", );
+if (err != NULL) {
+error_propagate(errp, err);
+return;
+}
+busdev = SYS_BUS_DEVICE(dev);
+sysbus_mmio_map(busdev, 0, MSF2_EMAC_BASE);
+sysbus_connect_irq(busdev, 0,
+   qdev_get_gpio_in(armv7m, emac_irq[0]));
+
 /* Below devices are not modelled yet. */
 create_unimplemented_device("i2c_0", 0x40002000, 0x1000);
 create_unimplemented_device("dma", 0x40003000, 0x1000);
@@ -202,7 +222,6 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error 
**errp)
 create_unimplemented_device("can", 0x40015000, 0x1000);
 create_unimplemented_device("rtc", 0x40017000, 0x1000);
 create_unimplemented_device("apb_config", 0x4002, 0x1);
-create_unimplemented_device("emac", 0x40041000, 0x1000);
 create_unimplemented_device("usb", 0x40043000, 0x1000);
 }
 
diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs
index ab22968..d9b4cae 100644
--- a/hw/net/Makefile.objs
+++ b/hw/net/Makefile.objs
@@ -48,3 +48,4 @@ common-obj-$(CONFIG_ROCKER) += rocker/rocker.o 
rocker/rocker_fp.o \
 obj-$(call lnot,$(CONFIG_ROCKER)) += rocker/qmp-norocker.o
 
 common-obj-$(CONFIG_CAN_BUS) += can/
+common-obj-$(CONFIG_MSF2) += mss-emac.o
diff --git a/hw/net/mss-emac.c b/hw/net/mss-emac.c
new file mode 100644
index 000..a9588c0
--- /dev/null
+++ b/hw/net/mss-emac.c
@@ -0,0 +1,544 @@
+/*
+ * QEMU model of the Smartfusion2 Ethernet MAC.
+ *
+ * Copyright (c) 2018 Subbaraya Sundeep .
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qemu/log.h"
+#include "hw/net/mss-emac.h"
+#include "hw/net/mii.h"
+
+#define R_CFG1  (0x0 / 4)
+#define R_CFG2  (0x4 / 4)
+#define R_IFG   (0x8 / 4)
+#define R_HALF_DUPLEX   (0xc / 4)
+#define R_FRM_LEN   (0x10 / 4)
+#define R_MII_CFG   (0x20 / 4)
+#define 

[Qemu-devel] [[Qemu devel] RFC] hw/net: Add Smartfusion2 emac block

2018-05-26 Thread Subbaraya Sundeep
Modelled Ethernet MAC of Smartfusion2 SoC.
Micrel KSZ8051 PHY is present on Emcraft's SOM kit hence same
PHY is emulated.

Signed-off-by: Subbaraya Sundeep 
---
 hw/arm/msf2-soc.c |  21 +-
 hw/net/Makefile.objs  |   1 +
 hw/net/mss-emac.c | 544 ++
 include/hw/arm/msf2-soc.h |   3 +
 include/hw/net/mss-emac.h |  23 ++
 5 files changed, 591 insertions(+), 1 deletion(-)
 create mode 100644 hw/net/mss-emac.c
 create mode 100644 include/hw/net/mss-emac.h

diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 75c44ad..ed3d0f5 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -35,6 +35,7 @@
 
 #define MSF2_TIMER_BASE   0x40004000
 #define MSF2_SYSREG_BASE  0x40038000
+#define MSF2_EMAC_BASE0x40041000
 
 #define ENVM_BASE_ADDRESS 0x6000
 
@@ -55,6 +56,7 @@ static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 
0x4000 , 0x4001 };
 static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
 static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
 static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
+static const int emac_irq[MSF2_NUM_EMACS] = { 12 };
 
 static void do_sys_reset(void *opaque, int n, int level)
 {
@@ -82,6 +84,13 @@ static void m2sxxx_soc_initfn(Object *obj)
   TYPE_MSS_SPI);
 qdev_set_parent_bus(DEVICE(>spi[i]), sysbus_get_default());
 }
+
+object_initialize(>emac, sizeof(s->emac), TYPE_MSS_EMAC);
+qdev_set_parent_bus(DEVICE(>emac), sysbus_get_default());
+if (nd_table[0].used) {
+qemu_check_nic_model(_table[0], TYPE_MSS_EMAC);
+qdev_set_nic_properties(DEVICE(>emac), _table[0]);
+}
 }
 
 static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
@@ -192,6 +201,17 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error 
**errp)
 g_free(bus_name);
 }
 
+dev = DEVICE(>emac);
+object_property_set_bool(OBJECT(>emac), true, "realized", );
+if (err != NULL) {
+error_propagate(errp, err);
+return;
+}
+busdev = SYS_BUS_DEVICE(dev);
+sysbus_mmio_map(busdev, 0, MSF2_EMAC_BASE);
+sysbus_connect_irq(busdev, 0,
+   qdev_get_gpio_in(armv7m, emac_irq[0]));
+
 /* Below devices are not modelled yet. */
 create_unimplemented_device("i2c_0", 0x40002000, 0x1000);
 create_unimplemented_device("dma", 0x40003000, 0x1000);
@@ -202,7 +222,6 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error 
**errp)
 create_unimplemented_device("can", 0x40015000, 0x1000);
 create_unimplemented_device("rtc", 0x40017000, 0x1000);
 create_unimplemented_device("apb_config", 0x4002, 0x1);
-create_unimplemented_device("emac", 0x40041000, 0x1000);
 create_unimplemented_device("usb", 0x40043000, 0x1000);
 }
 
diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs
index ab22968..d9b4cae 100644
--- a/hw/net/Makefile.objs
+++ b/hw/net/Makefile.objs
@@ -48,3 +48,4 @@ common-obj-$(CONFIG_ROCKER) += rocker/rocker.o 
rocker/rocker_fp.o \
 obj-$(call lnot,$(CONFIG_ROCKER)) += rocker/qmp-norocker.o
 
 common-obj-$(CONFIG_CAN_BUS) += can/
+common-obj-$(CONFIG_MSF2) += mss-emac.o
diff --git a/hw/net/mss-emac.c b/hw/net/mss-emac.c
new file mode 100644
index 000..a9588c0
--- /dev/null
+++ b/hw/net/mss-emac.c
@@ -0,0 +1,544 @@
+/*
+ * QEMU model of the Smartfusion2 Ethernet MAC.
+ *
+ * Copyright (c) 2018 Subbaraya Sundeep .
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qemu/log.h"
+#include "hw/net/mss-emac.h"
+#include "hw/net/mii.h"
+
+#define R_CFG1  (0x0 / 4)
+#define R_CFG2  (0x4 / 4)
+#define R_IFG   (0x8 / 4)
+#define R_HALF_DUPLEX   (0xc / 4)
+#define R_FRM_LEN   (0x10 / 4)
+#define R_MII_CFG   (0x20 / 4)
+#define 

Re: [Qemu-devel] [PATCH 2/4] sparp_pci: simplify how the PCI LSIs are allocated

2018-05-26 Thread Greg Kurz
On Fri, 18 May 2018 18:44:03 +0200
Cédric Le Goater  wrote:

> PCI LSIs are today allocated one by one using the IRQ alloc_block
> routine. Change the code sequence to first allocate a PCI_NUM_PINS
> block. It will help us providing a generic IRQ framework to the
> machine.
> 
> Signed-off-by: Cédric Le Goater 
> ---
>  hw/ppc/spapr_pci.c | 21 ++---
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 39a14980d397..4fd97ffe4c6e 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -1546,6 +1546,8 @@ static void spapr_phb_realize(DeviceState *dev, Error 
> **errp)
>  sPAPRTCETable *tcet;
>  const unsigned windows_supported =
>  sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1;
> +uint32_t irq;
> +Error *local_err = NULL;
>  
>  if (!spapr) {
>  error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries 
> machine");
> @@ -1694,18 +1696,15 @@ static void spapr_phb_realize(DeviceState *dev, Error 
> **errp)
>  QLIST_INSERT_HEAD(>phbs, sphb, list);
>  
>  /* Initialize the LSI table */
> -for (i = 0; i < PCI_NUM_PINS; i++) {
> -uint32_t irq;
> -Error *local_err = NULL;
> -
> -irq = spapr_irq_alloc_block(spapr, 1, true, false, _err);
> -if (local_err) {
> -error_propagate(errp, local_err);
> -error_prepend(errp, "can't allocate LSIs: ");
> -return;
> -}
> +irq = spapr_irq_alloc_block(spapr, PCI_NUM_PINS, true, false, 
> _err);
> +if (local_err) {
> +error_propagate(errp, local_err);
> +error_prepend(errp, "can't allocate LSIs: ");
> +return;
> +}
>  

It isn't strictly equivalent. The current code would be happy with
sparse IRQ numbers, while the proposed one wouldn't... Anyway, this
cannot happen since we don't have PHB hotplug.

Reviewed-by: Greg Kurz 

> -sphb->lsi_table[i].irq = irq;
> +for (i = 0; i < PCI_NUM_PINS; i++) {
> +sphb->lsi_table[i].irq = irq + i;
>  }
>  
>  /* allocate connectors for child PCI devices */



Re: [Qemu-devel] [PATCH] spapr: don't call KVM_PPC_CONFIGURE_V3_MMU if HPT is in userspace

2018-05-26 Thread Greg Kurz
On Fri, 25 May 2018 16:13:13 +0200
Laurent Vivier  wrote:

> On 25/05/2018 14:54, Greg Kurz wrote:
> > Since the kernel commit "dbfcf3cb9c68 powerpc/64: Call H_REGISTER_PROC_TBL
> > when running as a HPT guest on POWER9", a nested guest running with PR KVM
> > hangs at boot:
> > 
> > Preparing to boot Linux version 4.16.0-kvm-pr-hang-gku+ 
> > (greg@qemu.boston16) (gcc version 8.1.1 20180502 (Red Hat 8.1.1-1) 
> > (GCC)) #19 SMP Fri May 25 08:41:55 CEST 2018
> > Detected machine type: 0101
> > command line: root=UUID=22128c5c-30b1-4e0a-ac16-95853df31131 ro rhgb 
> > console=hvc0 early_printk disable-radix=on
> > Max number of cores passed to firmware: 1024 (NR_CPUS = 1024)
> > Calling ibm,client-architecture-support... done
> > memory layout at init:
> >   memory_limit :  (16 MB aligned)
> >   alloc_bottom : 01b8
> >   alloc_top: 3000
> >   alloc_top_hi : 0001
> >   rmo_top  : 3000
> >   ram_top  : 0001
> > instantiating rtas at 0x2fff... done
> > prom_hold_cpus: skipped
> > copying OF device tree...
> > Building dt strings...
> > Building dt structure...
> > Device tree strings 0x03d9 -> 0x03d90abb
> > Device tree struct  0x03da -> 0x03db
> > Quiescing Open Firmware ...
> > Booting Linux via __start() @ 0x0040 ...
> > 
> > This happens because the H_REGISTER_PROC_TBL implementation in QEMU
> > always call KVM_PPC_CONFIGURE_V3_MMU when KVM is present. This fails
> > in the case of PR KVM, which doesn't implement it, and QEMU returns
> > H_PARAMETER to the guest, which is a BUG() condition in linux.
> > 
> > In the case of PR, the HPT is allocated in userspace by QEMU, so it
> > doesn't make sense to call KVM_PPC_CONFIGURE_V3_MMU in the first
> > place. So, skip it in this case and let the guest boot.
> > 
> > Signed-off-by: Greg Kurz 
> > ---
> > 
> > Note that PR KVM requires this patch from Paul to work on POWER9:
> > 
> > https://patchwork.ozlabs.org/patch/916766/
> > 
> > The original request was coming from people who want to run openQA in
> > fedora28 under PowerVM on a POWER9 system. This requires PR KVM, which
> > will be running in HPT-mode since pHyp doesn't do radix.
> > 
> > Cc'ing stable because fedora28 ships QEMU 2.11.x.
> > ---
> >  hw/ppc/spapr_hcall.c |2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> > index 022f6d810182..12cbb317e5e8 100644
> > --- a/hw/ppc/spapr_hcall.c
> > +++ b/hw/ppc/spapr_hcall.c
> > @@ -1420,7 +1420,7 @@ static target_ulong 
> > h_register_process_table(PowerPCCPU *cpu,
> >((flags & FLAG_GTSE) ? LPCR_GTSE : 0),
> >LPCR_UPRT | LPCR_GTSE);
> >  
> > -if (kvm_enabled()) {
> > +if (kvm_enabled() && !spapr->htab) {
> >  return kvmppc_configure_v3_mmu(cpu, flags & FLAG_RADIX,
> > flags & FLAG_GTSE, cproc);
> >  }
> >   
> 
> I'm wondering if you should use kvmppc_has_cap_mmu_hash_v3() instead?
> 

The meaning of KVM_CAP_PPC_HASH_MMU_V3 is basically: KVM supports POWER9
hash... even if that would *work* when using PR KVM, I'm not sure this
helps to understand.

The true reason for not calling kvmppc_configure_v3_mmu() is that we
already know that we're using a QEMU-side HPT.

> Thanks,
> Laurent

Cheers,

--
Greg



Re: [Qemu-devel] [PATCH 01/13] 9p: linux: Fix a couple Linux assumptions

2018-05-26 Thread Philippe Mathieu-Daudé
Hi Keno,

On 05/26/2018 02:23 AM, k...@juliacomputing.com wrote:
> From: Keno Fischer 
> 
>  - Guard two Linux only headers.
>  - Define `ENOATTR` only if not only defined
>(it's defined in system headers on Darwin).
> 
> Signed-off-by: Keno Fischer 
> ---
>  fsdev/file-op-9p.h   | 2 ++
>  hw/9pfs/9p-local.c   | 2 ++
>  include/qemu/xattr.h | 4 +++-
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
> index 3fa062b..a13e729 100644
> --- a/fsdev/file-op-9p.h
> +++ b/fsdev/file-op-9p.h
> @@ -16,7 +16,9 @@
>  
>  #include 
>  #include 
> +#ifdef CONFIG_LINUX

What about a less restrictive:

#ifndef __APPLE__

>  #include 
> +#endif
>  #include "qemu-fsdev-throttle.h"
>  
>  #define SM_LOCAL_MODE_BITS0600
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index b37b1db..f6c7526 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -27,10 +27,12 @@
>  #include "qemu/error-report.h"
>  #include "qemu/option.h"
>  #include 
> +#ifdef CONFIG_LINUX
>  #include 
>  #ifdef CONFIG_LINUX_MAGIC_H
>  #include 
>  #endif
> +#endif
>  #include 
>  
>  #ifndef XFS_SUPER_MAGIC
> diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h
> index a83fe8e..f1d0f7b 100644
> --- a/include/qemu/xattr.h
> +++ b/include/qemu/xattr.h
> @@ -22,7 +22,9 @@
>  #ifdef CONFIG_LIBATTR
>  #  include 
>  #else
> -#  define ENOATTR ENODATA
> +#  if !defined(ENOATTR)
> +#define ENOATTR ENODATA
> +#  endif
>  #  include 
>  #endif
>  

Rest looks correct.



Re: [Qemu-devel] [PATCH v5 45/49] tests/tcg/Makefile: update to be called from Makefile.target

2018-05-26 Thread Philippe Mathieu-Daudé
Hi Alex,

On 05/25/2018 11:19 AM, Alex Bennée wrote:
> This make is now invoked from each individual target make with the
> appropriate CC and EXTRA_CFLAGS set for each guest. It then includes
> additional Makefile.targets from:
> 
>   - tests/tcg/multiarch (always)
>   - tests/tcg/$(TARGET_BASE_ARCH) (if available)
>   - tests/tcg/$(TARGET_NAME)
> 
> The order is important as the later Makefile's may want to suppress
> TESTS from its base arch profile. Each included Makefile.target is
> responsible for adding TESTS as well as defining any special build
> instructions for individual tests.
> 
> Signed-off-by: Alex Bennée 
> Reviewed-by: Richard Henderson 
> Reviewed-by: Philippe Mathieu-Daudé 
> Tested-by: Philippe Mathieu-Daudé 
> ---
> v2
>   - cleaner approach to include sub makefiles
>   - move TESTS/VPATH manipulation into sub-makefile
>   - avoid double inclusion when TARGET_BASE_ARCH==TARGET_NAME
> v4
>   - add timeout to default runner
>   - clean-up comments about build flags
>   - update to handle BUILD_STATIC
>   - add MAINTAINERS entry
> v5
>   - support EXTRA_RUNS for run variants
> ---
>  MAINTAINERS|   5 ++
>  tests/tcg/Makefile | 179 ++---
>  2 files changed, 76 insertions(+), 108 deletions(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ec385a15df..bfa8d0fb9c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2138,6 +2138,11 @@ W: https://travis-ci.org/qemu/qemu
>  W: https://app.shippable.com/github/qemu/qemu
>  W: http://patchew.org/QEMU/
>  
> +Guest Test Compilation Support
> +M: Alex Bennée 
> +F: tests/tcg/Makefile
> +L: qemu-devel@nongnu.org
> +
>  Documentation
>  -
>  Build system architecture
> diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
> index e12395117a..8158c1f099 100644
> --- a/tests/tcg/Makefile
> +++ b/tests/tcg/Makefile
> @@ -1,125 +1,88 @@
> +# -*- Mode: makefile -*-
> +#
> +# TCG tests
> +#
> +# These are complicated by the fact we want to build them for guest
> +# systems. This requires knowing what guests we are building and which
> +# ones we have cross-compilers for or docker images with
> +# cross-compilers.
> +#
> +# The tests themselves should be as minimal as possible as
> +# cross-compilers don't always have a large amount of libraries
> +# available.
> +#
> +# We only include the host build system for SRC_PATH and we don't
> +# bother with the common rules.mk. We expect the following:
> +#
> +#   CC - the C compiler command
> +#   EXTRA_CFLAGS - any extra CFLAGS
> +#   BUILD_STATIC - are we building static binaries
> +#
> +# By default all tests are statically compiled but some host systems
> +# may not package static libraries by default. If an external
> +# cross-compiler can only build dynamic libraries the user might need
> +# to make extra efforts to ensure ld.so can link at runtime when the
> +# tests are run.
> +#
> +# We also accept SPEED=slow to enable slower running tests
> +#
> +# We also expect to be in the tests build dir for the FOO-linux-user.
> +#
> +
>  -include ../../config-host.mak
> --include $(SRC_PATH)/rules.mak
> +-include ../config-target.mak
>  
> -$(call set-vpath, $(SRC_PATH)/tests/tcg)
> +quiet-command = $(if $(V),$1,$(if $(2),@printf "  %-7s %s\n" $2 $3 && $1, 
> @$1))
>  
> -QEMU=../../i386-linux-user/qemu-i386
> -QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
> -CC_X86_64=$(CC_I386) -m64
> +# Tests we are building
> +TESTS=
>  
> -QEMU_INCLUDES += -I../..
> -CFLAGS=-Wall -O2 -g -fno-strict-aliasing
> -#CFLAGS+=-msse2
> +# Start with a blank slate, the build targets get to add stuff first
> +CFLAGS=
> +QEMU_CFLAGS=
>  LDFLAGS=
>  
> -# TODO: automatically detect ARM and MIPS compilers, and run those too
> -
> -# runcom maps page 0, so it requires root privileges
> -# also, pi_10.com runs indefinitely
> -
> -I386_TESTS=hello-i386 \
> -sha1-i386 \
> -test-i386 \
> -test-i386-fprem \
> -# runcom
> +# The QEMU for this TARGET
> +QEMU=../qemu-$(TARGET_NAME)
> +TIMEOUT=15
>  
> -# native i386 compilers sometimes are not biarch.  assume cross-compilers are
> -ifneq ($(ARCH),i386)
> -I386_TESTS+=run-test-x86_64
> +# The order we include is important. We include multiarch, base arch
> +# and finally arch if it's not the same as base arch.
> +-include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
> +-include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target
> +ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
> +-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
>  endif
>  
> -TESTS = test_path
> -ifneq ($(call find-in-path, $(CC_I386)),)
> -TESTS += $(I386_TESTS)
> +# Add the common build options
> +CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
> +ifeq ($(BUILD_STATIC),y)
> +LDFLAGS+=-static
>  endif
>  
> -all: $(patsubst %,run-%,$(TESTS))
> -test: all
> -
> -# rules to run tests
> -
> -.PHONY: $(patsubst